blob: 7627ea61e0ea82d649c600773a660f3ff4edac5b [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);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200712 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
713 mode == MLO_AN_FIXED) && ops->port_set_link)
Russell King30c4a5b2020-02-26 10:23:51 +0000714 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Russell King5d5b2312020-03-14 10:16:03 +0000715 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000716
Russell King5d5b2312020-03-14 10:16:03 +0000717 if (err)
718 dev_err(chip->dev,
719 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700720}
721
722static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
723 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000724 struct phy_device *phydev,
725 int speed, int duplex,
726 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700727{
Russell King30c4a5b2020-02-26 10:23:51 +0000728 struct mv88e6xxx_chip *chip = ds->priv;
729 const struct mv88e6xxx_ops *ops;
730 int err = 0;
731
732 ops = chip->info->ops;
733
Russell King5d5b2312020-03-14 10:16:03 +0000734 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200735 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000736 /* FIXME: for an automedia port, should we force the link
737 * down here - what if the link comes up due to "other" media
738 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000739 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000740 * shared between internal PHY and Serdes.
741 */
Russell Kinga5a68582020-03-14 10:15:43 +0000742 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
743 duplex);
744 if (err)
745 goto error;
746
Russell Kingf365c6f2020-03-14 10:15:53 +0000747 if (ops->port_set_speed_duplex) {
748 err = ops->port_set_speed_duplex(chip, port,
749 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000750 if (err && err != -EOPNOTSUPP)
751 goto error;
752 }
753
754 if (ops->port_set_link)
755 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
Russell King30c4a5b2020-02-26 10:23:51 +0000756 }
Russell King5d5b2312020-03-14 10:16:03 +0000757error:
758 mv88e6xxx_reg_unlock(chip);
759
760 if (err && err != -EOPNOTSUPP)
761 dev_err(ds->dev,
762 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700763}
764
Andrew Lunna605a0f2016-11-21 23:26:58 +0100765static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000766{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100767 if (!chip->info->ops->stats_snapshot)
768 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000769
Andrew Lunna605a0f2016-11-21 23:26:58 +0100770 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000771}
772
Andrew Lunne413e7e2015-04-02 04:06:38 +0200773static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100774 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
775 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
776 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
777 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
778 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
779 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
780 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
781 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
782 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
783 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
784 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
785 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
786 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
787 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
788 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
789 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
790 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
791 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
792 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
793 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
794 { "single", 4, 0x14, STATS_TYPE_BANK0, },
795 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
796 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
797 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
798 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
799 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
800 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
801 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
802 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
803 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
804 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
805 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
806 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
807 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
808 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
809 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
810 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
811 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
812 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
813 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
814 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
815 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
816 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
817 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
818 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
819 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
820 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
821 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
822 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
823 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
824 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
825 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
826 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
827 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
828 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
829 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
830 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
831 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
832 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200833};
834
Vivien Didelotfad09c72016-06-21 12:28:20 -0400835static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100836 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100837 int port, u16 bank1_select,
838 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200839{
Andrew Lunn80c46272015-06-20 18:42:30 +0200840 u32 low;
841 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200843 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200844 u64 value;
845
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100846 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100847 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200848 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
849 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800850 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200851
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200852 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100853 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200854 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
855 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800856 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000857 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200858 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100860 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100861 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100862 /* fall through */
863 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100864 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100865 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100866 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100867 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500868 break;
869 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800870 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200871 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100872 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200873 return value;
874}
875
Andrew Lunn436fe172018-03-01 02:02:29 +0100876static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
877 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100878{
879 struct mv88e6xxx_hw_stat *stat;
880 int i, j;
881
882 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
883 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100884 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100885 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
886 ETH_GSTRING_LEN);
887 j++;
888 }
889 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100890
891 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100892}
893
Andrew Lunn436fe172018-03-01 02:02:29 +0100894static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
895 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100896{
Andrew Lunn436fe172018-03-01 02:02:29 +0100897 return mv88e6xxx_stats_get_strings(chip, data,
898 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100899}
900
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000901static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
902 uint8_t *data)
903{
904 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
905}
906
Andrew Lunn436fe172018-03-01 02:02:29 +0100907static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
908 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100909{
Andrew Lunn436fe172018-03-01 02:02:29 +0100910 return mv88e6xxx_stats_get_strings(chip, data,
911 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100912}
913
Andrew Lunn65f60e42018-03-28 23:50:28 +0200914static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
915 "atu_member_violation",
916 "atu_miss_violation",
917 "atu_full_violation",
918 "vtu_member_violation",
919 "vtu_miss_violation",
920};
921
922static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
923{
924 unsigned int i;
925
926 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
927 strlcpy(data + i * ETH_GSTRING_LEN,
928 mv88e6xxx_atu_vtu_stats_strings[i],
929 ETH_GSTRING_LEN);
930}
931
Andrew Lunndfafe442016-11-21 23:27:02 +0100932static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700933 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100934{
Vivien Didelot04bed142016-08-31 18:06:13 -0400935 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100936 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100937
Florian Fainelli89f09042018-04-25 12:12:50 -0700938 if (stringset != ETH_SS_STATS)
939 return;
940
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000941 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100942
Andrew Lunndfafe442016-11-21 23:27:02 +0100943 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100944 count = chip->info->ops->stats_get_strings(chip, data);
945
946 if (chip->info->ops->serdes_get_strings) {
947 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200948 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100950
Andrew Lunn65f60e42018-03-28 23:50:28 +0200951 data += count * ETH_GSTRING_LEN;
952 mv88e6xxx_atu_vtu_get_strings(data);
953
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000954 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100955}
956
957static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
958 int types)
959{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100960 struct mv88e6xxx_hw_stat *stat;
961 int i, j;
962
963 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
964 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100965 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100966 j++;
967 }
968 return j;
969}
970
Andrew Lunndfafe442016-11-21 23:27:02 +0100971static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
972{
973 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
974 STATS_TYPE_PORT);
975}
976
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000977static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
978{
979 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
980}
981
Andrew Lunndfafe442016-11-21 23:27:02 +0100982static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
983{
984 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
985 STATS_TYPE_BANK1);
986}
987
Florian Fainelli89f09042018-04-25 12:12:50 -0700988static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100989{
990 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 int serdes_count = 0;
992 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100993
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 if (sset != ETH_SS_STATS)
995 return 0;
996
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000997 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100998 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_sset_count(chip);
1000 if (count < 0)
1001 goto out;
1002
1003 if (chip->info->ops->serdes_get_sset_count)
1004 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1005 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 goto out;
1009 }
1010 count += serdes_count;
1011 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1012
Andrew Lunn436fe172018-03-01 02:02:29 +01001013out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001014 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001017}
1018
Andrew Lunn436fe172018-03-01 02:02:29 +01001019static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1020 uint64_t *data, int types,
1021 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001022{
1023 struct mv88e6xxx_hw_stat *stat;
1024 int i, j;
1025
1026 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1027 stat = &mv88e6xxx_hw_stats[i];
1028 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001029 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001030 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1031 bank1_select,
1032 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001033 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001034
Andrew Lunn052f9472016-11-21 23:27:03 +01001035 j++;
1036 }
1037 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001038 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001039}
1040
Andrew Lunn436fe172018-03-01 02:02:29 +01001041static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1042 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001043{
1044 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001045 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001046 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001049static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1050 uint64_t *data)
1051{
1052 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1053 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1054}
1055
Andrew Lunn436fe172018-03-01 02:02:29 +01001056static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1057 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001058{
1059 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001060 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001061 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1062 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001063}
1064
Andrew Lunn436fe172018-03-01 02:02:29 +01001065static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001067{
1068 return mv88e6xxx_stats_get_stats(chip, port, data,
1069 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001070 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1071 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001072}
1073
Andrew Lunn65f60e42018-03-28 23:50:28 +02001074static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1075 uint64_t *data)
1076{
1077 *data++ = chip->ports[port].atu_member_violation;
1078 *data++ = chip->ports[port].atu_miss_violation;
1079 *data++ = chip->ports[port].atu_full_violation;
1080 *data++ = chip->ports[port].vtu_member_violation;
1081 *data++ = chip->ports[port].vtu_miss_violation;
1082}
1083
Andrew Lunn052f9472016-11-21 23:27:03 +01001084static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1085 uint64_t *data)
1086{
Andrew Lunn436fe172018-03-01 02:02:29 +01001087 int count = 0;
1088
Andrew Lunn052f9472016-11-21 23:27:03 +01001089 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001090 count = chip->info->ops->stats_get_stats(chip, port, data);
1091
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001092 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001093 if (chip->info->ops->serdes_get_stats) {
1094 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001095 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001096 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001097 data += count;
1098 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001099 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001100}
1101
Vivien Didelotf81ec902016-05-09 13:22:58 -04001102static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1103 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001104{
Vivien Didelot04bed142016-08-31 18:06:13 -04001105 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001106 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001107
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001108 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001109
Andrew Lunna605a0f2016-11-21 23:26:58 +01001110 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001111 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001112
1113 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001114 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001115
1116 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001117
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001118}
Ben Hutchings98e67302011-11-25 14:36:19 +00001119
Vivien Didelotf81ec902016-05-09 13:22:58 -04001120static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001121{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001122 struct mv88e6xxx_chip *chip = ds->priv;
1123 int len;
1124
1125 len = 32 * sizeof(u16);
1126 if (chip->info->ops->serdes_get_regs_len)
1127 len += chip->info->ops->serdes_get_regs_len(chip, port);
1128
1129 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001130}
1131
Vivien Didelotf81ec902016-05-09 13:22:58 -04001132static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1133 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134{
Vivien Didelot04bed142016-08-31 18:06:13 -04001135 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001136 int err;
1137 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138 u16 *p = _p;
1139 int i;
1140
Vivien Didelota5f39322018-12-17 16:05:21 -05001141 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001142
1143 memset(p, 0xff, 32 * sizeof(u16));
1144
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001145 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001146
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001148
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001149 err = mv88e6xxx_port_read(chip, port, i, &reg);
1150 if (!err)
1151 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001152 }
Vivien Didelot23062512016-05-09 13:22:45 -04001153
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001154 if (chip->info->ops->serdes_get_regs)
1155 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1156
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001157 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001158}
1159
Vivien Didelot08f50062017-08-01 16:32:41 -04001160static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1161 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001162{
Vivien Didelot5480db62017-08-01 16:32:40 -04001163 /* Nothing to do on the port's MAC */
1164 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001165}
1166
Vivien Didelot08f50062017-08-01 16:32:41 -04001167static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1168 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001169{
Vivien Didelot5480db62017-08-01 16:32:40 -04001170 /* Nothing to do on the port's MAC */
1171 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001172}
1173
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001174/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001175static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001176{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001177 struct dsa_switch *ds = chip->ds;
1178 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001179 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001180 struct dsa_port *dp;
1181 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001182 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001183
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001184 list_for_each_entry(dp, &dst->ports, list) {
1185 if (dp->ds->index == dev && dp->index == port) {
1186 found = true;
1187 break;
1188 }
1189 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001190
Vivien Didelote5887a22017-03-30 17:37:11 -04001191 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001192 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001193 return 0;
1194
1195 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001196 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001197 return mv88e6xxx_port_mask(chip);
1198
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001199 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001200 pvlan = 0;
1201
1202 /* Frames from user ports can egress any local DSA links and CPU ports,
1203 * as well as any local member of their bridge group.
1204 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001205 list_for_each_entry(dp, &dst->ports, list)
1206 if (dp->ds == ds &&
1207 (dp->type == DSA_PORT_TYPE_CPU ||
1208 dp->type == DSA_PORT_TYPE_DSA ||
1209 (br && dp->bridge_dev == br)))
1210 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001211
1212 return pvlan;
1213}
1214
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001215static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001216{
1217 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001218
1219 /* prevent frames from going back out of the port they came in on */
1220 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001221
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001222 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001223}
1224
Vivien Didelotf81ec902016-05-09 13:22:58 -04001225static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1226 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001227{
Vivien Didelot04bed142016-08-31 18:06:13 -04001228 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001229 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001230
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001231 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001232 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001233 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001234
1235 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001236 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001237}
1238
Vivien Didelot93e18d62018-05-11 17:16:35 -04001239static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1240{
1241 int err;
1242
1243 if (chip->info->ops->ieee_pri_map) {
1244 err = chip->info->ops->ieee_pri_map(chip);
1245 if (err)
1246 return err;
1247 }
1248
1249 if (chip->info->ops->ip_pri_map) {
1250 err = chip->info->ops->ip_pri_map(chip);
1251 if (err)
1252 return err;
1253 }
1254
1255 return 0;
1256}
1257
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001258static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1259{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001260 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001261 int target, port;
1262 int err;
1263
1264 if (!chip->info->global2_addr)
1265 return 0;
1266
1267 /* Initialize the routing port to the 32 possible target devices */
1268 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001269 port = dsa_routing_port(ds, target);
1270 if (port == ds->num_ports)
1271 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001272
1273 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1274 if (err)
1275 return err;
1276 }
1277
Vivien Didelot02317e62018-05-09 11:38:49 -04001278 if (chip->info->ops->set_cascade_port) {
1279 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1280 err = chip->info->ops->set_cascade_port(chip, port);
1281 if (err)
1282 return err;
1283 }
1284
Vivien Didelot23c98912018-05-09 11:38:50 -04001285 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1286 if (err)
1287 return err;
1288
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001289 return 0;
1290}
1291
Vivien Didelotb28f8722018-04-26 21:56:44 -04001292static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1293{
1294 /* Clear all trunk masks and mapping */
1295 if (chip->info->global2_addr)
1296 return mv88e6xxx_g2_trunk_clear(chip);
1297
1298 return 0;
1299}
1300
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001301static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1302{
1303 if (chip->info->ops->rmu_disable)
1304 return chip->info->ops->rmu_disable(chip);
1305
1306 return 0;
1307}
1308
Vivien Didelot9e907d72017-07-17 13:03:43 -04001309static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1310{
1311 if (chip->info->ops->pot_clear)
1312 return chip->info->ops->pot_clear(chip);
1313
1314 return 0;
1315}
1316
Vivien Didelot51c901a2017-07-17 13:03:41 -04001317static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1318{
1319 if (chip->info->ops->mgmt_rsvd2cpu)
1320 return chip->info->ops->mgmt_rsvd2cpu(chip);
1321
1322 return 0;
1323}
1324
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001325static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1326{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001327 int err;
1328
Vivien Didelotdaefc942017-03-11 16:12:54 -05001329 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1330 if (err)
1331 return err;
1332
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001333 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1334 if (err)
1335 return err;
1336
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001337 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1338}
1339
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001340static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1341{
1342 int port;
1343 int err;
1344
1345 if (!chip->info->ops->irl_init_all)
1346 return 0;
1347
1348 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1349 /* Disable ingress rate limiting by resetting all per port
1350 * ingress rate limit resources to their initial state.
1351 */
1352 err = chip->info->ops->irl_init_all(chip, port);
1353 if (err)
1354 return err;
1355 }
1356
1357 return 0;
1358}
1359
Vivien Didelot04a69a12017-10-13 14:18:05 -04001360static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1361{
1362 if (chip->info->ops->set_switch_mac) {
1363 u8 addr[ETH_ALEN];
1364
1365 eth_random_addr(addr);
1366
1367 return chip->info->ops->set_switch_mac(chip, addr);
1368 }
1369
1370 return 0;
1371}
1372
Vivien Didelot17a15942017-03-30 17:37:09 -04001373static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1374{
1375 u16 pvlan = 0;
1376
1377 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001378 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001379
1380 /* Skip the local source device, which uses in-chip port VLAN */
1381 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001382 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001383
1384 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1385}
1386
Vivien Didelot81228992017-03-30 17:37:08 -04001387static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1388{
Vivien Didelot17a15942017-03-30 17:37:09 -04001389 int dev, port;
1390 int err;
1391
Vivien Didelot81228992017-03-30 17:37:08 -04001392 if (!mv88e6xxx_has_pvt(chip))
1393 return 0;
1394
1395 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1396 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1397 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001398 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1399 if (err)
1400 return err;
1401
1402 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1403 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1404 err = mv88e6xxx_pvt_map(chip, dev, port);
1405 if (err)
1406 return err;
1407 }
1408 }
1409
1410 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001411}
1412
Vivien Didelot749efcb2016-09-22 16:49:24 -04001413static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1414{
1415 struct mv88e6xxx_chip *chip = ds->priv;
1416 int err;
1417
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001418 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001419 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001420 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001421
1422 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001423 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001424}
1425
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001426static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1427{
1428 if (!chip->info->max_vid)
1429 return 0;
1430
1431 return mv88e6xxx_g1_vtu_flush(chip);
1432}
1433
Vivien Didelotf1394b782017-05-01 14:05:22 -04001434static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1435 struct mv88e6xxx_vtu_entry *entry)
1436{
1437 if (!chip->info->ops->vtu_getnext)
1438 return -EOPNOTSUPP;
1439
1440 return chip->info->ops->vtu_getnext(chip, entry);
1441}
1442
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001443static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1444 struct mv88e6xxx_vtu_entry *entry)
1445{
1446 if (!chip->info->ops->vtu_loadpurge)
1447 return -EOPNOTSUPP;
1448
1449 return chip->info->ops->vtu_loadpurge(chip, entry);
1450}
1451
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001452static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001453{
1454 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001455 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001456 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001457
1458 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1459
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001460 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001461 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001462 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001463 if (err)
1464 return err;
1465
1466 set_bit(*fid, fid_bitmap);
1467 }
1468
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001469 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001470 vlan.vid = chip->info->max_vid;
1471 vlan.valid = false;
1472
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001473 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001474 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001475 if (err)
1476 return err;
1477
1478 if (!vlan.valid)
1479 break;
1480
1481 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001482 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001483
1484 /* The reset value 0x000 is used to indicate that multiple address
1485 * databases are not needed. Return the next positive available.
1486 */
1487 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001488 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001489 return -ENOSPC;
1490
1491 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001492 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001493}
1494
Andrew Lunn23e8b472019-10-25 01:03:52 +02001495static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1496{
1497 if (chip->info->ops->atu_get_hash)
1498 return chip->info->ops->atu_get_hash(chip, hash);
1499
1500 return -EOPNOTSUPP;
1501}
1502
1503static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1504{
1505 if (chip->info->ops->atu_set_hash)
1506 return chip->info->ops->atu_set_hash(chip, hash);
1507
1508 return -EOPNOTSUPP;
1509}
1510
Vivien Didelotda9c3592016-02-12 12:09:40 -05001511static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1512 u16 vid_begin, u16 vid_end)
1513{
Vivien Didelot04bed142016-08-31 18:06:13 -04001514 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001515 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001516 int i, err;
1517
Andrew Lunndb06ae412017-09-25 23:32:20 +02001518 /* DSA and CPU ports have to be members of multiple vlans */
1519 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1520 return 0;
1521
Vivien Didelotda9c3592016-02-12 12:09:40 -05001522 if (!vid_begin)
1523 return -EOPNOTSUPP;
1524
Vivien Didelot425d2d32019-08-01 14:36:34 -04001525 vlan.vid = vid_begin - 1;
1526 vlan.valid = false;
1527
Vivien Didelotda9c3592016-02-12 12:09:40 -05001528 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001529 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001530 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001531 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001532
1533 if (!vlan.valid)
1534 break;
1535
1536 if (vlan.vid > vid_end)
1537 break;
1538
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001539 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001540 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1541 continue;
1542
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001543 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001544 continue;
1545
Vivien Didelotbd00e052017-05-01 14:05:11 -04001546 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001547 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001548 continue;
1549
Vivien Didelotc8652c82017-10-16 11:12:19 -04001550 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001551 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001552 break; /* same bridge, check next VLAN */
1553
Vivien Didelotc8652c82017-10-16 11:12:19 -04001554 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001555 continue;
1556
Andrew Lunn743fcc22017-11-09 22:29:54 +01001557 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1558 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001559 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001560 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 }
1562 } while (vlan.vid < vid_end);
1563
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001564 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565}
1566
Vivien Didelotf81ec902016-05-09 13:22:58 -04001567static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1568 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001569{
Vivien Didelot04bed142016-08-31 18:06:13 -04001570 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001571 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1572 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001573 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001574
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001575 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001576 return -EOPNOTSUPP;
1577
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001578 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001579 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001580 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001581
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001582 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001583}
1584
Vivien Didelot57d32312016-06-20 13:13:58 -04001585static int
1586mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001587 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001588{
Vivien Didelot04bed142016-08-31 18:06:13 -04001589 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001590 int err;
1591
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001592 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001593 return -EOPNOTSUPP;
1594
Vivien Didelotda9c3592016-02-12 12:09:40 -05001595 /* If the requested port doesn't belong to the same bridge as the VLAN
1596 * members, do not support it (yet) and fallback to software VLAN.
1597 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001598 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001599 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1600 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001601 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001602
Vivien Didelot76e398a2015-11-01 12:33:55 -05001603 /* We don't need any dynamic resource from the kernel (yet),
1604 * so skip the prepare phase.
1605 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001606 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001607}
1608
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001609static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1610 const unsigned char *addr, u16 vid,
1611 u8 state)
1612{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001613 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001614 struct mv88e6xxx_vtu_entry vlan;
1615 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001616 int err;
1617
1618 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001619 if (vid == 0) {
1620 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1621 if (err)
1622 return err;
1623 } else {
1624 vlan.vid = vid - 1;
1625 vlan.valid = false;
1626
1627 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1628 if (err)
1629 return err;
1630
1631 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1632 if (vlan.vid != vid || !vlan.valid)
1633 return -EOPNOTSUPP;
1634
1635 fid = vlan.fid;
1636 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001637
Vivien Didelotd8291a92019-09-07 16:00:47 -04001638 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001639 ether_addr_copy(entry.mac, addr);
1640 eth_addr_dec(entry.mac);
1641
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001642 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001643 if (err)
1644 return err;
1645
1646 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001647 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001648 memset(&entry, 0, sizeof(entry));
1649 ether_addr_copy(entry.mac, addr);
1650 }
1651
1652 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001653 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001654 entry.portvec &= ~BIT(port);
1655 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001656 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001657 } else {
1658 entry.portvec |= BIT(port);
1659 entry.state = state;
1660 }
1661
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001662 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001663}
1664
Vivien Didelotda7dc872019-09-07 16:00:49 -04001665static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1666 const struct mv88e6xxx_policy *policy)
1667{
1668 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1669 enum mv88e6xxx_policy_action action = policy->action;
1670 const u8 *addr = policy->addr;
1671 u16 vid = policy->vid;
1672 u8 state;
1673 int err;
1674 int id;
1675
1676 if (!chip->info->ops->port_set_policy)
1677 return -EOPNOTSUPP;
1678
1679 switch (mapping) {
1680 case MV88E6XXX_POLICY_MAPPING_DA:
1681 case MV88E6XXX_POLICY_MAPPING_SA:
1682 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1683 state = 0; /* Dissociate the port and address */
1684 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1685 is_multicast_ether_addr(addr))
1686 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1687 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1688 is_unicast_ether_addr(addr))
1689 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1690 else
1691 return -EOPNOTSUPP;
1692
1693 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1694 state);
1695 if (err)
1696 return err;
1697 break;
1698 default:
1699 return -EOPNOTSUPP;
1700 }
1701
1702 /* Skip the port's policy clearing if the mapping is still in use */
1703 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1704 idr_for_each_entry(&chip->policies, policy, id)
1705 if (policy->port == port &&
1706 policy->mapping == mapping &&
1707 policy->action != action)
1708 return 0;
1709
1710 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1711}
1712
1713static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1714 struct ethtool_rx_flow_spec *fs)
1715{
1716 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1717 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1718 enum mv88e6xxx_policy_mapping mapping;
1719 enum mv88e6xxx_policy_action action;
1720 struct mv88e6xxx_policy *policy;
1721 u16 vid = 0;
1722 u8 *addr;
1723 int err;
1724 int id;
1725
1726 if (fs->location != RX_CLS_LOC_ANY)
1727 return -EINVAL;
1728
1729 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1730 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1731 else
1732 return -EOPNOTSUPP;
1733
1734 switch (fs->flow_type & ~FLOW_EXT) {
1735 case ETHER_FLOW:
1736 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1737 is_zero_ether_addr(mac_mask->h_source)) {
1738 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1739 addr = mac_entry->h_dest;
1740 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1741 !is_zero_ether_addr(mac_mask->h_source)) {
1742 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1743 addr = mac_entry->h_source;
1744 } else {
1745 /* Cannot support DA and SA mapping in the same rule */
1746 return -EOPNOTSUPP;
1747 }
1748 break;
1749 default:
1750 return -EOPNOTSUPP;
1751 }
1752
1753 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1754 if (fs->m_ext.vlan_tci != 0xffff)
1755 return -EOPNOTSUPP;
1756 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1757 }
1758
1759 idr_for_each_entry(&chip->policies, policy, id) {
1760 if (policy->port == port && policy->mapping == mapping &&
1761 policy->action == action && policy->vid == vid &&
1762 ether_addr_equal(policy->addr, addr))
1763 return -EEXIST;
1764 }
1765
1766 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1767 if (!policy)
1768 return -ENOMEM;
1769
1770 fs->location = 0;
1771 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1772 GFP_KERNEL);
1773 if (err) {
1774 devm_kfree(chip->dev, policy);
1775 return err;
1776 }
1777
1778 memcpy(&policy->fs, fs, sizeof(*fs));
1779 ether_addr_copy(policy->addr, addr);
1780 policy->mapping = mapping;
1781 policy->action = action;
1782 policy->port = port;
1783 policy->vid = vid;
1784
1785 err = mv88e6xxx_policy_apply(chip, port, policy);
1786 if (err) {
1787 idr_remove(&chip->policies, fs->location);
1788 devm_kfree(chip->dev, policy);
1789 return err;
1790 }
1791
1792 return 0;
1793}
1794
1795static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1796 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1797{
1798 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1799 struct mv88e6xxx_chip *chip = ds->priv;
1800 struct mv88e6xxx_policy *policy;
1801 int err;
1802 int id;
1803
1804 mv88e6xxx_reg_lock(chip);
1805
1806 switch (rxnfc->cmd) {
1807 case ETHTOOL_GRXCLSRLCNT:
1808 rxnfc->data = 0;
1809 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1810 rxnfc->rule_cnt = 0;
1811 idr_for_each_entry(&chip->policies, policy, id)
1812 if (policy->port == port)
1813 rxnfc->rule_cnt++;
1814 err = 0;
1815 break;
1816 case ETHTOOL_GRXCLSRULE:
1817 err = -ENOENT;
1818 policy = idr_find(&chip->policies, fs->location);
1819 if (policy) {
1820 memcpy(fs, &policy->fs, sizeof(*fs));
1821 err = 0;
1822 }
1823 break;
1824 case ETHTOOL_GRXCLSRLALL:
1825 rxnfc->data = 0;
1826 rxnfc->rule_cnt = 0;
1827 idr_for_each_entry(&chip->policies, policy, id)
1828 if (policy->port == port)
1829 rule_locs[rxnfc->rule_cnt++] = id;
1830 err = 0;
1831 break;
1832 default:
1833 err = -EOPNOTSUPP;
1834 break;
1835 }
1836
1837 mv88e6xxx_reg_unlock(chip);
1838
1839 return err;
1840}
1841
1842static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1843 struct ethtool_rxnfc *rxnfc)
1844{
1845 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1846 struct mv88e6xxx_chip *chip = ds->priv;
1847 struct mv88e6xxx_policy *policy;
1848 int err;
1849
1850 mv88e6xxx_reg_lock(chip);
1851
1852 switch (rxnfc->cmd) {
1853 case ETHTOOL_SRXCLSRLINS:
1854 err = mv88e6xxx_policy_insert(chip, port, fs);
1855 break;
1856 case ETHTOOL_SRXCLSRLDEL:
1857 err = -ENOENT;
1858 policy = idr_remove(&chip->policies, fs->location);
1859 if (policy) {
1860 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1861 err = mv88e6xxx_policy_apply(chip, port, policy);
1862 devm_kfree(chip->dev, policy);
1863 }
1864 break;
1865 default:
1866 err = -EOPNOTSUPP;
1867 break;
1868 }
1869
1870 mv88e6xxx_reg_unlock(chip);
1871
1872 return err;
1873}
1874
Andrew Lunn87fa8862017-11-09 22:29:56 +01001875static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1876 u16 vid)
1877{
1878 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1879 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1880
1881 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1882}
1883
1884static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1885{
1886 int port;
1887 int err;
1888
1889 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1890 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1891 if (err)
1892 return err;
1893 }
1894
1895 return 0;
1896}
1897
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001898static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001899 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001900{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001901 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001902 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001903 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001904
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001905 if (!vid)
1906 return -EOPNOTSUPP;
1907
1908 vlan.vid = vid - 1;
1909 vlan.valid = false;
1910
1911 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001912 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001913 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001914
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001915 if (vlan.vid != vid || !vlan.valid) {
1916 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001917
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001918 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1919 if (err)
1920 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001921
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001922 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1923 if (i == port)
1924 vlan.member[i] = member;
1925 else
1926 vlan.member[i] = non_member;
1927
1928 vlan.vid = vid;
1929 vlan.valid = true;
1930
1931 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1932 if (err)
1933 return err;
1934
1935 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1936 if (err)
1937 return err;
1938 } else if (vlan.member[port] != member) {
1939 vlan.member[port] = member;
1940
1941 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1942 if (err)
1943 return err;
Russell King933b4422020-02-26 17:14:26 +00001944 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001945 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1946 port, vid);
1947 }
1948
1949 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001950}
1951
Vivien Didelotf81ec902016-05-09 13:22:58 -04001952static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001953 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001954{
Vivien Didelot04bed142016-08-31 18:06:13 -04001955 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001956 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1957 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001958 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001959 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001960 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001961
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001962 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001963 return;
1964
Vivien Didelotc91498e2017-06-07 18:12:13 -04001965 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001966 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001967 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001968 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001969 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001970 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001971
Russell King933b4422020-02-26 17:14:26 +00001972 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1973 * and then the CPU port. Do not warn for duplicates for the CPU port.
1974 */
1975 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1976
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001977 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001978
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001979 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001980 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001981 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1982 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001983
Vivien Didelot77064f32016-11-04 03:23:30 +01001984 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001985 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1986 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001988 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001989}
1990
Vivien Didelot521098922019-08-01 14:36:36 -04001991static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1992 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001993{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001994 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001995 int i, err;
1996
Vivien Didelot521098922019-08-01 14:36:36 -04001997 if (!vid)
1998 return -EOPNOTSUPP;
1999
2000 vlan.vid = vid - 1;
2001 vlan.valid = false;
2002
2003 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002004 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002005 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002006
Vivien Didelot521098922019-08-01 14:36:36 -04002007 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2008 * tell switchdev that this VLAN is likely handled in software.
2009 */
2010 if (vlan.vid != vid || !vlan.valid ||
2011 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002012 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002013
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002014 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002015
2016 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002017 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002018 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002019 if (vlan.member[i] !=
2020 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002021 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002022 break;
2023 }
2024 }
2025
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002026 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002027 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002028 return err;
2029
Vivien Didelote606ca32017-03-11 16:12:55 -05002030 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002031}
2032
Vivien Didelotf81ec902016-05-09 13:22:58 -04002033static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2034 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002035{
Vivien Didelot04bed142016-08-31 18:06:13 -04002036 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002037 u16 pvid, vid;
2038 int err = 0;
2039
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002040 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002041 return -EOPNOTSUPP;
2042
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002043 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002044
Vivien Didelot77064f32016-11-04 03:23:30 +01002045 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002046 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002047 goto unlock;
2048
Vivien Didelot76e398a2015-11-01 12:33:55 -05002049 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002050 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002051 if (err)
2052 goto unlock;
2053
2054 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002055 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002056 if (err)
2057 goto unlock;
2058 }
2059 }
2060
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002061unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002062 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002063
2064 return err;
2065}
2066
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002067static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2068 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002069{
Vivien Didelot04bed142016-08-31 18:06:13 -04002070 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002071 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002072
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002073 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002074 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2075 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002076 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002077
2078 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002079}
2080
Vivien Didelotf81ec902016-05-09 13:22:58 -04002081static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002082 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002083{
Vivien Didelot04bed142016-08-31 18:06:13 -04002084 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002085 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002086
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002087 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002088 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002089 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002090
Vivien Didelot83dabd12016-08-31 11:50:04 -04002091 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002092}
2093
Vivien Didelot83dabd12016-08-31 11:50:04 -04002094static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2095 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002096 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002097{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002098 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002099 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002100 int err;
2101
Vivien Didelotd8291a92019-09-07 16:00:47 -04002102 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002103 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002104
2105 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002106 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002107 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002108 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002109
Vivien Didelotd8291a92019-09-07 16:00:47 -04002110 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002111 break;
2112
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002113 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002114 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002115
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002116 if (!is_unicast_ether_addr(addr.mac))
2117 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002118
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002119 is_static = (addr.state ==
2120 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2121 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002122 if (err)
2123 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002124 } while (!is_broadcast_ether_addr(addr.mac));
2125
2126 return err;
2127}
2128
Vivien Didelot83dabd12016-08-31 11:50:04 -04002129static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002130 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002131{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002132 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002133 u16 fid;
2134 int err;
2135
2136 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002137 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002138 if (err)
2139 return err;
2140
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002141 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002142 if (err)
2143 return err;
2144
2145 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002146 vlan.vid = chip->info->max_vid;
2147 vlan.valid = false;
2148
Vivien Didelot83dabd12016-08-31 11:50:04 -04002149 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002150 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002151 if (err)
2152 return err;
2153
2154 if (!vlan.valid)
2155 break;
2156
2157 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002158 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002159 if (err)
2160 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002161 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002162
2163 return err;
2164}
2165
Vivien Didelotf81ec902016-05-09 13:22:58 -04002166static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002167 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002168{
Vivien Didelot04bed142016-08-31 18:06:13 -04002169 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002170 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002171
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002172 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002173 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002174 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002175
2176 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002177}
2178
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002179static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2180 struct net_device *br)
2181{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002182 struct dsa_switch *ds = chip->ds;
2183 struct dsa_switch_tree *dst = ds->dst;
2184 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002185 int err;
2186
Vivien Didelotef2025e2019-10-21 16:51:27 -04002187 list_for_each_entry(dp, &dst->ports, list) {
2188 if (dp->bridge_dev == br) {
2189 if (dp->ds == ds) {
2190 /* This is a local bridge group member,
2191 * remap its Port VLAN Map.
2192 */
2193 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2194 if (err)
2195 return err;
2196 } else {
2197 /* This is an external bridge group member,
2198 * remap its cross-chip Port VLAN Table entry.
2199 */
2200 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2201 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002202 if (err)
2203 return err;
2204 }
2205 }
2206 }
2207
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002208 return 0;
2209}
2210
Vivien Didelotf81ec902016-05-09 13:22:58 -04002211static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002212 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002213{
Vivien Didelot04bed142016-08-31 18:06:13 -04002214 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002215 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002216
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002217 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002218 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002219 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002220
Vivien Didelot466dfa02016-02-26 13:16:05 -05002221 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002222}
2223
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002224static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2225 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002226{
Vivien Didelot04bed142016-08-31 18:06:13 -04002227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002228
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002229 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002230 if (mv88e6xxx_bridge_map(chip, br) ||
2231 mv88e6xxx_port_vlan_map(chip, port))
2232 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002233 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002234}
2235
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002236static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2237 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002238 int port, struct net_device *br)
2239{
2240 struct mv88e6xxx_chip *chip = ds->priv;
2241 int err;
2242
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002243 if (tree_index != ds->dst->index)
2244 return 0;
2245
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002246 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002247 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002248 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002249
2250 return err;
2251}
2252
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002253static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2254 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002255 int port, struct net_device *br)
2256{
2257 struct mv88e6xxx_chip *chip = ds->priv;
2258
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002259 if (tree_index != ds->dst->index)
2260 return;
2261
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002262 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002263 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002264 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002265 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002266}
2267
Vivien Didelot17e708b2016-12-05 17:30:27 -05002268static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2269{
2270 if (chip->info->ops->reset)
2271 return chip->info->ops->reset(chip);
2272
2273 return 0;
2274}
2275
Vivien Didelot309eca62016-12-05 17:30:26 -05002276static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2277{
2278 struct gpio_desc *gpiod = chip->reset;
2279
2280 /* If there is a GPIO connected to the reset pin, toggle it */
2281 if (gpiod) {
2282 gpiod_set_value_cansleep(gpiod, 1);
2283 usleep_range(10000, 20000);
2284 gpiod_set_value_cansleep(gpiod, 0);
2285 usleep_range(10000, 20000);
2286 }
2287}
2288
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002289static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2290{
2291 int i, err;
2292
2293 /* Set all ports to the Disabled state */
2294 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002295 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002296 if (err)
2297 return err;
2298 }
2299
2300 /* Wait for transmit queues to drain,
2301 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2302 */
2303 usleep_range(2000, 4000);
2304
2305 return 0;
2306}
2307
Vivien Didelotfad09c72016-06-21 12:28:20 -04002308static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002309{
Vivien Didelota935c052016-09-29 12:21:53 -04002310 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002311
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002312 err = mv88e6xxx_disable_ports(chip);
2313 if (err)
2314 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002315
Vivien Didelot309eca62016-12-05 17:30:26 -05002316 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002317
Vivien Didelot17e708b2016-12-05 17:30:27 -05002318 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002319}
2320
Vivien Didelot43145572017-03-11 16:12:59 -05002321static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002322 enum mv88e6xxx_frame_mode frame,
2323 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002324{
2325 int err;
2326
Vivien Didelot43145572017-03-11 16:12:59 -05002327 if (!chip->info->ops->port_set_frame_mode)
2328 return -EOPNOTSUPP;
2329
2330 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002331 if (err)
2332 return err;
2333
Vivien Didelot43145572017-03-11 16:12:59 -05002334 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2335 if (err)
2336 return err;
2337
2338 if (chip->info->ops->port_set_ether_type)
2339 return chip->info->ops->port_set_ether_type(chip, port, etype);
2340
2341 return 0;
2342}
2343
2344static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2345{
2346 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002347 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002348 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002349}
2350
2351static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2352{
2353 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002354 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002355 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002356}
2357
2358static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2359{
2360 return mv88e6xxx_set_port_mode(chip, port,
2361 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002362 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2363 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002364}
2365
2366static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2367{
2368 if (dsa_is_dsa_port(chip->ds, port))
2369 return mv88e6xxx_set_port_mode_dsa(chip, port);
2370
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002371 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002372 return mv88e6xxx_set_port_mode_normal(chip, port);
2373
2374 /* Setup CPU port mode depending on its supported tag format */
2375 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2376 return mv88e6xxx_set_port_mode_dsa(chip, port);
2377
2378 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2379 return mv88e6xxx_set_port_mode_edsa(chip, port);
2380
2381 return -EINVAL;
2382}
2383
Vivien Didelotea698f42017-03-11 16:12:50 -05002384static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2385{
2386 bool message = dsa_is_dsa_port(chip->ds, port);
2387
2388 return mv88e6xxx_port_set_message_port(chip, port, message);
2389}
2390
Vivien Didelot601aeed2017-03-11 16:13:00 -05002391static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2392{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002393 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002394 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002395
David S. Miller407308f2019-06-15 13:35:29 -07002396 /* Upstream ports flood frames with unknown unicast or multicast DA */
2397 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2398 if (chip->info->ops->port_set_egress_floods)
2399 return chip->info->ops->port_set_egress_floods(chip, port,
2400 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002401
David S. Miller407308f2019-06-15 13:35:29 -07002402 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002403}
2404
Vivien Didelot45de77f2019-08-31 16:18:36 -04002405static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2406{
2407 struct mv88e6xxx_port *mvp = dev_id;
2408 struct mv88e6xxx_chip *chip = mvp->chip;
2409 irqreturn_t ret = IRQ_NONE;
2410 int port = mvp->port;
2411 u8 lane;
2412
2413 mv88e6xxx_reg_lock(chip);
2414 lane = mv88e6xxx_serdes_get_lane(chip, port);
2415 if (lane)
2416 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2417 mv88e6xxx_reg_unlock(chip);
2418
2419 return ret;
2420}
2421
2422static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2423 u8 lane)
2424{
2425 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2426 unsigned int irq;
2427 int err;
2428
2429 /* Nothing to request if this SERDES port has no IRQ */
2430 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2431 if (!irq)
2432 return 0;
2433
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002434 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2435 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2436
Vivien Didelot45de77f2019-08-31 16:18:36 -04002437 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2438 mv88e6xxx_reg_unlock(chip);
2439 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002440 IRQF_ONESHOT, dev_id->serdes_irq_name,
2441 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002442 mv88e6xxx_reg_lock(chip);
2443 if (err)
2444 return err;
2445
2446 dev_id->serdes_irq = irq;
2447
2448 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2449}
2450
2451static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2452 u8 lane)
2453{
2454 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2455 unsigned int irq = dev_id->serdes_irq;
2456 int err;
2457
2458 /* Nothing to free if no IRQ has been requested */
2459 if (!irq)
2460 return 0;
2461
2462 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2463
2464 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2465 mv88e6xxx_reg_unlock(chip);
2466 free_irq(irq, dev_id);
2467 mv88e6xxx_reg_lock(chip);
2468
2469 dev_id->serdes_irq = 0;
2470
2471 return err;
2472}
2473
Andrew Lunn6d917822017-05-26 01:03:21 +02002474static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2475 bool on)
2476{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002477 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002478 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002479
Vivien Didelotdc272f62019-08-31 16:18:33 -04002480 lane = mv88e6xxx_serdes_get_lane(chip, port);
2481 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002482 return 0;
2483
2484 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002485 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002486 if (err)
2487 return err;
2488
Vivien Didelot45de77f2019-08-31 16:18:36 -04002489 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002490 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002491 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2492 if (err)
2493 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002494
Vivien Didelotdc272f62019-08-31 16:18:33 -04002495 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002496 }
2497
2498 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002499}
2500
Vivien Didelotfa371c82017-12-05 15:34:10 -05002501static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2502{
2503 struct dsa_switch *ds = chip->ds;
2504 int upstream_port;
2505 int err;
2506
Vivien Didelot07073c72017-12-05 15:34:13 -05002507 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002508 if (chip->info->ops->port_set_upstream_port) {
2509 err = chip->info->ops->port_set_upstream_port(chip, port,
2510 upstream_port);
2511 if (err)
2512 return err;
2513 }
2514
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002515 if (port == upstream_port) {
2516 if (chip->info->ops->set_cpu_port) {
2517 err = chip->info->ops->set_cpu_port(chip,
2518 upstream_port);
2519 if (err)
2520 return err;
2521 }
2522
2523 if (chip->info->ops->set_egress_port) {
2524 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002525 MV88E6XXX_EGRESS_DIR_INGRESS,
2526 upstream_port);
2527 if (err)
2528 return err;
2529
2530 err = chip->info->ops->set_egress_port(chip,
2531 MV88E6XXX_EGRESS_DIR_EGRESS,
2532 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002533 if (err)
2534 return err;
2535 }
2536 }
2537
Vivien Didelotfa371c82017-12-05 15:34:10 -05002538 return 0;
2539}
2540
Vivien Didelotfad09c72016-06-21 12:28:20 -04002541static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002542{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002543 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002544 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002545 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002546
Andrew Lunn7b898462018-08-09 15:38:47 +02002547 chip->ports[port].chip = chip;
2548 chip->ports[port].port = port;
2549
Vivien Didelotd78343d2016-11-04 03:23:36 +01002550 /* MAC Forcing register: don't force link, speed, duplex or flow control
2551 * state to any particular values on physical ports, but force the CPU
2552 * port and all DSA ports to their maximum bandwidth and full duplex.
2553 */
2554 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2555 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2556 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002557 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002558 PHY_INTERFACE_MODE_NA);
2559 else
2560 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2561 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002562 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002563 PHY_INTERFACE_MODE_NA);
2564 if (err)
2565 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002566
2567 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2568 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2569 * tunneling, determine priority by looking at 802.1p and IP
2570 * priority fields (IP prio has precedence), and set STP state
2571 * to Forwarding.
2572 *
2573 * If this is the CPU link, use DSA or EDSA tagging depending
2574 * on which tagging mode was configured.
2575 *
2576 * If this is a link to another switch, use DSA tagging mode.
2577 *
2578 * If this is the upstream port for this switch, enable
2579 * forwarding of unknown unicasts and multicasts.
2580 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002581 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2582 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2583 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2584 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002585 if (err)
2586 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002587
Vivien Didelot601aeed2017-03-11 16:13:00 -05002588 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002589 if (err)
2590 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002591
Vivien Didelot601aeed2017-03-11 16:13:00 -05002592 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002593 if (err)
2594 return err;
2595
Vivien Didelot8efdda42015-08-13 12:52:23 -04002596 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002597 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002598 * untagged frames on this port, do a destination address lookup on all
2599 * received packets as usual, disable ARP mirroring and don't send a
2600 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002601 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002602 err = mv88e6xxx_port_set_map_da(chip, port);
2603 if (err)
2604 return err;
2605
Vivien Didelotfa371c82017-12-05 15:34:10 -05002606 err = mv88e6xxx_setup_upstream_port(chip, port);
2607 if (err)
2608 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002609
Andrew Lunna23b2962017-02-04 20:15:28 +01002610 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002611 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002612 if (err)
2613 return err;
2614
Vivien Didelotcd782652017-06-08 18:34:13 -04002615 if (chip->info->ops->port_set_jumbo_size) {
2616 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002617 if (err)
2618 return err;
2619 }
2620
Andrew Lunn54d792f2015-05-06 01:09:47 +02002621 /* Port Association Vector: when learning source addresses
2622 * of packets, add the address to the address database using
2623 * a port bitmap that has only the bit for this port set and
2624 * the other bits clear.
2625 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002626 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002627 /* Disable learning for CPU port */
2628 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002629 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002630
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002631 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2632 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002633 if (err)
2634 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002635
2636 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002637 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2638 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002639 if (err)
2640 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002641
Vivien Didelot08984322017-06-08 18:34:12 -04002642 if (chip->info->ops->port_pause_limit) {
2643 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002644 if (err)
2645 return err;
2646 }
2647
Vivien Didelotc8c94892017-03-11 16:13:01 -05002648 if (chip->info->ops->port_disable_learn_limit) {
2649 err = chip->info->ops->port_disable_learn_limit(chip, port);
2650 if (err)
2651 return err;
2652 }
2653
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002654 if (chip->info->ops->port_disable_pri_override) {
2655 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002656 if (err)
2657 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002658 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002659
Andrew Lunnef0a7312016-12-03 04:35:16 +01002660 if (chip->info->ops->port_tag_remap) {
2661 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002662 if (err)
2663 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002664 }
2665
Andrew Lunnef70b112016-12-03 04:45:18 +01002666 if (chip->info->ops->port_egress_rate_limiting) {
2667 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002668 if (err)
2669 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002670 }
2671
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002672 if (chip->info->ops->port_setup_message_port) {
2673 err = chip->info->ops->port_setup_message_port(chip, port);
2674 if (err)
2675 return err;
2676 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002677
Vivien Didelot207afda2016-04-14 14:42:09 -04002678 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002679 * database, and allow bidirectional communication between the
2680 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002681 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002682 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002683 if (err)
2684 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002685
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002686 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002687 if (err)
2688 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002689
2690 /* Default VLAN ID and priority: don't set a default VLAN
2691 * ID, and set the default packet priority to zero.
2692 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002693 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002694}
2695
Andrew Lunn04aca992017-05-26 01:03:24 +02002696static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2697 struct phy_device *phydev)
2698{
2699 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002700 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002701
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002702 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002703 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002704 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002705
2706 return err;
2707}
2708
Andrew Lunn75104db2019-02-24 20:44:43 +01002709static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002710{
2711 struct mv88e6xxx_chip *chip = ds->priv;
2712
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002713 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002714 if (mv88e6xxx_serdes_power(chip, port, false))
2715 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002716 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002717}
2718
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002719static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2720 unsigned int ageing_time)
2721{
Vivien Didelot04bed142016-08-31 18:06:13 -04002722 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002723 int err;
2724
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002725 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002726 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002727 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002728
2729 return err;
2730}
2731
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002732static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002733{
2734 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002735
Andrew Lunnde2273872016-11-21 23:27:01 +01002736 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002737 if (chip->info->ops->stats_set_histogram) {
2738 err = chip->info->ops->stats_set_histogram(chip);
2739 if (err)
2740 return err;
2741 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002742
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002743 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002744}
2745
Andrew Lunnea890982019-01-09 00:24:03 +01002746/* Check if the errata has already been applied. */
2747static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2748{
2749 int port;
2750 int err;
2751 u16 val;
2752
2753 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002754 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002755 if (err) {
2756 dev_err(chip->dev,
2757 "Error reading hidden register: %d\n", err);
2758 return false;
2759 }
2760 if (val != 0x01c0)
2761 return false;
2762 }
2763
2764 return true;
2765}
2766
2767/* The 6390 copper ports have an errata which require poking magic
2768 * values into undocumented hidden registers and then performing a
2769 * software reset.
2770 */
2771static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2772{
2773 int port;
2774 int err;
2775
2776 if (mv88e6390_setup_errata_applied(chip))
2777 return 0;
2778
2779 /* Set the ports into blocking mode */
2780 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2781 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2782 if (err)
2783 return err;
2784 }
2785
2786 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002787 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002788 if (err)
2789 return err;
2790 }
2791
2792 return mv88e6xxx_software_reset(chip);
2793}
2794
Andrew Lunn23e8b472019-10-25 01:03:52 +02002795enum mv88e6xxx_devlink_param_id {
2796 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2797 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2798};
2799
2800static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2801 struct devlink_param_gset_ctx *ctx)
2802{
2803 struct mv88e6xxx_chip *chip = ds->priv;
2804 int err;
2805
2806 mv88e6xxx_reg_lock(chip);
2807
2808 switch (id) {
2809 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2810 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2811 break;
2812 default:
2813 err = -EOPNOTSUPP;
2814 break;
2815 }
2816
2817 mv88e6xxx_reg_unlock(chip);
2818
2819 return err;
2820}
2821
2822static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2823 struct devlink_param_gset_ctx *ctx)
2824{
2825 struct mv88e6xxx_chip *chip = ds->priv;
2826 int err;
2827
2828 mv88e6xxx_reg_lock(chip);
2829
2830 switch (id) {
2831 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2832 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2833 break;
2834 default:
2835 err = -EOPNOTSUPP;
2836 break;
2837 }
2838
2839 mv88e6xxx_reg_unlock(chip);
2840
2841 return err;
2842}
2843
2844static const struct devlink_param mv88e6xxx_devlink_params[] = {
2845 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2846 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2847 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2848};
2849
2850static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2851{
2852 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2853 ARRAY_SIZE(mv88e6xxx_devlink_params));
2854}
2855
2856static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2857{
2858 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2859 ARRAY_SIZE(mv88e6xxx_devlink_params));
2860}
2861
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002862enum mv88e6xxx_devlink_resource_id {
2863 MV88E6XXX_RESOURCE_ID_ATU,
2864 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2865 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2866 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2867 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2868};
2869
2870static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2871 u16 bin)
2872{
2873 u16 occupancy = 0;
2874 int err;
2875
2876 mv88e6xxx_reg_lock(chip);
2877
2878 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2879 bin);
2880 if (err) {
2881 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2882 goto unlock;
2883 }
2884
2885 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2886 if (err) {
2887 dev_err(chip->dev, "failed to perform ATU get next\n");
2888 goto unlock;
2889 }
2890
2891 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2892 if (err) {
2893 dev_err(chip->dev, "failed to get ATU stats\n");
2894 goto unlock;
2895 }
2896
Andrew Lunn012fc742020-03-11 21:02:31 +01002897 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2898
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002899unlock:
2900 mv88e6xxx_reg_unlock(chip);
2901
2902 return occupancy;
2903}
2904
2905static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2906{
2907 struct mv88e6xxx_chip *chip = priv;
2908
2909 return mv88e6xxx_devlink_atu_bin_get(chip,
2910 MV88E6XXX_G2_ATU_STATS_BIN_0);
2911}
2912
2913static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2914{
2915 struct mv88e6xxx_chip *chip = priv;
2916
2917 return mv88e6xxx_devlink_atu_bin_get(chip,
2918 MV88E6XXX_G2_ATU_STATS_BIN_1);
2919}
2920
2921static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2922{
2923 struct mv88e6xxx_chip *chip = priv;
2924
2925 return mv88e6xxx_devlink_atu_bin_get(chip,
2926 MV88E6XXX_G2_ATU_STATS_BIN_2);
2927}
2928
2929static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2930{
2931 struct mv88e6xxx_chip *chip = priv;
2932
2933 return mv88e6xxx_devlink_atu_bin_get(chip,
2934 MV88E6XXX_G2_ATU_STATS_BIN_3);
2935}
2936
2937static u64 mv88e6xxx_devlink_atu_get(void *priv)
2938{
2939 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2940 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2941 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2942 mv88e6xxx_devlink_atu_bin_3_get(priv);
2943}
2944
2945static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2946{
2947 struct devlink_resource_size_params size_params;
2948 struct mv88e6xxx_chip *chip = ds->priv;
2949 int err;
2950
2951 devlink_resource_size_params_init(&size_params,
2952 mv88e6xxx_num_macs(chip),
2953 mv88e6xxx_num_macs(chip),
2954 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2955
2956 err = dsa_devlink_resource_register(ds, "ATU",
2957 mv88e6xxx_num_macs(chip),
2958 MV88E6XXX_RESOURCE_ID_ATU,
2959 DEVLINK_RESOURCE_ID_PARENT_TOP,
2960 &size_params);
2961 if (err)
2962 goto out;
2963
2964 devlink_resource_size_params_init(&size_params,
2965 mv88e6xxx_num_macs(chip) / 4,
2966 mv88e6xxx_num_macs(chip) / 4,
2967 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2968
2969 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2970 mv88e6xxx_num_macs(chip) / 4,
2971 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2972 MV88E6XXX_RESOURCE_ID_ATU,
2973 &size_params);
2974 if (err)
2975 goto out;
2976
2977 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2978 mv88e6xxx_num_macs(chip) / 4,
2979 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2980 MV88E6XXX_RESOURCE_ID_ATU,
2981 &size_params);
2982 if (err)
2983 goto out;
2984
2985 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2986 mv88e6xxx_num_macs(chip) / 4,
2987 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2988 MV88E6XXX_RESOURCE_ID_ATU,
2989 &size_params);
2990 if (err)
2991 goto out;
2992
2993 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2994 mv88e6xxx_num_macs(chip) / 4,
2995 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2996 MV88E6XXX_RESOURCE_ID_ATU,
2997 &size_params);
2998 if (err)
2999 goto out;
3000
3001 dsa_devlink_resource_occ_get_register(ds,
3002 MV88E6XXX_RESOURCE_ID_ATU,
3003 mv88e6xxx_devlink_atu_get,
3004 chip);
3005
3006 dsa_devlink_resource_occ_get_register(ds,
3007 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
3008 mv88e6xxx_devlink_atu_bin_0_get,
3009 chip);
3010
3011 dsa_devlink_resource_occ_get_register(ds,
3012 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3013 mv88e6xxx_devlink_atu_bin_1_get,
3014 chip);
3015
3016 dsa_devlink_resource_occ_get_register(ds,
3017 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3018 mv88e6xxx_devlink_atu_bin_2_get,
3019 chip);
3020
3021 dsa_devlink_resource_occ_get_register(ds,
3022 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3023 mv88e6xxx_devlink_atu_bin_3_get,
3024 chip);
3025
3026 return 0;
3027
3028out:
3029 dsa_devlink_resources_unregister(ds);
3030 return err;
3031}
3032
Andrew Lunn23e8b472019-10-25 01:03:52 +02003033static void mv88e6xxx_teardown(struct dsa_switch *ds)
3034{
3035 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003036 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003037}
3038
Vivien Didelotf81ec902016-05-09 13:22:58 -04003039static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003040{
Vivien Didelot04bed142016-08-31 18:06:13 -04003041 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003042 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003043 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003044 int i;
3045
Vivien Didelotfad09c72016-06-21 12:28:20 -04003046 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003047 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003048
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003049 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003050
Andrew Lunnea890982019-01-09 00:24:03 +01003051 if (chip->info->ops->setup_errata) {
3052 err = chip->info->ops->setup_errata(chip);
3053 if (err)
3054 goto unlock;
3055 }
3056
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003057 /* Cache the cmode of each port. */
3058 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3059 if (chip->info->ops->port_get_cmode) {
3060 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3061 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003062 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003063
3064 chip->ports[i].cmode = cmode;
3065 }
3066 }
3067
Vivien Didelot97299342016-07-18 20:45:30 -04003068 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003069 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003070 if (dsa_is_unused_port(ds, i))
3071 continue;
3072
Hubert Feursteinc8574862019-07-31 10:23:48 +02003073 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003074 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003075 dev_err(chip->dev, "port %d is invalid\n", i);
3076 err = -EINVAL;
3077 goto unlock;
3078 }
3079
Vivien Didelot97299342016-07-18 20:45:30 -04003080 err = mv88e6xxx_setup_port(chip, i);
3081 if (err)
3082 goto unlock;
3083 }
3084
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003085 err = mv88e6xxx_irl_setup(chip);
3086 if (err)
3087 goto unlock;
3088
Vivien Didelot04a69a12017-10-13 14:18:05 -04003089 err = mv88e6xxx_mac_setup(chip);
3090 if (err)
3091 goto unlock;
3092
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003093 err = mv88e6xxx_phy_setup(chip);
3094 if (err)
3095 goto unlock;
3096
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003097 err = mv88e6xxx_vtu_setup(chip);
3098 if (err)
3099 goto unlock;
3100
Vivien Didelot81228992017-03-30 17:37:08 -04003101 err = mv88e6xxx_pvt_setup(chip);
3102 if (err)
3103 goto unlock;
3104
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003105 err = mv88e6xxx_atu_setup(chip);
3106 if (err)
3107 goto unlock;
3108
Andrew Lunn87fa8862017-11-09 22:29:56 +01003109 err = mv88e6xxx_broadcast_setup(chip, 0);
3110 if (err)
3111 goto unlock;
3112
Vivien Didelot9e907d72017-07-17 13:03:43 -04003113 err = mv88e6xxx_pot_setup(chip);
3114 if (err)
3115 goto unlock;
3116
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003117 err = mv88e6xxx_rmu_setup(chip);
3118 if (err)
3119 goto unlock;
3120
Vivien Didelot51c901a2017-07-17 13:03:41 -04003121 err = mv88e6xxx_rsvd2cpu_setup(chip);
3122 if (err)
3123 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003124
Vivien Didelotb28f8722018-04-26 21:56:44 -04003125 err = mv88e6xxx_trunk_setup(chip);
3126 if (err)
3127 goto unlock;
3128
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003129 err = mv88e6xxx_devmap_setup(chip);
3130 if (err)
3131 goto unlock;
3132
Vivien Didelot93e18d62018-05-11 17:16:35 -04003133 err = mv88e6xxx_pri_setup(chip);
3134 if (err)
3135 goto unlock;
3136
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003137 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003138 if (chip->info->ptp_support) {
3139 err = mv88e6xxx_ptp_setup(chip);
3140 if (err)
3141 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003142
3143 err = mv88e6xxx_hwtstamp_setup(chip);
3144 if (err)
3145 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003146 }
3147
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003148 err = mv88e6xxx_stats_setup(chip);
3149 if (err)
3150 goto unlock;
3151
Vivien Didelot6b17e862015-08-13 12:52:18 -04003152unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003154
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003155 if (err)
3156 return err;
3157
3158 /* Have to be called without holding the register lock, since
3159 * they take the devlink lock, and we later take the locks in
3160 * the reverse order when getting/setting parameters or
3161 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003162 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003163 err = mv88e6xxx_setup_devlink_resources(ds);
3164 if (err)
3165 return err;
3166
3167 err = mv88e6xxx_setup_devlink_params(ds);
3168 if (err)
3169 dsa_devlink_resources_unregister(ds);
3170
3171 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003172}
3173
Vivien Didelote57e5e72016-08-15 17:19:00 -04003174static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003175{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003176 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3177 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003178 u16 val;
3179 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003180
Andrew Lunnee26a222017-01-24 14:53:48 +01003181 if (!chip->info->ops->phy_read)
3182 return -EOPNOTSUPP;
3183
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003184 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003185 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003186 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003187
Andrew Lunnda9f3302017-02-01 03:40:05 +01003188 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003189 /* Some internal PHYs don't have a model number. */
3190 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3191 /* Then there is the 6165 family. It gets is
3192 * PHYs correct. But it can also have two
3193 * SERDES interfaces in the PHY address
3194 * space. And these don't have a model
3195 * number. But they are not PHYs, so we don't
3196 * want to give them something a PHY driver
3197 * will recognise.
3198 *
3199 * Use the mv88e6390 family model number
3200 * instead, for anything which really could be
3201 * a PHY,
3202 */
3203 if (!(val & 0x3f0))
3204 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003205 }
3206
Vivien Didelote57e5e72016-08-15 17:19:00 -04003207 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003208}
3209
Vivien Didelote57e5e72016-08-15 17:19:00 -04003210static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003211{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003212 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3213 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003214 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003215
Andrew Lunnee26a222017-01-24 14:53:48 +01003216 if (!chip->info->ops->phy_write)
3217 return -EOPNOTSUPP;
3218
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003219 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003220 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003221 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003222
3223 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003224}
3225
Vivien Didelotfad09c72016-06-21 12:28:20 -04003226static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003227 struct device_node *np,
3228 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003229{
3230 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003231 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003232 struct mii_bus *bus;
3233 int err;
3234
Andrew Lunn2510bab2018-02-22 01:51:49 +01003235 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003236 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003237 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003238 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003239
3240 if (err)
3241 return err;
3242 }
3243
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003244 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003245 if (!bus)
3246 return -ENOMEM;
3247
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003248 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003249 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003250 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003251 INIT_LIST_HEAD(&mdio_bus->list);
3252 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003253
Andrew Lunnb516d452016-06-04 21:17:06 +02003254 if (np) {
3255 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003256 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003257 } else {
3258 bus->name = "mv88e6xxx SMI";
3259 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3260 }
3261
3262 bus->read = mv88e6xxx_mdio_read;
3263 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003264 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003265
Andrew Lunn6f882842018-03-17 20:32:05 +01003266 if (!external) {
3267 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3268 if (err)
3269 return err;
3270 }
3271
Florian Fainelli00e798c2018-05-15 16:56:19 -07003272 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003273 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003274 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003275 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003276 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003277 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003278
3279 if (external)
3280 list_add_tail(&mdio_bus->list, &chip->mdios);
3281 else
3282 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003283
3284 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003285}
3286
Andrew Lunna3c53be52017-01-24 14:53:50 +01003287static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3288 { .compatible = "marvell,mv88e6xxx-mdio-external",
3289 .data = (void *)true },
3290 { },
3291};
3292
Andrew Lunn3126aee2017-12-07 01:05:57 +01003293static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3294
3295{
3296 struct mv88e6xxx_mdio_bus *mdio_bus;
3297 struct mii_bus *bus;
3298
3299 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3300 bus = mdio_bus->bus;
3301
Andrew Lunn6f882842018-03-17 20:32:05 +01003302 if (!mdio_bus->external)
3303 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3304
Andrew Lunn3126aee2017-12-07 01:05:57 +01003305 mdiobus_unregister(bus);
3306 }
3307}
3308
Andrew Lunna3c53be52017-01-24 14:53:50 +01003309static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3310 struct device_node *np)
3311{
3312 const struct of_device_id *match;
3313 struct device_node *child;
3314 int err;
3315
3316 /* Always register one mdio bus for the internal/default mdio
3317 * bus. This maybe represented in the device tree, but is
3318 * optional.
3319 */
3320 child = of_get_child_by_name(np, "mdio");
3321 err = mv88e6xxx_mdio_register(chip, child, false);
3322 if (err)
3323 return err;
3324
3325 /* Walk the device tree, and see if there are any other nodes
3326 * which say they are compatible with the external mdio
3327 * bus.
3328 */
3329 for_each_available_child_of_node(np, child) {
3330 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3331 if (match) {
3332 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003333 if (err) {
3334 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303335 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003336 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003337 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003338 }
3339 }
3340
3341 return 0;
3342}
3343
Vivien Didelot855b1932016-07-20 18:18:35 -04003344static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3345{
Vivien Didelot04bed142016-08-31 18:06:13 -04003346 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003347
3348 return chip->eeprom_len;
3349}
3350
Vivien Didelot855b1932016-07-20 18:18:35 -04003351static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3352 struct ethtool_eeprom *eeprom, u8 *data)
3353{
Vivien Didelot04bed142016-08-31 18:06:13 -04003354 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003355 int err;
3356
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003357 if (!chip->info->ops->get_eeprom)
3358 return -EOPNOTSUPP;
3359
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003360 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003361 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003362 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003363
3364 if (err)
3365 return err;
3366
3367 eeprom->magic = 0xc3ec4951;
3368
3369 return 0;
3370}
3371
Vivien Didelot855b1932016-07-20 18:18:35 -04003372static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3373 struct ethtool_eeprom *eeprom, u8 *data)
3374{
Vivien Didelot04bed142016-08-31 18:06:13 -04003375 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003376 int err;
3377
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003378 if (!chip->info->ops->set_eeprom)
3379 return -EOPNOTSUPP;
3380
Vivien Didelot855b1932016-07-20 18:18:35 -04003381 if (eeprom->magic != 0xc3ec4951)
3382 return -EINVAL;
3383
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003384 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003385 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003386 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003387
3388 return err;
3389}
3390
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003391static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003392 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003393 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3394 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003395 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003396 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003397 .phy_read = mv88e6185_phy_ppu_read,
3398 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003399 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003400 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003401 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003402 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003403 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003404 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003405 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003406 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003407 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003408 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003409 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003410 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003411 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003412 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003413 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3414 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003415 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003416 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3417 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003418 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003419 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003420 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003421 .ppu_enable = mv88e6185_g1_ppu_enable,
3422 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003423 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003424 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003425 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003426 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003427 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003428};
3429
3430static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003431 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003432 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3433 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003434 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003435 .phy_read = mv88e6185_phy_ppu_read,
3436 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003437 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003438 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003439 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003440 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003441 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003442 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003443 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003444 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003445 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003446 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3447 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003448 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003449 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003450 .ppu_enable = mv88e6185_g1_ppu_enable,
3451 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003452 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003453 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003454 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003455 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003456};
3457
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003458static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003459 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003460 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3461 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003462 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003463 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3464 .phy_read = mv88e6xxx_g2_smi_phy_read,
3465 .phy_write = mv88e6xxx_g2_smi_phy_write,
3466 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003467 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003468 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003469 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003470 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003471 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003472 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003473 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003474 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003475 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003476 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003477 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003478 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003479 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003480 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003481 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3482 .stats_get_strings = mv88e6095_stats_get_strings,
3483 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003484 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3485 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003486 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003487 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003488 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003489 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003490 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003491 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003492 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003493 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003494};
3495
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003496static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003497 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003498 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3499 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003500 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003501 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003502 .phy_read = mv88e6xxx_g2_smi_phy_read,
3503 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003504 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003505 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003506 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003507 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003508 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003509 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003510 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003511 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003512 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003513 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003514 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3515 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003516 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003517 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3518 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003519 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003520 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003521 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003522 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003523 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3524 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003525 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003526 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003527 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003528};
3529
3530static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003531 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003532 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3533 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003534 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003535 .phy_read = mv88e6185_phy_ppu_read,
3536 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003537 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003538 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003539 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003540 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003541 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003542 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003543 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003544 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003545 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003546 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003547 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003548 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003549 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003550 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003551 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003552 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3553 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003554 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003555 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3556 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003557 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003558 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003559 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003560 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003561 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003562 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003563 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003564 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003565 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003566};
3567
Vivien Didelot990e27b2017-03-28 13:50:32 -04003568static const struct mv88e6xxx_ops mv88e6141_ops = {
3569 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003570 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3571 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003572 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003573 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3574 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3575 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3576 .phy_read = mv88e6xxx_g2_smi_phy_read,
3577 .phy_write = mv88e6xxx_g2_smi_phy_write,
3578 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003579 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003580 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003581 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003582 .port_tag_remap = mv88e6095_port_tag_remap,
3583 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3584 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3585 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003586 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003587 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003588 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003589 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3590 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003591 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003592 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003593 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003594 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003595 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003596 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3597 .stats_get_strings = mv88e6320_stats_get_strings,
3598 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003599 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3600 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003601 .watchdog_ops = &mv88e6390_watchdog_ops,
3602 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003603 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003604 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003605 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003606 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003607 .serdes_power = mv88e6390_serdes_power,
3608 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003609 /* Check status register pause & lpa register */
3610 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3611 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3612 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3613 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003614 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003615 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003616 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003617 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003618 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003619};
3620
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003621static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003622 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003623 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3624 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003625 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003626 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003627 .phy_read = mv88e6xxx_g2_smi_phy_read,
3628 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003629 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003630 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003631 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003632 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003633 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003635 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003636 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003637 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003638 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003639 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003640 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003641 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003642 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003643 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003644 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3645 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003646 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003647 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3648 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003649 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003650 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003651 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003652 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003653 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3654 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003655 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003656 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003657 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003658 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003659 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003660};
3661
3662static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003663 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003664 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3665 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003666 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003667 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003668 .phy_read = mv88e6165_phy_read,
3669 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003670 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003671 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003672 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003673 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003674 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003675 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003676 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003677 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003678 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3679 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003680 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003681 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3682 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003683 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003684 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003685 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003686 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003687 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3688 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003689 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003690 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003691 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003692 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003693 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003694};
3695
3696static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003697 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003698 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3699 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003700 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003701 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003702 .phy_read = mv88e6xxx_g2_smi_phy_read,
3703 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003704 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003705 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003706 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003707 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003708 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003709 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003710 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003711 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003712 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003713 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003714 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003715 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003716 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003717 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003718 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003719 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003720 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3721 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003722 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003723 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3724 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003725 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003726 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003727 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003728 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003729 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3730 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003731 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003732 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003733 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003734};
3735
3736static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003737 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003738 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3739 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003740 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003741 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3742 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003743 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003744 .phy_read = mv88e6xxx_g2_smi_phy_read,
3745 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003746 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003747 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003748 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003749 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003750 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003751 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003752 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003753 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003754 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003755 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003756 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003757 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003758 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003759 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003760 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003761 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003762 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003763 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3764 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003765 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003766 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3767 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003768 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003769 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003770 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003771 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003772 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003773 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3774 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003775 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003776 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003777 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003778 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3779 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3780 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3781 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003782 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003783 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3784 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003785 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003786 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003787};
3788
3789static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003790 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003791 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3792 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003793 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003794 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003795 .phy_read = mv88e6xxx_g2_smi_phy_read,
3796 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003797 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003798 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003799 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003800 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003801 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003802 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003803 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003804 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003805 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003806 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003807 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003808 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003809 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003810 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003811 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003812 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003813 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3814 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003815 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003816 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3817 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003818 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003819 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003820 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003821 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003822 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3823 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003824 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003825 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003826 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003827};
3828
3829static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003830 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003831 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3832 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003833 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003834 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3835 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003836 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003837 .phy_read = mv88e6xxx_g2_smi_phy_read,
3838 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003839 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003840 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003841 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003842 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003843 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003844 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003845 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003847 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003848 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003849 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003850 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003851 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003852 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003853 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003854 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003855 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003856 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3857 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003858 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003859 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3860 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003861 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003862 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003863 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003864 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003865 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003866 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3867 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003868 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003869 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003870 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003871 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3872 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3873 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3874 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003875 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003876 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003877 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003878 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003879 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3880 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003881 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003882 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003883};
3884
3885static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003886 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003887 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3888 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003889 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003890 .phy_read = mv88e6185_phy_ppu_read,
3891 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003892 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003893 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003894 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003895 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003896 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003897 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003898 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003899 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003900 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003901 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003902 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003903 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3904 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003905 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003906 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3907 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003908 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003909 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003910 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003911 .ppu_enable = mv88e6185_g1_ppu_enable,
3912 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003913 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003914 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003915 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003916 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003917};
3918
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003919static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003920 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003921 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003922 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003923 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3924 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003925 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3926 .phy_read = mv88e6xxx_g2_smi_phy_read,
3927 .phy_write = mv88e6xxx_g2_smi_phy_write,
3928 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003929 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003930 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003931 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003932 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003933 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003934 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003935 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003936 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003937 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003938 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003939 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003940 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003941 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003942 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003943 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003944 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003945 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3946 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003947 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003948 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3949 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003950 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003951 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003952 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003953 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003954 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003955 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3956 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003957 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3958 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003959 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003960 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003961 /* Check status register pause & lpa register */
3962 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3963 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3964 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3965 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003966 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003967 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003968 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003969 .serdes_get_strings = mv88e6390_serdes_get_strings,
3970 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003971 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3972 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003973 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003974 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003975};
3976
3977static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003978 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003979 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003980 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003981 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3982 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003983 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3984 .phy_read = mv88e6xxx_g2_smi_phy_read,
3985 .phy_write = mv88e6xxx_g2_smi_phy_write,
3986 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003987 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003988 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003989 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003990 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003991 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003992 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003993 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003994 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003995 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003996 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003997 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003998 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003999 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004000 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004001 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004002 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004003 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4004 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004005 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004006 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4007 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004008 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004009 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004010 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004011 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004012 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004013 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4014 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004015 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4016 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004017 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004018 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004019 /* Check status register pause & lpa register */
4020 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4021 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4022 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4023 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004024 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004025 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004026 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004027 .serdes_get_strings = mv88e6390_serdes_get_strings,
4028 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004029 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4030 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004031 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004032 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004033};
4034
4035static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004036 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004037 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004038 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004039 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4040 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004041 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4042 .phy_read = mv88e6xxx_g2_smi_phy_read,
4043 .phy_write = mv88e6xxx_g2_smi_phy_write,
4044 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004045 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004046 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004047 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004048 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004049 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004050 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004051 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004052 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004053 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004054 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004055 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004056 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004057 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004058 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004059 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004060 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4061 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004062 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004063 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4064 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004065 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004066 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004067 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004068 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004069 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004070 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4071 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004072 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4073 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004074 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004075 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004076 /* Check status register pause & lpa register */
4077 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4078 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4079 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4080 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004081 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004082 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004083 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004084 .serdes_get_strings = mv88e6390_serdes_get_strings,
4085 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004086 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4087 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004088 .avb_ops = &mv88e6390_avb_ops,
4089 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004090 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004091};
4092
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004093static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004094 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004095 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4096 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004097 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004098 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4099 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004100 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004101 .phy_read = mv88e6xxx_g2_smi_phy_read,
4102 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004103 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004104 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004105 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004106 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004107 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004108 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004109 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004110 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004111 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004112 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004113 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004114 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004115 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004116 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004117 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004118 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004119 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004120 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4121 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004122 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004123 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4124 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004125 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004126 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004127 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004128 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004129 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004130 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4131 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004132 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004133 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004134 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004135 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4136 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4137 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4138 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004139 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004140 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004141 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004142 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004143 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4144 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004145 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004146 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004147 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004148 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004149};
4150
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004151static const struct mv88e6xxx_ops mv88e6250_ops = {
4152 /* MV88E6XXX_FAMILY_6250 */
4153 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4154 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4155 .irl_init_all = mv88e6352_g2_irl_init_all,
4156 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4157 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4158 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4159 .phy_read = mv88e6xxx_g2_smi_phy_read,
4160 .phy_write = mv88e6xxx_g2_smi_phy_write,
4161 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004162 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004163 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004164 .port_tag_remap = mv88e6095_port_tag_remap,
4165 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4166 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4167 .port_set_ether_type = mv88e6351_port_set_ether_type,
4168 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4169 .port_pause_limit = mv88e6097_port_pause_limit,
4170 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004171 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4172 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4173 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4174 .stats_get_strings = mv88e6250_stats_get_strings,
4175 .stats_get_stats = mv88e6250_stats_get_stats,
4176 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4177 .set_egress_port = mv88e6095_g1_set_egress_port,
4178 .watchdog_ops = &mv88e6250_watchdog_ops,
4179 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4180 .pot_clear = mv88e6xxx_g2_pot_clear,
4181 .reset = mv88e6250_g1_reset,
4182 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4183 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004184 .avb_ops = &mv88e6352_avb_ops,
4185 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004186 .phylink_validate = mv88e6065_phylink_validate,
4187};
4188
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004189static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004190 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004191 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004192 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004193 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4194 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004195 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4196 .phy_read = mv88e6xxx_g2_smi_phy_read,
4197 .phy_write = mv88e6xxx_g2_smi_phy_write,
4198 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004199 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004200 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004201 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004202 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004203 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004204 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004205 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004206 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004207 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004208 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004209 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004210 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004211 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004212 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004213 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004214 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004215 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4216 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004217 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004218 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4219 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004220 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004221 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004222 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004223 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004224 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004225 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4226 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004227 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4228 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004229 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004230 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004231 /* Check status register pause & lpa register */
4232 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4233 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4234 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4235 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004236 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004237 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004238 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004239 .serdes_get_strings = mv88e6390_serdes_get_strings,
4240 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004241 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4242 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004243 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004244 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004245 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004246 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004247};
4248
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004249static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004250 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004251 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4252 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004253 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004254 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4255 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004256 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004257 .phy_read = mv88e6xxx_g2_smi_phy_read,
4258 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004259 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004260 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004261 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004262 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004263 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004264 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004265 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004266 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004267 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004268 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004269 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004270 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004271 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004272 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004273 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004274 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4275 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004276 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004277 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4278 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004279 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004280 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004281 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004282 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004283 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004284 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004285 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004286 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004287 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004288 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004289};
4290
4291static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004292 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004293 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4294 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004295 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004296 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4297 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004298 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004299 .phy_read = mv88e6xxx_g2_smi_phy_read,
4300 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004301 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004302 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004303 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004304 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004305 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004306 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004307 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004308 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004309 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004310 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004311 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004312 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004313 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004314 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004315 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004316 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4317 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004318 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004319 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4320 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004321 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004322 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004323 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004324 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004325 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004326 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004327 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004328 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004329};
4330
Vivien Didelot16e329a2017-03-28 13:50:33 -04004331static const struct mv88e6xxx_ops mv88e6341_ops = {
4332 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004333 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4334 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004335 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004336 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4337 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4338 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4339 .phy_read = mv88e6xxx_g2_smi_phy_read,
4340 .phy_write = mv88e6xxx_g2_smi_phy_write,
4341 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004342 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004343 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004344 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004345 .port_tag_remap = mv88e6095_port_tag_remap,
4346 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4347 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4348 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004349 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004350 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004351 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004352 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4353 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004354 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004355 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004356 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004357 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004358 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004359 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4360 .stats_get_strings = mv88e6320_stats_get_strings,
4361 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004362 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4363 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004364 .watchdog_ops = &mv88e6390_watchdog_ops,
4365 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004366 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004367 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004368 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004369 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004370 .serdes_power = mv88e6390_serdes_power,
4371 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004372 /* Check status register pause & lpa register */
4373 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4374 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4375 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4376 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004377 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004378 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004379 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004380 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004381 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004382 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004383 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004384};
4385
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004386static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004387 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004388 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4389 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004390 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004391 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004392 .phy_read = mv88e6xxx_g2_smi_phy_read,
4393 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004394 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004395 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004396 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004397 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004398 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004399 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004400 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004401 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004402 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004403 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004404 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004405 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004406 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004407 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004408 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004409 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004410 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4411 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004412 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004413 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4414 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004415 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004416 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004417 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004418 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004419 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4420 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004421 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004422 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004423 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004424};
4425
4426static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004427 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004428 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4429 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004430 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004431 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004432 .phy_read = mv88e6xxx_g2_smi_phy_read,
4433 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004434 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004435 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004436 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004437 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004438 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004439 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004440 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004441 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004442 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004443 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004444 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004445 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004446 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004447 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004448 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004449 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004450 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4451 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004452 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004453 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4454 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004455 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004456 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004457 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004458 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004459 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4460 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004461 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004462 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004463 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004464 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004465 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004466};
4467
4468static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004469 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004470 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4471 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004472 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004473 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4474 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004475 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004476 .phy_read = mv88e6xxx_g2_smi_phy_read,
4477 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004478 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004479 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004480 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004481 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004482 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004483 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004484 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004485 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004486 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004487 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004488 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004489 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004490 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004491 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004492 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004493 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004494 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004495 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4496 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004497 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004498 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4499 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004500 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004501 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004502 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004503 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004504 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004505 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4506 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004507 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004508 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004509 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004510 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4511 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4512 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4513 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004514 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004515 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004516 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004517 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004518 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004519 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004520 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004521 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4522 .serdes_get_strings = mv88e6352_serdes_get_strings,
4523 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004524 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4525 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004526 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004527};
4528
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004529static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004530 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004531 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004532 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004533 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4534 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004535 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4536 .phy_read = mv88e6xxx_g2_smi_phy_read,
4537 .phy_write = mv88e6xxx_g2_smi_phy_write,
4538 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004539 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004540 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004541 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004542 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004543 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004544 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004545 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004546 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004547 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004548 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004549 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004550 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004551 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004552 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004553 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004554 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004555 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004556 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004557 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4558 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004559 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004560 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4561 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004562 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004563 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004564 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004565 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004566 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004567 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4568 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004569 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4570 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004571 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004572 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004573 /* Check status register pause & lpa register */
4574 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4575 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4576 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4577 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004578 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004579 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004580 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004581 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004582 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004583 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004584 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4585 .serdes_get_strings = mv88e6390_serdes_get_strings,
4586 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004587 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4588 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004589 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004590};
4591
4592static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004593 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004594 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004595 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004596 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4597 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004598 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4599 .phy_read = mv88e6xxx_g2_smi_phy_read,
4600 .phy_write = mv88e6xxx_g2_smi_phy_write,
4601 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004602 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004603 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004604 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004605 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004606 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004607 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004608 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004609 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004610 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004611 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004612 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004613 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004614 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004615 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004616 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004617 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004618 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004619 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004620 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4621 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004622 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004623 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4624 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004625 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004626 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004627 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004628 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004629 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004630 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4631 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004632 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4633 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004634 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004635 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004636 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4637 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4638 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4639 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004640 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004641 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004642 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004643 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4644 .serdes_get_strings = mv88e6390_serdes_get_strings,
4645 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004646 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4647 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004648 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004649 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004650 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004651 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004652};
4653
Vivien Didelotf81ec902016-05-09 13:22:58 -04004654static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4655 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004656 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004657 .family = MV88E6XXX_FAMILY_6097,
4658 .name = "Marvell 88E6085",
4659 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004660 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004661 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004662 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004663 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004664 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004665 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004666 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004667 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004668 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004669 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004670 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004671 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004672 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004673 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004674 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004675 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004676 },
4677
4678 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004679 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004680 .family = MV88E6XXX_FAMILY_6095,
4681 .name = "Marvell 88E6095/88E6095F",
4682 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004683 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004684 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004685 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004686 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004687 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004688 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004689 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004690 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004691 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004692 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004693 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004694 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004695 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004696 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004697 },
4698
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004699 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004700 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004701 .family = MV88E6XXX_FAMILY_6097,
4702 .name = "Marvell 88E6097/88E6097F",
4703 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004704 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004705 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004706 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004707 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004708 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004709 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004710 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004711 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004712 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004713 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004714 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004715 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004716 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004717 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004718 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004719 .ops = &mv88e6097_ops,
4720 },
4721
Vivien Didelotf81ec902016-05-09 13:22:58 -04004722 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004723 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004724 .family = MV88E6XXX_FAMILY_6165,
4725 .name = "Marvell 88E6123",
4726 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004727 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004729 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004730 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004731 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004732 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004733 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004734 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004735 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004736 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004737 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004738 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004739 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004740 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004741 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004742 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004743 },
4744
4745 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004746 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 .family = MV88E6XXX_FAMILY_6185,
4748 .name = "Marvell 88E6131",
4749 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004750 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004751 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004752 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004753 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004754 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004755 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004756 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004757 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004758 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004759 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004760 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004761 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004762 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004763 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004764 },
4765
Vivien Didelot990e27b2017-03-28 13:50:32 -04004766 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004767 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004768 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004769 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004770 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004771 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004772 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004773 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004774 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004775 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004776 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004777 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004778 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004779 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004780 .age_time_coeff = 3750,
4781 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004782 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004783 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004784 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004785 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004786 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004787 .ops = &mv88e6141_ops,
4788 },
4789
Vivien Didelotf81ec902016-05-09 13:22:58 -04004790 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004791 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004792 .family = MV88E6XXX_FAMILY_6165,
4793 .name = "Marvell 88E6161",
4794 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004795 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004796 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004797 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004798 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004799 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004800 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004801 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004802 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004803 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004804 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004805 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004806 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004807 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004808 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004809 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004810 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004811 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004812 },
4813
4814 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004815 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004816 .family = MV88E6XXX_FAMILY_6165,
4817 .name = "Marvell 88E6165",
4818 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004819 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004820 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004821 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004822 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004823 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004824 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004825 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004826 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004827 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004828 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004829 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004830 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004831 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004832 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004833 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004834 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004835 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004836 },
4837
4838 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004839 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004840 .family = MV88E6XXX_FAMILY_6351,
4841 .name = "Marvell 88E6171",
4842 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004843 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004844 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004845 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004846 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004847 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004848 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004849 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004850 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004851 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004852 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004853 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004854 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004855 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004856 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004857 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004858 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004859 },
4860
4861 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004862 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004863 .family = MV88E6XXX_FAMILY_6352,
4864 .name = "Marvell 88E6172",
4865 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004866 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004867 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004868 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004869 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004870 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004871 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004872 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004873 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004874 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004875 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004876 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004877 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004878 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004879 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004880 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004881 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004882 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004883 },
4884
4885 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004886 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004887 .family = MV88E6XXX_FAMILY_6351,
4888 .name = "Marvell 88E6175",
4889 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004890 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004891 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004892 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004893 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004894 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004895 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004896 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004897 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004898 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004899 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004900 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004901 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004902 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004903 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004904 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004905 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004906 },
4907
4908 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004909 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004910 .family = MV88E6XXX_FAMILY_6352,
4911 .name = "Marvell 88E6176",
4912 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004913 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004914 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004915 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004916 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004917 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004918 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004919 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004920 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004921 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004922 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004923 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004924 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004925 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004926 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004927 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004928 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004929 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004930 },
4931
4932 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004933 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004934 .family = MV88E6XXX_FAMILY_6185,
4935 .name = "Marvell 88E6185",
4936 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004937 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004938 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004939 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004940 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004941 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004942 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004943 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004944 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004945 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004946 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004947 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004948 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004949 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004950 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004951 },
4952
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004953 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004954 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004955 .family = MV88E6XXX_FAMILY_6390,
4956 .name = "Marvell 88E6190",
4957 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004958 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004959 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004960 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004961 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004962 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004963 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004964 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004965 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004966 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004967 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004968 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004969 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004970 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004971 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004972 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004973 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004974 .ops = &mv88e6190_ops,
4975 },
4976
4977 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004978 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004979 .family = MV88E6XXX_FAMILY_6390,
4980 .name = "Marvell 88E6190X",
4981 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004982 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004983 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004984 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004985 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004986 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004987 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004988 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004989 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004990 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004991 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004992 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004993 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004994 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004995 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004996 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004997 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004998 .ops = &mv88e6190x_ops,
4999 },
5000
5001 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005002 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005003 .family = MV88E6XXX_FAMILY_6390,
5004 .name = "Marvell 88E6191",
5005 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005006 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005007 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005008 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005009 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005010 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005011 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005012 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005013 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005014 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005015 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005016 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005017 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005018 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005019 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005020 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005021 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005022 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005023 },
5024
Hubert Feurstein49022642019-07-31 10:23:46 +02005025 [MV88E6220] = {
5026 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5027 .family = MV88E6XXX_FAMILY_6250,
5028 .name = "Marvell 88E6220",
5029 .num_databases = 64,
5030
5031 /* Ports 2-4 are not routed to pins
5032 * => usable ports 0, 1, 5, 6
5033 */
5034 .num_ports = 7,
5035 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005036 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005037 .max_vid = 4095,
5038 .port_base_addr = 0x08,
5039 .phy_base_addr = 0x00,
5040 .global1_addr = 0x0f,
5041 .global2_addr = 0x07,
5042 .age_time_coeff = 15000,
5043 .g1_irqs = 9,
5044 .g2_irqs = 10,
5045 .atu_move_port_mask = 0xf,
5046 .dual_chip = true,
5047 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005048 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005049 .ops = &mv88e6250_ops,
5050 },
5051
Vivien Didelotf81ec902016-05-09 13:22:58 -04005052 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005053 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005054 .family = MV88E6XXX_FAMILY_6352,
5055 .name = "Marvell 88E6240",
5056 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005057 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005058 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005059 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005060 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005061 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005062 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005063 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005064 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005065 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005066 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005067 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005068 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005069 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005070 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005071 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005072 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005073 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005074 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005075 },
5076
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005077 [MV88E6250] = {
5078 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5079 .family = MV88E6XXX_FAMILY_6250,
5080 .name = "Marvell 88E6250",
5081 .num_databases = 64,
5082 .num_ports = 7,
5083 .num_internal_phys = 5,
5084 .max_vid = 4095,
5085 .port_base_addr = 0x08,
5086 .phy_base_addr = 0x00,
5087 .global1_addr = 0x0f,
5088 .global2_addr = 0x07,
5089 .age_time_coeff = 15000,
5090 .g1_irqs = 9,
5091 .g2_irqs = 10,
5092 .atu_move_port_mask = 0xf,
5093 .dual_chip = true,
5094 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005095 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005096 .ops = &mv88e6250_ops,
5097 },
5098
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005099 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005100 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005101 .family = MV88E6XXX_FAMILY_6390,
5102 .name = "Marvell 88E6290",
5103 .num_databases = 4096,
5104 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005105 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005106 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005107 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005108 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005109 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005110 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005111 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005112 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005113 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005114 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005115 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005116 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005117 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005118 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005119 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005120 .ops = &mv88e6290_ops,
5121 },
5122
Vivien Didelotf81ec902016-05-09 13:22:58 -04005123 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005124 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005125 .family = MV88E6XXX_FAMILY_6320,
5126 .name = "Marvell 88E6320",
5127 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005128 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005129 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005130 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005131 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005132 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005133 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005134 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005135 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005136 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005137 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005138 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005139 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005140 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005141 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005142 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005143 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005144 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005145 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005146 },
5147
5148 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005149 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005150 .family = MV88E6XXX_FAMILY_6320,
5151 .name = "Marvell 88E6321",
5152 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005153 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005154 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005155 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005156 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005157 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005158 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005159 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005160 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005161 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005162 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005163 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005164 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005165 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005166 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005167 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005168 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005169 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005170 },
5171
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005172 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005173 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005174 .family = MV88E6XXX_FAMILY_6341,
5175 .name = "Marvell 88E6341",
5176 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005177 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005178 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005179 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005180 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005181 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005182 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005183 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005184 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005185 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005186 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005187 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005188 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005189 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005190 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005191 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005192 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005193 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005194 .ops = &mv88e6341_ops,
5195 },
5196
Vivien Didelotf81ec902016-05-09 13:22:58 -04005197 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005198 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005199 .family = MV88E6XXX_FAMILY_6351,
5200 .name = "Marvell 88E6350",
5201 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005202 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005203 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005204 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005205 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005206 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005207 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005208 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005209 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005210 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005211 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005212 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005213 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005214 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005215 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005216 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005217 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005218 },
5219
5220 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005221 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005222 .family = MV88E6XXX_FAMILY_6351,
5223 .name = "Marvell 88E6351",
5224 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005225 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005226 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005227 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005228 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005229 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005230 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005231 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005232 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005233 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005234 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005235 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005236 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005237 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005238 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005239 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005240 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005241 },
5242
5243 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005244 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005245 .family = MV88E6XXX_FAMILY_6352,
5246 .name = "Marvell 88E6352",
5247 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005248 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005249 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005250 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005251 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005252 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005253 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005254 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005255 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005256 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005257 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005258 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005259 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005260 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005261 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005262 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005263 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005264 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005265 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005266 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005267 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005268 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005269 .family = MV88E6XXX_FAMILY_6390,
5270 .name = "Marvell 88E6390",
5271 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005272 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005273 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005274 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005275 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005276 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005277 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005278 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005279 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005280 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005281 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005282 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005283 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005284 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005285 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005286 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005287 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005288 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005289 .ops = &mv88e6390_ops,
5290 },
5291 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005292 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005293 .family = MV88E6XXX_FAMILY_6390,
5294 .name = "Marvell 88E6390X",
5295 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005296 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005297 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005298 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005299 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005300 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005301 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005302 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005303 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005304 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005305 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005306 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005307 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005308 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005309 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005310 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005311 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005312 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005313 .ops = &mv88e6390x_ops,
5314 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005315};
5316
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005317static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005318{
Vivien Didelota439c062016-04-17 13:23:58 -04005319 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005320
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005321 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5322 if (mv88e6xxx_table[i].prod_num == prod_num)
5323 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005324
Vivien Didelotb9b37712015-10-30 19:39:48 -04005325 return NULL;
5326}
5327
Vivien Didelotfad09c72016-06-21 12:28:20 -04005328static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005329{
5330 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005331 unsigned int prod_num, rev;
5332 u16 id;
5333 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005334
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005335 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005336 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005337 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005338 if (err)
5339 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005340
Vivien Didelot107fcc12017-06-12 12:37:36 -04005341 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5342 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005343
5344 info = mv88e6xxx_lookup_info(prod_num);
5345 if (!info)
5346 return -ENODEV;
5347
Vivien Didelotcaac8542016-06-20 13:14:09 -04005348 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005349 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005350
Vivien Didelotca070c12016-09-02 14:45:34 -04005351 err = mv88e6xxx_g2_require(chip);
5352 if (err)
5353 return err;
5354
Vivien Didelotfad09c72016-06-21 12:28:20 -04005355 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5356 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005357
5358 return 0;
5359}
5360
Vivien Didelotfad09c72016-06-21 12:28:20 -04005361static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005362{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005363 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005364
Vivien Didelotfad09c72016-06-21 12:28:20 -04005365 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5366 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005367 return NULL;
5368
Vivien Didelotfad09c72016-06-21 12:28:20 -04005369 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005370
Vivien Didelotfad09c72016-06-21 12:28:20 -04005371 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005372 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005373 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005374
Vivien Didelotfad09c72016-06-21 12:28:20 -04005375 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005376}
5377
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005378static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005379 int port,
5380 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005381{
Vivien Didelot04bed142016-08-31 18:06:13 -04005382 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005383
Andrew Lunn443d5a12016-12-03 04:35:18 +01005384 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005385}
5386
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005387static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005388 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005389{
5390 /* We don't need any dynamic resource from the kernel (yet),
5391 * so skip the prepare phase.
5392 */
5393
5394 return 0;
5395}
5396
5397static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005398 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005399{
Vivien Didelot04bed142016-08-31 18:06:13 -04005400 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005401
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005402 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005403 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005404 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005405 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5406 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005407 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005408}
5409
5410static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5411 const struct switchdev_obj_port_mdb *mdb)
5412{
Vivien Didelot04bed142016-08-31 18:06:13 -04005413 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005414 int err;
5415
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005416 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005417 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005418 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005419
5420 return err;
5421}
5422
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005423static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5424 struct dsa_mall_mirror_tc_entry *mirror,
5425 bool ingress)
5426{
5427 enum mv88e6xxx_egress_direction direction = ingress ?
5428 MV88E6XXX_EGRESS_DIR_INGRESS :
5429 MV88E6XXX_EGRESS_DIR_EGRESS;
5430 struct mv88e6xxx_chip *chip = ds->priv;
5431 bool other_mirrors = false;
5432 int i;
5433 int err;
5434
5435 if (!chip->info->ops->set_egress_port)
5436 return -EOPNOTSUPP;
5437
5438 mutex_lock(&chip->reg_lock);
5439 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5440 mirror->to_local_port) {
5441 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5442 other_mirrors |= ingress ?
5443 chip->ports[i].mirror_ingress :
5444 chip->ports[i].mirror_egress;
5445
5446 /* Can't change egress port when other mirror is active */
5447 if (other_mirrors) {
5448 err = -EBUSY;
5449 goto out;
5450 }
5451
5452 err = chip->info->ops->set_egress_port(chip,
5453 direction,
5454 mirror->to_local_port);
5455 if (err)
5456 goto out;
5457 }
5458
5459 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5460out:
5461 mutex_unlock(&chip->reg_lock);
5462
5463 return err;
5464}
5465
5466static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5467 struct dsa_mall_mirror_tc_entry *mirror)
5468{
5469 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5470 MV88E6XXX_EGRESS_DIR_INGRESS :
5471 MV88E6XXX_EGRESS_DIR_EGRESS;
5472 struct mv88e6xxx_chip *chip = ds->priv;
5473 bool other_mirrors = false;
5474 int i;
5475
5476 mutex_lock(&chip->reg_lock);
5477 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5478 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5479
5480 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5481 other_mirrors |= mirror->ingress ?
5482 chip->ports[i].mirror_ingress :
5483 chip->ports[i].mirror_egress;
5484
5485 /* Reset egress port when no other mirror is active */
5486 if (!other_mirrors) {
5487 if (chip->info->ops->set_egress_port(chip,
5488 direction,
5489 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005490 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005491 dev_err(ds->dev, "failed to set egress port\n");
5492 }
5493
5494 mutex_unlock(&chip->reg_lock);
5495}
5496
Russell King4f859012019-02-20 15:35:05 -08005497static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5498 bool unicast, bool multicast)
5499{
5500 struct mv88e6xxx_chip *chip = ds->priv;
5501 int err = -EOPNOTSUPP;
5502
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005503 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005504 if (chip->info->ops->port_set_egress_floods)
5505 err = chip->info->ops->port_set_egress_floods(chip, port,
5506 unicast,
5507 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005508 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005509
5510 return err;
5511}
5512
Florian Fainellia82f67a2017-01-08 14:52:08 -08005513static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005514 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005515 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005516 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005517 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005518 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005519 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005520 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005521 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5522 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005523 .get_strings = mv88e6xxx_get_strings,
5524 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5525 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005526 .port_enable = mv88e6xxx_port_enable,
5527 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005528 .get_mac_eee = mv88e6xxx_get_mac_eee,
5529 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005530 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005531 .get_eeprom = mv88e6xxx_get_eeprom,
5532 .set_eeprom = mv88e6xxx_set_eeprom,
5533 .get_regs_len = mv88e6xxx_get_regs_len,
5534 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005535 .get_rxnfc = mv88e6xxx_get_rxnfc,
5536 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005537 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005538 .port_bridge_join = mv88e6xxx_port_bridge_join,
5539 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005540 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005541 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005542 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005543 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5544 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5545 .port_vlan_add = mv88e6xxx_port_vlan_add,
5546 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005547 .port_fdb_add = mv88e6xxx_port_fdb_add,
5548 .port_fdb_del = mv88e6xxx_port_fdb_del,
5549 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005550 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5551 .port_mdb_add = mv88e6xxx_port_mdb_add,
5552 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005553 .port_mirror_add = mv88e6xxx_port_mirror_add,
5554 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005555 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5556 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005557 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5558 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5559 .port_txtstamp = mv88e6xxx_port_txtstamp,
5560 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5561 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005562 .devlink_param_get = mv88e6xxx_devlink_param_get,
5563 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005564};
5565
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005566static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005567{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005568 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005569 struct dsa_switch *ds;
5570
Vivien Didelot7e99e342019-10-21 16:51:30 -04005571 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005572 if (!ds)
5573 return -ENOMEM;
5574
Vivien Didelot7e99e342019-10-21 16:51:30 -04005575 ds->dev = dev;
5576 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005577 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005578 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005579 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005580 ds->ageing_time_min = chip->info->age_time_coeff;
5581 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005582
5583 dev_set_drvdata(dev, ds);
5584
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005585 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005586}
5587
Vivien Didelotfad09c72016-06-21 12:28:20 -04005588static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005589{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005590 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005591}
5592
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005593static const void *pdata_device_get_match_data(struct device *dev)
5594{
5595 const struct of_device_id *matches = dev->driver->of_match_table;
5596 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5597
5598 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5599 matches++) {
5600 if (!strcmp(pdata->compatible, matches->compatible))
5601 return matches->data;
5602 }
5603 return NULL;
5604}
5605
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005606/* There is no suspend to RAM support at DSA level yet, the switch configuration
5607 * would be lost after a power cycle so prevent it to be suspended.
5608 */
5609static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5610{
5611 return -EOPNOTSUPP;
5612}
5613
5614static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5615{
5616 return 0;
5617}
5618
5619static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5620
Vivien Didelot57d32312016-06-20 13:13:58 -04005621static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005622{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005623 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005624 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005625 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005626 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005627 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005628 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005629 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005630
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005631 if (!np && !pdata)
5632 return -EINVAL;
5633
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005634 if (np)
5635 compat_info = of_device_get_match_data(dev);
5636
5637 if (pdata) {
5638 compat_info = pdata_device_get_match_data(dev);
5639
5640 if (!pdata->netdev)
5641 return -EINVAL;
5642
5643 for (port = 0; port < DSA_MAX_PORTS; port++) {
5644 if (!(pdata->enabled_ports & (1 << port)))
5645 continue;
5646 if (strcmp(pdata->cd.port_names[port], "cpu"))
5647 continue;
5648 pdata->cd.netdev[port] = &pdata->netdev->dev;
5649 break;
5650 }
5651 }
5652
Vivien Didelotcaac8542016-06-20 13:14:09 -04005653 if (!compat_info)
5654 return -EINVAL;
5655
Vivien Didelotfad09c72016-06-21 12:28:20 -04005656 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005657 if (!chip) {
5658 err = -ENOMEM;
5659 goto out;
5660 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005661
Vivien Didelotfad09c72016-06-21 12:28:20 -04005662 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005663
Vivien Didelotfad09c72016-06-21 12:28:20 -04005664 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005665 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005666 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005667
Andrew Lunnb4308f02016-11-21 23:26:55 +01005668 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005669 if (IS_ERR(chip->reset)) {
5670 err = PTR_ERR(chip->reset);
5671 goto out;
5672 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005673 if (chip->reset)
5674 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005675
Vivien Didelotfad09c72016-06-21 12:28:20 -04005676 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005677 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005678 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005679
Vivien Didelote57e5e72016-08-15 17:19:00 -04005680 mv88e6xxx_phy_init(chip);
5681
Andrew Lunn00baabe2018-05-19 22:31:35 +02005682 if (chip->info->ops->get_eeprom) {
5683 if (np)
5684 of_property_read_u32(np, "eeprom-length",
5685 &chip->eeprom_len);
5686 else
5687 chip->eeprom_len = pdata->eeprom_len;
5688 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005689
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005690 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005691 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005692 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005693 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005694 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005695
Andrew Lunna27415d2019-05-01 00:10:50 +02005696 if (np) {
5697 chip->irq = of_irq_get(np, 0);
5698 if (chip->irq == -EPROBE_DEFER) {
5699 err = chip->irq;
5700 goto out;
5701 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005702 }
5703
Andrew Lunna27415d2019-05-01 00:10:50 +02005704 if (pdata)
5705 chip->irq = pdata->irq;
5706
Andrew Lunn294d7112018-02-22 22:58:32 +01005707 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005708 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005709 * controllers
5710 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005711 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005712 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005713 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005714 else
5715 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005716 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005717
Andrew Lunn294d7112018-02-22 22:58:32 +01005718 if (err)
5719 goto out;
5720
5721 if (chip->info->g2_irqs > 0) {
5722 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005723 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005724 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005725 }
5726
Andrew Lunn294d7112018-02-22 22:58:32 +01005727 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5728 if (err)
5729 goto out_g2_irq;
5730
5731 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5732 if (err)
5733 goto out_g1_atu_prob_irq;
5734
Andrew Lunna3c53be52017-01-24 14:53:50 +01005735 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005736 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005737 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005738
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005739 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005740 if (err)
5741 goto out_mdio;
5742
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005743 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005744
5745out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005746 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005747out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005748 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005749out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005750 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005751out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005752 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005753 mv88e6xxx_g2_irq_free(chip);
5754out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005755 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005756 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005757 else
5758 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005759out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005760 if (pdata)
5761 dev_put(pdata->netdev);
5762
Andrew Lunndc30c352016-10-16 19:56:49 +02005763 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005764}
5765
5766static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5767{
5768 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005769 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005770
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005771 if (chip->info->ptp_support) {
5772 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005773 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005774 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005775
Andrew Lunn930188c2016-08-22 16:01:03 +02005776 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005777 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005778 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005779
Andrew Lunn76f38f12018-03-17 20:21:09 +01005780 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5781 mv88e6xxx_g1_atu_prob_irq_free(chip);
5782
5783 if (chip->info->g2_irqs > 0)
5784 mv88e6xxx_g2_irq_free(chip);
5785
Andrew Lunn76f38f12018-03-17 20:21:09 +01005786 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005787 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005788 else
5789 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005790}
5791
5792static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005793 {
5794 .compatible = "marvell,mv88e6085",
5795 .data = &mv88e6xxx_table[MV88E6085],
5796 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005797 {
5798 .compatible = "marvell,mv88e6190",
5799 .data = &mv88e6xxx_table[MV88E6190],
5800 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005801 {
5802 .compatible = "marvell,mv88e6250",
5803 .data = &mv88e6xxx_table[MV88E6250],
5804 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005805 { /* sentinel */ },
5806};
5807
5808MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5809
5810static struct mdio_driver mv88e6xxx_driver = {
5811 .probe = mv88e6xxx_probe,
5812 .remove = mv88e6xxx_remove,
5813 .mdiodrv.driver = {
5814 .name = "mv88e6085",
5815 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005816 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005817 },
5818};
5819
Andrew Lunn7324d502019-04-27 19:19:10 +02005820mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005821
5822MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5823MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5824MODULE_LICENSE("GPL");