blob: 705c118f6fdd62fd761fc20587b16036e87481f1 [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
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100400int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
401 int speed, int duplex, int pause,
402 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100403{
Andrew Lunna26deec2019-04-18 03:11:39 +0200404 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100405 int err;
406
407 if (!chip->info->ops->port_set_link)
408 return 0;
409
Andrew Lunna26deec2019-04-18 03:11:39 +0200410 if (!chip->info->ops->port_link_state)
411 return 0;
412
413 err = chip->info->ops->port_link_state(chip, port, &state);
414 if (err)
415 return err;
416
417 /* Has anything actually changed? We don't expect the
418 * interface mode to change without one of the other
419 * parameters also changing
420 */
421 if (state.link == link &&
422 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200423 state.duplex == duplex &&
424 (state.interface == mode ||
425 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 return 0;
427
Vivien Didelotd78343d2016-11-04 03:23:36 +0100428 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200429 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100430 if (err)
431 return err;
432
433 if (chip->info->ops->port_set_speed) {
434 err = chip->info->ops->port_set_speed(chip, port, speed);
435 if (err && err != -EOPNOTSUPP)
436 goto restore_link;
437 }
438
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100439 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
440 mode = chip->info->ops->port_max_speed_mode(port);
441
Andrew Lunn54186b92018-08-09 15:38:37 +0200442 if (chip->info->ops->port_set_pause) {
443 err = chip->info->ops->port_set_pause(chip, port, pause);
444 if (err)
445 goto restore_link;
446 }
447
Vivien Didelotd78343d2016-11-04 03:23:36 +0100448 if (chip->info->ops->port_set_duplex) {
449 err = chip->info->ops->port_set_duplex(chip, port, duplex);
450 if (err && err != -EOPNOTSUPP)
451 goto restore_link;
452 }
453
454 if (chip->info->ops->port_set_rgmii_delay) {
455 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
456 if (err && err != -EOPNOTSUPP)
457 goto restore_link;
458 }
459
Andrew Lunnf39908d2017-02-04 20:02:50 +0100460 if (chip->info->ops->port_set_cmode) {
461 err = chip->info->ops->port_set_cmode(chip, port, mode);
462 if (err && err != -EOPNOTSUPP)
463 goto restore_link;
464 }
465
Vivien Didelotd78343d2016-11-04 03:23:36 +0100466 err = 0;
467restore_link:
468 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400469 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470
471 return err;
472}
473
Marek Vasutd700ec42018-09-12 00:15:24 +0200474static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
475{
476 struct mv88e6xxx_chip *chip = ds->priv;
477
478 return port < chip->info->num_internal_phys;
479}
480
Russell King6c422e32018-08-09 15:38:39 +0200481static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
482 unsigned long *mask,
483 struct phylink_link_state *state)
484{
485 if (!phy_interface_mode_is_8023z(state->interface)) {
486 /* 10M and 100M are only supported in non-802.3z mode */
487 phylink_set(mask, 10baseT_Half);
488 phylink_set(mask, 10baseT_Full);
489 phylink_set(mask, 100baseT_Half);
490 phylink_set(mask, 100baseT_Full);
491 }
492}
493
494static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
495 unsigned long *mask,
496 struct phylink_link_state *state)
497{
498 /* FIXME: if the port is in 1000Base-X mode, then it only supports
499 * 1000M FD speeds. In this case, CMODE will indicate 5.
500 */
501 phylink_set(mask, 1000baseT_Full);
502 phylink_set(mask, 1000baseX_Full);
503
504 mv88e6065_phylink_validate(chip, port, mask, state);
505}
506
Marek Behúne3af71a2019-02-25 12:39:55 +0100507static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
508 unsigned long *mask,
509 struct phylink_link_state *state)
510{
511 if (port >= 5)
512 phylink_set(mask, 2500baseX_Full);
513
514 /* No ethtool bits for 200Mbps */
515 phylink_set(mask, 1000baseT_Full);
516 phylink_set(mask, 1000baseX_Full);
517
518 mv88e6065_phylink_validate(chip, port, mask, state);
519}
520
Russell King6c422e32018-08-09 15:38:39 +0200521static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
522 unsigned long *mask,
523 struct phylink_link_state *state)
524{
525 /* No ethtool bits for 200Mbps */
526 phylink_set(mask, 1000baseT_Full);
527 phylink_set(mask, 1000baseX_Full);
528
529 mv88e6065_phylink_validate(chip, port, mask, state);
530}
531
532static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
533 unsigned long *mask,
534 struct phylink_link_state *state)
535{
Andrew Lunnec260162019-02-08 22:25:44 +0100536 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200537 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100538 phylink_set(mask, 2500baseT_Full);
539 }
Russell King6c422e32018-08-09 15:38:39 +0200540
541 /* No ethtool bits for 200Mbps */
542 phylink_set(mask, 1000baseT_Full);
543 phylink_set(mask, 1000baseX_Full);
544
545 mv88e6065_phylink_validate(chip, port, mask, state);
546}
547
548static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
549 unsigned long *mask,
550 struct phylink_link_state *state)
551{
552 if (port >= 9) {
553 phylink_set(mask, 10000baseT_Full);
554 phylink_set(mask, 10000baseKR_Full);
555 }
556
557 mv88e6390_phylink_validate(chip, port, mask, state);
558}
559
Russell Kingc9a23562018-05-10 13:17:35 -0700560static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
561 unsigned long *supported,
562 struct phylink_link_state *state)
563{
Russell King6c422e32018-08-09 15:38:39 +0200564 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
565 struct mv88e6xxx_chip *chip = ds->priv;
566
567 /* Allow all the expected bits */
568 phylink_set(mask, Autoneg);
569 phylink_set(mask, Pause);
570 phylink_set_port_modes(mask);
571
572 if (chip->info->ops->phylink_validate)
573 chip->info->ops->phylink_validate(chip, port, mask, state);
574
575 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
576 bitmap_and(state->advertising, state->advertising, mask,
577 __ETHTOOL_LINK_MODE_MASK_NBITS);
578
579 /* We can only operate at 2500BaseX or 1000BaseX. If requested
580 * to advertise both, only report advertising at 2500BaseX.
581 */
582 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700583}
584
585static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
586 struct phylink_link_state *state)
587{
588 struct mv88e6xxx_chip *chip = ds->priv;
589 int err;
590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000591 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200592 if (chip->info->ops->port_link_state)
593 err = chip->info->ops->port_link_state(chip, port, state);
594 else
595 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000596 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700597
598 return err;
599}
600
601static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
602 unsigned int mode,
603 const struct phylink_link_state *state)
604{
605 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200606 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700607
Marek Vasutd700ec42018-09-12 00:15:24 +0200608 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700609 return;
610
611 if (mode == MLO_AN_FIXED) {
612 link = LINK_FORCED_UP;
613 speed = state->speed;
614 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200615 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
616 link = state->link;
617 speed = state->speed;
618 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700619 } else {
620 speed = SPEED_UNFORCED;
621 duplex = DUPLEX_UNFORCED;
622 link = LINK_UNFORCED;
623 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700625
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700628 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000629 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700630
631 if (err && err != -EOPNOTSUPP)
632 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
633}
634
635static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
636{
637 struct mv88e6xxx_chip *chip = ds->priv;
638 int err;
639
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000640 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700641 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000642 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700643
644 if (err)
645 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
646}
647
648static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
649 unsigned int mode,
650 phy_interface_t interface)
651{
652 if (mode == MLO_AN_FIXED)
653 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
654}
655
656static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
657 unsigned int mode, phy_interface_t interface,
658 struct phy_device *phydev)
659{
660 if (mode == MLO_AN_FIXED)
661 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
662}
663
Andrew Lunna605a0f2016-11-21 23:26:58 +0100664static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 if (!chip->info->ops->stats_snapshot)
667 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000668
Andrew Lunna605a0f2016-11-21 23:26:58 +0100669 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000670}
671
Andrew Lunne413e7e2015-04-02 04:06:38 +0200672static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100673 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
674 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
675 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
676 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
677 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
678 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
679 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
680 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
681 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
682 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
683 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
684 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
685 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
686 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
687 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
688 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
689 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
690 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
691 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
692 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
693 { "single", 4, 0x14, STATS_TYPE_BANK0, },
694 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
695 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
696 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
697 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
698 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
699 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
700 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
701 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
702 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
703 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
704 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
705 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
706 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
707 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
708 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
709 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
710 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
711 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
712 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
713 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
714 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
715 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
716 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
717 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
718 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
719 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
720 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
721 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
722 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
723 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
724 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
725 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
726 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
727 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
728 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
729 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
730 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
731 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200732};
733
Vivien Didelotfad09c72016-06-21 12:28:20 -0400734static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100735 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100736 int port, u16 bank1_select,
737 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200738{
Andrew Lunn80c46272015-06-20 18:42:30 +0200739 u32 low;
740 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100741 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200742 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200743 u64 value;
744
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100745 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100746 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200747 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
748 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800749 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200750
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200751 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100752 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200753 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
754 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800755 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000756 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200757 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100758 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100759 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100761 /* fall through */
762 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100763 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100764 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100765 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100766 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500767 break;
768 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800769 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200770 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100771 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200772 return value;
773}
774
Andrew Lunn436fe172018-03-01 02:02:29 +0100775static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
776 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100777{
778 struct mv88e6xxx_hw_stat *stat;
779 int i, j;
780
781 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
782 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100783 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100784 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
785 ETH_GSTRING_LEN);
786 j++;
787 }
788 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100789
790 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100791}
792
Andrew Lunn436fe172018-03-01 02:02:29 +0100793static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
794 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100795{
Andrew Lunn436fe172018-03-01 02:02:29 +0100796 return mv88e6xxx_stats_get_strings(chip, data,
797 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100798}
799
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000800static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
801 uint8_t *data)
802{
803 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
804}
805
Andrew Lunn436fe172018-03-01 02:02:29 +0100806static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
807 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100808{
Andrew Lunn436fe172018-03-01 02:02:29 +0100809 return mv88e6xxx_stats_get_strings(chip, data,
810 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100811}
812
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
814 "atu_member_violation",
815 "atu_miss_violation",
816 "atu_full_violation",
817 "vtu_member_violation",
818 "vtu_miss_violation",
819};
820
821static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
822{
823 unsigned int i;
824
825 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
826 strlcpy(data + i * ETH_GSTRING_LEN,
827 mv88e6xxx_atu_vtu_stats_strings[i],
828 ETH_GSTRING_LEN);
829}
830
Andrew Lunndfafe442016-11-21 23:27:02 +0100831static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700832 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100833{
Vivien Didelot04bed142016-08-31 18:06:13 -0400834 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100835 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100836
Florian Fainelli89f09042018-04-25 12:12:50 -0700837 if (stringset != ETH_SS_STATS)
838 return;
839
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000840 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100841
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100843 count = chip->info->ops->stats_get_strings(chip, data);
844
845 if (chip->info->ops->serdes_get_strings) {
846 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100848 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100849
Andrew Lunn65f60e42018-03-28 23:50:28 +0200850 data += count * ETH_GSTRING_LEN;
851 mv88e6xxx_atu_vtu_get_strings(data);
852
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000853 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100854}
855
856static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
857 int types)
858{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 struct mv88e6xxx_hw_stat *stat;
860 int i, j;
861
862 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
863 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865 j++;
866 }
867 return j;
868}
869
Andrew Lunndfafe442016-11-21 23:27:02 +0100870static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
871{
872 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
873 STATS_TYPE_PORT);
874}
875
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000876static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
877{
878 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
879}
880
Andrew Lunndfafe442016-11-21 23:27:02 +0100881static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
882{
883 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
884 STATS_TYPE_BANK1);
885}
886
Florian Fainelli89f09042018-04-25 12:12:50 -0700887static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100888{
889 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 int serdes_count = 0;
891 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100892
Florian Fainelli89f09042018-04-25 12:12:50 -0700893 if (sset != ETH_SS_STATS)
894 return 0;
895
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000896 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100898 count = chip->info->ops->stats_get_sset_count(chip);
899 if (count < 0)
900 goto out;
901
902 if (chip->info->ops->serdes_get_sset_count)
903 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
904 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200905 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100906 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907 goto out;
908 }
909 count += serdes_count;
910 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000913 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Andrew Lunn436fe172018-03-01 02:02:29 +0100918static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
919 uint64_t *data, int types,
920 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100921{
922 struct mv88e6xxx_hw_stat *stat;
923 int i, j;
924
925 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
926 stat = &mv88e6xxx_hw_stats[i];
927 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000928 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100929 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
930 bank1_select,
931 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000932 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100933
Andrew Lunn052f9472016-11-21 23:27:03 +0100934 j++;
935 }
936 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100938}
939
Andrew Lunn436fe172018-03-01 02:02:29 +0100940static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
941 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100942{
943 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100944 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400945 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100946}
947
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000948static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
949 uint64_t *data)
950{
951 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
952 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
953}
954
Andrew Lunn436fe172018-03-01 02:02:29 +0100955static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
956 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100957{
958 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400960 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
961 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100962}
963
Andrew Lunn436fe172018-03-01 02:02:29 +0100964static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
965 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100966{
967 return mv88e6xxx_stats_get_stats(chip, port, data,
968 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400969 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
970 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100971}
972
Andrew Lunn65f60e42018-03-28 23:50:28 +0200973static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
974 uint64_t *data)
975{
976 *data++ = chip->ports[port].atu_member_violation;
977 *data++ = chip->ports[port].atu_miss_violation;
978 *data++ = chip->ports[port].atu_full_violation;
979 *data++ = chip->ports[port].vtu_member_violation;
980 *data++ = chip->ports[port].vtu_miss_violation;
981}
982
Andrew Lunn052f9472016-11-21 23:27:03 +0100983static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
985{
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 int count = 0;
987
Andrew Lunn052f9472016-11-21 23:27:03 +0100988 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 count = chip->info->ops->stats_get_stats(chip, port, data);
990
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000991 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 if (chip->info->ops->serdes_get_stats) {
993 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 data += count;
997 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000998 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100999}
1000
Vivien Didelotf81ec902016-05-09 13:22:58 -04001001static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1002 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003{
Vivien Didelot04bed142016-08-31 18:06:13 -04001004 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001006
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001008
Andrew Lunna605a0f2016-11-21 23:26:58 +01001009 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001011
1012 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001014
1015 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017}
Ben Hutchings98e67302011-11-25 14:36:19 +00001018
Vivien Didelotf81ec902016-05-09 13:22:58 -04001019static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001020{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001021 struct mv88e6xxx_chip *chip = ds->priv;
1022 int len;
1023
1024 len = 32 * sizeof(u16);
1025 if (chip->info->ops->serdes_get_regs_len)
1026 len += chip->info->ops->serdes_get_regs_len(chip, port);
1027
1028 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001029}
1030
Vivien Didelotf81ec902016-05-09 13:22:58 -04001031static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1032 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001033{
Vivien Didelot04bed142016-08-31 18:06:13 -04001034 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001035 int err;
1036 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037 u16 *p = _p;
1038 int i;
1039
Vivien Didelota5f39322018-12-17 16:05:21 -05001040 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001041
1042 memset(p, 0xff, 32 * sizeof(u16));
1043
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001044 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001045
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001046 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001048 err = mv88e6xxx_port_read(chip, port, i, &reg);
1049 if (!err)
1050 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001051 }
Vivien Didelot23062512016-05-09 13:22:45 -04001052
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001053 if (chip->info->ops->serdes_get_regs)
1054 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1055
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001056 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001057}
1058
Vivien Didelot08f50062017-08-01 16:32:41 -04001059static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1060 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061{
Vivien Didelot5480db62017-08-01 16:32:40 -04001062 /* Nothing to do on the port's MAC */
1063 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001064}
1065
Vivien Didelot08f50062017-08-01 16:32:41 -04001066static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1067 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001068{
Vivien Didelot5480db62017-08-01 16:32:40 -04001069 /* Nothing to do on the port's MAC */
1070 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001071}
1072
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001073/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001074static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001075{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001076 struct dsa_switch *ds = chip->ds;
1077 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001078 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001079 struct dsa_port *dp;
1080 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001081 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001082
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001083 list_for_each_entry(dp, &dst->ports, list) {
1084 if (dp->ds->index == dev && dp->index == port) {
1085 found = true;
1086 break;
1087 }
1088 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001089
Vivien Didelote5887a22017-03-30 17:37:11 -04001090 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001091 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001092 return 0;
1093
1094 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001095 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001096 return mv88e6xxx_port_mask(chip);
1097
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001098 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001099 pvlan = 0;
1100
1101 /* Frames from user ports can egress any local DSA links and CPU ports,
1102 * as well as any local member of their bridge group.
1103 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001104 list_for_each_entry(dp, &dst->ports, list)
1105 if (dp->ds == ds &&
1106 (dp->type == DSA_PORT_TYPE_CPU ||
1107 dp->type == DSA_PORT_TYPE_DSA ||
1108 (br && dp->bridge_dev == br)))
1109 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001110
1111 return pvlan;
1112}
1113
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001114static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001115{
1116 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001117
1118 /* prevent frames from going back out of the port they came in on */
1119 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001120
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001121 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001122}
1123
Vivien Didelotf81ec902016-05-09 13:22:58 -04001124static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1125 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001126{
Vivien Didelot04bed142016-08-31 18:06:13 -04001127 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001128 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001129
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001130 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001131 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001132 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001133
1134 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001135 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001136}
1137
Vivien Didelot93e18d62018-05-11 17:16:35 -04001138static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1139{
1140 int err;
1141
1142 if (chip->info->ops->ieee_pri_map) {
1143 err = chip->info->ops->ieee_pri_map(chip);
1144 if (err)
1145 return err;
1146 }
1147
1148 if (chip->info->ops->ip_pri_map) {
1149 err = chip->info->ops->ip_pri_map(chip);
1150 if (err)
1151 return err;
1152 }
1153
1154 return 0;
1155}
1156
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001157static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1158{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001159 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001160 int target, port;
1161 int err;
1162
1163 if (!chip->info->global2_addr)
1164 return 0;
1165
1166 /* Initialize the routing port to the 32 possible target devices */
1167 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001168 port = dsa_routing_port(ds, target);
1169 if (port == ds->num_ports)
1170 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001171
1172 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1173 if (err)
1174 return err;
1175 }
1176
Vivien Didelot02317e62018-05-09 11:38:49 -04001177 if (chip->info->ops->set_cascade_port) {
1178 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1179 err = chip->info->ops->set_cascade_port(chip, port);
1180 if (err)
1181 return err;
1182 }
1183
Vivien Didelot23c98912018-05-09 11:38:50 -04001184 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1185 if (err)
1186 return err;
1187
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001188 return 0;
1189}
1190
Vivien Didelotb28f8722018-04-26 21:56:44 -04001191static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1192{
1193 /* Clear all trunk masks and mapping */
1194 if (chip->info->global2_addr)
1195 return mv88e6xxx_g2_trunk_clear(chip);
1196
1197 return 0;
1198}
1199
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001200static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1201{
1202 if (chip->info->ops->rmu_disable)
1203 return chip->info->ops->rmu_disable(chip);
1204
1205 return 0;
1206}
1207
Vivien Didelot9e907d72017-07-17 13:03:43 -04001208static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1209{
1210 if (chip->info->ops->pot_clear)
1211 return chip->info->ops->pot_clear(chip);
1212
1213 return 0;
1214}
1215
Vivien Didelot51c901a2017-07-17 13:03:41 -04001216static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1217{
1218 if (chip->info->ops->mgmt_rsvd2cpu)
1219 return chip->info->ops->mgmt_rsvd2cpu(chip);
1220
1221 return 0;
1222}
1223
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001224static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1225{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001226 int err;
1227
Vivien Didelotdaefc942017-03-11 16:12:54 -05001228 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1229 if (err)
1230 return err;
1231
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001232 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1233 if (err)
1234 return err;
1235
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001236 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1237}
1238
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001239static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1240{
1241 int port;
1242 int err;
1243
1244 if (!chip->info->ops->irl_init_all)
1245 return 0;
1246
1247 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1248 /* Disable ingress rate limiting by resetting all per port
1249 * ingress rate limit resources to their initial state.
1250 */
1251 err = chip->info->ops->irl_init_all(chip, port);
1252 if (err)
1253 return err;
1254 }
1255
1256 return 0;
1257}
1258
Vivien Didelot04a69a12017-10-13 14:18:05 -04001259static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1260{
1261 if (chip->info->ops->set_switch_mac) {
1262 u8 addr[ETH_ALEN];
1263
1264 eth_random_addr(addr);
1265
1266 return chip->info->ops->set_switch_mac(chip, addr);
1267 }
1268
1269 return 0;
1270}
1271
Vivien Didelot17a15942017-03-30 17:37:09 -04001272static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1273{
1274 u16 pvlan = 0;
1275
1276 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001277 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001278
1279 /* Skip the local source device, which uses in-chip port VLAN */
1280 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001281 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001282
1283 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1284}
1285
Vivien Didelot81228992017-03-30 17:37:08 -04001286static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1287{
Vivien Didelot17a15942017-03-30 17:37:09 -04001288 int dev, port;
1289 int err;
1290
Vivien Didelot81228992017-03-30 17:37:08 -04001291 if (!mv88e6xxx_has_pvt(chip))
1292 return 0;
1293
1294 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1295 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1296 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001297 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1298 if (err)
1299 return err;
1300
1301 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1302 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1303 err = mv88e6xxx_pvt_map(chip, dev, port);
1304 if (err)
1305 return err;
1306 }
1307 }
1308
1309 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001310}
1311
Vivien Didelot749efcb2016-09-22 16:49:24 -04001312static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1313{
1314 struct mv88e6xxx_chip *chip = ds->priv;
1315 int err;
1316
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001317 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001318 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001319 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001320
1321 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001322 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001323}
1324
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001325static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1326{
1327 if (!chip->info->max_vid)
1328 return 0;
1329
1330 return mv88e6xxx_g1_vtu_flush(chip);
1331}
1332
Vivien Didelotf1394b782017-05-01 14:05:22 -04001333static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1334 struct mv88e6xxx_vtu_entry *entry)
1335{
1336 if (!chip->info->ops->vtu_getnext)
1337 return -EOPNOTSUPP;
1338
1339 return chip->info->ops->vtu_getnext(chip, entry);
1340}
1341
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001342static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1343 struct mv88e6xxx_vtu_entry *entry)
1344{
1345 if (!chip->info->ops->vtu_loadpurge)
1346 return -EOPNOTSUPP;
1347
1348 return chip->info->ops->vtu_loadpurge(chip, entry);
1349}
1350
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001351static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001352{
1353 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001354 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001355 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001356
1357 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1358
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001359 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001360 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001361 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001362 if (err)
1363 return err;
1364
1365 set_bit(*fid, fid_bitmap);
1366 }
1367
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001368 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001369 vlan.vid = chip->info->max_vid;
1370 vlan.valid = false;
1371
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001372 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001373 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001374 if (err)
1375 return err;
1376
1377 if (!vlan.valid)
1378 break;
1379
1380 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001381 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001382
1383 /* The reset value 0x000 is used to indicate that multiple address
1384 * databases are not needed. Return the next positive available.
1385 */
1386 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001387 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001388 return -ENOSPC;
1389
1390 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001391 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001392}
1393
Andrew Lunn23e8b472019-10-25 01:03:52 +02001394static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1395{
1396 if (chip->info->ops->atu_get_hash)
1397 return chip->info->ops->atu_get_hash(chip, hash);
1398
1399 return -EOPNOTSUPP;
1400}
1401
1402static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1403{
1404 if (chip->info->ops->atu_set_hash)
1405 return chip->info->ops->atu_set_hash(chip, hash);
1406
1407 return -EOPNOTSUPP;
1408}
1409
Vivien Didelotda9c3592016-02-12 12:09:40 -05001410static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1411 u16 vid_begin, u16 vid_end)
1412{
Vivien Didelot04bed142016-08-31 18:06:13 -04001413 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001414 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001415 int i, err;
1416
Andrew Lunndb06ae412017-09-25 23:32:20 +02001417 /* DSA and CPU ports have to be members of multiple vlans */
1418 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1419 return 0;
1420
Vivien Didelotda9c3592016-02-12 12:09:40 -05001421 if (!vid_begin)
1422 return -EOPNOTSUPP;
1423
Vivien Didelot425d2d32019-08-01 14:36:34 -04001424 vlan.vid = vid_begin - 1;
1425 vlan.valid = false;
1426
Vivien Didelotda9c3592016-02-12 12:09:40 -05001427 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001428 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001429 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001430 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001431
1432 if (!vlan.valid)
1433 break;
1434
1435 if (vlan.vid > vid_end)
1436 break;
1437
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001438 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001439 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1440 continue;
1441
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001442 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001443 continue;
1444
Vivien Didelotbd00e052017-05-01 14:05:11 -04001445 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001446 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001447 continue;
1448
Vivien Didelotc8652c82017-10-16 11:12:19 -04001449 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001450 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001451 break; /* same bridge, check next VLAN */
1452
Vivien Didelotc8652c82017-10-16 11:12:19 -04001453 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001454 continue;
1455
Andrew Lunn743fcc22017-11-09 22:29:54 +01001456 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1457 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001458 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001459 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001460 }
1461 } while (vlan.vid < vid_end);
1462
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001463 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001464}
1465
Vivien Didelotf81ec902016-05-09 13:22:58 -04001466static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1467 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001468{
Vivien Didelot04bed142016-08-31 18:06:13 -04001469 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001470 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1471 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001472 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001473
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001474 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001475 return -EOPNOTSUPP;
1476
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001477 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001478 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001479 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001480
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001481 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001482}
1483
Vivien Didelot57d32312016-06-20 13:13:58 -04001484static int
1485mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001486 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001487{
Vivien Didelot04bed142016-08-31 18:06:13 -04001488 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001489 int err;
1490
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001491 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001492 return -EOPNOTSUPP;
1493
Vivien Didelotda9c3592016-02-12 12:09:40 -05001494 /* If the requested port doesn't belong to the same bridge as the VLAN
1495 * members, do not support it (yet) and fallback to software VLAN.
1496 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001497 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001498 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1499 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001500 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001501
Vivien Didelot76e398a2015-11-01 12:33:55 -05001502 /* We don't need any dynamic resource from the kernel (yet),
1503 * so skip the prepare phase.
1504 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001505 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001506}
1507
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001508static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1509 const unsigned char *addr, u16 vid,
1510 u8 state)
1511{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001512 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001513 struct mv88e6xxx_vtu_entry vlan;
1514 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001515 int err;
1516
1517 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001518 if (vid == 0) {
1519 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1520 if (err)
1521 return err;
1522 } else {
1523 vlan.vid = vid - 1;
1524 vlan.valid = false;
1525
1526 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1527 if (err)
1528 return err;
1529
1530 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1531 if (vlan.vid != vid || !vlan.valid)
1532 return -EOPNOTSUPP;
1533
1534 fid = vlan.fid;
1535 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001536
Vivien Didelotd8291a92019-09-07 16:00:47 -04001537 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001538 ether_addr_copy(entry.mac, addr);
1539 eth_addr_dec(entry.mac);
1540
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001541 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001542 if (err)
1543 return err;
1544
1545 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001546 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001547 memset(&entry, 0, sizeof(entry));
1548 ether_addr_copy(entry.mac, addr);
1549 }
1550
1551 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001552 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001553 entry.portvec &= ~BIT(port);
1554 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001555 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001556 } else {
1557 entry.portvec |= BIT(port);
1558 entry.state = state;
1559 }
1560
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001561 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001562}
1563
Vivien Didelotda7dc872019-09-07 16:00:49 -04001564static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1565 const struct mv88e6xxx_policy *policy)
1566{
1567 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1568 enum mv88e6xxx_policy_action action = policy->action;
1569 const u8 *addr = policy->addr;
1570 u16 vid = policy->vid;
1571 u8 state;
1572 int err;
1573 int id;
1574
1575 if (!chip->info->ops->port_set_policy)
1576 return -EOPNOTSUPP;
1577
1578 switch (mapping) {
1579 case MV88E6XXX_POLICY_MAPPING_DA:
1580 case MV88E6XXX_POLICY_MAPPING_SA:
1581 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1582 state = 0; /* Dissociate the port and address */
1583 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1584 is_multicast_ether_addr(addr))
1585 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1586 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1587 is_unicast_ether_addr(addr))
1588 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1589 else
1590 return -EOPNOTSUPP;
1591
1592 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1593 state);
1594 if (err)
1595 return err;
1596 break;
1597 default:
1598 return -EOPNOTSUPP;
1599 }
1600
1601 /* Skip the port's policy clearing if the mapping is still in use */
1602 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1603 idr_for_each_entry(&chip->policies, policy, id)
1604 if (policy->port == port &&
1605 policy->mapping == mapping &&
1606 policy->action != action)
1607 return 0;
1608
1609 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1610}
1611
1612static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1613 struct ethtool_rx_flow_spec *fs)
1614{
1615 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1616 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1617 enum mv88e6xxx_policy_mapping mapping;
1618 enum mv88e6xxx_policy_action action;
1619 struct mv88e6xxx_policy *policy;
1620 u16 vid = 0;
1621 u8 *addr;
1622 int err;
1623 int id;
1624
1625 if (fs->location != RX_CLS_LOC_ANY)
1626 return -EINVAL;
1627
1628 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1629 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1630 else
1631 return -EOPNOTSUPP;
1632
1633 switch (fs->flow_type & ~FLOW_EXT) {
1634 case ETHER_FLOW:
1635 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1636 is_zero_ether_addr(mac_mask->h_source)) {
1637 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1638 addr = mac_entry->h_dest;
1639 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1640 !is_zero_ether_addr(mac_mask->h_source)) {
1641 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1642 addr = mac_entry->h_source;
1643 } else {
1644 /* Cannot support DA and SA mapping in the same rule */
1645 return -EOPNOTSUPP;
1646 }
1647 break;
1648 default:
1649 return -EOPNOTSUPP;
1650 }
1651
1652 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1653 if (fs->m_ext.vlan_tci != 0xffff)
1654 return -EOPNOTSUPP;
1655 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1656 }
1657
1658 idr_for_each_entry(&chip->policies, policy, id) {
1659 if (policy->port == port && policy->mapping == mapping &&
1660 policy->action == action && policy->vid == vid &&
1661 ether_addr_equal(policy->addr, addr))
1662 return -EEXIST;
1663 }
1664
1665 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1666 if (!policy)
1667 return -ENOMEM;
1668
1669 fs->location = 0;
1670 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1671 GFP_KERNEL);
1672 if (err) {
1673 devm_kfree(chip->dev, policy);
1674 return err;
1675 }
1676
1677 memcpy(&policy->fs, fs, sizeof(*fs));
1678 ether_addr_copy(policy->addr, addr);
1679 policy->mapping = mapping;
1680 policy->action = action;
1681 policy->port = port;
1682 policy->vid = vid;
1683
1684 err = mv88e6xxx_policy_apply(chip, port, policy);
1685 if (err) {
1686 idr_remove(&chip->policies, fs->location);
1687 devm_kfree(chip->dev, policy);
1688 return err;
1689 }
1690
1691 return 0;
1692}
1693
1694static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1695 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1696{
1697 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1698 struct mv88e6xxx_chip *chip = ds->priv;
1699 struct mv88e6xxx_policy *policy;
1700 int err;
1701 int id;
1702
1703 mv88e6xxx_reg_lock(chip);
1704
1705 switch (rxnfc->cmd) {
1706 case ETHTOOL_GRXCLSRLCNT:
1707 rxnfc->data = 0;
1708 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1709 rxnfc->rule_cnt = 0;
1710 idr_for_each_entry(&chip->policies, policy, id)
1711 if (policy->port == port)
1712 rxnfc->rule_cnt++;
1713 err = 0;
1714 break;
1715 case ETHTOOL_GRXCLSRULE:
1716 err = -ENOENT;
1717 policy = idr_find(&chip->policies, fs->location);
1718 if (policy) {
1719 memcpy(fs, &policy->fs, sizeof(*fs));
1720 err = 0;
1721 }
1722 break;
1723 case ETHTOOL_GRXCLSRLALL:
1724 rxnfc->data = 0;
1725 rxnfc->rule_cnt = 0;
1726 idr_for_each_entry(&chip->policies, policy, id)
1727 if (policy->port == port)
1728 rule_locs[rxnfc->rule_cnt++] = id;
1729 err = 0;
1730 break;
1731 default:
1732 err = -EOPNOTSUPP;
1733 break;
1734 }
1735
1736 mv88e6xxx_reg_unlock(chip);
1737
1738 return err;
1739}
1740
1741static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1742 struct ethtool_rxnfc *rxnfc)
1743{
1744 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1745 struct mv88e6xxx_chip *chip = ds->priv;
1746 struct mv88e6xxx_policy *policy;
1747 int err;
1748
1749 mv88e6xxx_reg_lock(chip);
1750
1751 switch (rxnfc->cmd) {
1752 case ETHTOOL_SRXCLSRLINS:
1753 err = mv88e6xxx_policy_insert(chip, port, fs);
1754 break;
1755 case ETHTOOL_SRXCLSRLDEL:
1756 err = -ENOENT;
1757 policy = idr_remove(&chip->policies, fs->location);
1758 if (policy) {
1759 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1760 err = mv88e6xxx_policy_apply(chip, port, policy);
1761 devm_kfree(chip->dev, policy);
1762 }
1763 break;
1764 default:
1765 err = -EOPNOTSUPP;
1766 break;
1767 }
1768
1769 mv88e6xxx_reg_unlock(chip);
1770
1771 return err;
1772}
1773
Andrew Lunn87fa8862017-11-09 22:29:56 +01001774static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1775 u16 vid)
1776{
1777 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1778 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1779
1780 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1781}
1782
1783static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1784{
1785 int port;
1786 int err;
1787
1788 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1789 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1790 if (err)
1791 return err;
1792 }
1793
1794 return 0;
1795}
1796
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001797static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001798 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001800 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001801 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001802 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001803
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001804 if (!vid)
1805 return -EOPNOTSUPP;
1806
1807 vlan.vid = vid - 1;
1808 vlan.valid = false;
1809
1810 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001811 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001812 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001813
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001814 if (vlan.vid != vid || !vlan.valid) {
1815 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001816
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001817 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1818 if (err)
1819 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001820
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001821 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1822 if (i == port)
1823 vlan.member[i] = member;
1824 else
1825 vlan.member[i] = non_member;
1826
1827 vlan.vid = vid;
1828 vlan.valid = true;
1829
1830 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1831 if (err)
1832 return err;
1833
1834 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1835 if (err)
1836 return err;
1837 } else if (vlan.member[port] != member) {
1838 vlan.member[port] = member;
1839
1840 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1841 if (err)
1842 return err;
Russell King933b4422020-02-26 17:14:26 +00001843 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001844 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1845 port, vid);
1846 }
1847
1848 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001849}
1850
Vivien Didelotf81ec902016-05-09 13:22:58 -04001851static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001852 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001853{
Vivien Didelot04bed142016-08-31 18:06:13 -04001854 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001855 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1856 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001857 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001858 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001859 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001860
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001861 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001862 return;
1863
Vivien Didelotc91498e2017-06-07 18:12:13 -04001864 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001865 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001866 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001867 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001868 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001869 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001870
Russell King933b4422020-02-26 17:14:26 +00001871 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1872 * and then the CPU port. Do not warn for duplicates for the CPU port.
1873 */
1874 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1875
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001876 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001877
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001878 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001879 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001880 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1881 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001882
Vivien Didelot77064f32016-11-04 03:23:30 +01001883 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001884 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1885 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001886
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001887 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001888}
1889
Vivien Didelot521098922019-08-01 14:36:36 -04001890static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1891 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001892{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001893 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001894 int i, err;
1895
Vivien Didelot521098922019-08-01 14:36:36 -04001896 if (!vid)
1897 return -EOPNOTSUPP;
1898
1899 vlan.vid = vid - 1;
1900 vlan.valid = false;
1901
1902 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001903 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001904 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001905
Vivien Didelot521098922019-08-01 14:36:36 -04001906 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1907 * tell switchdev that this VLAN is likely handled in software.
1908 */
1909 if (vlan.vid != vid || !vlan.valid ||
1910 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001911 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001912
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001913 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001914
1915 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001916 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001917 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001918 if (vlan.member[i] !=
1919 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001920 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001921 break;
1922 }
1923 }
1924
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001925 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001926 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001927 return err;
1928
Vivien Didelote606ca32017-03-11 16:12:55 -05001929 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001930}
1931
Vivien Didelotf81ec902016-05-09 13:22:58 -04001932static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1933 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001934{
Vivien Didelot04bed142016-08-31 18:06:13 -04001935 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001936 u16 pvid, vid;
1937 int err = 0;
1938
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001939 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001940 return -EOPNOTSUPP;
1941
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001942 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001943
Vivien Didelot77064f32016-11-04 03:23:30 +01001944 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001945 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001946 goto unlock;
1947
Vivien Didelot76e398a2015-11-01 12:33:55 -05001948 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001949 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001950 if (err)
1951 goto unlock;
1952
1953 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001954 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001955 if (err)
1956 goto unlock;
1957 }
1958 }
1959
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001960unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001961 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001962
1963 return err;
1964}
1965
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001966static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1967 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001968{
Vivien Didelot04bed142016-08-31 18:06:13 -04001969 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001970 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001971
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001972 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001973 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1974 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001975 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001976
1977 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001978}
1979
Vivien Didelotf81ec902016-05-09 13:22:58 -04001980static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001981 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001982{
Vivien Didelot04bed142016-08-31 18:06:13 -04001983 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001984 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001985
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001986 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04001987 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001988 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001989
Vivien Didelot83dabd12016-08-31 11:50:04 -04001990 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001991}
1992
Vivien Didelot83dabd12016-08-31 11:50:04 -04001993static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1994 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001995 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001996{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001997 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001998 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001999 int err;
2000
Vivien Didelotd8291a92019-09-07 16:00:47 -04002001 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002002 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002003
2004 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002005 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002006 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002007 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002008
Vivien Didelotd8291a92019-09-07 16:00:47 -04002009 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002010 break;
2011
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002012 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002013 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002014
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002015 if (!is_unicast_ether_addr(addr.mac))
2016 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002017
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002018 is_static = (addr.state ==
2019 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2020 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002021 if (err)
2022 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002023 } while (!is_broadcast_ether_addr(addr.mac));
2024
2025 return err;
2026}
2027
Vivien Didelot83dabd12016-08-31 11:50:04 -04002028static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002029 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002030{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002031 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002032 u16 fid;
2033 int err;
2034
2035 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002036 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002037 if (err)
2038 return err;
2039
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002040 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002041 if (err)
2042 return err;
2043
2044 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002045 vlan.vid = chip->info->max_vid;
2046 vlan.valid = false;
2047
Vivien Didelot83dabd12016-08-31 11:50:04 -04002048 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002049 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002050 if (err)
2051 return err;
2052
2053 if (!vlan.valid)
2054 break;
2055
2056 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002057 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002058 if (err)
2059 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002060 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002061
2062 return err;
2063}
2064
Vivien Didelotf81ec902016-05-09 13:22:58 -04002065static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002066 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002067{
Vivien Didelot04bed142016-08-31 18:06:13 -04002068 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002069 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002070
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002071 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002072 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002073 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002074
2075 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002076}
2077
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002078static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2079 struct net_device *br)
2080{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002081 struct dsa_switch *ds = chip->ds;
2082 struct dsa_switch_tree *dst = ds->dst;
2083 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002084 int err;
2085
Vivien Didelotef2025e2019-10-21 16:51:27 -04002086 list_for_each_entry(dp, &dst->ports, list) {
2087 if (dp->bridge_dev == br) {
2088 if (dp->ds == ds) {
2089 /* This is a local bridge group member,
2090 * remap its Port VLAN Map.
2091 */
2092 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2093 if (err)
2094 return err;
2095 } else {
2096 /* This is an external bridge group member,
2097 * remap its cross-chip Port VLAN Table entry.
2098 */
2099 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2100 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002101 if (err)
2102 return err;
2103 }
2104 }
2105 }
2106
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002107 return 0;
2108}
2109
Vivien Didelotf81ec902016-05-09 13:22:58 -04002110static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002111 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002112{
Vivien Didelot04bed142016-08-31 18:06:13 -04002113 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002114 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002115
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002116 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002117 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002118 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002119
Vivien Didelot466dfa02016-02-26 13:16:05 -05002120 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002121}
2122
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002123static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2124 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002125{
Vivien Didelot04bed142016-08-31 18:06:13 -04002126 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002127
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002128 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002129 if (mv88e6xxx_bridge_map(chip, br) ||
2130 mv88e6xxx_port_vlan_map(chip, port))
2131 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002132 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002133}
2134
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002135static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2136 int port, struct net_device *br)
2137{
2138 struct mv88e6xxx_chip *chip = ds->priv;
2139 int err;
2140
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002141 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002142 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002143 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002144
2145 return err;
2146}
2147
2148static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2149 int port, struct net_device *br)
2150{
2151 struct mv88e6xxx_chip *chip = ds->priv;
2152
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002153 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002154 if (mv88e6xxx_pvt_map(chip, dev, port))
2155 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002156 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002157}
2158
Vivien Didelot17e708b2016-12-05 17:30:27 -05002159static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2160{
2161 if (chip->info->ops->reset)
2162 return chip->info->ops->reset(chip);
2163
2164 return 0;
2165}
2166
Vivien Didelot309eca62016-12-05 17:30:26 -05002167static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2168{
2169 struct gpio_desc *gpiod = chip->reset;
2170
2171 /* If there is a GPIO connected to the reset pin, toggle it */
2172 if (gpiod) {
2173 gpiod_set_value_cansleep(gpiod, 1);
2174 usleep_range(10000, 20000);
2175 gpiod_set_value_cansleep(gpiod, 0);
2176 usleep_range(10000, 20000);
2177 }
2178}
2179
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002180static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2181{
2182 int i, err;
2183
2184 /* Set all ports to the Disabled state */
2185 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002186 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002187 if (err)
2188 return err;
2189 }
2190
2191 /* Wait for transmit queues to drain,
2192 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2193 */
2194 usleep_range(2000, 4000);
2195
2196 return 0;
2197}
2198
Vivien Didelotfad09c72016-06-21 12:28:20 -04002199static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002200{
Vivien Didelota935c052016-09-29 12:21:53 -04002201 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002202
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002203 err = mv88e6xxx_disable_ports(chip);
2204 if (err)
2205 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002206
Vivien Didelot309eca62016-12-05 17:30:26 -05002207 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002208
Vivien Didelot17e708b2016-12-05 17:30:27 -05002209 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002210}
2211
Vivien Didelot43145572017-03-11 16:12:59 -05002212static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002213 enum mv88e6xxx_frame_mode frame,
2214 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002215{
2216 int err;
2217
Vivien Didelot43145572017-03-11 16:12:59 -05002218 if (!chip->info->ops->port_set_frame_mode)
2219 return -EOPNOTSUPP;
2220
2221 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002222 if (err)
2223 return err;
2224
Vivien Didelot43145572017-03-11 16:12:59 -05002225 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2226 if (err)
2227 return err;
2228
2229 if (chip->info->ops->port_set_ether_type)
2230 return chip->info->ops->port_set_ether_type(chip, port, etype);
2231
2232 return 0;
2233}
2234
2235static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2236{
2237 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002238 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002239 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002240}
2241
2242static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2243{
2244 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002245 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002246 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002247}
2248
2249static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2250{
2251 return mv88e6xxx_set_port_mode(chip, port,
2252 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002253 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2254 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002255}
2256
2257static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2258{
2259 if (dsa_is_dsa_port(chip->ds, port))
2260 return mv88e6xxx_set_port_mode_dsa(chip, port);
2261
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002262 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002263 return mv88e6xxx_set_port_mode_normal(chip, port);
2264
2265 /* Setup CPU port mode depending on its supported tag format */
2266 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2267 return mv88e6xxx_set_port_mode_dsa(chip, port);
2268
2269 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2270 return mv88e6xxx_set_port_mode_edsa(chip, port);
2271
2272 return -EINVAL;
2273}
2274
Vivien Didelotea698f42017-03-11 16:12:50 -05002275static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2276{
2277 bool message = dsa_is_dsa_port(chip->ds, port);
2278
2279 return mv88e6xxx_port_set_message_port(chip, port, message);
2280}
2281
Vivien Didelot601aeed2017-03-11 16:13:00 -05002282static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2283{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002284 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002285 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002286
David S. Miller407308f2019-06-15 13:35:29 -07002287 /* Upstream ports flood frames with unknown unicast or multicast DA */
2288 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2289 if (chip->info->ops->port_set_egress_floods)
2290 return chip->info->ops->port_set_egress_floods(chip, port,
2291 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002292
David S. Miller407308f2019-06-15 13:35:29 -07002293 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002294}
2295
Vivien Didelot45de77f2019-08-31 16:18:36 -04002296static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2297{
2298 struct mv88e6xxx_port *mvp = dev_id;
2299 struct mv88e6xxx_chip *chip = mvp->chip;
2300 irqreturn_t ret = IRQ_NONE;
2301 int port = mvp->port;
2302 u8 lane;
2303
2304 mv88e6xxx_reg_lock(chip);
2305 lane = mv88e6xxx_serdes_get_lane(chip, port);
2306 if (lane)
2307 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2308 mv88e6xxx_reg_unlock(chip);
2309
2310 return ret;
2311}
2312
2313static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2314 u8 lane)
2315{
2316 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2317 unsigned int irq;
2318 int err;
2319
2320 /* Nothing to request if this SERDES port has no IRQ */
2321 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2322 if (!irq)
2323 return 0;
2324
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002325 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2326 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2327
Vivien Didelot45de77f2019-08-31 16:18:36 -04002328 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2329 mv88e6xxx_reg_unlock(chip);
2330 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002331 IRQF_ONESHOT, dev_id->serdes_irq_name,
2332 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002333 mv88e6xxx_reg_lock(chip);
2334 if (err)
2335 return err;
2336
2337 dev_id->serdes_irq = irq;
2338
2339 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2340}
2341
2342static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2343 u8 lane)
2344{
2345 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2346 unsigned int irq = dev_id->serdes_irq;
2347 int err;
2348
2349 /* Nothing to free if no IRQ has been requested */
2350 if (!irq)
2351 return 0;
2352
2353 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2354
2355 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2356 mv88e6xxx_reg_unlock(chip);
2357 free_irq(irq, dev_id);
2358 mv88e6xxx_reg_lock(chip);
2359
2360 dev_id->serdes_irq = 0;
2361
2362 return err;
2363}
2364
Andrew Lunn6d917822017-05-26 01:03:21 +02002365static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2366 bool on)
2367{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002368 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002369 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002370
Vivien Didelotdc272f62019-08-31 16:18:33 -04002371 lane = mv88e6xxx_serdes_get_lane(chip, port);
2372 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002373 return 0;
2374
2375 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002376 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002377 if (err)
2378 return err;
2379
Vivien Didelot45de77f2019-08-31 16:18:36 -04002380 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002381 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002382 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2383 if (err)
2384 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002385
Vivien Didelotdc272f62019-08-31 16:18:33 -04002386 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002387 }
2388
2389 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002390}
2391
Vivien Didelotfa371c82017-12-05 15:34:10 -05002392static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2393{
2394 struct dsa_switch *ds = chip->ds;
2395 int upstream_port;
2396 int err;
2397
Vivien Didelot07073c72017-12-05 15:34:13 -05002398 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002399 if (chip->info->ops->port_set_upstream_port) {
2400 err = chip->info->ops->port_set_upstream_port(chip, port,
2401 upstream_port);
2402 if (err)
2403 return err;
2404 }
2405
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002406 if (port == upstream_port) {
2407 if (chip->info->ops->set_cpu_port) {
2408 err = chip->info->ops->set_cpu_port(chip,
2409 upstream_port);
2410 if (err)
2411 return err;
2412 }
2413
2414 if (chip->info->ops->set_egress_port) {
2415 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002416 MV88E6XXX_EGRESS_DIR_INGRESS,
2417 upstream_port);
2418 if (err)
2419 return err;
2420
2421 err = chip->info->ops->set_egress_port(chip,
2422 MV88E6XXX_EGRESS_DIR_EGRESS,
2423 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002424 if (err)
2425 return err;
2426 }
2427 }
2428
Vivien Didelotfa371c82017-12-05 15:34:10 -05002429 return 0;
2430}
2431
Vivien Didelotfad09c72016-06-21 12:28:20 -04002432static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002433{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002434 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002435 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002436 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002437
Andrew Lunn7b898462018-08-09 15:38:47 +02002438 chip->ports[port].chip = chip;
2439 chip->ports[port].port = port;
2440
Vivien Didelotd78343d2016-11-04 03:23:36 +01002441 /* MAC Forcing register: don't force link, speed, duplex or flow control
2442 * state to any particular values on physical ports, but force the CPU
2443 * port and all DSA ports to their maximum bandwidth and full duplex.
2444 */
2445 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2446 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2447 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002448 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002449 PHY_INTERFACE_MODE_NA);
2450 else
2451 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2452 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002453 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002454 PHY_INTERFACE_MODE_NA);
2455 if (err)
2456 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002457
2458 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2459 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2460 * tunneling, determine priority by looking at 802.1p and IP
2461 * priority fields (IP prio has precedence), and set STP state
2462 * to Forwarding.
2463 *
2464 * If this is the CPU link, use DSA or EDSA tagging depending
2465 * on which tagging mode was configured.
2466 *
2467 * If this is a link to another switch, use DSA tagging mode.
2468 *
2469 * If this is the upstream port for this switch, enable
2470 * forwarding of unknown unicasts and multicasts.
2471 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002472 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2473 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2474 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2475 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002476 if (err)
2477 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002478
Vivien Didelot601aeed2017-03-11 16:13:00 -05002479 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002480 if (err)
2481 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002482
Vivien Didelot601aeed2017-03-11 16:13:00 -05002483 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002484 if (err)
2485 return err;
2486
Vivien Didelot8efdda42015-08-13 12:52:23 -04002487 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002488 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002489 * untagged frames on this port, do a destination address lookup on all
2490 * received packets as usual, disable ARP mirroring and don't send a
2491 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002492 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002493 err = mv88e6xxx_port_set_map_da(chip, port);
2494 if (err)
2495 return err;
2496
Vivien Didelotfa371c82017-12-05 15:34:10 -05002497 err = mv88e6xxx_setup_upstream_port(chip, port);
2498 if (err)
2499 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002500
Andrew Lunna23b2962017-02-04 20:15:28 +01002501 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002502 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002503 if (err)
2504 return err;
2505
Vivien Didelotcd782652017-06-08 18:34:13 -04002506 if (chip->info->ops->port_set_jumbo_size) {
2507 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002508 if (err)
2509 return err;
2510 }
2511
Andrew Lunn54d792f2015-05-06 01:09:47 +02002512 /* Port Association Vector: when learning source addresses
2513 * of packets, add the address to the address database using
2514 * a port bitmap that has only the bit for this port set and
2515 * the other bits clear.
2516 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002517 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002518 /* Disable learning for CPU port */
2519 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002520 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002521
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002522 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2523 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002524 if (err)
2525 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002526
2527 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002528 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2529 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002530 if (err)
2531 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002532
Vivien Didelot08984322017-06-08 18:34:12 -04002533 if (chip->info->ops->port_pause_limit) {
2534 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002535 if (err)
2536 return err;
2537 }
2538
Vivien Didelotc8c94892017-03-11 16:13:01 -05002539 if (chip->info->ops->port_disable_learn_limit) {
2540 err = chip->info->ops->port_disable_learn_limit(chip, port);
2541 if (err)
2542 return err;
2543 }
2544
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002545 if (chip->info->ops->port_disable_pri_override) {
2546 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002547 if (err)
2548 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002549 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002550
Andrew Lunnef0a7312016-12-03 04:35:16 +01002551 if (chip->info->ops->port_tag_remap) {
2552 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002553 if (err)
2554 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002555 }
2556
Andrew Lunnef70b112016-12-03 04:45:18 +01002557 if (chip->info->ops->port_egress_rate_limiting) {
2558 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002559 if (err)
2560 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002561 }
2562
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002563 if (chip->info->ops->port_setup_message_port) {
2564 err = chip->info->ops->port_setup_message_port(chip, port);
2565 if (err)
2566 return err;
2567 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002568
Vivien Didelot207afda2016-04-14 14:42:09 -04002569 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002570 * database, and allow bidirectional communication between the
2571 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002572 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002573 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002574 if (err)
2575 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002576
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002577 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002578 if (err)
2579 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002580
2581 /* Default VLAN ID and priority: don't set a default VLAN
2582 * ID, and set the default packet priority to zero.
2583 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002584 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002585}
2586
Andrew Lunn04aca992017-05-26 01:03:24 +02002587static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2588 struct phy_device *phydev)
2589{
2590 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002591 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002592
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002593 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002594 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002595 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002596
2597 return err;
2598}
2599
Andrew Lunn75104db2019-02-24 20:44:43 +01002600static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002601{
2602 struct mv88e6xxx_chip *chip = ds->priv;
2603
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002604 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002605 if (mv88e6xxx_serdes_power(chip, port, false))
2606 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002607 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002608}
2609
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002610static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2611 unsigned int ageing_time)
2612{
Vivien Didelot04bed142016-08-31 18:06:13 -04002613 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002614 int err;
2615
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002616 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002617 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002618 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002619
2620 return err;
2621}
2622
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002623static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002624{
2625 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002626
Andrew Lunnde2273872016-11-21 23:27:01 +01002627 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002628 if (chip->info->ops->stats_set_histogram) {
2629 err = chip->info->ops->stats_set_histogram(chip);
2630 if (err)
2631 return err;
2632 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002633
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002634 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002635}
2636
Andrew Lunnea890982019-01-09 00:24:03 +01002637/* Check if the errata has already been applied. */
2638static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2639{
2640 int port;
2641 int err;
2642 u16 val;
2643
2644 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002645 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002646 if (err) {
2647 dev_err(chip->dev,
2648 "Error reading hidden register: %d\n", err);
2649 return false;
2650 }
2651 if (val != 0x01c0)
2652 return false;
2653 }
2654
2655 return true;
2656}
2657
2658/* The 6390 copper ports have an errata which require poking magic
2659 * values into undocumented hidden registers and then performing a
2660 * software reset.
2661 */
2662static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2663{
2664 int port;
2665 int err;
2666
2667 if (mv88e6390_setup_errata_applied(chip))
2668 return 0;
2669
2670 /* Set the ports into blocking mode */
2671 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2672 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2673 if (err)
2674 return err;
2675 }
2676
2677 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002678 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002679 if (err)
2680 return err;
2681 }
2682
2683 return mv88e6xxx_software_reset(chip);
2684}
2685
Andrew Lunn23e8b472019-10-25 01:03:52 +02002686enum mv88e6xxx_devlink_param_id {
2687 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2688 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2689};
2690
2691static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2692 struct devlink_param_gset_ctx *ctx)
2693{
2694 struct mv88e6xxx_chip *chip = ds->priv;
2695 int err;
2696
2697 mv88e6xxx_reg_lock(chip);
2698
2699 switch (id) {
2700 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2701 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2702 break;
2703 default:
2704 err = -EOPNOTSUPP;
2705 break;
2706 }
2707
2708 mv88e6xxx_reg_unlock(chip);
2709
2710 return err;
2711}
2712
2713static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2714 struct devlink_param_gset_ctx *ctx)
2715{
2716 struct mv88e6xxx_chip *chip = ds->priv;
2717 int err;
2718
2719 mv88e6xxx_reg_lock(chip);
2720
2721 switch (id) {
2722 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2723 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2724 break;
2725 default:
2726 err = -EOPNOTSUPP;
2727 break;
2728 }
2729
2730 mv88e6xxx_reg_unlock(chip);
2731
2732 return err;
2733}
2734
2735static const struct devlink_param mv88e6xxx_devlink_params[] = {
2736 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2737 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2738 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2739};
2740
2741static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2742{
2743 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2744 ARRAY_SIZE(mv88e6xxx_devlink_params));
2745}
2746
2747static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2748{
2749 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2750 ARRAY_SIZE(mv88e6xxx_devlink_params));
2751}
2752
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002753enum mv88e6xxx_devlink_resource_id {
2754 MV88E6XXX_RESOURCE_ID_ATU,
2755 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2756 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2757 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2758 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2759};
2760
2761static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2762 u16 bin)
2763{
2764 u16 occupancy = 0;
2765 int err;
2766
2767 mv88e6xxx_reg_lock(chip);
2768
2769 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2770 bin);
2771 if (err) {
2772 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2773 goto unlock;
2774 }
2775
2776 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2777 if (err) {
2778 dev_err(chip->dev, "failed to perform ATU get next\n");
2779 goto unlock;
2780 }
2781
2782 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2783 if (err) {
2784 dev_err(chip->dev, "failed to get ATU stats\n");
2785 goto unlock;
2786 }
2787
2788unlock:
2789 mv88e6xxx_reg_unlock(chip);
2790
2791 return occupancy;
2792}
2793
2794static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2795{
2796 struct mv88e6xxx_chip *chip = priv;
2797
2798 return mv88e6xxx_devlink_atu_bin_get(chip,
2799 MV88E6XXX_G2_ATU_STATS_BIN_0);
2800}
2801
2802static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2803{
2804 struct mv88e6xxx_chip *chip = priv;
2805
2806 return mv88e6xxx_devlink_atu_bin_get(chip,
2807 MV88E6XXX_G2_ATU_STATS_BIN_1);
2808}
2809
2810static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2811{
2812 struct mv88e6xxx_chip *chip = priv;
2813
2814 return mv88e6xxx_devlink_atu_bin_get(chip,
2815 MV88E6XXX_G2_ATU_STATS_BIN_2);
2816}
2817
2818static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2819{
2820 struct mv88e6xxx_chip *chip = priv;
2821
2822 return mv88e6xxx_devlink_atu_bin_get(chip,
2823 MV88E6XXX_G2_ATU_STATS_BIN_3);
2824}
2825
2826static u64 mv88e6xxx_devlink_atu_get(void *priv)
2827{
2828 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2829 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2830 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2831 mv88e6xxx_devlink_atu_bin_3_get(priv);
2832}
2833
2834static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2835{
2836 struct devlink_resource_size_params size_params;
2837 struct mv88e6xxx_chip *chip = ds->priv;
2838 int err;
2839
2840 devlink_resource_size_params_init(&size_params,
2841 mv88e6xxx_num_macs(chip),
2842 mv88e6xxx_num_macs(chip),
2843 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2844
2845 err = dsa_devlink_resource_register(ds, "ATU",
2846 mv88e6xxx_num_macs(chip),
2847 MV88E6XXX_RESOURCE_ID_ATU,
2848 DEVLINK_RESOURCE_ID_PARENT_TOP,
2849 &size_params);
2850 if (err)
2851 goto out;
2852
2853 devlink_resource_size_params_init(&size_params,
2854 mv88e6xxx_num_macs(chip) / 4,
2855 mv88e6xxx_num_macs(chip) / 4,
2856 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2857
2858 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2859 mv88e6xxx_num_macs(chip) / 4,
2860 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2861 MV88E6XXX_RESOURCE_ID_ATU,
2862 &size_params);
2863 if (err)
2864 goto out;
2865
2866 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2867 mv88e6xxx_num_macs(chip) / 4,
2868 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2869 MV88E6XXX_RESOURCE_ID_ATU,
2870 &size_params);
2871 if (err)
2872 goto out;
2873
2874 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2875 mv88e6xxx_num_macs(chip) / 4,
2876 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2877 MV88E6XXX_RESOURCE_ID_ATU,
2878 &size_params);
2879 if (err)
2880 goto out;
2881
2882 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2883 mv88e6xxx_num_macs(chip) / 4,
2884 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2885 MV88E6XXX_RESOURCE_ID_ATU,
2886 &size_params);
2887 if (err)
2888 goto out;
2889
2890 dsa_devlink_resource_occ_get_register(ds,
2891 MV88E6XXX_RESOURCE_ID_ATU,
2892 mv88e6xxx_devlink_atu_get,
2893 chip);
2894
2895 dsa_devlink_resource_occ_get_register(ds,
2896 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2897 mv88e6xxx_devlink_atu_bin_0_get,
2898 chip);
2899
2900 dsa_devlink_resource_occ_get_register(ds,
2901 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2902 mv88e6xxx_devlink_atu_bin_1_get,
2903 chip);
2904
2905 dsa_devlink_resource_occ_get_register(ds,
2906 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2907 mv88e6xxx_devlink_atu_bin_2_get,
2908 chip);
2909
2910 dsa_devlink_resource_occ_get_register(ds,
2911 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2912 mv88e6xxx_devlink_atu_bin_3_get,
2913 chip);
2914
2915 return 0;
2916
2917out:
2918 dsa_devlink_resources_unregister(ds);
2919 return err;
2920}
2921
Andrew Lunn23e8b472019-10-25 01:03:52 +02002922static void mv88e6xxx_teardown(struct dsa_switch *ds)
2923{
2924 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002925 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002926}
2927
Vivien Didelotf81ec902016-05-09 13:22:58 -04002928static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002929{
Vivien Didelot04bed142016-08-31 18:06:13 -04002930 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002931 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002932 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002933 int i;
2934
Vivien Didelotfad09c72016-06-21 12:28:20 -04002935 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002936 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002937
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002938 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002939
Andrew Lunnea890982019-01-09 00:24:03 +01002940 if (chip->info->ops->setup_errata) {
2941 err = chip->info->ops->setup_errata(chip);
2942 if (err)
2943 goto unlock;
2944 }
2945
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002946 /* Cache the cmode of each port. */
2947 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2948 if (chip->info->ops->port_get_cmode) {
2949 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2950 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002951 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002952
2953 chip->ports[i].cmode = cmode;
2954 }
2955 }
2956
Vivien Didelot97299342016-07-18 20:45:30 -04002957 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002958 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002959 if (dsa_is_unused_port(ds, i))
2960 continue;
2961
Hubert Feursteinc8574862019-07-31 10:23:48 +02002962 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002963 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002964 dev_err(chip->dev, "port %d is invalid\n", i);
2965 err = -EINVAL;
2966 goto unlock;
2967 }
2968
Vivien Didelot97299342016-07-18 20:45:30 -04002969 err = mv88e6xxx_setup_port(chip, i);
2970 if (err)
2971 goto unlock;
2972 }
2973
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002974 err = mv88e6xxx_irl_setup(chip);
2975 if (err)
2976 goto unlock;
2977
Vivien Didelot04a69a12017-10-13 14:18:05 -04002978 err = mv88e6xxx_mac_setup(chip);
2979 if (err)
2980 goto unlock;
2981
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002982 err = mv88e6xxx_phy_setup(chip);
2983 if (err)
2984 goto unlock;
2985
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002986 err = mv88e6xxx_vtu_setup(chip);
2987 if (err)
2988 goto unlock;
2989
Vivien Didelot81228992017-03-30 17:37:08 -04002990 err = mv88e6xxx_pvt_setup(chip);
2991 if (err)
2992 goto unlock;
2993
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002994 err = mv88e6xxx_atu_setup(chip);
2995 if (err)
2996 goto unlock;
2997
Andrew Lunn87fa8862017-11-09 22:29:56 +01002998 err = mv88e6xxx_broadcast_setup(chip, 0);
2999 if (err)
3000 goto unlock;
3001
Vivien Didelot9e907d72017-07-17 13:03:43 -04003002 err = mv88e6xxx_pot_setup(chip);
3003 if (err)
3004 goto unlock;
3005
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003006 err = mv88e6xxx_rmu_setup(chip);
3007 if (err)
3008 goto unlock;
3009
Vivien Didelot51c901a2017-07-17 13:03:41 -04003010 err = mv88e6xxx_rsvd2cpu_setup(chip);
3011 if (err)
3012 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003013
Vivien Didelotb28f8722018-04-26 21:56:44 -04003014 err = mv88e6xxx_trunk_setup(chip);
3015 if (err)
3016 goto unlock;
3017
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003018 err = mv88e6xxx_devmap_setup(chip);
3019 if (err)
3020 goto unlock;
3021
Vivien Didelot93e18d62018-05-11 17:16:35 -04003022 err = mv88e6xxx_pri_setup(chip);
3023 if (err)
3024 goto unlock;
3025
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003026 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003027 if (chip->info->ptp_support) {
3028 err = mv88e6xxx_ptp_setup(chip);
3029 if (err)
3030 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003031
3032 err = mv88e6xxx_hwtstamp_setup(chip);
3033 if (err)
3034 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003035 }
3036
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003037 err = mv88e6xxx_stats_setup(chip);
3038 if (err)
3039 goto unlock;
3040
Vivien Didelot6b17e862015-08-13 12:52:18 -04003041unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003042 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003043
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003044 if (err)
3045 return err;
3046
3047 /* Have to be called without holding the register lock, since
3048 * they take the devlink lock, and we later take the locks in
3049 * the reverse order when getting/setting parameters or
3050 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003051 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003052 err = mv88e6xxx_setup_devlink_resources(ds);
3053 if (err)
3054 return err;
3055
3056 err = mv88e6xxx_setup_devlink_params(ds);
3057 if (err)
3058 dsa_devlink_resources_unregister(ds);
3059
3060 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003061}
3062
Vivien Didelote57e5e72016-08-15 17:19:00 -04003063static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003064{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003065 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3066 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003067 u16 val;
3068 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003069
Andrew Lunnee26a222017-01-24 14:53:48 +01003070 if (!chip->info->ops->phy_read)
3071 return -EOPNOTSUPP;
3072
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003073 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003074 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003075 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003076
Andrew Lunnda9f3302017-02-01 03:40:05 +01003077 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003078 /* Some internal PHYs don't have a model number. */
3079 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3080 /* Then there is the 6165 family. It gets is
3081 * PHYs correct. But it can also have two
3082 * SERDES interfaces in the PHY address
3083 * space. And these don't have a model
3084 * number. But they are not PHYs, so we don't
3085 * want to give them something a PHY driver
3086 * will recognise.
3087 *
3088 * Use the mv88e6390 family model number
3089 * instead, for anything which really could be
3090 * a PHY,
3091 */
3092 if (!(val & 0x3f0))
3093 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003094 }
3095
Vivien Didelote57e5e72016-08-15 17:19:00 -04003096 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003097}
3098
Vivien Didelote57e5e72016-08-15 17:19:00 -04003099static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003100{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003101 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3102 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003103 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003104
Andrew Lunnee26a222017-01-24 14:53:48 +01003105 if (!chip->info->ops->phy_write)
3106 return -EOPNOTSUPP;
3107
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003108 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003109 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003110 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003111
3112 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003113}
3114
Vivien Didelotfad09c72016-06-21 12:28:20 -04003115static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003116 struct device_node *np,
3117 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003118{
3119 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003120 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003121 struct mii_bus *bus;
3122 int err;
3123
Andrew Lunn2510bab2018-02-22 01:51:49 +01003124 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003125 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003126 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003127 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003128
3129 if (err)
3130 return err;
3131 }
3132
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003133 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003134 if (!bus)
3135 return -ENOMEM;
3136
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003137 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003138 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003139 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003140 INIT_LIST_HEAD(&mdio_bus->list);
3141 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003142
Andrew Lunnb516d452016-06-04 21:17:06 +02003143 if (np) {
3144 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003145 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003146 } else {
3147 bus->name = "mv88e6xxx SMI";
3148 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3149 }
3150
3151 bus->read = mv88e6xxx_mdio_read;
3152 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003153 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003154
Andrew Lunn6f882842018-03-17 20:32:05 +01003155 if (!external) {
3156 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3157 if (err)
3158 return err;
3159 }
3160
Florian Fainelli00e798c2018-05-15 16:56:19 -07003161 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003162 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003163 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003164 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003165 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003166 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003167
3168 if (external)
3169 list_add_tail(&mdio_bus->list, &chip->mdios);
3170 else
3171 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003172
3173 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003174}
3175
Andrew Lunna3c53be52017-01-24 14:53:50 +01003176static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3177 { .compatible = "marvell,mv88e6xxx-mdio-external",
3178 .data = (void *)true },
3179 { },
3180};
3181
Andrew Lunn3126aee2017-12-07 01:05:57 +01003182static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3183
3184{
3185 struct mv88e6xxx_mdio_bus *mdio_bus;
3186 struct mii_bus *bus;
3187
3188 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3189 bus = mdio_bus->bus;
3190
Andrew Lunn6f882842018-03-17 20:32:05 +01003191 if (!mdio_bus->external)
3192 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3193
Andrew Lunn3126aee2017-12-07 01:05:57 +01003194 mdiobus_unregister(bus);
3195 }
3196}
3197
Andrew Lunna3c53be52017-01-24 14:53:50 +01003198static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3199 struct device_node *np)
3200{
3201 const struct of_device_id *match;
3202 struct device_node *child;
3203 int err;
3204
3205 /* Always register one mdio bus for the internal/default mdio
3206 * bus. This maybe represented in the device tree, but is
3207 * optional.
3208 */
3209 child = of_get_child_by_name(np, "mdio");
3210 err = mv88e6xxx_mdio_register(chip, child, false);
3211 if (err)
3212 return err;
3213
3214 /* Walk the device tree, and see if there are any other nodes
3215 * which say they are compatible with the external mdio
3216 * bus.
3217 */
3218 for_each_available_child_of_node(np, child) {
3219 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3220 if (match) {
3221 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003222 if (err) {
3223 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303224 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003225 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003226 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003227 }
3228 }
3229
3230 return 0;
3231}
3232
Vivien Didelot855b1932016-07-20 18:18:35 -04003233static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3234{
Vivien Didelot04bed142016-08-31 18:06:13 -04003235 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003236
3237 return chip->eeprom_len;
3238}
3239
Vivien Didelot855b1932016-07-20 18:18:35 -04003240static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3241 struct ethtool_eeprom *eeprom, u8 *data)
3242{
Vivien Didelot04bed142016-08-31 18:06:13 -04003243 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003244 int err;
3245
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003246 if (!chip->info->ops->get_eeprom)
3247 return -EOPNOTSUPP;
3248
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003249 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003250 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003251 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003252
3253 if (err)
3254 return err;
3255
3256 eeprom->magic = 0xc3ec4951;
3257
3258 return 0;
3259}
3260
Vivien Didelot855b1932016-07-20 18:18:35 -04003261static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3262 struct ethtool_eeprom *eeprom, u8 *data)
3263{
Vivien Didelot04bed142016-08-31 18:06:13 -04003264 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003265 int err;
3266
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003267 if (!chip->info->ops->set_eeprom)
3268 return -EOPNOTSUPP;
3269
Vivien Didelot855b1932016-07-20 18:18:35 -04003270 if (eeprom->magic != 0xc3ec4951)
3271 return -EINVAL;
3272
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003273 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003274 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003275 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003276
3277 return err;
3278}
3279
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003280static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003281 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003282 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3283 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003284 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003285 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003286 .phy_read = mv88e6185_phy_ppu_read,
3287 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003288 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003289 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003290 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003291 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003292 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003293 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003294 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003295 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003296 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003297 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003298 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003299 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003300 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003301 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003302 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003303 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003304 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3305 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003306 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003307 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3308 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003309 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003310 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003311 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003312 .ppu_enable = mv88e6185_g1_ppu_enable,
3313 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003314 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003315 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003316 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003317 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003318 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003319};
3320
3321static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003322 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003323 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3324 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003325 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003326 .phy_read = mv88e6185_phy_ppu_read,
3327 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003328 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003329 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003330 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003331 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003332 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003333 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003334 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003335 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003336 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003337 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003338 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003339 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3340 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003341 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003342 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003343 .ppu_enable = mv88e6185_g1_ppu_enable,
3344 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003345 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003346 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003347 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003348 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003349};
3350
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003351static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003352 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003353 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3354 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003355 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003356 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3357 .phy_read = mv88e6xxx_g2_smi_phy_read,
3358 .phy_write = mv88e6xxx_g2_smi_phy_write,
3359 .port_set_link = mv88e6xxx_port_set_link,
3360 .port_set_duplex = mv88e6xxx_port_set_duplex,
3361 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003362 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003363 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003364 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003365 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003366 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003367 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003368 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003369 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003370 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003371 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003372 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003373 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003374 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003375 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003376 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3377 .stats_get_strings = mv88e6095_stats_get_strings,
3378 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003379 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3380 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003381 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003382 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003383 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003384 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003385 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003386 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003387 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003388 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003389};
3390
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003391static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003392 /* MV88E6XXX_FAMILY_6165 */
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_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003397 .phy_read = mv88e6xxx_g2_smi_phy_read,
3398 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003399 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003400 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003401 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003402 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003403 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003404 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003405 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003406 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003407 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003408 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003409 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003410 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003411 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3412 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003413 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003414 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3415 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003416 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003417 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003418 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003419 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003420 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3421 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003422 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003423 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003424 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003425};
3426
3427static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003428 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003429 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3430 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003431 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003432 .phy_read = mv88e6185_phy_ppu_read,
3433 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003434 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003435 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003436 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003437 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003438 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003439 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003440 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003441 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003442 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003443 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003444 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003445 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003446 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003447 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003448 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003449 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003450 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003451 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3452 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003453 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003454 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3455 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003456 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003457 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003458 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003459 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003460 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003461 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003462 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003463 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003464 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003465};
3466
Vivien Didelot990e27b2017-03-28 13:50:32 -04003467static const struct mv88e6xxx_ops mv88e6141_ops = {
3468 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003469 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3470 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003471 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003472 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3473 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3474 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3475 .phy_read = mv88e6xxx_g2_smi_phy_read,
3476 .phy_write = mv88e6xxx_g2_smi_phy_write,
3477 .port_set_link = mv88e6xxx_port_set_link,
3478 .port_set_duplex = mv88e6xxx_port_set_duplex,
3479 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003480 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003481 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003482 .port_tag_remap = mv88e6095_port_tag_remap,
3483 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3484 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3485 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003486 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003487 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003488 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003489 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3490 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003491 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003492 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003493 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003494 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003495 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003496 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003497 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3498 .stats_get_strings = mv88e6320_stats_get_strings,
3499 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003500 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3501 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003502 .watchdog_ops = &mv88e6390_watchdog_ops,
3503 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003504 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003505 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003506 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003507 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003508 .serdes_power = mv88e6390_serdes_power,
3509 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003510 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003511 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003512 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003513 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003514 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003515};
3516
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003517static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003518 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003519 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3520 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003521 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003522 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003523 .phy_read = mv88e6xxx_g2_smi_phy_read,
3524 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003525 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003526 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003527 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003528 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003529 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003530 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003531 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003532 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003533 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003534 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003535 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003536 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003537 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003538 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003539 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003540 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003541 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003542 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3543 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003544 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003545 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3546 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003547 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003548 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003549 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003550 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003551 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3552 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003553 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003554 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003555 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003556 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003557 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003558};
3559
3560static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003561 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003562 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3563 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003564 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003565 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003566 .phy_read = mv88e6165_phy_read,
3567 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003568 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003569 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003570 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003571 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003572 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003573 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003574 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003575 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003576 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003577 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003578 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3579 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003580 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003581 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3582 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003583 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003584 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003585 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003586 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003587 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3588 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003589 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003590 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003591 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003592 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003593 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003594};
3595
3596static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003597 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003598 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3599 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003600 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003601 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003602 .phy_read = mv88e6xxx_g2_smi_phy_read,
3603 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003604 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003605 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003606 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003607 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003608 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003609 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003610 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003611 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003612 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003613 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003614 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003615 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003616 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003617 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003618 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003619 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003620 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003621 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003622 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3623 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003624 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003625 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3626 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003627 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003628 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003629 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003630 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003631 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3632 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003633 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003634 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003635 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003636};
3637
3638static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003639 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003640 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3641 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003642 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003643 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3644 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003645 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003646 .phy_read = mv88e6xxx_g2_smi_phy_read,
3647 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003648 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003649 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003650 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003651 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003652 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003653 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003654 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003655 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003656 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003657 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003658 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003659 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003660 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003661 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003662 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003663 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003664 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003665 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003666 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003667 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3668 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003669 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003670 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3671 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003672 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003673 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003674 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003675 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003676 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003677 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3678 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003679 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003680 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003681 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003682 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003683 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3684 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003685 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003686 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003687};
3688
3689static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003690 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003691 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3692 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003693 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003694 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003695 .phy_read = mv88e6xxx_g2_smi_phy_read,
3696 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003697 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003698 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003699 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003700 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003701 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003702 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003703 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003704 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003705 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003706 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003707 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003708 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003709 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003710 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003711 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003712 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003713 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003714 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003715 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3716 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003717 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003718 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3719 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003720 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003721 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003722 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003723 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003724 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3725 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003726 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003727 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003728 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003729};
3730
3731static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003732 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003733 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3734 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003735 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003736 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3737 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003738 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003739 .phy_read = mv88e6xxx_g2_smi_phy_read,
3740 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003741 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003742 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003743 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003744 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003745 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003746 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003747 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003748 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003749 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003750 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003751 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003752 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003753 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003754 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003755 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003756 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003757 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003758 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003759 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003760 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3761 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003762 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003763 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3764 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003765 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003766 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003767 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003768 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003769 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003770 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3771 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003772 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003773 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003774 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003775 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003776 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003777 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003778 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003779 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3780 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003781 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003782 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003783};
3784
3785static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003786 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003787 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3788 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003789 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003790 .phy_read = mv88e6185_phy_ppu_read,
3791 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003792 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003793 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003794 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003795 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003796 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003797 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003798 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003799 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003800 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003801 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003802 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003803 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003804 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003805 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3806 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003807 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003808 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3809 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003810 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003811 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003812 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003813 .ppu_enable = mv88e6185_g1_ppu_enable,
3814 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003815 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003816 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003817 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003818 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003819};
3820
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003821static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003822 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003823 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003824 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003825 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3826 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003827 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3828 .phy_read = mv88e6xxx_g2_smi_phy_read,
3829 .phy_write = mv88e6xxx_g2_smi_phy_write,
3830 .port_set_link = mv88e6xxx_port_set_link,
3831 .port_set_duplex = mv88e6xxx_port_set_duplex,
3832 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3833 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003834 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003835 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003836 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003837 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003838 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003839 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003840 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003841 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003842 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003843 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003844 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003845 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003846 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003847 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003848 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003849 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3850 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003851 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003852 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3853 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003854 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003855 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003856 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003857 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003858 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003859 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3860 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003861 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3862 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003863 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003864 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003865 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003866 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003867 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003868 .serdes_get_strings = mv88e6390_serdes_get_strings,
3869 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003870 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3871 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003872 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003873 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003874 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003875};
3876
3877static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003878 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003879 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003880 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003881 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3882 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003883 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3884 .phy_read = mv88e6xxx_g2_smi_phy_read,
3885 .phy_write = mv88e6xxx_g2_smi_phy_write,
3886 .port_set_link = mv88e6xxx_port_set_link,
3887 .port_set_duplex = mv88e6xxx_port_set_duplex,
3888 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3889 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003890 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003891 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003892 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003893 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003894 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003895 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003896 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003897 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003898 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003899 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003900 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003901 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003902 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003903 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003904 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003905 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3906 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003907 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003908 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3909 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003910 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003911 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003912 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003913 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003914 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003915 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3916 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003917 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3918 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003919 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003920 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003921 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003922 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003923 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003924 .serdes_get_strings = mv88e6390_serdes_get_strings,
3925 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003926 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3927 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003928 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003929 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003930 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003931};
3932
3933static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003934 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003935 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003936 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003937 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3938 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003939 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3940 .phy_read = mv88e6xxx_g2_smi_phy_read,
3941 .phy_write = mv88e6xxx_g2_smi_phy_write,
3942 .port_set_link = mv88e6xxx_port_set_link,
3943 .port_set_duplex = mv88e6xxx_port_set_duplex,
3944 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3945 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003946 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003947 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003948 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003949 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003950 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003951 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003952 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003953 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003954 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003955 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003956 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003957 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003958 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003959 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003960 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3961 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003962 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003963 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3964 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003965 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003966 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003967 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003968 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003969 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003970 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3971 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003972 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3973 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003974 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003975 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003976 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003977 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003978 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003979 .serdes_get_strings = mv88e6390_serdes_get_strings,
3980 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003981 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3982 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003983 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003984 .avb_ops = &mv88e6390_avb_ops,
3985 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003986 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003987};
3988
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003989static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003990 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003991 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3992 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003993 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003994 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3995 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003996 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003997 .phy_read = mv88e6xxx_g2_smi_phy_read,
3998 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003999 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004000 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004001 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004002 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004003 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004004 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004005 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004006 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004007 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004008 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004009 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004010 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004011 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004012 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004013 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004014 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004015 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004016 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004017 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004018 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4019 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004020 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004021 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4022 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004023 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004024 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004025 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004026 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004027 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004028 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4029 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004030 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004031 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004032 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004033 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004034 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004035 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004036 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004037 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4038 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004039 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004040 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004041 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004042 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004043};
4044
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004045static const struct mv88e6xxx_ops mv88e6250_ops = {
4046 /* MV88E6XXX_FAMILY_6250 */
4047 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4048 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4049 .irl_init_all = mv88e6352_g2_irl_init_all,
4050 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4051 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4052 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4053 .phy_read = mv88e6xxx_g2_smi_phy_read,
4054 .phy_write = mv88e6xxx_g2_smi_phy_write,
4055 .port_set_link = mv88e6xxx_port_set_link,
4056 .port_set_duplex = mv88e6xxx_port_set_duplex,
4057 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4058 .port_set_speed = mv88e6250_port_set_speed,
4059 .port_tag_remap = mv88e6095_port_tag_remap,
4060 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4061 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4062 .port_set_ether_type = mv88e6351_port_set_ether_type,
4063 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4064 .port_pause_limit = mv88e6097_port_pause_limit,
4065 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4066 .port_link_state = mv88e6250_port_link_state,
4067 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4068 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4069 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4070 .stats_get_strings = mv88e6250_stats_get_strings,
4071 .stats_get_stats = mv88e6250_stats_get_stats,
4072 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4073 .set_egress_port = mv88e6095_g1_set_egress_port,
4074 .watchdog_ops = &mv88e6250_watchdog_ops,
4075 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4076 .pot_clear = mv88e6xxx_g2_pot_clear,
4077 .reset = mv88e6250_g1_reset,
4078 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4079 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004080 .avb_ops = &mv88e6352_avb_ops,
4081 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004082 .phylink_validate = mv88e6065_phylink_validate,
4083};
4084
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004085static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004086 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004087 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004088 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004089 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4090 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004091 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4092 .phy_read = mv88e6xxx_g2_smi_phy_read,
4093 .phy_write = mv88e6xxx_g2_smi_phy_write,
4094 .port_set_link = mv88e6xxx_port_set_link,
4095 .port_set_duplex = mv88e6xxx_port_set_duplex,
4096 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4097 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004098 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004099 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004100 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004101 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004102 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004103 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004104 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004105 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004106 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004107 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004108 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004109 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004110 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004111 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004112 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004113 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4114 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004115 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004116 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4117 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004118 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004119 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004120 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004121 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004122 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004123 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4124 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004125 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4126 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004127 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004128 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004129 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004130 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004131 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004132 .serdes_get_strings = mv88e6390_serdes_get_strings,
4133 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004134 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4135 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004136 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004137 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004138 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004139 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004140 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004141};
4142
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004143static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004144 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004145 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4146 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004147 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004148 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4149 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004150 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004151 .phy_read = mv88e6xxx_g2_smi_phy_read,
4152 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004153 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004154 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004155 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004156 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004157 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004158 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004159 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004160 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004161 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004162 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004163 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004164 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004165 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004166 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004167 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004168 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004169 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004170 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4171 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004172 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004173 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4174 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004175 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004176 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004177 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004178 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004179 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004180 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004181 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004182 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004183 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004184 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004185};
4186
4187static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004188 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004189 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4190 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004191 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004192 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4193 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004194 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004195 .phy_read = mv88e6xxx_g2_smi_phy_read,
4196 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004197 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004198 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004199 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004200 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004201 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004202 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004203 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004204 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004205 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004206 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004207 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004208 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004209 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004210 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004211 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004212 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004213 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004214 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4215 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004216 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004217 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4218 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004219 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004220 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004221 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004222 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004223 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004224 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004225 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004226 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004227};
4228
Vivien Didelot16e329a2017-03-28 13:50:33 -04004229static const struct mv88e6xxx_ops mv88e6341_ops = {
4230 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004231 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4232 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004233 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004234 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4235 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4236 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4237 .phy_read = mv88e6xxx_g2_smi_phy_read,
4238 .phy_write = mv88e6xxx_g2_smi_phy_write,
4239 .port_set_link = mv88e6xxx_port_set_link,
4240 .port_set_duplex = mv88e6xxx_port_set_duplex,
4241 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004242 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004243 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004244 .port_tag_remap = mv88e6095_port_tag_remap,
4245 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4246 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4247 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004248 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004249 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004250 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004251 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4252 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004253 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004254 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004255 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004256 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004257 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004258 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004259 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4260 .stats_get_strings = mv88e6320_stats_get_strings,
4261 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004262 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4263 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004264 .watchdog_ops = &mv88e6390_watchdog_ops,
4265 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004266 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004267 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004268 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004269 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004270 .serdes_power = mv88e6390_serdes_power,
4271 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004272 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004273 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004274 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004275 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004276 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004277 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004278 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004279};
4280
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004281static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004282 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004283 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4284 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004285 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004286 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004287 .phy_read = mv88e6xxx_g2_smi_phy_read,
4288 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004289 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004290 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004291 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004292 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004293 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004294 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004295 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004296 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004297 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004298 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004299 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004300 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004301 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004302 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004303 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004304 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004305 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004306 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004307 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4308 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004309 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004310 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4311 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004312 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004313 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004314 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004315 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004316 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4317 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004318 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004319 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004320 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004321};
4322
4323static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004324 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004325 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4326 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004327 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004328 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004329 .phy_read = mv88e6xxx_g2_smi_phy_read,
4330 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004331 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004332 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004333 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004334 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004335 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004336 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004337 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004338 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004339 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004340 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004341 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004342 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004343 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004344 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004345 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004346 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004347 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004348 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004349 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4350 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004351 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004352 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4353 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004354 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004355 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004356 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004357 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004358 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4359 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004360 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004361 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004362 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004363 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004364 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004365};
4366
4367static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004368 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004369 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4370 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004371 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004372 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4373 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004374 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004375 .phy_read = mv88e6xxx_g2_smi_phy_read,
4376 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004377 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004378 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004379 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004380 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004381 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004382 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004383 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004384 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004385 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004386 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004387 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004388 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004389 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004390 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004391 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004392 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004393 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004394 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004395 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004396 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4397 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004398 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004399 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4400 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004401 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004402 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004403 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004404 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004405 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004406 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4407 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004408 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004409 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004410 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004411 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004412 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004413 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004414 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004415 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004416 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004417 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004418 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4419 .serdes_get_strings = mv88e6352_serdes_get_strings,
4420 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004421 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4422 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004423 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004424};
4425
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004426static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004427 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004428 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004429 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004430 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4431 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004432 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4433 .phy_read = mv88e6xxx_g2_smi_phy_read,
4434 .phy_write = mv88e6xxx_g2_smi_phy_write,
4435 .port_set_link = mv88e6xxx_port_set_link,
4436 .port_set_duplex = mv88e6xxx_port_set_duplex,
4437 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4438 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004439 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004440 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004441 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004442 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004443 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004444 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004445 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004446 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004447 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004448 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004449 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004450 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004451 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004452 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004453 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004454 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004455 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004456 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4457 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004458 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004459 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4460 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004461 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004462 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004463 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004464 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004465 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004466 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4467 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004468 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4469 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004470 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004471 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004472 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004473 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004474 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004475 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004476 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004477 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004478 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4479 .serdes_get_strings = mv88e6390_serdes_get_strings,
4480 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004481 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4482 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004483 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004484};
4485
4486static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004487 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004488 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004489 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004490 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4491 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004492 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4493 .phy_read = mv88e6xxx_g2_smi_phy_read,
4494 .phy_write = mv88e6xxx_g2_smi_phy_write,
4495 .port_set_link = mv88e6xxx_port_set_link,
4496 .port_set_duplex = mv88e6xxx_port_set_duplex,
4497 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4498 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004499 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004500 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004501 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004502 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004503 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004504 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004505 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004506 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004507 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004508 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004509 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004510 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004511 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004512 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004513 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004514 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004515 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004516 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4517 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004518 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004519 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4520 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004521 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004522 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004523 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004524 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004525 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004526 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4527 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004528 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4529 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004530 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004531 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004532 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004533 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004534 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004535 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4536 .serdes_get_strings = mv88e6390_serdes_get_strings,
4537 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004538 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4539 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004540 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004541 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004542 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004543 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004544};
4545
Vivien Didelotf81ec902016-05-09 13:22:58 -04004546static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4547 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004548 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004549 .family = MV88E6XXX_FAMILY_6097,
4550 .name = "Marvell 88E6085",
4551 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004552 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004553 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004554 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004555 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004556 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004557 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004558 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004559 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004560 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004561 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004562 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004563 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004564 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004565 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004566 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004567 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004568 },
4569
4570 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004571 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004572 .family = MV88E6XXX_FAMILY_6095,
4573 .name = "Marvell 88E6095/88E6095F",
4574 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004575 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004577 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004578 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004579 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004580 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004581 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004582 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004583 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004584 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004585 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004586 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004587 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004588 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004589 },
4590
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004591 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004592 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004593 .family = MV88E6XXX_FAMILY_6097,
4594 .name = "Marvell 88E6097/88E6097F",
4595 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004596 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004597 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004598 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004599 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004600 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004601 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004602 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004603 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004604 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004605 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004606 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004607 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004608 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004609 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004610 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004611 .ops = &mv88e6097_ops,
4612 },
4613
Vivien Didelotf81ec902016-05-09 13:22:58 -04004614 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004615 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004616 .family = MV88E6XXX_FAMILY_6165,
4617 .name = "Marvell 88E6123",
4618 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004619 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004620 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004621 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004622 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004623 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004624 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004625 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004626 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004627 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004628 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004629 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004630 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004631 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004632 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004633 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004634 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004635 },
4636
4637 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004638 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004639 .family = MV88E6XXX_FAMILY_6185,
4640 .name = "Marvell 88E6131",
4641 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004642 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004643 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004644 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004645 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004646 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004647 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004648 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004649 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004650 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004651 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004652 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004653 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004654 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004655 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004656 },
4657
Vivien Didelot990e27b2017-03-28 13:50:32 -04004658 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004659 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004660 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004661 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004662 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004663 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004664 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004665 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004666 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004667 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004668 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004669 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004670 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004671 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004672 .age_time_coeff = 3750,
4673 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004674 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004675 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004676 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004677 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004678 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004679 .ops = &mv88e6141_ops,
4680 },
4681
Vivien Didelotf81ec902016-05-09 13:22:58 -04004682 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004683 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004684 .family = MV88E6XXX_FAMILY_6165,
4685 .name = "Marvell 88E6161",
4686 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004687 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004688 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004689 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004690 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004691 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004692 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004693 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004694 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004695 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004696 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004697 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004698 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004699 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004700 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004701 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004702 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004703 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004704 },
4705
4706 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004707 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004708 .family = MV88E6XXX_FAMILY_6165,
4709 .name = "Marvell 88E6165",
4710 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004711 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004712 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004713 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004714 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004715 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004716 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004717 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004718 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004719 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004720 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004721 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004722 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004723 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004724 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004725 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004726 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004727 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 },
4729
4730 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004731 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004732 .family = MV88E6XXX_FAMILY_6351,
4733 .name = "Marvell 88E6171",
4734 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004735 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004736 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004737 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004738 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004739 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004740 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004741 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004742 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004743 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004744 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004745 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004746 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004747 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004748 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004749 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004750 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004751 },
4752
4753 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004754 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004755 .family = MV88E6XXX_FAMILY_6352,
4756 .name = "Marvell 88E6172",
4757 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004758 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004759 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004760 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004761 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004762 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004763 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004764 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004765 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004766 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004767 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004768 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004769 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004770 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004771 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004772 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004773 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004774 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 },
4776
4777 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004778 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004779 .family = MV88E6XXX_FAMILY_6351,
4780 .name = "Marvell 88E6175",
4781 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004782 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004783 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004784 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004785 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004786 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004787 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004788 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004789 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004790 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004791 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004792 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004793 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004794 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004795 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004796 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004797 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004798 },
4799
4800 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004801 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004802 .family = MV88E6XXX_FAMILY_6352,
4803 .name = "Marvell 88E6176",
4804 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004805 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004806 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004807 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004808 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004809 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004810 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004811 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004812 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004813 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004814 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004815 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004816 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004817 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004818 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004819 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004820 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004821 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004822 },
4823
4824 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004825 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004826 .family = MV88E6XXX_FAMILY_6185,
4827 .name = "Marvell 88E6185",
4828 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004829 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004830 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004831 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004832 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004833 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004834 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004835 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004836 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004837 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004838 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004839 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004840 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004841 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004842 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004843 },
4844
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004845 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004846 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004847 .family = MV88E6XXX_FAMILY_6390,
4848 .name = "Marvell 88E6190",
4849 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004850 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004851 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004852 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004853 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004854 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004855 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004856 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004857 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004858 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004859 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004860 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004861 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004862 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004863 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004864 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004865 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004866 .ops = &mv88e6190_ops,
4867 },
4868
4869 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004870 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004871 .family = MV88E6XXX_FAMILY_6390,
4872 .name = "Marvell 88E6190X",
4873 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004874 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004875 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004876 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004877 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004878 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004879 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004880 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004881 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004882 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004883 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004884 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004885 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004886 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004887 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004888 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004889 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004890 .ops = &mv88e6190x_ops,
4891 },
4892
4893 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004894 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004895 .family = MV88E6XXX_FAMILY_6390,
4896 .name = "Marvell 88E6191",
4897 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004898 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004899 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004900 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004901 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004902 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004903 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004904 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004905 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004906 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004907 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004908 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004909 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004910 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004911 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004912 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004913 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004914 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004915 },
4916
Hubert Feurstein49022642019-07-31 10:23:46 +02004917 [MV88E6220] = {
4918 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4919 .family = MV88E6XXX_FAMILY_6250,
4920 .name = "Marvell 88E6220",
4921 .num_databases = 64,
4922
4923 /* Ports 2-4 are not routed to pins
4924 * => usable ports 0, 1, 5, 6
4925 */
4926 .num_ports = 7,
4927 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004928 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004929 .max_vid = 4095,
4930 .port_base_addr = 0x08,
4931 .phy_base_addr = 0x00,
4932 .global1_addr = 0x0f,
4933 .global2_addr = 0x07,
4934 .age_time_coeff = 15000,
4935 .g1_irqs = 9,
4936 .g2_irqs = 10,
4937 .atu_move_port_mask = 0xf,
4938 .dual_chip = true,
4939 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004940 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004941 .ops = &mv88e6250_ops,
4942 },
4943
Vivien Didelotf81ec902016-05-09 13:22:58 -04004944 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004946 .family = MV88E6XXX_FAMILY_6352,
4947 .name = "Marvell 88E6240",
4948 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004949 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004950 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004951 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004952 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004953 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004954 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004955 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004956 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004957 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004958 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004959 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004960 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004961 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004962 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004963 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004964 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004965 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004966 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004967 },
4968
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004969 [MV88E6250] = {
4970 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4971 .family = MV88E6XXX_FAMILY_6250,
4972 .name = "Marvell 88E6250",
4973 .num_databases = 64,
4974 .num_ports = 7,
4975 .num_internal_phys = 5,
4976 .max_vid = 4095,
4977 .port_base_addr = 0x08,
4978 .phy_base_addr = 0x00,
4979 .global1_addr = 0x0f,
4980 .global2_addr = 0x07,
4981 .age_time_coeff = 15000,
4982 .g1_irqs = 9,
4983 .g2_irqs = 10,
4984 .atu_move_port_mask = 0xf,
4985 .dual_chip = true,
4986 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004987 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004988 .ops = &mv88e6250_ops,
4989 },
4990
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004991 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004992 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004993 .family = MV88E6XXX_FAMILY_6390,
4994 .name = "Marvell 88E6290",
4995 .num_databases = 4096,
4996 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004997 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004998 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004999 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005000 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005001 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005002 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005003 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005004 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005005 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005006 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005007 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005008 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005009 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005010 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005011 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005012 .ops = &mv88e6290_ops,
5013 },
5014
Vivien Didelotf81ec902016-05-09 13:22:58 -04005015 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005016 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005017 .family = MV88E6XXX_FAMILY_6320,
5018 .name = "Marvell 88E6320",
5019 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005020 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005021 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005022 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005023 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005024 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005025 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005026 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005027 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005028 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005029 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005030 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005031 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005032 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005033 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005034 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005035 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005036 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005037 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005038 },
5039
5040 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005041 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005042 .family = MV88E6XXX_FAMILY_6320,
5043 .name = "Marvell 88E6321",
5044 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005045 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005046 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005047 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005048 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005049 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005050 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005051 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005052 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005053 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005054 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005055 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005056 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005057 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005058 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005059 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005060 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005061 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005062 },
5063
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005064 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005065 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005066 .family = MV88E6XXX_FAMILY_6341,
5067 .name = "Marvell 88E6341",
5068 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005069 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005070 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005071 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005072 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005073 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005074 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005075 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005076 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005077 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005078 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005079 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005080 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005081 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005082 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005083 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005084 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005085 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005086 .ops = &mv88e6341_ops,
5087 },
5088
Vivien Didelotf81ec902016-05-09 13:22:58 -04005089 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005090 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005091 .family = MV88E6XXX_FAMILY_6351,
5092 .name = "Marvell 88E6350",
5093 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005094 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005095 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005096 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005097 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005098 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005099 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005100 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005101 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005102 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005103 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005104 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005105 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005106 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005107 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005108 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005109 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005110 },
5111
5112 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005113 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005114 .family = MV88E6XXX_FAMILY_6351,
5115 .name = "Marvell 88E6351",
5116 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005117 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005118 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005119 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005120 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005121 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005122 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005123 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005124 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005125 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005126 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005127 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005128 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005129 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005130 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005131 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005132 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005133 },
5134
5135 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005136 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005137 .family = MV88E6XXX_FAMILY_6352,
5138 .name = "Marvell 88E6352",
5139 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005140 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005141 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005142 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005143 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005144 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005145 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005146 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005147 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005148 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005149 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005150 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005151 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005152 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005153 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005154 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005155 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005156 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005157 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005158 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005159 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005160 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005161 .family = MV88E6XXX_FAMILY_6390,
5162 .name = "Marvell 88E6390",
5163 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005164 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005165 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005166 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005167 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005168 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005169 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005170 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005171 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005172 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005173 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005174 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005175 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005176 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005177 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005178 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005179 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005180 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005181 .ops = &mv88e6390_ops,
5182 },
5183 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005184 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005185 .family = MV88E6XXX_FAMILY_6390,
5186 .name = "Marvell 88E6390X",
5187 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005188 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005189 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005190 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005191 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005192 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005193 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005194 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005195 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005196 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005197 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005198 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005199 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005200 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005201 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005202 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005203 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005204 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005205 .ops = &mv88e6390x_ops,
5206 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005207};
5208
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005209static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005210{
Vivien Didelota439c062016-04-17 13:23:58 -04005211 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005212
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005213 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5214 if (mv88e6xxx_table[i].prod_num == prod_num)
5215 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005216
Vivien Didelotb9b37712015-10-30 19:39:48 -04005217 return NULL;
5218}
5219
Vivien Didelotfad09c72016-06-21 12:28:20 -04005220static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005221{
5222 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005223 unsigned int prod_num, rev;
5224 u16 id;
5225 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005226
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005227 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005228 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005229 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005230 if (err)
5231 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005232
Vivien Didelot107fcc12017-06-12 12:37:36 -04005233 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5234 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005235
5236 info = mv88e6xxx_lookup_info(prod_num);
5237 if (!info)
5238 return -ENODEV;
5239
Vivien Didelotcaac8542016-06-20 13:14:09 -04005240 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005241 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005242
Vivien Didelotca070c12016-09-02 14:45:34 -04005243 err = mv88e6xxx_g2_require(chip);
5244 if (err)
5245 return err;
5246
Vivien Didelotfad09c72016-06-21 12:28:20 -04005247 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5248 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005249
5250 return 0;
5251}
5252
Vivien Didelotfad09c72016-06-21 12:28:20 -04005253static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005254{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005255 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005256
Vivien Didelotfad09c72016-06-21 12:28:20 -04005257 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5258 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005259 return NULL;
5260
Vivien Didelotfad09c72016-06-21 12:28:20 -04005261 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005262
Vivien Didelotfad09c72016-06-21 12:28:20 -04005263 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005264 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005265 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005266
Vivien Didelotfad09c72016-06-21 12:28:20 -04005267 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005268}
5269
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005270static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005271 int port,
5272 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005273{
Vivien Didelot04bed142016-08-31 18:06:13 -04005274 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005275
Andrew Lunn443d5a12016-12-03 04:35:18 +01005276 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005277}
5278
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005279static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005280 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005281{
5282 /* We don't need any dynamic resource from the kernel (yet),
5283 * so skip the prepare phase.
5284 */
5285
5286 return 0;
5287}
5288
5289static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005290 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005291{
Vivien Didelot04bed142016-08-31 18:06:13 -04005292 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005293
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005294 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005295 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005296 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005297 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5298 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005299 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005300}
5301
5302static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5303 const struct switchdev_obj_port_mdb *mdb)
5304{
Vivien Didelot04bed142016-08-31 18:06:13 -04005305 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005306 int err;
5307
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005308 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005309 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005310 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005311
5312 return err;
5313}
5314
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005315static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5316 struct dsa_mall_mirror_tc_entry *mirror,
5317 bool ingress)
5318{
5319 enum mv88e6xxx_egress_direction direction = ingress ?
5320 MV88E6XXX_EGRESS_DIR_INGRESS :
5321 MV88E6XXX_EGRESS_DIR_EGRESS;
5322 struct mv88e6xxx_chip *chip = ds->priv;
5323 bool other_mirrors = false;
5324 int i;
5325 int err;
5326
5327 if (!chip->info->ops->set_egress_port)
5328 return -EOPNOTSUPP;
5329
5330 mutex_lock(&chip->reg_lock);
5331 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5332 mirror->to_local_port) {
5333 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5334 other_mirrors |= ingress ?
5335 chip->ports[i].mirror_ingress :
5336 chip->ports[i].mirror_egress;
5337
5338 /* Can't change egress port when other mirror is active */
5339 if (other_mirrors) {
5340 err = -EBUSY;
5341 goto out;
5342 }
5343
5344 err = chip->info->ops->set_egress_port(chip,
5345 direction,
5346 mirror->to_local_port);
5347 if (err)
5348 goto out;
5349 }
5350
5351 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5352out:
5353 mutex_unlock(&chip->reg_lock);
5354
5355 return err;
5356}
5357
5358static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5359 struct dsa_mall_mirror_tc_entry *mirror)
5360{
5361 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5362 MV88E6XXX_EGRESS_DIR_INGRESS :
5363 MV88E6XXX_EGRESS_DIR_EGRESS;
5364 struct mv88e6xxx_chip *chip = ds->priv;
5365 bool other_mirrors = false;
5366 int i;
5367
5368 mutex_lock(&chip->reg_lock);
5369 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5370 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5371
5372 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5373 other_mirrors |= mirror->ingress ?
5374 chip->ports[i].mirror_ingress :
5375 chip->ports[i].mirror_egress;
5376
5377 /* Reset egress port when no other mirror is active */
5378 if (!other_mirrors) {
5379 if (chip->info->ops->set_egress_port(chip,
5380 direction,
5381 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005382 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005383 dev_err(ds->dev, "failed to set egress port\n");
5384 }
5385
5386 mutex_unlock(&chip->reg_lock);
5387}
5388
Russell King4f859012019-02-20 15:35:05 -08005389static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5390 bool unicast, bool multicast)
5391{
5392 struct mv88e6xxx_chip *chip = ds->priv;
5393 int err = -EOPNOTSUPP;
5394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005395 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005396 if (chip->info->ops->port_set_egress_floods)
5397 err = chip->info->ops->port_set_egress_floods(chip, port,
5398 unicast,
5399 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005400 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005401
5402 return err;
5403}
5404
Florian Fainellia82f67a2017-01-08 14:52:08 -08005405static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005406 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005407 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005408 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005409 .phylink_validate = mv88e6xxx_validate,
5410 .phylink_mac_link_state = mv88e6xxx_link_state,
5411 .phylink_mac_config = mv88e6xxx_mac_config,
5412 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5413 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005414 .get_strings = mv88e6xxx_get_strings,
5415 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5416 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005417 .port_enable = mv88e6xxx_port_enable,
5418 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005419 .get_mac_eee = mv88e6xxx_get_mac_eee,
5420 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005421 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005422 .get_eeprom = mv88e6xxx_get_eeprom,
5423 .set_eeprom = mv88e6xxx_set_eeprom,
5424 .get_regs_len = mv88e6xxx_get_regs_len,
5425 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005426 .get_rxnfc = mv88e6xxx_get_rxnfc,
5427 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005428 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005429 .port_bridge_join = mv88e6xxx_port_bridge_join,
5430 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005431 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005432 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005433 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005434 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5435 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5436 .port_vlan_add = mv88e6xxx_port_vlan_add,
5437 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005438 .port_fdb_add = mv88e6xxx_port_fdb_add,
5439 .port_fdb_del = mv88e6xxx_port_fdb_del,
5440 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005441 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5442 .port_mdb_add = mv88e6xxx_port_mdb_add,
5443 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005444 .port_mirror_add = mv88e6xxx_port_mirror_add,
5445 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005446 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5447 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005448 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5449 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5450 .port_txtstamp = mv88e6xxx_port_txtstamp,
5451 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5452 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005453 .devlink_param_get = mv88e6xxx_devlink_param_get,
5454 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005455};
5456
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005457static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005458{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005459 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005460 struct dsa_switch *ds;
5461
Vivien Didelot7e99e342019-10-21 16:51:30 -04005462 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005463 if (!ds)
5464 return -ENOMEM;
5465
Vivien Didelot7e99e342019-10-21 16:51:30 -04005466 ds->dev = dev;
5467 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005468 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005469 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005470 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005471 ds->ageing_time_min = chip->info->age_time_coeff;
5472 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005473
5474 dev_set_drvdata(dev, ds);
5475
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005476 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005477}
5478
Vivien Didelotfad09c72016-06-21 12:28:20 -04005479static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005480{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005481 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005482}
5483
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005484static const void *pdata_device_get_match_data(struct device *dev)
5485{
5486 const struct of_device_id *matches = dev->driver->of_match_table;
5487 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5488
5489 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5490 matches++) {
5491 if (!strcmp(pdata->compatible, matches->compatible))
5492 return matches->data;
5493 }
5494 return NULL;
5495}
5496
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005497/* There is no suspend to RAM support at DSA level yet, the switch configuration
5498 * would be lost after a power cycle so prevent it to be suspended.
5499 */
5500static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5501{
5502 return -EOPNOTSUPP;
5503}
5504
5505static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5506{
5507 return 0;
5508}
5509
5510static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5511
Vivien Didelot57d32312016-06-20 13:13:58 -04005512static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005513{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005514 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005515 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005516 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005517 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005518 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005519 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005520 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005521
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005522 if (!np && !pdata)
5523 return -EINVAL;
5524
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005525 if (np)
5526 compat_info = of_device_get_match_data(dev);
5527
5528 if (pdata) {
5529 compat_info = pdata_device_get_match_data(dev);
5530
5531 if (!pdata->netdev)
5532 return -EINVAL;
5533
5534 for (port = 0; port < DSA_MAX_PORTS; port++) {
5535 if (!(pdata->enabled_ports & (1 << port)))
5536 continue;
5537 if (strcmp(pdata->cd.port_names[port], "cpu"))
5538 continue;
5539 pdata->cd.netdev[port] = &pdata->netdev->dev;
5540 break;
5541 }
5542 }
5543
Vivien Didelotcaac8542016-06-20 13:14:09 -04005544 if (!compat_info)
5545 return -EINVAL;
5546
Vivien Didelotfad09c72016-06-21 12:28:20 -04005547 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005548 if (!chip) {
5549 err = -ENOMEM;
5550 goto out;
5551 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005552
Vivien Didelotfad09c72016-06-21 12:28:20 -04005553 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005554
Vivien Didelotfad09c72016-06-21 12:28:20 -04005555 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005556 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005557 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005558
Andrew Lunnb4308f02016-11-21 23:26:55 +01005559 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005560 if (IS_ERR(chip->reset)) {
5561 err = PTR_ERR(chip->reset);
5562 goto out;
5563 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005564 if (chip->reset)
5565 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005566
Vivien Didelotfad09c72016-06-21 12:28:20 -04005567 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005568 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005569 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005570
Vivien Didelote57e5e72016-08-15 17:19:00 -04005571 mv88e6xxx_phy_init(chip);
5572
Andrew Lunn00baabe2018-05-19 22:31:35 +02005573 if (chip->info->ops->get_eeprom) {
5574 if (np)
5575 of_property_read_u32(np, "eeprom-length",
5576 &chip->eeprom_len);
5577 else
5578 chip->eeprom_len = pdata->eeprom_len;
5579 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005580
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005581 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005582 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005583 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005584 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005585 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005586
Andrew Lunna27415d2019-05-01 00:10:50 +02005587 if (np) {
5588 chip->irq = of_irq_get(np, 0);
5589 if (chip->irq == -EPROBE_DEFER) {
5590 err = chip->irq;
5591 goto out;
5592 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005593 }
5594
Andrew Lunna27415d2019-05-01 00:10:50 +02005595 if (pdata)
5596 chip->irq = pdata->irq;
5597
Andrew Lunn294d7112018-02-22 22:58:32 +01005598 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005599 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005600 * controllers
5601 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005602 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005603 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005604 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005605 else
5606 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005607 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005608
Andrew Lunn294d7112018-02-22 22:58:32 +01005609 if (err)
5610 goto out;
5611
5612 if (chip->info->g2_irqs > 0) {
5613 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005614 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005615 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005616 }
5617
Andrew Lunn294d7112018-02-22 22:58:32 +01005618 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5619 if (err)
5620 goto out_g2_irq;
5621
5622 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5623 if (err)
5624 goto out_g1_atu_prob_irq;
5625
Andrew Lunna3c53be52017-01-24 14:53:50 +01005626 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005627 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005628 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005629
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005630 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005631 if (err)
5632 goto out_mdio;
5633
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005634 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005635
5636out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005637 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005638out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005639 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005640out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005641 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005642out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005643 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005644 mv88e6xxx_g2_irq_free(chip);
5645out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005646 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005647 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005648 else
5649 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005650out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005651 if (pdata)
5652 dev_put(pdata->netdev);
5653
Andrew Lunndc30c352016-10-16 19:56:49 +02005654 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005655}
5656
5657static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5658{
5659 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005660 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005661
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005662 if (chip->info->ptp_support) {
5663 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005664 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005665 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005666
Andrew Lunn930188c2016-08-22 16:01:03 +02005667 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005668 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005669 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005670
Andrew Lunn76f38f12018-03-17 20:21:09 +01005671 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5672 mv88e6xxx_g1_atu_prob_irq_free(chip);
5673
5674 if (chip->info->g2_irqs > 0)
5675 mv88e6xxx_g2_irq_free(chip);
5676
Andrew Lunn76f38f12018-03-17 20:21:09 +01005677 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005678 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005679 else
5680 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005681}
5682
5683static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005684 {
5685 .compatible = "marvell,mv88e6085",
5686 .data = &mv88e6xxx_table[MV88E6085],
5687 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005688 {
5689 .compatible = "marvell,mv88e6190",
5690 .data = &mv88e6xxx_table[MV88E6190],
5691 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005692 {
5693 .compatible = "marvell,mv88e6250",
5694 .data = &mv88e6xxx_table[MV88E6250],
5695 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005696 { /* sentinel */ },
5697};
5698
5699MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5700
5701static struct mdio_driver mv88e6xxx_driver = {
5702 .probe = mv88e6xxx_probe,
5703 .remove = mv88e6xxx_remove,
5704 .mdiodrv.driver = {
5705 .name = "mv88e6085",
5706 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005707 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005708 },
5709};
5710
Andrew Lunn7324d502019-04-27 19:19:10 +02005711mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005712
5713MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5714MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5715MODULE_LICENSE("GPL");