blob: 14a716779bc34d54dac24820dde44f9fdd8f8b68 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Russell King64d47d52020-03-14 10:15:38 +0000400static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
401 int port, phy_interface_t interface)
402{
403 int err;
404
405 if (chip->info->ops->port_set_rgmii_delay) {
406 err = chip->info->ops->port_set_rgmii_delay(chip, port,
407 interface);
408 if (err && err != -EOPNOTSUPP)
409 return err;
410 }
411
412 if (chip->info->ops->port_set_cmode) {
413 err = chip->info->ops->port_set_cmode(chip, port,
414 interface);
415 if (err && err != -EOPNOTSUPP)
416 return err;
417 }
418
419 return 0;
420}
421
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100422int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
423 int speed, int duplex, int pause,
424 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425{
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100427 int err;
428
429 if (!chip->info->ops->port_set_link)
430 return 0;
431
Andrew Lunna26deec2019-04-18 03:11:39 +0200432 if (!chip->info->ops->port_link_state)
433 return 0;
434
435 err = chip->info->ops->port_link_state(chip, port, &state);
436 if (err)
437 return err;
438
439 /* Has anything actually changed? We don't expect the
440 * interface mode to change without one of the other
441 * parameters also changing
442 */
443 if (state.link == link &&
444 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200445 state.duplex == duplex &&
446 (state.interface == mode ||
447 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200448 return 0;
449
Vivien Didelotd78343d2016-11-04 03:23:36 +0100450 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200451 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100452 if (err)
453 return err;
454
455 if (chip->info->ops->port_set_speed) {
456 err = chip->info->ops->port_set_speed(chip, port, speed);
457 if (err && err != -EOPNOTSUPP)
458 goto restore_link;
459 }
460
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100461 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
462 mode = chip->info->ops->port_max_speed_mode(port);
463
Andrew Lunn54186b92018-08-09 15:38:37 +0200464 if (chip->info->ops->port_set_pause) {
465 err = chip->info->ops->port_set_pause(chip, port, pause);
466 if (err)
467 goto restore_link;
468 }
469
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470 if (chip->info->ops->port_set_duplex) {
471 err = chip->info->ops->port_set_duplex(chip, port, duplex);
472 if (err && err != -EOPNOTSUPP)
473 goto restore_link;
474 }
475
Russell King64d47d52020-03-14 10:15:38 +0000476 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100477restore_link:
478 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400479 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100480
481 return err;
482}
483
Marek Vasutd700ec42018-09-12 00:15:24 +0200484static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
485{
486 struct mv88e6xxx_chip *chip = ds->priv;
487
488 return port < chip->info->num_internal_phys;
489}
490
Russell King6c422e32018-08-09 15:38:39 +0200491static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
492 unsigned long *mask,
493 struct phylink_link_state *state)
494{
495 if (!phy_interface_mode_is_8023z(state->interface)) {
496 /* 10M and 100M are only supported in non-802.3z mode */
497 phylink_set(mask, 10baseT_Half);
498 phylink_set(mask, 10baseT_Full);
499 phylink_set(mask, 100baseT_Half);
500 phylink_set(mask, 100baseT_Full);
501 }
502}
503
504static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
505 unsigned long *mask,
506 struct phylink_link_state *state)
507{
508 /* FIXME: if the port is in 1000Base-X mode, then it only supports
509 * 1000M FD speeds. In this case, CMODE will indicate 5.
510 */
511 phylink_set(mask, 1000baseT_Full);
512 phylink_set(mask, 1000baseX_Full);
513
514 mv88e6065_phylink_validate(chip, port, mask, state);
515}
516
Marek Behúne3af71a2019-02-25 12:39:55 +0100517static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
518 unsigned long *mask,
519 struct phylink_link_state *state)
520{
521 if (port >= 5)
522 phylink_set(mask, 2500baseX_Full);
523
524 /* No ethtool bits for 200Mbps */
525 phylink_set(mask, 1000baseT_Full);
526 phylink_set(mask, 1000baseX_Full);
527
528 mv88e6065_phylink_validate(chip, port, mask, state);
529}
530
Russell King6c422e32018-08-09 15:38:39 +0200531static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
532 unsigned long *mask,
533 struct phylink_link_state *state)
534{
535 /* No ethtool bits for 200Mbps */
536 phylink_set(mask, 1000baseT_Full);
537 phylink_set(mask, 1000baseX_Full);
538
539 mv88e6065_phylink_validate(chip, port, mask, state);
540}
541
542static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
543 unsigned long *mask,
544 struct phylink_link_state *state)
545{
Andrew Lunnec260162019-02-08 22:25:44 +0100546 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200547 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100548 phylink_set(mask, 2500baseT_Full);
549 }
Russell King6c422e32018-08-09 15:38:39 +0200550
551 /* No ethtool bits for 200Mbps */
552 phylink_set(mask, 1000baseT_Full);
553 phylink_set(mask, 1000baseX_Full);
554
555 mv88e6065_phylink_validate(chip, port, mask, state);
556}
557
558static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
559 unsigned long *mask,
560 struct phylink_link_state *state)
561{
562 if (port >= 9) {
563 phylink_set(mask, 10000baseT_Full);
564 phylink_set(mask, 10000baseKR_Full);
565 }
566
567 mv88e6390_phylink_validate(chip, port, mask, state);
568}
569
Russell Kingc9a23562018-05-10 13:17:35 -0700570static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
571 unsigned long *supported,
572 struct phylink_link_state *state)
573{
Russell King6c422e32018-08-09 15:38:39 +0200574 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
575 struct mv88e6xxx_chip *chip = ds->priv;
576
577 /* Allow all the expected bits */
578 phylink_set(mask, Autoneg);
579 phylink_set(mask, Pause);
580 phylink_set_port_modes(mask);
581
582 if (chip->info->ops->phylink_validate)
583 chip->info->ops->phylink_validate(chip, port, mask, state);
584
585 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
586 bitmap_and(state->advertising, state->advertising, mask,
587 __ETHTOOL_LINK_MODE_MASK_NBITS);
588
589 /* We can only operate at 2500BaseX or 1000BaseX. If requested
590 * to advertise both, only report advertising at 2500BaseX.
591 */
592 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700593}
594
595static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
596 struct phylink_link_state *state)
597{
598 struct mv88e6xxx_chip *chip = ds->priv;
599 int err;
600
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000601 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200602 if (chip->info->ops->port_link_state)
603 err = chip->info->ops->port_link_state(chip, port, state);
604 else
605 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000606 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700607
608 return err;
609}
610
611static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
612 unsigned int mode,
613 const struct phylink_link_state *state)
614{
615 struct mv88e6xxx_chip *chip = ds->priv;
Russell King64d47d52020-03-14 10:15:38 +0000616 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700617
Russell King64d47d52020-03-14 10:15:38 +0000618 /* FIXME: is this the correct test? If we're in fixed mode on an
619 * internal port, why should we process this any different from
620 * PHY mode? On the other hand, the port may be automedia between
621 * an internal PHY and the serdes...
622 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200623 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700624 return;
625
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_lock(chip);
Russell King64d47d52020-03-14 10:15:38 +0000627 /* FIXME: should we force the link down here - but if we do, how
628 * do we restore the link force/unforce state? The driver layering
629 * gets in the way.
630 */
631 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000632 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700633
634 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000635 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700636}
637
Russell Kingc9a23562018-05-10 13:17:35 -0700638static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
639 unsigned int mode,
640 phy_interface_t interface)
641{
Russell King30c4a5b2020-02-26 10:23:51 +0000642 struct mv88e6xxx_chip *chip = ds->priv;
643 const struct mv88e6xxx_ops *ops;
644 int err = 0;
645
646 ops = chip->info->ops;
647
648 /* Internal PHYs propagate their configuration directly to the MAC.
649 * External PHYs depend on whether the PPU is enabled for this port.
650 * FIXME: we should be using the PPU enable state here. What about
651 * an automedia port?
652 */
653 if (!mv88e6xxx_phy_is_internal(ds, port) && ops->port_set_link) {
654 mv88e6xxx_reg_lock(chip);
655 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
656 mv88e6xxx_reg_unlock(chip);
657
658 if (err)
659 dev_err(chip->dev,
660 "p%d: failed to force MAC link down\n", port);
661 }
Russell Kingc9a23562018-05-10 13:17:35 -0700662}
663
664static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
665 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000666 struct phy_device *phydev,
667 int speed, int duplex,
668 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700669{
Russell King30c4a5b2020-02-26 10:23:51 +0000670 struct mv88e6xxx_chip *chip = ds->priv;
671 const struct mv88e6xxx_ops *ops;
672 int err = 0;
673
674 ops = chip->info->ops;
675
676 /* Internal PHYs propagate their configuration directly to the MAC.
677 * External PHYs depend on whether the PPU is enabled for this port.
678 * FIXME: we should be using the PPU enable state here. What about
679 * an automedia port?
680 */
681 if (!mv88e6xxx_phy_is_internal(ds, port)) {
682 mv88e6xxx_reg_lock(chip);
683 /* FIXME: for an automedia port, should we force the link
684 * down here - what if the link comes up due to "other" media
685 * while we're bringing the port up, how is the exclusivity
686 * handled in the Marvell hardware? E.g. port 4 on 88E6532
687 * shared between internal PHY and Serdes.
688 */
689 if (ops->port_set_speed) {
690 err = ops->port_set_speed(chip, port, speed);
691 if (err && err != -EOPNOTSUPP)
692 goto error;
693 }
694
695 if (ops->port_set_duplex) {
696 err = ops->port_set_duplex(chip, port, duplex);
697 if (err && err != -EOPNOTSUPP)
698 goto error;
699 }
700
701 if (ops->port_set_link)
702 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
703error:
704 mv88e6xxx_reg_unlock(chip);
705
706 if (err && err != -EOPNOTSUPP)
707 dev_err(ds->dev,
708 "p%d: failed to configure MAC link up\n", port);
709 }
Russell Kingc9a23562018-05-10 13:17:35 -0700710}
711
Andrew Lunna605a0f2016-11-21 23:26:58 +0100712static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000713{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100714 if (!chip->info->ops->stats_snapshot)
715 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000716
Andrew Lunna605a0f2016-11-21 23:26:58 +0100717 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000718}
719
Andrew Lunne413e7e2015-04-02 04:06:38 +0200720static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100721 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
722 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
723 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
724 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
725 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
726 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
727 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
728 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
729 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
730 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
731 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
732 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
733 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
734 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
735 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
736 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
737 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
738 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
739 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
740 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
741 { "single", 4, 0x14, STATS_TYPE_BANK0, },
742 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
743 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
744 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
745 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
746 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
747 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
748 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
749 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
750 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
751 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
752 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
753 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
754 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
755 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
756 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
757 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
758 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
759 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
760 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
761 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
762 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
763 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
764 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
765 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
766 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
767 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
768 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
769 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
770 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
771 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
772 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
773 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
774 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
775 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
776 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
777 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
778 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
779 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200780};
781
Vivien Didelotfad09c72016-06-21 12:28:20 -0400782static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100783 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100784 int port, u16 bank1_select,
785 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200786{
Andrew Lunn80c46272015-06-20 18:42:30 +0200787 u32 low;
788 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100789 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200790 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200791 u64 value;
792
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100793 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100794 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200795 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
796 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800797 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200798
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200799 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100800 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200801 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
802 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800803 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000804 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200805 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100806 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100807 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100808 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100809 /* fall through */
810 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100811 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100812 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100813 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100814 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500815 break;
816 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800817 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200818 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100819 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200820 return value;
821}
822
Andrew Lunn436fe172018-03-01 02:02:29 +0100823static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
824 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100825{
826 struct mv88e6xxx_hw_stat *stat;
827 int i, j;
828
829 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
830 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100831 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100832 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
833 ETH_GSTRING_LEN);
834 j++;
835 }
836 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100837
838 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100839}
840
Andrew Lunn436fe172018-03-01 02:02:29 +0100841static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
842 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100843{
Andrew Lunn436fe172018-03-01 02:02:29 +0100844 return mv88e6xxx_stats_get_strings(chip, data,
845 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100846}
847
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000848static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
849 uint8_t *data)
850{
851 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
852}
853
Andrew Lunn436fe172018-03-01 02:02:29 +0100854static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
855 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100856{
Andrew Lunn436fe172018-03-01 02:02:29 +0100857 return mv88e6xxx_stats_get_strings(chip, data,
858 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100859}
860
Andrew Lunn65f60e42018-03-28 23:50:28 +0200861static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
862 "atu_member_violation",
863 "atu_miss_violation",
864 "atu_full_violation",
865 "vtu_member_violation",
866 "vtu_miss_violation",
867};
868
869static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
870{
871 unsigned int i;
872
873 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
874 strlcpy(data + i * ETH_GSTRING_LEN,
875 mv88e6xxx_atu_vtu_stats_strings[i],
876 ETH_GSTRING_LEN);
877}
878
Andrew Lunndfafe442016-11-21 23:27:02 +0100879static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700880 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100881{
Vivien Didelot04bed142016-08-31 18:06:13 -0400882 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100883 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100884
Florian Fainelli89f09042018-04-25 12:12:50 -0700885 if (stringset != ETH_SS_STATS)
886 return;
887
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000888 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100889
Andrew Lunndfafe442016-11-21 23:27:02 +0100890 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100891 count = chip->info->ops->stats_get_strings(chip, data);
892
893 if (chip->info->ops->serdes_get_strings) {
894 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200895 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100897
Andrew Lunn65f60e42018-03-28 23:50:28 +0200898 data += count * ETH_GSTRING_LEN;
899 mv88e6xxx_atu_vtu_get_strings(data);
900
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000901 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100902}
903
904static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
905 int types)
906{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100907 struct mv88e6xxx_hw_stat *stat;
908 int i, j;
909
910 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
911 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100912 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100913 j++;
914 }
915 return j;
916}
917
Andrew Lunndfafe442016-11-21 23:27:02 +0100918static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
919{
920 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
921 STATS_TYPE_PORT);
922}
923
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000924static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
925{
926 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
927}
928
Andrew Lunndfafe442016-11-21 23:27:02 +0100929static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
930{
931 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
932 STATS_TYPE_BANK1);
933}
934
Florian Fainelli89f09042018-04-25 12:12:50 -0700935static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100936{
937 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100938 int serdes_count = 0;
939 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100940
Florian Fainelli89f09042018-04-25 12:12:50 -0700941 if (sset != ETH_SS_STATS)
942 return 0;
943
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000944 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100945 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100946 count = chip->info->ops->stats_get_sset_count(chip);
947 if (count < 0)
948 goto out;
949
950 if (chip->info->ops->serdes_get_sset_count)
951 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
952 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200953 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200955 goto out;
956 }
957 count += serdes_count;
958 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
959
Andrew Lunn436fe172018-03-01 02:02:29 +0100960out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000961 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100962
Andrew Lunn436fe172018-03-01 02:02:29 +0100963 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100964}
965
Andrew Lunn436fe172018-03-01 02:02:29 +0100966static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
967 uint64_t *data, int types,
968 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100969{
970 struct mv88e6xxx_hw_stat *stat;
971 int i, j;
972
973 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
974 stat = &mv88e6xxx_hw_stats[i];
975 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000976 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100977 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
978 bank1_select,
979 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000980 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100981
Andrew Lunn052f9472016-11-21 23:27:03 +0100982 j++;
983 }
984 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100985 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100986}
987
Andrew Lunn436fe172018-03-01 02:02:29 +0100988static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
989 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100990{
991 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100992 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400993 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100994}
995
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000996static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
997 uint64_t *data)
998{
999 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1000 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1001}
1002
Andrew Lunn436fe172018-03-01 02:02:29 +01001003static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1004 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001005{
1006 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001007 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001008 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1009 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001010}
1011
Andrew Lunn436fe172018-03-01 02:02:29 +01001012static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1013 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001014{
1015 return mv88e6xxx_stats_get_stats(chip, port, data,
1016 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001017 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1018 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001019}
1020
Andrew Lunn65f60e42018-03-28 23:50:28 +02001021static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1022 uint64_t *data)
1023{
1024 *data++ = chip->ports[port].atu_member_violation;
1025 *data++ = chip->ports[port].atu_miss_violation;
1026 *data++ = chip->ports[port].atu_full_violation;
1027 *data++ = chip->ports[port].vtu_member_violation;
1028 *data++ = chip->ports[port].vtu_miss_violation;
1029}
1030
Andrew Lunn052f9472016-11-21 23:27:03 +01001031static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1032 uint64_t *data)
1033{
Andrew Lunn436fe172018-03-01 02:02:29 +01001034 int count = 0;
1035
Andrew Lunn052f9472016-11-21 23:27:03 +01001036 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001037 count = chip->info->ops->stats_get_stats(chip, port, data);
1038
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001039 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001040 if (chip->info->ops->serdes_get_stats) {
1041 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001042 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001043 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001044 data += count;
1045 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Vivien Didelotf81ec902016-05-09 13:22:58 -04001049static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1050 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001051{
Vivien Didelot04bed142016-08-31 18:06:13 -04001052 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001053 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001054
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001055 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001056
Andrew Lunna605a0f2016-11-21 23:26:58 +01001057 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001058 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001059
1060 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001061 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001062
1063 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001064
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001065}
Ben Hutchings98e67302011-11-25 14:36:19 +00001066
Vivien Didelotf81ec902016-05-09 13:22:58 -04001067static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001068{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001069 struct mv88e6xxx_chip *chip = ds->priv;
1070 int len;
1071
1072 len = 32 * sizeof(u16);
1073 if (chip->info->ops->serdes_get_regs_len)
1074 len += chip->info->ops->serdes_get_regs_len(chip, port);
1075
1076 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001077}
1078
Vivien Didelotf81ec902016-05-09 13:22:58 -04001079static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1080 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001081{
Vivien Didelot04bed142016-08-31 18:06:13 -04001082 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001083 int err;
1084 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001085 u16 *p = _p;
1086 int i;
1087
Vivien Didelota5f39322018-12-17 16:05:21 -05001088 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001089
1090 memset(p, 0xff, 32 * sizeof(u16));
1091
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001092 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001093
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001094 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001095
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001096 err = mv88e6xxx_port_read(chip, port, i, &reg);
1097 if (!err)
1098 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001099 }
Vivien Didelot23062512016-05-09 13:22:45 -04001100
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001101 if (chip->info->ops->serdes_get_regs)
1102 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1103
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001104 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001105}
1106
Vivien Didelot08f50062017-08-01 16:32:41 -04001107static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1108 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001109{
Vivien Didelot5480db62017-08-01 16:32:40 -04001110 /* Nothing to do on the port's MAC */
1111 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001112}
1113
Vivien Didelot08f50062017-08-01 16:32:41 -04001114static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1115 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001116{
Vivien Didelot5480db62017-08-01 16:32:40 -04001117 /* Nothing to do on the port's MAC */
1118 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001119}
1120
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001121/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001122static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001123{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001124 struct dsa_switch *ds = chip->ds;
1125 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001126 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001127 struct dsa_port *dp;
1128 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001129 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001130
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001131 list_for_each_entry(dp, &dst->ports, list) {
1132 if (dp->ds->index == dev && dp->index == port) {
1133 found = true;
1134 break;
1135 }
1136 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001137
Vivien Didelote5887a22017-03-30 17:37:11 -04001138 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001139 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001140 return 0;
1141
1142 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001143 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001144 return mv88e6xxx_port_mask(chip);
1145
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001146 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001147 pvlan = 0;
1148
1149 /* Frames from user ports can egress any local DSA links and CPU ports,
1150 * as well as any local member of their bridge group.
1151 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001152 list_for_each_entry(dp, &dst->ports, list)
1153 if (dp->ds == ds &&
1154 (dp->type == DSA_PORT_TYPE_CPU ||
1155 dp->type == DSA_PORT_TYPE_DSA ||
1156 (br && dp->bridge_dev == br)))
1157 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001158
1159 return pvlan;
1160}
1161
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001162static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001163{
1164 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001165
1166 /* prevent frames from going back out of the port they came in on */
1167 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001168
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001169 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001170}
1171
Vivien Didelotf81ec902016-05-09 13:22:58 -04001172static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1173 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001174{
Vivien Didelot04bed142016-08-31 18:06:13 -04001175 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001176 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001177
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001178 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001179 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001180 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001181
1182 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001183 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001184}
1185
Vivien Didelot93e18d62018-05-11 17:16:35 -04001186static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1187{
1188 int err;
1189
1190 if (chip->info->ops->ieee_pri_map) {
1191 err = chip->info->ops->ieee_pri_map(chip);
1192 if (err)
1193 return err;
1194 }
1195
1196 if (chip->info->ops->ip_pri_map) {
1197 err = chip->info->ops->ip_pri_map(chip);
1198 if (err)
1199 return err;
1200 }
1201
1202 return 0;
1203}
1204
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001205static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1206{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001207 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001208 int target, port;
1209 int err;
1210
1211 if (!chip->info->global2_addr)
1212 return 0;
1213
1214 /* Initialize the routing port to the 32 possible target devices */
1215 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001216 port = dsa_routing_port(ds, target);
1217 if (port == ds->num_ports)
1218 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001219
1220 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1221 if (err)
1222 return err;
1223 }
1224
Vivien Didelot02317e62018-05-09 11:38:49 -04001225 if (chip->info->ops->set_cascade_port) {
1226 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1227 err = chip->info->ops->set_cascade_port(chip, port);
1228 if (err)
1229 return err;
1230 }
1231
Vivien Didelot23c98912018-05-09 11:38:50 -04001232 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1233 if (err)
1234 return err;
1235
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001236 return 0;
1237}
1238
Vivien Didelotb28f8722018-04-26 21:56:44 -04001239static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1240{
1241 /* Clear all trunk masks and mapping */
1242 if (chip->info->global2_addr)
1243 return mv88e6xxx_g2_trunk_clear(chip);
1244
1245 return 0;
1246}
1247
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001248static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1249{
1250 if (chip->info->ops->rmu_disable)
1251 return chip->info->ops->rmu_disable(chip);
1252
1253 return 0;
1254}
1255
Vivien Didelot9e907d72017-07-17 13:03:43 -04001256static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1257{
1258 if (chip->info->ops->pot_clear)
1259 return chip->info->ops->pot_clear(chip);
1260
1261 return 0;
1262}
1263
Vivien Didelot51c901a2017-07-17 13:03:41 -04001264static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1265{
1266 if (chip->info->ops->mgmt_rsvd2cpu)
1267 return chip->info->ops->mgmt_rsvd2cpu(chip);
1268
1269 return 0;
1270}
1271
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001272static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1273{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001274 int err;
1275
Vivien Didelotdaefc942017-03-11 16:12:54 -05001276 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1277 if (err)
1278 return err;
1279
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001280 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1281 if (err)
1282 return err;
1283
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001284 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1285}
1286
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001287static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1288{
1289 int port;
1290 int err;
1291
1292 if (!chip->info->ops->irl_init_all)
1293 return 0;
1294
1295 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1296 /* Disable ingress rate limiting by resetting all per port
1297 * ingress rate limit resources to their initial state.
1298 */
1299 err = chip->info->ops->irl_init_all(chip, port);
1300 if (err)
1301 return err;
1302 }
1303
1304 return 0;
1305}
1306
Vivien Didelot04a69a12017-10-13 14:18:05 -04001307static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1308{
1309 if (chip->info->ops->set_switch_mac) {
1310 u8 addr[ETH_ALEN];
1311
1312 eth_random_addr(addr);
1313
1314 return chip->info->ops->set_switch_mac(chip, addr);
1315 }
1316
1317 return 0;
1318}
1319
Vivien Didelot17a15942017-03-30 17:37:09 -04001320static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1321{
1322 u16 pvlan = 0;
1323
1324 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001325 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001326
1327 /* Skip the local source device, which uses in-chip port VLAN */
1328 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001329 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001330
1331 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1332}
1333
Vivien Didelot81228992017-03-30 17:37:08 -04001334static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1335{
Vivien Didelot17a15942017-03-30 17:37:09 -04001336 int dev, port;
1337 int err;
1338
Vivien Didelot81228992017-03-30 17:37:08 -04001339 if (!mv88e6xxx_has_pvt(chip))
1340 return 0;
1341
1342 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1343 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1344 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001345 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1346 if (err)
1347 return err;
1348
1349 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1350 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1351 err = mv88e6xxx_pvt_map(chip, dev, port);
1352 if (err)
1353 return err;
1354 }
1355 }
1356
1357 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001358}
1359
Vivien Didelot749efcb2016-09-22 16:49:24 -04001360static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1361{
1362 struct mv88e6xxx_chip *chip = ds->priv;
1363 int err;
1364
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001365 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001366 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001367 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001368
1369 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001370 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001371}
1372
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001373static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1374{
1375 if (!chip->info->max_vid)
1376 return 0;
1377
1378 return mv88e6xxx_g1_vtu_flush(chip);
1379}
1380
Vivien Didelotf1394b782017-05-01 14:05:22 -04001381static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1382 struct mv88e6xxx_vtu_entry *entry)
1383{
1384 if (!chip->info->ops->vtu_getnext)
1385 return -EOPNOTSUPP;
1386
1387 return chip->info->ops->vtu_getnext(chip, entry);
1388}
1389
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001390static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1391 struct mv88e6xxx_vtu_entry *entry)
1392{
1393 if (!chip->info->ops->vtu_loadpurge)
1394 return -EOPNOTSUPP;
1395
1396 return chip->info->ops->vtu_loadpurge(chip, entry);
1397}
1398
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001399static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001400{
1401 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001402 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001403 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001404
1405 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1406
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001407 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001408 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001409 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001410 if (err)
1411 return err;
1412
1413 set_bit(*fid, fid_bitmap);
1414 }
1415
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001416 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001417 vlan.vid = chip->info->max_vid;
1418 vlan.valid = false;
1419
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001420 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001421 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001422 if (err)
1423 return err;
1424
1425 if (!vlan.valid)
1426 break;
1427
1428 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001429 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001430
1431 /* The reset value 0x000 is used to indicate that multiple address
1432 * databases are not needed. Return the next positive available.
1433 */
1434 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001435 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001436 return -ENOSPC;
1437
1438 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001439 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001440}
1441
Andrew Lunn23e8b472019-10-25 01:03:52 +02001442static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1443{
1444 if (chip->info->ops->atu_get_hash)
1445 return chip->info->ops->atu_get_hash(chip, hash);
1446
1447 return -EOPNOTSUPP;
1448}
1449
1450static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1451{
1452 if (chip->info->ops->atu_set_hash)
1453 return chip->info->ops->atu_set_hash(chip, hash);
1454
1455 return -EOPNOTSUPP;
1456}
1457
Vivien Didelotda9c3592016-02-12 12:09:40 -05001458static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1459 u16 vid_begin, u16 vid_end)
1460{
Vivien Didelot04bed142016-08-31 18:06:13 -04001461 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001462 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001463 int i, err;
1464
Andrew Lunndb06ae412017-09-25 23:32:20 +02001465 /* DSA and CPU ports have to be members of multiple vlans */
1466 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1467 return 0;
1468
Vivien Didelotda9c3592016-02-12 12:09:40 -05001469 if (!vid_begin)
1470 return -EOPNOTSUPP;
1471
Vivien Didelot425d2d32019-08-01 14:36:34 -04001472 vlan.vid = vid_begin - 1;
1473 vlan.valid = false;
1474
Vivien Didelotda9c3592016-02-12 12:09:40 -05001475 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001476 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001477 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001478 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001479
1480 if (!vlan.valid)
1481 break;
1482
1483 if (vlan.vid > vid_end)
1484 break;
1485
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001486 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001487 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1488 continue;
1489
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001490 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001491 continue;
1492
Vivien Didelotbd00e052017-05-01 14:05:11 -04001493 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001494 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001495 continue;
1496
Vivien Didelotc8652c82017-10-16 11:12:19 -04001497 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001498 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001499 break; /* same bridge, check next VLAN */
1500
Vivien Didelotc8652c82017-10-16 11:12:19 -04001501 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001502 continue;
1503
Andrew Lunn743fcc22017-11-09 22:29:54 +01001504 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1505 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001506 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001507 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001508 }
1509 } while (vlan.vid < vid_end);
1510
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001511 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001512}
1513
Vivien Didelotf81ec902016-05-09 13:22:58 -04001514static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1515 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001516{
Vivien Didelot04bed142016-08-31 18:06:13 -04001517 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001518 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1519 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001520 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001521
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001522 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001523 return -EOPNOTSUPP;
1524
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001525 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001526 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001527 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001528
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001529 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001530}
1531
Vivien Didelot57d32312016-06-20 13:13:58 -04001532static int
1533mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001534 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001535{
Vivien Didelot04bed142016-08-31 18:06:13 -04001536 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 int err;
1538
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001539 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001540 return -EOPNOTSUPP;
1541
Vivien Didelotda9c3592016-02-12 12:09:40 -05001542 /* If the requested port doesn't belong to the same bridge as the VLAN
1543 * members, do not support it (yet) and fallback to software VLAN.
1544 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001545 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001546 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1547 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001548 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001549
Vivien Didelot76e398a2015-11-01 12:33:55 -05001550 /* We don't need any dynamic resource from the kernel (yet),
1551 * so skip the prepare phase.
1552 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001553 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001554}
1555
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001556static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1557 const unsigned char *addr, u16 vid,
1558 u8 state)
1559{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001560 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001561 struct mv88e6xxx_vtu_entry vlan;
1562 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001563 int err;
1564
1565 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001566 if (vid == 0) {
1567 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1568 if (err)
1569 return err;
1570 } else {
1571 vlan.vid = vid - 1;
1572 vlan.valid = false;
1573
1574 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1575 if (err)
1576 return err;
1577
1578 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1579 if (vlan.vid != vid || !vlan.valid)
1580 return -EOPNOTSUPP;
1581
1582 fid = vlan.fid;
1583 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001584
Vivien Didelotd8291a92019-09-07 16:00:47 -04001585 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001586 ether_addr_copy(entry.mac, addr);
1587 eth_addr_dec(entry.mac);
1588
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001589 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001590 if (err)
1591 return err;
1592
1593 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001594 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001595 memset(&entry, 0, sizeof(entry));
1596 ether_addr_copy(entry.mac, addr);
1597 }
1598
1599 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001600 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001601 entry.portvec &= ~BIT(port);
1602 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001603 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001604 } else {
1605 entry.portvec |= BIT(port);
1606 entry.state = state;
1607 }
1608
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001609 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001610}
1611
Vivien Didelotda7dc872019-09-07 16:00:49 -04001612static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1613 const struct mv88e6xxx_policy *policy)
1614{
1615 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1616 enum mv88e6xxx_policy_action action = policy->action;
1617 const u8 *addr = policy->addr;
1618 u16 vid = policy->vid;
1619 u8 state;
1620 int err;
1621 int id;
1622
1623 if (!chip->info->ops->port_set_policy)
1624 return -EOPNOTSUPP;
1625
1626 switch (mapping) {
1627 case MV88E6XXX_POLICY_MAPPING_DA:
1628 case MV88E6XXX_POLICY_MAPPING_SA:
1629 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1630 state = 0; /* Dissociate the port and address */
1631 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1632 is_multicast_ether_addr(addr))
1633 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1634 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1635 is_unicast_ether_addr(addr))
1636 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1637 else
1638 return -EOPNOTSUPP;
1639
1640 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1641 state);
1642 if (err)
1643 return err;
1644 break;
1645 default:
1646 return -EOPNOTSUPP;
1647 }
1648
1649 /* Skip the port's policy clearing if the mapping is still in use */
1650 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1651 idr_for_each_entry(&chip->policies, policy, id)
1652 if (policy->port == port &&
1653 policy->mapping == mapping &&
1654 policy->action != action)
1655 return 0;
1656
1657 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1658}
1659
1660static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1661 struct ethtool_rx_flow_spec *fs)
1662{
1663 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1664 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1665 enum mv88e6xxx_policy_mapping mapping;
1666 enum mv88e6xxx_policy_action action;
1667 struct mv88e6xxx_policy *policy;
1668 u16 vid = 0;
1669 u8 *addr;
1670 int err;
1671 int id;
1672
1673 if (fs->location != RX_CLS_LOC_ANY)
1674 return -EINVAL;
1675
1676 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1677 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1678 else
1679 return -EOPNOTSUPP;
1680
1681 switch (fs->flow_type & ~FLOW_EXT) {
1682 case ETHER_FLOW:
1683 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1684 is_zero_ether_addr(mac_mask->h_source)) {
1685 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1686 addr = mac_entry->h_dest;
1687 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1688 !is_zero_ether_addr(mac_mask->h_source)) {
1689 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1690 addr = mac_entry->h_source;
1691 } else {
1692 /* Cannot support DA and SA mapping in the same rule */
1693 return -EOPNOTSUPP;
1694 }
1695 break;
1696 default:
1697 return -EOPNOTSUPP;
1698 }
1699
1700 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1701 if (fs->m_ext.vlan_tci != 0xffff)
1702 return -EOPNOTSUPP;
1703 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1704 }
1705
1706 idr_for_each_entry(&chip->policies, policy, id) {
1707 if (policy->port == port && policy->mapping == mapping &&
1708 policy->action == action && policy->vid == vid &&
1709 ether_addr_equal(policy->addr, addr))
1710 return -EEXIST;
1711 }
1712
1713 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1714 if (!policy)
1715 return -ENOMEM;
1716
1717 fs->location = 0;
1718 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1719 GFP_KERNEL);
1720 if (err) {
1721 devm_kfree(chip->dev, policy);
1722 return err;
1723 }
1724
1725 memcpy(&policy->fs, fs, sizeof(*fs));
1726 ether_addr_copy(policy->addr, addr);
1727 policy->mapping = mapping;
1728 policy->action = action;
1729 policy->port = port;
1730 policy->vid = vid;
1731
1732 err = mv88e6xxx_policy_apply(chip, port, policy);
1733 if (err) {
1734 idr_remove(&chip->policies, fs->location);
1735 devm_kfree(chip->dev, policy);
1736 return err;
1737 }
1738
1739 return 0;
1740}
1741
1742static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1743 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1744{
1745 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1746 struct mv88e6xxx_chip *chip = ds->priv;
1747 struct mv88e6xxx_policy *policy;
1748 int err;
1749 int id;
1750
1751 mv88e6xxx_reg_lock(chip);
1752
1753 switch (rxnfc->cmd) {
1754 case ETHTOOL_GRXCLSRLCNT:
1755 rxnfc->data = 0;
1756 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1757 rxnfc->rule_cnt = 0;
1758 idr_for_each_entry(&chip->policies, policy, id)
1759 if (policy->port == port)
1760 rxnfc->rule_cnt++;
1761 err = 0;
1762 break;
1763 case ETHTOOL_GRXCLSRULE:
1764 err = -ENOENT;
1765 policy = idr_find(&chip->policies, fs->location);
1766 if (policy) {
1767 memcpy(fs, &policy->fs, sizeof(*fs));
1768 err = 0;
1769 }
1770 break;
1771 case ETHTOOL_GRXCLSRLALL:
1772 rxnfc->data = 0;
1773 rxnfc->rule_cnt = 0;
1774 idr_for_each_entry(&chip->policies, policy, id)
1775 if (policy->port == port)
1776 rule_locs[rxnfc->rule_cnt++] = id;
1777 err = 0;
1778 break;
1779 default:
1780 err = -EOPNOTSUPP;
1781 break;
1782 }
1783
1784 mv88e6xxx_reg_unlock(chip);
1785
1786 return err;
1787}
1788
1789static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1790 struct ethtool_rxnfc *rxnfc)
1791{
1792 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1793 struct mv88e6xxx_chip *chip = ds->priv;
1794 struct mv88e6xxx_policy *policy;
1795 int err;
1796
1797 mv88e6xxx_reg_lock(chip);
1798
1799 switch (rxnfc->cmd) {
1800 case ETHTOOL_SRXCLSRLINS:
1801 err = mv88e6xxx_policy_insert(chip, port, fs);
1802 break;
1803 case ETHTOOL_SRXCLSRLDEL:
1804 err = -ENOENT;
1805 policy = idr_remove(&chip->policies, fs->location);
1806 if (policy) {
1807 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1808 err = mv88e6xxx_policy_apply(chip, port, policy);
1809 devm_kfree(chip->dev, policy);
1810 }
1811 break;
1812 default:
1813 err = -EOPNOTSUPP;
1814 break;
1815 }
1816
1817 mv88e6xxx_reg_unlock(chip);
1818
1819 return err;
1820}
1821
Andrew Lunn87fa8862017-11-09 22:29:56 +01001822static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1823 u16 vid)
1824{
1825 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1826 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1827
1828 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1829}
1830
1831static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1832{
1833 int port;
1834 int err;
1835
1836 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1837 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1838 if (err)
1839 return err;
1840 }
1841
1842 return 0;
1843}
1844
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001845static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001846 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001847{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001848 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001849 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001850 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001851
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001852 if (!vid)
1853 return -EOPNOTSUPP;
1854
1855 vlan.vid = vid - 1;
1856 vlan.valid = false;
1857
1858 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001859 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001860 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001861
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001862 if (vlan.vid != vid || !vlan.valid) {
1863 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001864
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001865 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1866 if (err)
1867 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001868
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001869 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1870 if (i == port)
1871 vlan.member[i] = member;
1872 else
1873 vlan.member[i] = non_member;
1874
1875 vlan.vid = vid;
1876 vlan.valid = true;
1877
1878 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1879 if (err)
1880 return err;
1881
1882 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1883 if (err)
1884 return err;
1885 } else if (vlan.member[port] != member) {
1886 vlan.member[port] = member;
1887
1888 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1889 if (err)
1890 return err;
Russell King933b4422020-02-26 17:14:26 +00001891 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001892 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1893 port, vid);
1894 }
1895
1896 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001897}
1898
Vivien Didelotf81ec902016-05-09 13:22:58 -04001899static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001900 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001901{
Vivien Didelot04bed142016-08-31 18:06:13 -04001902 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001903 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1904 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001905 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001906 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001907 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001908
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001909 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001910 return;
1911
Vivien Didelotc91498e2017-06-07 18:12:13 -04001912 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001913 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001914 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001915 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001916 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001917 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001918
Russell King933b4422020-02-26 17:14:26 +00001919 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1920 * and then the CPU port. Do not warn for duplicates for the CPU port.
1921 */
1922 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1923
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001924 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001925
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001926 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001927 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001928 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1929 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001930
Vivien Didelot77064f32016-11-04 03:23:30 +01001931 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001932 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1933 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001934
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001935 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001936}
1937
Vivien Didelot521098922019-08-01 14:36:36 -04001938static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1939 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001940{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001941 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001942 int i, err;
1943
Vivien Didelot521098922019-08-01 14:36:36 -04001944 if (!vid)
1945 return -EOPNOTSUPP;
1946
1947 vlan.vid = vid - 1;
1948 vlan.valid = false;
1949
1950 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001951 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001952 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001953
Vivien Didelot521098922019-08-01 14:36:36 -04001954 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1955 * tell switchdev that this VLAN is likely handled in software.
1956 */
1957 if (vlan.vid != vid || !vlan.valid ||
1958 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001959 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001960
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001961 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001962
1963 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001964 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001965 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001966 if (vlan.member[i] !=
1967 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001968 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001969 break;
1970 }
1971 }
1972
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001973 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001974 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001975 return err;
1976
Vivien Didelote606ca32017-03-11 16:12:55 -05001977 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001978}
1979
Vivien Didelotf81ec902016-05-09 13:22:58 -04001980static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1981 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001982{
Vivien Didelot04bed142016-08-31 18:06:13 -04001983 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001984 u16 pvid, vid;
1985 int err = 0;
1986
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001987 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001988 return -EOPNOTSUPP;
1989
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001990 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001991
Vivien Didelot77064f32016-11-04 03:23:30 +01001992 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001993 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001994 goto unlock;
1995
Vivien Didelot76e398a2015-11-01 12:33:55 -05001996 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001997 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001998 if (err)
1999 goto unlock;
2000
2001 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002002 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002003 if (err)
2004 goto unlock;
2005 }
2006 }
2007
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002008unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002009 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002010
2011 return err;
2012}
2013
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002014static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2015 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002016{
Vivien Didelot04bed142016-08-31 18:06:13 -04002017 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002018 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002019
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002020 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002021 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2022 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002023 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002024
2025 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002026}
2027
Vivien Didelotf81ec902016-05-09 13:22:58 -04002028static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002029 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002030{
Vivien Didelot04bed142016-08-31 18:06:13 -04002031 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002032 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002033
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002034 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002035 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002036 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002037
Vivien Didelot83dabd12016-08-31 11:50:04 -04002038 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002039}
2040
Vivien Didelot83dabd12016-08-31 11:50:04 -04002041static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2042 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002043 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002044{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002045 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002046 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002047 int err;
2048
Vivien Didelotd8291a92019-09-07 16:00:47 -04002049 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002050 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002051
2052 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002053 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002054 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002055 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002056
Vivien Didelotd8291a92019-09-07 16:00:47 -04002057 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002058 break;
2059
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002060 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002061 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002062
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002063 if (!is_unicast_ether_addr(addr.mac))
2064 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002065
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002066 is_static = (addr.state ==
2067 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2068 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002069 if (err)
2070 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002071 } while (!is_broadcast_ether_addr(addr.mac));
2072
2073 return err;
2074}
2075
Vivien Didelot83dabd12016-08-31 11:50:04 -04002076static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002077 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002078{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002079 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002080 u16 fid;
2081 int err;
2082
2083 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002084 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002085 if (err)
2086 return err;
2087
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002088 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002089 if (err)
2090 return err;
2091
2092 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002093 vlan.vid = chip->info->max_vid;
2094 vlan.valid = false;
2095
Vivien Didelot83dabd12016-08-31 11:50:04 -04002096 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002097 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002098 if (err)
2099 return err;
2100
2101 if (!vlan.valid)
2102 break;
2103
2104 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002105 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002106 if (err)
2107 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002108 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002109
2110 return err;
2111}
2112
Vivien Didelotf81ec902016-05-09 13:22:58 -04002113static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002114 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002115{
Vivien Didelot04bed142016-08-31 18:06:13 -04002116 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002117 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002118
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002119 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002120 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002121 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002122
2123 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002124}
2125
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002126static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2127 struct net_device *br)
2128{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002129 struct dsa_switch *ds = chip->ds;
2130 struct dsa_switch_tree *dst = ds->dst;
2131 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002132 int err;
2133
Vivien Didelotef2025e2019-10-21 16:51:27 -04002134 list_for_each_entry(dp, &dst->ports, list) {
2135 if (dp->bridge_dev == br) {
2136 if (dp->ds == ds) {
2137 /* This is a local bridge group member,
2138 * remap its Port VLAN Map.
2139 */
2140 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2141 if (err)
2142 return err;
2143 } else {
2144 /* This is an external bridge group member,
2145 * remap its cross-chip Port VLAN Table entry.
2146 */
2147 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2148 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002149 if (err)
2150 return err;
2151 }
2152 }
2153 }
2154
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002155 return 0;
2156}
2157
Vivien Didelotf81ec902016-05-09 13:22:58 -04002158static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002159 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002160{
Vivien Didelot04bed142016-08-31 18:06:13 -04002161 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002162 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002163
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002164 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002165 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002166 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002167
Vivien Didelot466dfa02016-02-26 13:16:05 -05002168 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002169}
2170
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002171static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2172 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002173{
Vivien Didelot04bed142016-08-31 18:06:13 -04002174 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002175
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002176 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002177 if (mv88e6xxx_bridge_map(chip, br) ||
2178 mv88e6xxx_port_vlan_map(chip, port))
2179 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002180 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002181}
2182
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002183static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2184 int port, struct net_device *br)
2185{
2186 struct mv88e6xxx_chip *chip = ds->priv;
2187 int err;
2188
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002189 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002190 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002191 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002192
2193 return err;
2194}
2195
2196static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2197 int port, struct net_device *br)
2198{
2199 struct mv88e6xxx_chip *chip = ds->priv;
2200
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002201 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002202 if (mv88e6xxx_pvt_map(chip, dev, port))
2203 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002204 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002205}
2206
Vivien Didelot17e708b2016-12-05 17:30:27 -05002207static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2208{
2209 if (chip->info->ops->reset)
2210 return chip->info->ops->reset(chip);
2211
2212 return 0;
2213}
2214
Vivien Didelot309eca62016-12-05 17:30:26 -05002215static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2216{
2217 struct gpio_desc *gpiod = chip->reset;
2218
2219 /* If there is a GPIO connected to the reset pin, toggle it */
2220 if (gpiod) {
2221 gpiod_set_value_cansleep(gpiod, 1);
2222 usleep_range(10000, 20000);
2223 gpiod_set_value_cansleep(gpiod, 0);
2224 usleep_range(10000, 20000);
2225 }
2226}
2227
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002228static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2229{
2230 int i, err;
2231
2232 /* Set all ports to the Disabled state */
2233 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002234 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002235 if (err)
2236 return err;
2237 }
2238
2239 /* Wait for transmit queues to drain,
2240 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2241 */
2242 usleep_range(2000, 4000);
2243
2244 return 0;
2245}
2246
Vivien Didelotfad09c72016-06-21 12:28:20 -04002247static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002248{
Vivien Didelota935c052016-09-29 12:21:53 -04002249 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002250
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002251 err = mv88e6xxx_disable_ports(chip);
2252 if (err)
2253 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002254
Vivien Didelot309eca62016-12-05 17:30:26 -05002255 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002256
Vivien Didelot17e708b2016-12-05 17:30:27 -05002257 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002258}
2259
Vivien Didelot43145572017-03-11 16:12:59 -05002260static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002261 enum mv88e6xxx_frame_mode frame,
2262 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002263{
2264 int err;
2265
Vivien Didelot43145572017-03-11 16:12:59 -05002266 if (!chip->info->ops->port_set_frame_mode)
2267 return -EOPNOTSUPP;
2268
2269 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002270 if (err)
2271 return err;
2272
Vivien Didelot43145572017-03-11 16:12:59 -05002273 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2274 if (err)
2275 return err;
2276
2277 if (chip->info->ops->port_set_ether_type)
2278 return chip->info->ops->port_set_ether_type(chip, port, etype);
2279
2280 return 0;
2281}
2282
2283static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2284{
2285 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002286 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002287 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002288}
2289
2290static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2291{
2292 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002293 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002294 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002295}
2296
2297static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2298{
2299 return mv88e6xxx_set_port_mode(chip, port,
2300 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002301 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2302 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002303}
2304
2305static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2306{
2307 if (dsa_is_dsa_port(chip->ds, port))
2308 return mv88e6xxx_set_port_mode_dsa(chip, port);
2309
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002310 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002311 return mv88e6xxx_set_port_mode_normal(chip, port);
2312
2313 /* Setup CPU port mode depending on its supported tag format */
2314 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2315 return mv88e6xxx_set_port_mode_dsa(chip, port);
2316
2317 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2318 return mv88e6xxx_set_port_mode_edsa(chip, port);
2319
2320 return -EINVAL;
2321}
2322
Vivien Didelotea698f42017-03-11 16:12:50 -05002323static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2324{
2325 bool message = dsa_is_dsa_port(chip->ds, port);
2326
2327 return mv88e6xxx_port_set_message_port(chip, port, message);
2328}
2329
Vivien Didelot601aeed2017-03-11 16:13:00 -05002330static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2331{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002332 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002333 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002334
David S. Miller407308f2019-06-15 13:35:29 -07002335 /* Upstream ports flood frames with unknown unicast or multicast DA */
2336 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2337 if (chip->info->ops->port_set_egress_floods)
2338 return chip->info->ops->port_set_egress_floods(chip, port,
2339 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002340
David S. Miller407308f2019-06-15 13:35:29 -07002341 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002342}
2343
Vivien Didelot45de77f2019-08-31 16:18:36 -04002344static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2345{
2346 struct mv88e6xxx_port *mvp = dev_id;
2347 struct mv88e6xxx_chip *chip = mvp->chip;
2348 irqreturn_t ret = IRQ_NONE;
2349 int port = mvp->port;
2350 u8 lane;
2351
2352 mv88e6xxx_reg_lock(chip);
2353 lane = mv88e6xxx_serdes_get_lane(chip, port);
2354 if (lane)
2355 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2356 mv88e6xxx_reg_unlock(chip);
2357
2358 return ret;
2359}
2360
2361static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2362 u8 lane)
2363{
2364 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2365 unsigned int irq;
2366 int err;
2367
2368 /* Nothing to request if this SERDES port has no IRQ */
2369 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2370 if (!irq)
2371 return 0;
2372
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002373 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2374 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2375
Vivien Didelot45de77f2019-08-31 16:18:36 -04002376 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2377 mv88e6xxx_reg_unlock(chip);
2378 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002379 IRQF_ONESHOT, dev_id->serdes_irq_name,
2380 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002381 mv88e6xxx_reg_lock(chip);
2382 if (err)
2383 return err;
2384
2385 dev_id->serdes_irq = irq;
2386
2387 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2388}
2389
2390static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2391 u8 lane)
2392{
2393 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2394 unsigned int irq = dev_id->serdes_irq;
2395 int err;
2396
2397 /* Nothing to free if no IRQ has been requested */
2398 if (!irq)
2399 return 0;
2400
2401 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2402
2403 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2404 mv88e6xxx_reg_unlock(chip);
2405 free_irq(irq, dev_id);
2406 mv88e6xxx_reg_lock(chip);
2407
2408 dev_id->serdes_irq = 0;
2409
2410 return err;
2411}
2412
Andrew Lunn6d917822017-05-26 01:03:21 +02002413static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2414 bool on)
2415{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002416 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002417 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002418
Vivien Didelotdc272f62019-08-31 16:18:33 -04002419 lane = mv88e6xxx_serdes_get_lane(chip, port);
2420 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002421 return 0;
2422
2423 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002424 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002425 if (err)
2426 return err;
2427
Vivien Didelot45de77f2019-08-31 16:18:36 -04002428 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002429 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002430 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2431 if (err)
2432 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002433
Vivien Didelotdc272f62019-08-31 16:18:33 -04002434 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002435 }
2436
2437 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002438}
2439
Vivien Didelotfa371c82017-12-05 15:34:10 -05002440static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2441{
2442 struct dsa_switch *ds = chip->ds;
2443 int upstream_port;
2444 int err;
2445
Vivien Didelot07073c72017-12-05 15:34:13 -05002446 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002447 if (chip->info->ops->port_set_upstream_port) {
2448 err = chip->info->ops->port_set_upstream_port(chip, port,
2449 upstream_port);
2450 if (err)
2451 return err;
2452 }
2453
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002454 if (port == upstream_port) {
2455 if (chip->info->ops->set_cpu_port) {
2456 err = chip->info->ops->set_cpu_port(chip,
2457 upstream_port);
2458 if (err)
2459 return err;
2460 }
2461
2462 if (chip->info->ops->set_egress_port) {
2463 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002464 MV88E6XXX_EGRESS_DIR_INGRESS,
2465 upstream_port);
2466 if (err)
2467 return err;
2468
2469 err = chip->info->ops->set_egress_port(chip,
2470 MV88E6XXX_EGRESS_DIR_EGRESS,
2471 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002472 if (err)
2473 return err;
2474 }
2475 }
2476
Vivien Didelotfa371c82017-12-05 15:34:10 -05002477 return 0;
2478}
2479
Vivien Didelotfad09c72016-06-21 12:28:20 -04002480static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002481{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002482 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002483 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002484 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002485
Andrew Lunn7b898462018-08-09 15:38:47 +02002486 chip->ports[port].chip = chip;
2487 chip->ports[port].port = port;
2488
Vivien Didelotd78343d2016-11-04 03:23:36 +01002489 /* MAC Forcing register: don't force link, speed, duplex or flow control
2490 * state to any particular values on physical ports, but force the CPU
2491 * port and all DSA ports to their maximum bandwidth and full duplex.
2492 */
2493 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2494 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2495 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002496 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002497 PHY_INTERFACE_MODE_NA);
2498 else
2499 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2500 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002501 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002502 PHY_INTERFACE_MODE_NA);
2503 if (err)
2504 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002505
2506 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2507 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2508 * tunneling, determine priority by looking at 802.1p and IP
2509 * priority fields (IP prio has precedence), and set STP state
2510 * to Forwarding.
2511 *
2512 * If this is the CPU link, use DSA or EDSA tagging depending
2513 * on which tagging mode was configured.
2514 *
2515 * If this is a link to another switch, use DSA tagging mode.
2516 *
2517 * If this is the upstream port for this switch, enable
2518 * forwarding of unknown unicasts and multicasts.
2519 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002520 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2521 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2522 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2523 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002524 if (err)
2525 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002526
Vivien Didelot601aeed2017-03-11 16:13:00 -05002527 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002528 if (err)
2529 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002530
Vivien Didelot601aeed2017-03-11 16:13:00 -05002531 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002532 if (err)
2533 return err;
2534
Vivien Didelot8efdda42015-08-13 12:52:23 -04002535 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002536 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002537 * untagged frames on this port, do a destination address lookup on all
2538 * received packets as usual, disable ARP mirroring and don't send a
2539 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002540 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002541 err = mv88e6xxx_port_set_map_da(chip, port);
2542 if (err)
2543 return err;
2544
Vivien Didelotfa371c82017-12-05 15:34:10 -05002545 err = mv88e6xxx_setup_upstream_port(chip, port);
2546 if (err)
2547 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002548
Andrew Lunna23b2962017-02-04 20:15:28 +01002549 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002550 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002551 if (err)
2552 return err;
2553
Vivien Didelotcd782652017-06-08 18:34:13 -04002554 if (chip->info->ops->port_set_jumbo_size) {
2555 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002556 if (err)
2557 return err;
2558 }
2559
Andrew Lunn54d792f2015-05-06 01:09:47 +02002560 /* Port Association Vector: when learning source addresses
2561 * of packets, add the address to the address database using
2562 * a port bitmap that has only the bit for this port set and
2563 * the other bits clear.
2564 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002565 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002566 /* Disable learning for CPU port */
2567 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002568 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002569
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002570 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2571 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002572 if (err)
2573 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002574
2575 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002576 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2577 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002578 if (err)
2579 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002580
Vivien Didelot08984322017-06-08 18:34:12 -04002581 if (chip->info->ops->port_pause_limit) {
2582 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002583 if (err)
2584 return err;
2585 }
2586
Vivien Didelotc8c94892017-03-11 16:13:01 -05002587 if (chip->info->ops->port_disable_learn_limit) {
2588 err = chip->info->ops->port_disable_learn_limit(chip, port);
2589 if (err)
2590 return err;
2591 }
2592
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002593 if (chip->info->ops->port_disable_pri_override) {
2594 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002595 if (err)
2596 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002597 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002598
Andrew Lunnef0a7312016-12-03 04:35:16 +01002599 if (chip->info->ops->port_tag_remap) {
2600 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002601 if (err)
2602 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002603 }
2604
Andrew Lunnef70b112016-12-03 04:45:18 +01002605 if (chip->info->ops->port_egress_rate_limiting) {
2606 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002607 if (err)
2608 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002609 }
2610
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002611 if (chip->info->ops->port_setup_message_port) {
2612 err = chip->info->ops->port_setup_message_port(chip, port);
2613 if (err)
2614 return err;
2615 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002616
Vivien Didelot207afda2016-04-14 14:42:09 -04002617 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002618 * database, and allow bidirectional communication between the
2619 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002620 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002621 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002622 if (err)
2623 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002624
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002625 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002626 if (err)
2627 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002628
2629 /* Default VLAN ID and priority: don't set a default VLAN
2630 * ID, and set the default packet priority to zero.
2631 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002632 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002633}
2634
Andrew Lunn04aca992017-05-26 01:03:24 +02002635static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2636 struct phy_device *phydev)
2637{
2638 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002639 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002640
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002641 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002642 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002643 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002644
2645 return err;
2646}
2647
Andrew Lunn75104db2019-02-24 20:44:43 +01002648static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002649{
2650 struct mv88e6xxx_chip *chip = ds->priv;
2651
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002652 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002653 if (mv88e6xxx_serdes_power(chip, port, false))
2654 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002655 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002656}
2657
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002658static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2659 unsigned int ageing_time)
2660{
Vivien Didelot04bed142016-08-31 18:06:13 -04002661 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002662 int err;
2663
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002664 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002665 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002666 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002667
2668 return err;
2669}
2670
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002671static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002672{
2673 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002674
Andrew Lunnde2273872016-11-21 23:27:01 +01002675 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002676 if (chip->info->ops->stats_set_histogram) {
2677 err = chip->info->ops->stats_set_histogram(chip);
2678 if (err)
2679 return err;
2680 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002681
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002682 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002683}
2684
Andrew Lunnea890982019-01-09 00:24:03 +01002685/* Check if the errata has already been applied. */
2686static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2687{
2688 int port;
2689 int err;
2690 u16 val;
2691
2692 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002693 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002694 if (err) {
2695 dev_err(chip->dev,
2696 "Error reading hidden register: %d\n", err);
2697 return false;
2698 }
2699 if (val != 0x01c0)
2700 return false;
2701 }
2702
2703 return true;
2704}
2705
2706/* The 6390 copper ports have an errata which require poking magic
2707 * values into undocumented hidden registers and then performing a
2708 * software reset.
2709 */
2710static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2711{
2712 int port;
2713 int err;
2714
2715 if (mv88e6390_setup_errata_applied(chip))
2716 return 0;
2717
2718 /* Set the ports into blocking mode */
2719 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2720 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2721 if (err)
2722 return err;
2723 }
2724
2725 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002726 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002727 if (err)
2728 return err;
2729 }
2730
2731 return mv88e6xxx_software_reset(chip);
2732}
2733
Andrew Lunn23e8b472019-10-25 01:03:52 +02002734enum mv88e6xxx_devlink_param_id {
2735 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2736 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2737};
2738
2739static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2740 struct devlink_param_gset_ctx *ctx)
2741{
2742 struct mv88e6xxx_chip *chip = ds->priv;
2743 int err;
2744
2745 mv88e6xxx_reg_lock(chip);
2746
2747 switch (id) {
2748 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2749 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2750 break;
2751 default:
2752 err = -EOPNOTSUPP;
2753 break;
2754 }
2755
2756 mv88e6xxx_reg_unlock(chip);
2757
2758 return err;
2759}
2760
2761static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2762 struct devlink_param_gset_ctx *ctx)
2763{
2764 struct mv88e6xxx_chip *chip = ds->priv;
2765 int err;
2766
2767 mv88e6xxx_reg_lock(chip);
2768
2769 switch (id) {
2770 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2771 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2772 break;
2773 default:
2774 err = -EOPNOTSUPP;
2775 break;
2776 }
2777
2778 mv88e6xxx_reg_unlock(chip);
2779
2780 return err;
2781}
2782
2783static const struct devlink_param mv88e6xxx_devlink_params[] = {
2784 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2785 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2786 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2787};
2788
2789static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2790{
2791 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2792 ARRAY_SIZE(mv88e6xxx_devlink_params));
2793}
2794
2795static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2796{
2797 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2798 ARRAY_SIZE(mv88e6xxx_devlink_params));
2799}
2800
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002801enum mv88e6xxx_devlink_resource_id {
2802 MV88E6XXX_RESOURCE_ID_ATU,
2803 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2804 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2805 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2806 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2807};
2808
2809static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2810 u16 bin)
2811{
2812 u16 occupancy = 0;
2813 int err;
2814
2815 mv88e6xxx_reg_lock(chip);
2816
2817 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2818 bin);
2819 if (err) {
2820 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2821 goto unlock;
2822 }
2823
2824 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2825 if (err) {
2826 dev_err(chip->dev, "failed to perform ATU get next\n");
2827 goto unlock;
2828 }
2829
2830 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2831 if (err) {
2832 dev_err(chip->dev, "failed to get ATU stats\n");
2833 goto unlock;
2834 }
2835
Andrew Lunn012fc742020-03-11 21:02:31 +01002836 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2837
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002838unlock:
2839 mv88e6xxx_reg_unlock(chip);
2840
2841 return occupancy;
2842}
2843
2844static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2845{
2846 struct mv88e6xxx_chip *chip = priv;
2847
2848 return mv88e6xxx_devlink_atu_bin_get(chip,
2849 MV88E6XXX_G2_ATU_STATS_BIN_0);
2850}
2851
2852static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2853{
2854 struct mv88e6xxx_chip *chip = priv;
2855
2856 return mv88e6xxx_devlink_atu_bin_get(chip,
2857 MV88E6XXX_G2_ATU_STATS_BIN_1);
2858}
2859
2860static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2861{
2862 struct mv88e6xxx_chip *chip = priv;
2863
2864 return mv88e6xxx_devlink_atu_bin_get(chip,
2865 MV88E6XXX_G2_ATU_STATS_BIN_2);
2866}
2867
2868static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2869{
2870 struct mv88e6xxx_chip *chip = priv;
2871
2872 return mv88e6xxx_devlink_atu_bin_get(chip,
2873 MV88E6XXX_G2_ATU_STATS_BIN_3);
2874}
2875
2876static u64 mv88e6xxx_devlink_atu_get(void *priv)
2877{
2878 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2879 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2880 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2881 mv88e6xxx_devlink_atu_bin_3_get(priv);
2882}
2883
2884static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2885{
2886 struct devlink_resource_size_params size_params;
2887 struct mv88e6xxx_chip *chip = ds->priv;
2888 int err;
2889
2890 devlink_resource_size_params_init(&size_params,
2891 mv88e6xxx_num_macs(chip),
2892 mv88e6xxx_num_macs(chip),
2893 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2894
2895 err = dsa_devlink_resource_register(ds, "ATU",
2896 mv88e6xxx_num_macs(chip),
2897 MV88E6XXX_RESOURCE_ID_ATU,
2898 DEVLINK_RESOURCE_ID_PARENT_TOP,
2899 &size_params);
2900 if (err)
2901 goto out;
2902
2903 devlink_resource_size_params_init(&size_params,
2904 mv88e6xxx_num_macs(chip) / 4,
2905 mv88e6xxx_num_macs(chip) / 4,
2906 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2907
2908 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2909 mv88e6xxx_num_macs(chip) / 4,
2910 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2911 MV88E6XXX_RESOURCE_ID_ATU,
2912 &size_params);
2913 if (err)
2914 goto out;
2915
2916 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2917 mv88e6xxx_num_macs(chip) / 4,
2918 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2919 MV88E6XXX_RESOURCE_ID_ATU,
2920 &size_params);
2921 if (err)
2922 goto out;
2923
2924 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2925 mv88e6xxx_num_macs(chip) / 4,
2926 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2927 MV88E6XXX_RESOURCE_ID_ATU,
2928 &size_params);
2929 if (err)
2930 goto out;
2931
2932 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2933 mv88e6xxx_num_macs(chip) / 4,
2934 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2935 MV88E6XXX_RESOURCE_ID_ATU,
2936 &size_params);
2937 if (err)
2938 goto out;
2939
2940 dsa_devlink_resource_occ_get_register(ds,
2941 MV88E6XXX_RESOURCE_ID_ATU,
2942 mv88e6xxx_devlink_atu_get,
2943 chip);
2944
2945 dsa_devlink_resource_occ_get_register(ds,
2946 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2947 mv88e6xxx_devlink_atu_bin_0_get,
2948 chip);
2949
2950 dsa_devlink_resource_occ_get_register(ds,
2951 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2952 mv88e6xxx_devlink_atu_bin_1_get,
2953 chip);
2954
2955 dsa_devlink_resource_occ_get_register(ds,
2956 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2957 mv88e6xxx_devlink_atu_bin_2_get,
2958 chip);
2959
2960 dsa_devlink_resource_occ_get_register(ds,
2961 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2962 mv88e6xxx_devlink_atu_bin_3_get,
2963 chip);
2964
2965 return 0;
2966
2967out:
2968 dsa_devlink_resources_unregister(ds);
2969 return err;
2970}
2971
Andrew Lunn23e8b472019-10-25 01:03:52 +02002972static void mv88e6xxx_teardown(struct dsa_switch *ds)
2973{
2974 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002975 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002976}
2977
Vivien Didelotf81ec902016-05-09 13:22:58 -04002978static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002979{
Vivien Didelot04bed142016-08-31 18:06:13 -04002980 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002981 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002982 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002983 int i;
2984
Vivien Didelotfad09c72016-06-21 12:28:20 -04002985 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002986 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002988 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002989
Andrew Lunnea890982019-01-09 00:24:03 +01002990 if (chip->info->ops->setup_errata) {
2991 err = chip->info->ops->setup_errata(chip);
2992 if (err)
2993 goto unlock;
2994 }
2995
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002996 /* Cache the cmode of each port. */
2997 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2998 if (chip->info->ops->port_get_cmode) {
2999 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3000 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003001 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003002
3003 chip->ports[i].cmode = cmode;
3004 }
3005 }
3006
Vivien Didelot97299342016-07-18 20:45:30 -04003007 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003008 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003009 if (dsa_is_unused_port(ds, i))
3010 continue;
3011
Hubert Feursteinc8574862019-07-31 10:23:48 +02003012 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003013 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003014 dev_err(chip->dev, "port %d is invalid\n", i);
3015 err = -EINVAL;
3016 goto unlock;
3017 }
3018
Vivien Didelot97299342016-07-18 20:45:30 -04003019 err = mv88e6xxx_setup_port(chip, i);
3020 if (err)
3021 goto unlock;
3022 }
3023
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003024 err = mv88e6xxx_irl_setup(chip);
3025 if (err)
3026 goto unlock;
3027
Vivien Didelot04a69a12017-10-13 14:18:05 -04003028 err = mv88e6xxx_mac_setup(chip);
3029 if (err)
3030 goto unlock;
3031
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003032 err = mv88e6xxx_phy_setup(chip);
3033 if (err)
3034 goto unlock;
3035
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003036 err = mv88e6xxx_vtu_setup(chip);
3037 if (err)
3038 goto unlock;
3039
Vivien Didelot81228992017-03-30 17:37:08 -04003040 err = mv88e6xxx_pvt_setup(chip);
3041 if (err)
3042 goto unlock;
3043
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003044 err = mv88e6xxx_atu_setup(chip);
3045 if (err)
3046 goto unlock;
3047
Andrew Lunn87fa8862017-11-09 22:29:56 +01003048 err = mv88e6xxx_broadcast_setup(chip, 0);
3049 if (err)
3050 goto unlock;
3051
Vivien Didelot9e907d72017-07-17 13:03:43 -04003052 err = mv88e6xxx_pot_setup(chip);
3053 if (err)
3054 goto unlock;
3055
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003056 err = mv88e6xxx_rmu_setup(chip);
3057 if (err)
3058 goto unlock;
3059
Vivien Didelot51c901a2017-07-17 13:03:41 -04003060 err = mv88e6xxx_rsvd2cpu_setup(chip);
3061 if (err)
3062 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003063
Vivien Didelotb28f8722018-04-26 21:56:44 -04003064 err = mv88e6xxx_trunk_setup(chip);
3065 if (err)
3066 goto unlock;
3067
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003068 err = mv88e6xxx_devmap_setup(chip);
3069 if (err)
3070 goto unlock;
3071
Vivien Didelot93e18d62018-05-11 17:16:35 -04003072 err = mv88e6xxx_pri_setup(chip);
3073 if (err)
3074 goto unlock;
3075
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003076 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003077 if (chip->info->ptp_support) {
3078 err = mv88e6xxx_ptp_setup(chip);
3079 if (err)
3080 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003081
3082 err = mv88e6xxx_hwtstamp_setup(chip);
3083 if (err)
3084 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003085 }
3086
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003087 err = mv88e6xxx_stats_setup(chip);
3088 if (err)
3089 goto unlock;
3090
Vivien Didelot6b17e862015-08-13 12:52:18 -04003091unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003092 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003093
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003094 if (err)
3095 return err;
3096
3097 /* Have to be called without holding the register lock, since
3098 * they take the devlink lock, and we later take the locks in
3099 * the reverse order when getting/setting parameters or
3100 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003101 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003102 err = mv88e6xxx_setup_devlink_resources(ds);
3103 if (err)
3104 return err;
3105
3106 err = mv88e6xxx_setup_devlink_params(ds);
3107 if (err)
3108 dsa_devlink_resources_unregister(ds);
3109
3110 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003111}
3112
Vivien Didelote57e5e72016-08-15 17:19:00 -04003113static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003114{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003115 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3116 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003117 u16 val;
3118 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003119
Andrew Lunnee26a222017-01-24 14:53:48 +01003120 if (!chip->info->ops->phy_read)
3121 return -EOPNOTSUPP;
3122
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003123 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003124 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003125 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003126
Andrew Lunnda9f3302017-02-01 03:40:05 +01003127 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003128 /* Some internal PHYs don't have a model number. */
3129 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3130 /* Then there is the 6165 family. It gets is
3131 * PHYs correct. But it can also have two
3132 * SERDES interfaces in the PHY address
3133 * space. And these don't have a model
3134 * number. But they are not PHYs, so we don't
3135 * want to give them something a PHY driver
3136 * will recognise.
3137 *
3138 * Use the mv88e6390 family model number
3139 * instead, for anything which really could be
3140 * a PHY,
3141 */
3142 if (!(val & 0x3f0))
3143 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003144 }
3145
Vivien Didelote57e5e72016-08-15 17:19:00 -04003146 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003147}
3148
Vivien Didelote57e5e72016-08-15 17:19:00 -04003149static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003150{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003151 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3152 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003153 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003154
Andrew Lunnee26a222017-01-24 14:53:48 +01003155 if (!chip->info->ops->phy_write)
3156 return -EOPNOTSUPP;
3157
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003158 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003159 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003160 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003161
3162 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003163}
3164
Vivien Didelotfad09c72016-06-21 12:28:20 -04003165static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003166 struct device_node *np,
3167 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003168{
3169 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003170 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003171 struct mii_bus *bus;
3172 int err;
3173
Andrew Lunn2510bab2018-02-22 01:51:49 +01003174 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003175 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003176 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003177 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003178
3179 if (err)
3180 return err;
3181 }
3182
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003183 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003184 if (!bus)
3185 return -ENOMEM;
3186
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003187 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003188 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003189 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003190 INIT_LIST_HEAD(&mdio_bus->list);
3191 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003192
Andrew Lunnb516d452016-06-04 21:17:06 +02003193 if (np) {
3194 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003195 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003196 } else {
3197 bus->name = "mv88e6xxx SMI";
3198 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3199 }
3200
3201 bus->read = mv88e6xxx_mdio_read;
3202 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003203 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003204
Andrew Lunn6f882842018-03-17 20:32:05 +01003205 if (!external) {
3206 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3207 if (err)
3208 return err;
3209 }
3210
Florian Fainelli00e798c2018-05-15 16:56:19 -07003211 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003212 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003213 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003214 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003215 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003216 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003217
3218 if (external)
3219 list_add_tail(&mdio_bus->list, &chip->mdios);
3220 else
3221 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003222
3223 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003224}
3225
Andrew Lunna3c53be52017-01-24 14:53:50 +01003226static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3227 { .compatible = "marvell,mv88e6xxx-mdio-external",
3228 .data = (void *)true },
3229 { },
3230};
3231
Andrew Lunn3126aee2017-12-07 01:05:57 +01003232static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3233
3234{
3235 struct mv88e6xxx_mdio_bus *mdio_bus;
3236 struct mii_bus *bus;
3237
3238 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3239 bus = mdio_bus->bus;
3240
Andrew Lunn6f882842018-03-17 20:32:05 +01003241 if (!mdio_bus->external)
3242 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3243
Andrew Lunn3126aee2017-12-07 01:05:57 +01003244 mdiobus_unregister(bus);
3245 }
3246}
3247
Andrew Lunna3c53be52017-01-24 14:53:50 +01003248static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3249 struct device_node *np)
3250{
3251 const struct of_device_id *match;
3252 struct device_node *child;
3253 int err;
3254
3255 /* Always register one mdio bus for the internal/default mdio
3256 * bus. This maybe represented in the device tree, but is
3257 * optional.
3258 */
3259 child = of_get_child_by_name(np, "mdio");
3260 err = mv88e6xxx_mdio_register(chip, child, false);
3261 if (err)
3262 return err;
3263
3264 /* Walk the device tree, and see if there are any other nodes
3265 * which say they are compatible with the external mdio
3266 * bus.
3267 */
3268 for_each_available_child_of_node(np, child) {
3269 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3270 if (match) {
3271 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003272 if (err) {
3273 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303274 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003275 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003276 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003277 }
3278 }
3279
3280 return 0;
3281}
3282
Vivien Didelot855b1932016-07-20 18:18:35 -04003283static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3284{
Vivien Didelot04bed142016-08-31 18:06:13 -04003285 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003286
3287 return chip->eeprom_len;
3288}
3289
Vivien Didelot855b1932016-07-20 18:18:35 -04003290static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3291 struct ethtool_eeprom *eeprom, u8 *data)
3292{
Vivien Didelot04bed142016-08-31 18:06:13 -04003293 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003294 int err;
3295
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003296 if (!chip->info->ops->get_eeprom)
3297 return -EOPNOTSUPP;
3298
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003299 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003300 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003301 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003302
3303 if (err)
3304 return err;
3305
3306 eeprom->magic = 0xc3ec4951;
3307
3308 return 0;
3309}
3310
Vivien Didelot855b1932016-07-20 18:18:35 -04003311static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3312 struct ethtool_eeprom *eeprom, u8 *data)
3313{
Vivien Didelot04bed142016-08-31 18:06:13 -04003314 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003315 int err;
3316
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003317 if (!chip->info->ops->set_eeprom)
3318 return -EOPNOTSUPP;
3319
Vivien Didelot855b1932016-07-20 18:18:35 -04003320 if (eeprom->magic != 0xc3ec4951)
3321 return -EINVAL;
3322
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003323 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003324 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003325 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003326
3327 return err;
3328}
3329
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003330static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003331 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003332 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3333 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003334 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003335 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003336 .phy_read = mv88e6185_phy_ppu_read,
3337 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003338 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003339 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003340 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003341 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003342 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003343 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003344 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003345 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003346 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003347 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003348 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003349 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003350 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003351 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003352 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003353 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003354 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3355 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003356 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003357 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3358 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003359 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003360 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003361 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003362 .ppu_enable = mv88e6185_g1_ppu_enable,
3363 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003364 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003365 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003366 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003367 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003368 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003369};
3370
3371static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003372 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003373 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3374 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003375 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003376 .phy_read = mv88e6185_phy_ppu_read,
3377 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003378 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003379 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003380 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003381 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003382 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003383 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003384 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003385 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003386 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003387 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003388 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003389 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3390 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003391 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003392 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003393 .ppu_enable = mv88e6185_g1_ppu_enable,
3394 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003395 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003396 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003397 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003398 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003399};
3400
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003401static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003402 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003403 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3404 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003405 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003406 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3407 .phy_read = mv88e6xxx_g2_smi_phy_read,
3408 .phy_write = mv88e6xxx_g2_smi_phy_write,
3409 .port_set_link = mv88e6xxx_port_set_link,
3410 .port_set_duplex = mv88e6xxx_port_set_duplex,
3411 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003412 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003413 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003414 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003415 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003416 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003417 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003418 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003419 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003420 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003421 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003422 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003423 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003424 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003425 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003426 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3427 .stats_get_strings = mv88e6095_stats_get_strings,
3428 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003429 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3430 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003431 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003432 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003433 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003434 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003435 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003436 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003437 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003438 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003439};
3440
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003441static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003442 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003443 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3444 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003445 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003446 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003447 .phy_read = mv88e6xxx_g2_smi_phy_read,
3448 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003449 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003450 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003451 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003452 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003453 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003454 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003455 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003456 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003457 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003458 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003459 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003460 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003461 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3462 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003463 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003464 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3465 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003466 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003467 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003468 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003469 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003470 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3471 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003472 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003473 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003474 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003475};
3476
3477static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003478 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003479 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3480 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003481 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003482 .phy_read = mv88e6185_phy_ppu_read,
3483 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003484 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003485 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003486 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003487 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003488 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003489 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003490 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003491 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003492 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003493 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003494 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003495 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003496 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003497 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003498 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003499 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003500 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003501 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3502 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003503 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003504 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3505 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003506 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003507 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003508 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003509 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003510 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003511 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003512 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003513 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003514 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003515};
3516
Vivien Didelot990e27b2017-03-28 13:50:32 -04003517static const struct mv88e6xxx_ops mv88e6141_ops = {
3518 /* MV88E6XXX_FAMILY_6341 */
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 Didelot990e27b2017-03-28 13:50:32 -04003522 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3523 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3524 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3525 .phy_read = mv88e6xxx_g2_smi_phy_read,
3526 .phy_write = mv88e6xxx_g2_smi_phy_write,
3527 .port_set_link = mv88e6xxx_port_set_link,
3528 .port_set_duplex = mv88e6xxx_port_set_duplex,
3529 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003530 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003531 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003532 .port_tag_remap = mv88e6095_port_tag_remap,
3533 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3534 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3535 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003536 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003537 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003538 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003539 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3540 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003541 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003542 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003543 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003544 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003545 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003546 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003547 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3548 .stats_get_strings = mv88e6320_stats_get_strings,
3549 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003550 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3551 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003552 .watchdog_ops = &mv88e6390_watchdog_ops,
3553 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003554 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003555 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003556 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003557 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003558 .serdes_power = mv88e6390_serdes_power,
3559 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003560 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003561 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003562 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003563 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003564 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003565};
3566
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003567static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003568 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003569 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3570 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003571 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003572 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003573 .phy_read = mv88e6xxx_g2_smi_phy_read,
3574 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003575 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003576 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003577 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003578 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003579 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003580 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003581 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003582 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003583 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003584 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003585 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003586 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003587 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003588 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003589 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003590 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003591 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003592 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3593 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003594 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003595 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3596 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003597 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003598 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003599 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003600 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003601 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3602 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003603 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003604 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003605 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003606 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003607 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003608};
3609
3610static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003611 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003612 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3613 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003614 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003615 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003616 .phy_read = mv88e6165_phy_read,
3617 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003618 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003619 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003620 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003621 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003622 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003623 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003624 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003625 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003626 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003627 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003628 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3629 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003630 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003631 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3632 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003633 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003634 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003635 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003636 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003637 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3638 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003639 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003640 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003641 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003642 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003643 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003644};
3645
3646static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003647 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003648 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3649 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003650 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003651 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003652 .phy_read = mv88e6xxx_g2_smi_phy_read,
3653 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003654 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003655 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003656 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003657 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003658 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003659 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003660 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003661 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003662 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003663 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003664 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003665 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003666 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003667 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003668 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003669 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003670 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003671 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003672 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3673 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003674 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003675 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3676 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003677 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003678 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003679 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003680 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003681 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3682 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003683 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003684 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003685 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003686};
3687
3688static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003689 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003690 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3691 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003692 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003693 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3694 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003695 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003696 .phy_read = mv88e6xxx_g2_smi_phy_read,
3697 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003698 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003699 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003700 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003701 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003702 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003703 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003704 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003705 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003706 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003707 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003708 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003709 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003710 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003711 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003712 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003713 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003714 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003715 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003716 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003717 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3718 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003719 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003720 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3721 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003722 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003723 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003724 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003725 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003726 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003727 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3728 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003729 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003730 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003731 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003732 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003733 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3734 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003735 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003736 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003737};
3738
3739static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003740 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003741 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3742 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003743 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003744 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003745 .phy_read = mv88e6xxx_g2_smi_phy_read,
3746 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003747 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003748 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003749 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003750 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003751 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003752 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003753 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003754 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003755 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003756 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003757 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003758 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003759 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003760 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003761 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003762 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003763 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003764 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003765 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3766 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003767 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003768 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3769 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003770 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003771 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003772 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003773 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003774 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3775 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003776 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003777 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003778 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003779};
3780
3781static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003782 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003783 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3784 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003785 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003786 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3787 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003788 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003789 .phy_read = mv88e6xxx_g2_smi_phy_read,
3790 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003791 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003792 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003793 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003794 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003795 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003796 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003797 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003798 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003799 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003800 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003801 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003802 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003803 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003804 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003805 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003806 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003807 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003808 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003809 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003810 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3811 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003812 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003813 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3814 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003815 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003816 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003818 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003819 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003820 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3821 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003822 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003823 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003824 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003825 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003826 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003827 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003828 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003829 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3830 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003831 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003832 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003833};
3834
3835static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003836 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003837 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3838 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003839 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003840 .phy_read = mv88e6185_phy_ppu_read,
3841 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003842 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003843 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003844 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003845 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003846 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003847 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003848 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003849 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003850 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003851 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003852 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003853 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003854 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003855 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3856 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003857 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003858 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3859 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003860 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003861 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003862 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003863 .ppu_enable = mv88e6185_g1_ppu_enable,
3864 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003865 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003866 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003867 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003868 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003869};
3870
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003871static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003872 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003873 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003874 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003875 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3876 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003877 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3878 .phy_read = mv88e6xxx_g2_smi_phy_read,
3879 .phy_write = mv88e6xxx_g2_smi_phy_write,
3880 .port_set_link = mv88e6xxx_port_set_link,
3881 .port_set_duplex = mv88e6xxx_port_set_duplex,
3882 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3883 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003884 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003885 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003886 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003887 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003888 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003889 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003890 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003891 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003892 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003893 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003894 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003895 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003896 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003897 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003898 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003899 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3900 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003901 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003902 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3903 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003904 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003905 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003906 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003907 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003908 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003909 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3910 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003911 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3912 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003913 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003914 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003915 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003916 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003917 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003918 .serdes_get_strings = mv88e6390_serdes_get_strings,
3919 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003920 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3921 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003922 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003923 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003924 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003925};
3926
3927static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003928 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003929 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003930 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003931 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3932 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003933 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3934 .phy_read = mv88e6xxx_g2_smi_phy_read,
3935 .phy_write = mv88e6xxx_g2_smi_phy_write,
3936 .port_set_link = mv88e6xxx_port_set_link,
3937 .port_set_duplex = mv88e6xxx_port_set_duplex,
3938 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3939 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003940 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003941 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003942 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003943 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003944 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003945 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003946 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003947 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003948 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003949 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003950 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003951 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003952 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003953 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003954 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003955 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3956 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003957 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003958 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3959 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003960 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003961 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003962 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003963 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003964 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003965 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3966 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003967 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3968 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003969 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003970 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003971 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003972 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003973 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003974 .serdes_get_strings = mv88e6390_serdes_get_strings,
3975 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003976 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3977 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003978 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003979 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003980 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003981};
3982
3983static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003984 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003985 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003986 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003987 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3988 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003989 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3990 .phy_read = mv88e6xxx_g2_smi_phy_read,
3991 .phy_write = mv88e6xxx_g2_smi_phy_write,
3992 .port_set_link = mv88e6xxx_port_set_link,
3993 .port_set_duplex = mv88e6xxx_port_set_duplex,
3994 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3995 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003996 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003997 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003998 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003999 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004000 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004001 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004002 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004003 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004004 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004005 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004006 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004007 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004008 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004009 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004010 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4011 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004012 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004013 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4014 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004015 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004016 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004017 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004018 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004019 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004020 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4021 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004022 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4023 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004024 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004025 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004026 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004027 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004028 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004029 .serdes_get_strings = mv88e6390_serdes_get_strings,
4030 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004031 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4032 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004033 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004034 .avb_ops = &mv88e6390_avb_ops,
4035 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004036 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004037};
4038
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004039static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004040 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004041 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4042 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004043 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004044 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4045 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004046 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004047 .phy_read = mv88e6xxx_g2_smi_phy_read,
4048 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004049 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004050 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004051 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004052 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004053 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004054 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004055 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004056 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004057 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004058 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004059 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004060 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004061 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004062 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004063 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004064 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004065 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004066 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004067 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004068 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4069 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004070 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004071 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4072 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004073 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004074 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004075 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004076 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004077 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004078 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4079 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004080 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004081 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004082 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004083 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004084 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004085 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004086 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004087 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4088 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004089 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004090 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004091 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004092 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004093};
4094
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004095static const struct mv88e6xxx_ops mv88e6250_ops = {
4096 /* MV88E6XXX_FAMILY_6250 */
4097 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4098 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4099 .irl_init_all = mv88e6352_g2_irl_init_all,
4100 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4101 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4102 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4103 .phy_read = mv88e6xxx_g2_smi_phy_read,
4104 .phy_write = mv88e6xxx_g2_smi_phy_write,
4105 .port_set_link = mv88e6xxx_port_set_link,
4106 .port_set_duplex = mv88e6xxx_port_set_duplex,
4107 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4108 .port_set_speed = mv88e6250_port_set_speed,
4109 .port_tag_remap = mv88e6095_port_tag_remap,
4110 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4111 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4112 .port_set_ether_type = mv88e6351_port_set_ether_type,
4113 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4114 .port_pause_limit = mv88e6097_port_pause_limit,
4115 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4116 .port_link_state = mv88e6250_port_link_state,
4117 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4118 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4119 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4120 .stats_get_strings = mv88e6250_stats_get_strings,
4121 .stats_get_stats = mv88e6250_stats_get_stats,
4122 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4123 .set_egress_port = mv88e6095_g1_set_egress_port,
4124 .watchdog_ops = &mv88e6250_watchdog_ops,
4125 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4126 .pot_clear = mv88e6xxx_g2_pot_clear,
4127 .reset = mv88e6250_g1_reset,
4128 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4129 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004130 .avb_ops = &mv88e6352_avb_ops,
4131 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004132 .phylink_validate = mv88e6065_phylink_validate,
4133};
4134
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004135static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004136 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004137 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004138 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004139 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4140 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004141 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4142 .phy_read = mv88e6xxx_g2_smi_phy_read,
4143 .phy_write = mv88e6xxx_g2_smi_phy_write,
4144 .port_set_link = mv88e6xxx_port_set_link,
4145 .port_set_duplex = mv88e6xxx_port_set_duplex,
4146 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4147 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004148 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004149 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004150 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004151 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004152 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004153 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004154 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004155 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004156 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004157 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004158 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004159 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004160 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004161 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004162 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004163 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4164 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004165 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004166 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4167 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004168 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004169 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004170 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004171 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004172 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004173 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4174 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004175 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4176 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004177 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004178 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004179 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004180 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004181 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004182 .serdes_get_strings = mv88e6390_serdes_get_strings,
4183 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004184 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4185 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004186 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004187 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004188 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004189 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004190 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004191};
4192
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004193static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004194 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004195 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4196 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004197 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004198 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4199 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004200 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004201 .phy_read = mv88e6xxx_g2_smi_phy_read,
4202 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004203 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004204 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004205 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004206 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004207 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004208 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004209 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004210 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004211 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004212 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004213 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004214 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004215 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004216 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004217 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004218 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004219 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004220 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4221 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004222 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004223 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4224 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004225 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004226 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004227 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004228 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004229 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004230 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004231 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004232 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004233 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004234 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004235};
4236
4237static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004238 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004239 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4240 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004241 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004242 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4243 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004244 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004245 .phy_read = mv88e6xxx_g2_smi_phy_read,
4246 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004247 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004248 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004249 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004250 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004251 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004252 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004253 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004254 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004255 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004256 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004257 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004258 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004259 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004260 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004261 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004262 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004263 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004264 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4265 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004266 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004267 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4268 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004269 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004270 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004271 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004272 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004273 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004274 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004275 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004276 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004277};
4278
Vivien Didelot16e329a2017-03-28 13:50:33 -04004279static const struct mv88e6xxx_ops mv88e6341_ops = {
4280 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004281 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4282 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004283 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004284 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4285 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4286 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4287 .phy_read = mv88e6xxx_g2_smi_phy_read,
4288 .phy_write = mv88e6xxx_g2_smi_phy_write,
4289 .port_set_link = mv88e6xxx_port_set_link,
4290 .port_set_duplex = mv88e6xxx_port_set_duplex,
4291 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004292 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004293 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004294 .port_tag_remap = mv88e6095_port_tag_remap,
4295 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4296 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4297 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004298 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004299 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004300 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004301 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4302 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004303 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004304 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004305 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004306 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004307 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004308 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004309 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4310 .stats_get_strings = mv88e6320_stats_get_strings,
4311 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004312 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4313 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004314 .watchdog_ops = &mv88e6390_watchdog_ops,
4315 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004316 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004317 .reset = mv88e6352_g1_reset,
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,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004320 .serdes_power = mv88e6390_serdes_power,
4321 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004322 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004323 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004324 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004325 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004326 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004327 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004328 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004329};
4330
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004331static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004332 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004333 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4334 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004335 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004336 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004337 .phy_read = mv88e6xxx_g2_smi_phy_read,
4338 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004339 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004340 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004341 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004342 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004343 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004344 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004345 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004346 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004347 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004348 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004349 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004350 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004351 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004352 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004353 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004354 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004355 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004356 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004357 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4358 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004359 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004360 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4361 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004362 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004363 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004364 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004365 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004366 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4367 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004368 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004369 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004370 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004371};
4372
4373static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004374 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004375 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4376 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004377 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004378 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004379 .phy_read = mv88e6xxx_g2_smi_phy_read,
4380 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004381 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004382 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004383 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004384 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004385 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004386 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004387 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004388 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004389 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004390 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004391 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004392 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004393 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004394 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004395 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004396 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004397 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004398 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004399 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4400 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004401 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004402 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4403 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004404 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004405 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004406 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004407 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004408 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4409 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004410 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004411 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004412 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004413 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004414 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004415};
4416
4417static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004418 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004419 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4420 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004421 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004422 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4423 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004424 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004425 .phy_read = mv88e6xxx_g2_smi_phy_read,
4426 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004427 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004428 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004429 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004430 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004431 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004432 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004433 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004434 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004435 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004436 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004437 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004438 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004439 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004440 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004441 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004442 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004443 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004444 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004445 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004446 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4447 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004448 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004449 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4450 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004451 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004452 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004453 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004454 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004455 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004456 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4457 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004458 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004459 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004460 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004461 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004462 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004463 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004464 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004465 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004466 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004467 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004468 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4469 .serdes_get_strings = mv88e6352_serdes_get_strings,
4470 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004471 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4472 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004473 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004474};
4475
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004476static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004477 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004478 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004479 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004480 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4481 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004482 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4483 .phy_read = mv88e6xxx_g2_smi_phy_read,
4484 .phy_write = mv88e6xxx_g2_smi_phy_write,
4485 .port_set_link = mv88e6xxx_port_set_link,
4486 .port_set_duplex = mv88e6xxx_port_set_duplex,
4487 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4488 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004489 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004490 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004491 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004492 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004493 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004494 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004495 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004496 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004497 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004498 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004499 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004500 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004501 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004502 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004503 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004504 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004505 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004506 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4507 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004508 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004509 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4510 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004511 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004512 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004513 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004514 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004515 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004516 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4517 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004518 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4519 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004520 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004521 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004522 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004523 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004524 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004525 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004526 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004527 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004528 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4529 .serdes_get_strings = mv88e6390_serdes_get_strings,
4530 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004531 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4532 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004533 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004534};
4535
4536static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004537 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004538 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004539 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004540 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4541 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004542 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4543 .phy_read = mv88e6xxx_g2_smi_phy_read,
4544 .phy_write = mv88e6xxx_g2_smi_phy_write,
4545 .port_set_link = mv88e6xxx_port_set_link,
4546 .port_set_duplex = mv88e6xxx_port_set_duplex,
4547 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4548 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004549 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004550 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004551 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004552 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004553 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004554 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004555 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004556 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004557 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004558 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004559 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004560 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004561 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004562 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004563 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004564 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004565 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004566 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4567 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004568 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004569 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4570 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004571 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004572 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004573 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004574 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004575 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004576 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4577 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004578 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4579 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004580 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004581 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004582 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004583 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004584 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004585 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4586 .serdes_get_strings = mv88e6390_serdes_get_strings,
4587 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004588 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4589 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004590 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004591 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004592 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004593 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004594};
4595
Vivien Didelotf81ec902016-05-09 13:22:58 -04004596static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4597 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004598 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004599 .family = MV88E6XXX_FAMILY_6097,
4600 .name = "Marvell 88E6085",
4601 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004602 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004603 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004604 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004605 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004606 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004607 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004608 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004609 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004610 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004611 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004612 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004613 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004614 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004615 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004616 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004617 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004618 },
4619
4620 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004621 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004622 .family = MV88E6XXX_FAMILY_6095,
4623 .name = "Marvell 88E6095/88E6095F",
4624 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004625 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004626 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004627 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004628 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004629 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004630 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004631 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004632 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004633 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004634 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004635 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004636 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004637 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004638 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004639 },
4640
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004641 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004642 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004643 .family = MV88E6XXX_FAMILY_6097,
4644 .name = "Marvell 88E6097/88E6097F",
4645 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004646 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004647 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004648 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004649 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004650 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004651 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004652 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004653 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004654 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004655 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004656 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004657 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004658 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004659 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004660 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004661 .ops = &mv88e6097_ops,
4662 },
4663
Vivien Didelotf81ec902016-05-09 13:22:58 -04004664 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004665 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 .family = MV88E6XXX_FAMILY_6165,
4667 .name = "Marvell 88E6123",
4668 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004669 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004670 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004671 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004672 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004673 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004674 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004675 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004676 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004677 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004678 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004679 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004680 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004681 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004682 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004683 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004684 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004685 },
4686
4687 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004688 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004689 .family = MV88E6XXX_FAMILY_6185,
4690 .name = "Marvell 88E6131",
4691 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004692 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004693 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004694 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004695 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004696 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004697 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004698 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004699 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004700 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004701 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004702 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004703 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004704 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004705 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004706 },
4707
Vivien Didelot990e27b2017-03-28 13:50:32 -04004708 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004709 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004710 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004711 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004712 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004713 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004714 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004715 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004716 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004717 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004718 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004719 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004720 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004721 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004722 .age_time_coeff = 3750,
4723 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004724 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004725 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004726 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004727 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004728 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004729 .ops = &mv88e6141_ops,
4730 },
4731
Vivien Didelotf81ec902016-05-09 13:22:58 -04004732 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004733 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004734 .family = MV88E6XXX_FAMILY_6165,
4735 .name = "Marvell 88E6161",
4736 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004737 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004739 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004740 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004741 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004742 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004743 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004744 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004745 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004746 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004747 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004748 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004749 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004750 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004751 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004752 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004753 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 },
4755
4756 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004757 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004758 .family = MV88E6XXX_FAMILY_6165,
4759 .name = "Marvell 88E6165",
4760 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004761 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004762 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004763 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004764 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004765 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004766 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004767 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004768 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004769 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004770 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004771 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004772 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004773 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004774 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004775 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004776 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004777 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004778 },
4779
4780 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004781 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004782 .family = MV88E6XXX_FAMILY_6351,
4783 .name = "Marvell 88E6171",
4784 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004785 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004786 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004787 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004788 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004789 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004790 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004791 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004792 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004793 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004794 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004795 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004796 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004797 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004798 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004799 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004800 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004801 },
4802
4803 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004804 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004805 .family = MV88E6XXX_FAMILY_6352,
4806 .name = "Marvell 88E6172",
4807 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004808 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004809 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004810 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004811 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004812 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004813 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004814 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004815 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004816 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004817 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004818 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004819 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004820 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004821 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004822 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004823 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004824 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004825 },
4826
4827 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004828 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004829 .family = MV88E6XXX_FAMILY_6351,
4830 .name = "Marvell 88E6175",
4831 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004832 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004833 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004834 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004835 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004836 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004837 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004838 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004839 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004840 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004841 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004842 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004843 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004844 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004845 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004846 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004847 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004848 },
4849
4850 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004851 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004852 .family = MV88E6XXX_FAMILY_6352,
4853 .name = "Marvell 88E6176",
4854 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004855 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004856 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004857 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004858 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004859 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004860 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004861 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004862 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004863 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004864 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004865 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004866 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004867 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004868 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004869 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004870 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004871 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004872 },
4873
4874 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004875 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004876 .family = MV88E6XXX_FAMILY_6185,
4877 .name = "Marvell 88E6185",
4878 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004879 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004880 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004881 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004882 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004883 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004884 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004885 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004886 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004887 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004888 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004889 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004890 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004891 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004892 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004893 },
4894
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004895 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004896 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004897 .family = MV88E6XXX_FAMILY_6390,
4898 .name = "Marvell 88E6190",
4899 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004900 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004901 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004902 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004903 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004904 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004905 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004906 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004907 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004908 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004909 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004910 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004911 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004912 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004913 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004914 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004915 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004916 .ops = &mv88e6190_ops,
4917 },
4918
4919 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004920 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004921 .family = MV88E6XXX_FAMILY_6390,
4922 .name = "Marvell 88E6190X",
4923 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004924 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004925 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004926 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004927 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004928 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004929 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004930 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004931 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004932 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004933 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004934 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004935 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004936 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004937 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004938 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004939 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004940 .ops = &mv88e6190x_ops,
4941 },
4942
4943 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004944 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004945 .family = MV88E6XXX_FAMILY_6390,
4946 .name = "Marvell 88E6191",
4947 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004948 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004949 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004950 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004951 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004952 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004953 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004954 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004955 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004956 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004957 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004958 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004959 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004960 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004961 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004962 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004963 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004964 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004965 },
4966
Hubert Feurstein49022642019-07-31 10:23:46 +02004967 [MV88E6220] = {
4968 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4969 .family = MV88E6XXX_FAMILY_6250,
4970 .name = "Marvell 88E6220",
4971 .num_databases = 64,
4972
4973 /* Ports 2-4 are not routed to pins
4974 * => usable ports 0, 1, 5, 6
4975 */
4976 .num_ports = 7,
4977 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004978 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004979 .max_vid = 4095,
4980 .port_base_addr = 0x08,
4981 .phy_base_addr = 0x00,
4982 .global1_addr = 0x0f,
4983 .global2_addr = 0x07,
4984 .age_time_coeff = 15000,
4985 .g1_irqs = 9,
4986 .g2_irqs = 10,
4987 .atu_move_port_mask = 0xf,
4988 .dual_chip = true,
4989 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004990 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004991 .ops = &mv88e6250_ops,
4992 },
4993
Vivien Didelotf81ec902016-05-09 13:22:58 -04004994 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004995 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004996 .family = MV88E6XXX_FAMILY_6352,
4997 .name = "Marvell 88E6240",
4998 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004999 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005000 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005001 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005002 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005003 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005004 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005005 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005006 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005007 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005008 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005009 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005010 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005011 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005012 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005013 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005014 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005015 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005016 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005017 },
5018
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005019 [MV88E6250] = {
5020 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5021 .family = MV88E6XXX_FAMILY_6250,
5022 .name = "Marvell 88E6250",
5023 .num_databases = 64,
5024 .num_ports = 7,
5025 .num_internal_phys = 5,
5026 .max_vid = 4095,
5027 .port_base_addr = 0x08,
5028 .phy_base_addr = 0x00,
5029 .global1_addr = 0x0f,
5030 .global2_addr = 0x07,
5031 .age_time_coeff = 15000,
5032 .g1_irqs = 9,
5033 .g2_irqs = 10,
5034 .atu_move_port_mask = 0xf,
5035 .dual_chip = true,
5036 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005037 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005038 .ops = &mv88e6250_ops,
5039 },
5040
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005041 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005042 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005043 .family = MV88E6XXX_FAMILY_6390,
5044 .name = "Marvell 88E6290",
5045 .num_databases = 4096,
5046 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005047 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005048 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005049 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005050 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005051 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005052 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005053 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005054 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005055 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005056 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005057 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005058 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005059 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005060 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005061 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005062 .ops = &mv88e6290_ops,
5063 },
5064
Vivien Didelotf81ec902016-05-09 13:22:58 -04005065 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005066 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005067 .family = MV88E6XXX_FAMILY_6320,
5068 .name = "Marvell 88E6320",
5069 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005070 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005071 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005072 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005073 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005074 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005075 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005076 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005077 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005078 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005079 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005080 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005081 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005082 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005083 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005084 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005085 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005086 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005087 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005088 },
5089
5090 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005091 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005092 .family = MV88E6XXX_FAMILY_6320,
5093 .name = "Marvell 88E6321",
5094 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005095 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005096 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005097 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005098 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005099 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005100 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005101 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005102 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005103 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005104 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005105 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005106 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005107 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005108 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005109 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005110 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005111 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005112 },
5113
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005114 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005115 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005116 .family = MV88E6XXX_FAMILY_6341,
5117 .name = "Marvell 88E6341",
5118 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005119 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005120 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005121 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005122 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005123 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005124 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005125 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005126 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005127 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005128 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005129 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005130 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005131 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005132 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005133 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005134 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005135 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005136 .ops = &mv88e6341_ops,
5137 },
5138
Vivien Didelotf81ec902016-05-09 13:22:58 -04005139 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005140 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005141 .family = MV88E6XXX_FAMILY_6351,
5142 .name = "Marvell 88E6350",
5143 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005144 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005145 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005146 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005147 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005148 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005149 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005150 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005151 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005152 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005153 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005154 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005155 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005156 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005157 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005158 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005159 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005160 },
5161
5162 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005163 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005164 .family = MV88E6XXX_FAMILY_6351,
5165 .name = "Marvell 88E6351",
5166 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005167 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005168 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005169 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005170 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005171 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005172 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005173 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005174 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005175 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005176 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005177 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005178 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005179 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005180 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005181 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005182 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005183 },
5184
5185 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005186 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005187 .family = MV88E6XXX_FAMILY_6352,
5188 .name = "Marvell 88E6352",
5189 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005190 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005191 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005192 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005193 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005194 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005195 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005196 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005197 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005198 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005199 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005200 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005201 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005202 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005203 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005204 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005205 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005206 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005207 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005208 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005209 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005210 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005211 .family = MV88E6XXX_FAMILY_6390,
5212 .name = "Marvell 88E6390",
5213 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005214 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005215 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005216 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005217 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005218 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005219 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005220 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005221 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005222 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005223 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005224 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005225 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005226 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005227 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005228 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005229 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005230 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005231 .ops = &mv88e6390_ops,
5232 },
5233 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005234 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005235 .family = MV88E6XXX_FAMILY_6390,
5236 .name = "Marvell 88E6390X",
5237 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005238 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005239 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005240 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005241 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005242 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005243 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005244 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005245 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005246 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005247 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005248 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005249 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005250 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005251 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005252 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005253 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005254 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005255 .ops = &mv88e6390x_ops,
5256 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005257};
5258
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005259static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005260{
Vivien Didelota439c062016-04-17 13:23:58 -04005261 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005262
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005263 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5264 if (mv88e6xxx_table[i].prod_num == prod_num)
5265 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005266
Vivien Didelotb9b37712015-10-30 19:39:48 -04005267 return NULL;
5268}
5269
Vivien Didelotfad09c72016-06-21 12:28:20 -04005270static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005271{
5272 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005273 unsigned int prod_num, rev;
5274 u16 id;
5275 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005276
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005277 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005278 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005279 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005280 if (err)
5281 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005282
Vivien Didelot107fcc12017-06-12 12:37:36 -04005283 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5284 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005285
5286 info = mv88e6xxx_lookup_info(prod_num);
5287 if (!info)
5288 return -ENODEV;
5289
Vivien Didelotcaac8542016-06-20 13:14:09 -04005290 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005291 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005292
Vivien Didelotca070c12016-09-02 14:45:34 -04005293 err = mv88e6xxx_g2_require(chip);
5294 if (err)
5295 return err;
5296
Vivien Didelotfad09c72016-06-21 12:28:20 -04005297 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5298 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005299
5300 return 0;
5301}
5302
Vivien Didelotfad09c72016-06-21 12:28:20 -04005303static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005304{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005305 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005306
Vivien Didelotfad09c72016-06-21 12:28:20 -04005307 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5308 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005309 return NULL;
5310
Vivien Didelotfad09c72016-06-21 12:28:20 -04005311 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005312
Vivien Didelotfad09c72016-06-21 12:28:20 -04005313 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005314 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005315 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005316
Vivien Didelotfad09c72016-06-21 12:28:20 -04005317 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005318}
5319
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005320static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005321 int port,
5322 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005323{
Vivien Didelot04bed142016-08-31 18:06:13 -04005324 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005325
Andrew Lunn443d5a12016-12-03 04:35:18 +01005326 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005327}
5328
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005329static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005330 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005331{
5332 /* We don't need any dynamic resource from the kernel (yet),
5333 * so skip the prepare phase.
5334 */
5335
5336 return 0;
5337}
5338
5339static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005340 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005341{
Vivien Didelot04bed142016-08-31 18:06:13 -04005342 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005343
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005344 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005345 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005346 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005347 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5348 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005349 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005350}
5351
5352static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5353 const struct switchdev_obj_port_mdb *mdb)
5354{
Vivien Didelot04bed142016-08-31 18:06:13 -04005355 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005356 int err;
5357
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005358 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005359 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005360 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005361
5362 return err;
5363}
5364
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005365static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5366 struct dsa_mall_mirror_tc_entry *mirror,
5367 bool ingress)
5368{
5369 enum mv88e6xxx_egress_direction direction = ingress ?
5370 MV88E6XXX_EGRESS_DIR_INGRESS :
5371 MV88E6XXX_EGRESS_DIR_EGRESS;
5372 struct mv88e6xxx_chip *chip = ds->priv;
5373 bool other_mirrors = false;
5374 int i;
5375 int err;
5376
5377 if (!chip->info->ops->set_egress_port)
5378 return -EOPNOTSUPP;
5379
5380 mutex_lock(&chip->reg_lock);
5381 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5382 mirror->to_local_port) {
5383 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5384 other_mirrors |= ingress ?
5385 chip->ports[i].mirror_ingress :
5386 chip->ports[i].mirror_egress;
5387
5388 /* Can't change egress port when other mirror is active */
5389 if (other_mirrors) {
5390 err = -EBUSY;
5391 goto out;
5392 }
5393
5394 err = chip->info->ops->set_egress_port(chip,
5395 direction,
5396 mirror->to_local_port);
5397 if (err)
5398 goto out;
5399 }
5400
5401 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5402out:
5403 mutex_unlock(&chip->reg_lock);
5404
5405 return err;
5406}
5407
5408static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5409 struct dsa_mall_mirror_tc_entry *mirror)
5410{
5411 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5412 MV88E6XXX_EGRESS_DIR_INGRESS :
5413 MV88E6XXX_EGRESS_DIR_EGRESS;
5414 struct mv88e6xxx_chip *chip = ds->priv;
5415 bool other_mirrors = false;
5416 int i;
5417
5418 mutex_lock(&chip->reg_lock);
5419 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5420 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5421
5422 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5423 other_mirrors |= mirror->ingress ?
5424 chip->ports[i].mirror_ingress :
5425 chip->ports[i].mirror_egress;
5426
5427 /* Reset egress port when no other mirror is active */
5428 if (!other_mirrors) {
5429 if (chip->info->ops->set_egress_port(chip,
5430 direction,
5431 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005432 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005433 dev_err(ds->dev, "failed to set egress port\n");
5434 }
5435
5436 mutex_unlock(&chip->reg_lock);
5437}
5438
Russell King4f859012019-02-20 15:35:05 -08005439static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5440 bool unicast, bool multicast)
5441{
5442 struct mv88e6xxx_chip *chip = ds->priv;
5443 int err = -EOPNOTSUPP;
5444
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005445 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005446 if (chip->info->ops->port_set_egress_floods)
5447 err = chip->info->ops->port_set_egress_floods(chip, port,
5448 unicast,
5449 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005450 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005451
5452 return err;
5453}
5454
Florian Fainellia82f67a2017-01-08 14:52:08 -08005455static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005456 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005457 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005458 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005459 .phylink_validate = mv88e6xxx_validate,
5460 .phylink_mac_link_state = mv88e6xxx_link_state,
5461 .phylink_mac_config = mv88e6xxx_mac_config,
5462 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5463 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005464 .get_strings = mv88e6xxx_get_strings,
5465 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5466 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005467 .port_enable = mv88e6xxx_port_enable,
5468 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005469 .get_mac_eee = mv88e6xxx_get_mac_eee,
5470 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005471 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005472 .get_eeprom = mv88e6xxx_get_eeprom,
5473 .set_eeprom = mv88e6xxx_set_eeprom,
5474 .get_regs_len = mv88e6xxx_get_regs_len,
5475 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005476 .get_rxnfc = mv88e6xxx_get_rxnfc,
5477 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005478 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005479 .port_bridge_join = mv88e6xxx_port_bridge_join,
5480 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005481 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005482 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005483 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005484 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5485 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5486 .port_vlan_add = mv88e6xxx_port_vlan_add,
5487 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005488 .port_fdb_add = mv88e6xxx_port_fdb_add,
5489 .port_fdb_del = mv88e6xxx_port_fdb_del,
5490 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005491 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5492 .port_mdb_add = mv88e6xxx_port_mdb_add,
5493 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005494 .port_mirror_add = mv88e6xxx_port_mirror_add,
5495 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005496 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5497 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005498 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5499 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5500 .port_txtstamp = mv88e6xxx_port_txtstamp,
5501 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5502 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005503 .devlink_param_get = mv88e6xxx_devlink_param_get,
5504 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005505};
5506
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005507static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005508{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005509 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005510 struct dsa_switch *ds;
5511
Vivien Didelot7e99e342019-10-21 16:51:30 -04005512 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005513 if (!ds)
5514 return -ENOMEM;
5515
Vivien Didelot7e99e342019-10-21 16:51:30 -04005516 ds->dev = dev;
5517 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005518 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005519 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005520 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005521 ds->ageing_time_min = chip->info->age_time_coeff;
5522 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005523
5524 dev_set_drvdata(dev, ds);
5525
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005526 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005527}
5528
Vivien Didelotfad09c72016-06-21 12:28:20 -04005529static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005530{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005531 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005532}
5533
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005534static const void *pdata_device_get_match_data(struct device *dev)
5535{
5536 const struct of_device_id *matches = dev->driver->of_match_table;
5537 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5538
5539 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5540 matches++) {
5541 if (!strcmp(pdata->compatible, matches->compatible))
5542 return matches->data;
5543 }
5544 return NULL;
5545}
5546
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005547/* There is no suspend to RAM support at DSA level yet, the switch configuration
5548 * would be lost after a power cycle so prevent it to be suspended.
5549 */
5550static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5551{
5552 return -EOPNOTSUPP;
5553}
5554
5555static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5556{
5557 return 0;
5558}
5559
5560static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5561
Vivien Didelot57d32312016-06-20 13:13:58 -04005562static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005563{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005564 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005565 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005566 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005567 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005568 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005569 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005570 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005571
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005572 if (!np && !pdata)
5573 return -EINVAL;
5574
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005575 if (np)
5576 compat_info = of_device_get_match_data(dev);
5577
5578 if (pdata) {
5579 compat_info = pdata_device_get_match_data(dev);
5580
5581 if (!pdata->netdev)
5582 return -EINVAL;
5583
5584 for (port = 0; port < DSA_MAX_PORTS; port++) {
5585 if (!(pdata->enabled_ports & (1 << port)))
5586 continue;
5587 if (strcmp(pdata->cd.port_names[port], "cpu"))
5588 continue;
5589 pdata->cd.netdev[port] = &pdata->netdev->dev;
5590 break;
5591 }
5592 }
5593
Vivien Didelotcaac8542016-06-20 13:14:09 -04005594 if (!compat_info)
5595 return -EINVAL;
5596
Vivien Didelotfad09c72016-06-21 12:28:20 -04005597 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005598 if (!chip) {
5599 err = -ENOMEM;
5600 goto out;
5601 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005602
Vivien Didelotfad09c72016-06-21 12:28:20 -04005603 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005604
Vivien Didelotfad09c72016-06-21 12:28:20 -04005605 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005606 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005607 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005608
Andrew Lunnb4308f02016-11-21 23:26:55 +01005609 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005610 if (IS_ERR(chip->reset)) {
5611 err = PTR_ERR(chip->reset);
5612 goto out;
5613 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005614 if (chip->reset)
5615 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005616
Vivien Didelotfad09c72016-06-21 12:28:20 -04005617 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005618 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005619 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005620
Vivien Didelote57e5e72016-08-15 17:19:00 -04005621 mv88e6xxx_phy_init(chip);
5622
Andrew Lunn00baabe2018-05-19 22:31:35 +02005623 if (chip->info->ops->get_eeprom) {
5624 if (np)
5625 of_property_read_u32(np, "eeprom-length",
5626 &chip->eeprom_len);
5627 else
5628 chip->eeprom_len = pdata->eeprom_len;
5629 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005630
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005631 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005632 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005633 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005634 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005635 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005636
Andrew Lunna27415d2019-05-01 00:10:50 +02005637 if (np) {
5638 chip->irq = of_irq_get(np, 0);
5639 if (chip->irq == -EPROBE_DEFER) {
5640 err = chip->irq;
5641 goto out;
5642 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005643 }
5644
Andrew Lunna27415d2019-05-01 00:10:50 +02005645 if (pdata)
5646 chip->irq = pdata->irq;
5647
Andrew Lunn294d7112018-02-22 22:58:32 +01005648 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005649 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005650 * controllers
5651 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005652 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005653 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005654 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005655 else
5656 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005657 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005658
Andrew Lunn294d7112018-02-22 22:58:32 +01005659 if (err)
5660 goto out;
5661
5662 if (chip->info->g2_irqs > 0) {
5663 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005664 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005665 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005666 }
5667
Andrew Lunn294d7112018-02-22 22:58:32 +01005668 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5669 if (err)
5670 goto out_g2_irq;
5671
5672 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5673 if (err)
5674 goto out_g1_atu_prob_irq;
5675
Andrew Lunna3c53be52017-01-24 14:53:50 +01005676 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005677 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005678 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005679
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005680 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005681 if (err)
5682 goto out_mdio;
5683
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005684 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005685
5686out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005687 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005688out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005689 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005690out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005691 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005692out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005693 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005694 mv88e6xxx_g2_irq_free(chip);
5695out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005696 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005697 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005698 else
5699 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005700out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005701 if (pdata)
5702 dev_put(pdata->netdev);
5703
Andrew Lunndc30c352016-10-16 19:56:49 +02005704 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005705}
5706
5707static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5708{
5709 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005710 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005711
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005712 if (chip->info->ptp_support) {
5713 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005714 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005715 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005716
Andrew Lunn930188c2016-08-22 16:01:03 +02005717 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005718 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005719 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005720
Andrew Lunn76f38f12018-03-17 20:21:09 +01005721 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5722 mv88e6xxx_g1_atu_prob_irq_free(chip);
5723
5724 if (chip->info->g2_irqs > 0)
5725 mv88e6xxx_g2_irq_free(chip);
5726
Andrew Lunn76f38f12018-03-17 20:21:09 +01005727 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005728 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005729 else
5730 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005731}
5732
5733static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005734 {
5735 .compatible = "marvell,mv88e6085",
5736 .data = &mv88e6xxx_table[MV88E6085],
5737 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005738 {
5739 .compatible = "marvell,mv88e6190",
5740 .data = &mv88e6xxx_table[MV88E6190],
5741 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005742 {
5743 .compatible = "marvell,mv88e6250",
5744 .data = &mv88e6xxx_table[MV88E6250],
5745 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005746 { /* sentinel */ },
5747};
5748
5749MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5750
5751static struct mdio_driver mv88e6xxx_driver = {
5752 .probe = mv88e6xxx_probe,
5753 .remove = mv88e6xxx_remove,
5754 .mdiodrv.driver = {
5755 .name = "mv88e6085",
5756 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005757 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005758 },
5759};
5760
Andrew Lunn7324d502019-04-27 19:19:10 +02005761mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005762
5763MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5764MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5765MODULE_LICENSE("GPL");