blob: cb284eb505c0f76e7466abaef52b17837cd87a29 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100400int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
401 int speed, int duplex, int pause,
402 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100403{
Andrew Lunna26deec2019-04-18 03:11:39 +0200404 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100405 int err;
406
407 if (!chip->info->ops->port_set_link)
408 return 0;
409
Andrew Lunna26deec2019-04-18 03:11:39 +0200410 if (!chip->info->ops->port_link_state)
411 return 0;
412
413 err = chip->info->ops->port_link_state(chip, port, &state);
414 if (err)
415 return err;
416
417 /* Has anything actually changed? We don't expect the
418 * interface mode to change without one of the other
419 * parameters also changing
420 */
421 if (state.link == link &&
422 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200423 state.duplex == duplex &&
424 (state.interface == mode ||
425 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 return 0;
427
Vivien Didelotd78343d2016-11-04 03:23:36 +0100428 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200429 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100430 if (err)
431 return err;
432
433 if (chip->info->ops->port_set_speed) {
434 err = chip->info->ops->port_set_speed(chip, port, speed);
435 if (err && err != -EOPNOTSUPP)
436 goto restore_link;
437 }
438
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100439 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
440 mode = chip->info->ops->port_max_speed_mode(port);
441
Andrew Lunn54186b92018-08-09 15:38:37 +0200442 if (chip->info->ops->port_set_pause) {
443 err = chip->info->ops->port_set_pause(chip, port, pause);
444 if (err)
445 goto restore_link;
446 }
447
Vivien Didelotd78343d2016-11-04 03:23:36 +0100448 if (chip->info->ops->port_set_duplex) {
449 err = chip->info->ops->port_set_duplex(chip, port, duplex);
450 if (err && err != -EOPNOTSUPP)
451 goto restore_link;
452 }
453
454 if (chip->info->ops->port_set_rgmii_delay) {
455 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
456 if (err && err != -EOPNOTSUPP)
457 goto restore_link;
458 }
459
Andrew Lunnf39908d2017-02-04 20:02:50 +0100460 if (chip->info->ops->port_set_cmode) {
461 err = chip->info->ops->port_set_cmode(chip, port, mode);
462 if (err && err != -EOPNOTSUPP)
463 goto restore_link;
464 }
465
Vivien Didelotd78343d2016-11-04 03:23:36 +0100466 err = 0;
467restore_link:
468 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400469 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470
471 return err;
472}
473
Marek Vasutd700ec42018-09-12 00:15:24 +0200474static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
475{
476 struct mv88e6xxx_chip *chip = ds->priv;
477
478 return port < chip->info->num_internal_phys;
479}
480
Russell King6c422e32018-08-09 15:38:39 +0200481static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
482 unsigned long *mask,
483 struct phylink_link_state *state)
484{
485 if (!phy_interface_mode_is_8023z(state->interface)) {
486 /* 10M and 100M are only supported in non-802.3z mode */
487 phylink_set(mask, 10baseT_Half);
488 phylink_set(mask, 10baseT_Full);
489 phylink_set(mask, 100baseT_Half);
490 phylink_set(mask, 100baseT_Full);
491 }
492}
493
494static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
495 unsigned long *mask,
496 struct phylink_link_state *state)
497{
498 /* FIXME: if the port is in 1000Base-X mode, then it only supports
499 * 1000M FD speeds. In this case, CMODE will indicate 5.
500 */
501 phylink_set(mask, 1000baseT_Full);
502 phylink_set(mask, 1000baseX_Full);
503
504 mv88e6065_phylink_validate(chip, port, mask, state);
505}
506
Marek Behúne3af71a2019-02-25 12:39:55 +0100507static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
508 unsigned long *mask,
509 struct phylink_link_state *state)
510{
511 if (port >= 5)
512 phylink_set(mask, 2500baseX_Full);
513
514 /* No ethtool bits for 200Mbps */
515 phylink_set(mask, 1000baseT_Full);
516 phylink_set(mask, 1000baseX_Full);
517
518 mv88e6065_phylink_validate(chip, port, mask, state);
519}
520
Russell King6c422e32018-08-09 15:38:39 +0200521static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
522 unsigned long *mask,
523 struct phylink_link_state *state)
524{
525 /* No ethtool bits for 200Mbps */
526 phylink_set(mask, 1000baseT_Full);
527 phylink_set(mask, 1000baseX_Full);
528
529 mv88e6065_phylink_validate(chip, port, mask, state);
530}
531
532static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
533 unsigned long *mask,
534 struct phylink_link_state *state)
535{
Andrew Lunnec260162019-02-08 22:25:44 +0100536 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200537 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100538 phylink_set(mask, 2500baseT_Full);
539 }
Russell King6c422e32018-08-09 15:38:39 +0200540
541 /* No ethtool bits for 200Mbps */
542 phylink_set(mask, 1000baseT_Full);
543 phylink_set(mask, 1000baseX_Full);
544
545 mv88e6065_phylink_validate(chip, port, mask, state);
546}
547
548static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
549 unsigned long *mask,
550 struct phylink_link_state *state)
551{
552 if (port >= 9) {
553 phylink_set(mask, 10000baseT_Full);
554 phylink_set(mask, 10000baseKR_Full);
555 }
556
557 mv88e6390_phylink_validate(chip, port, mask, state);
558}
559
Russell Kingc9a23562018-05-10 13:17:35 -0700560static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
561 unsigned long *supported,
562 struct phylink_link_state *state)
563{
Russell King6c422e32018-08-09 15:38:39 +0200564 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
565 struct mv88e6xxx_chip *chip = ds->priv;
566
567 /* Allow all the expected bits */
568 phylink_set(mask, Autoneg);
569 phylink_set(mask, Pause);
570 phylink_set_port_modes(mask);
571
572 if (chip->info->ops->phylink_validate)
573 chip->info->ops->phylink_validate(chip, port, mask, state);
574
575 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
576 bitmap_and(state->advertising, state->advertising, mask,
577 __ETHTOOL_LINK_MODE_MASK_NBITS);
578
579 /* We can only operate at 2500BaseX or 1000BaseX. If requested
580 * to advertise both, only report advertising at 2500BaseX.
581 */
582 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700583}
584
585static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
586 struct phylink_link_state *state)
587{
588 struct mv88e6xxx_chip *chip = ds->priv;
589 int err;
590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000591 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200592 if (chip->info->ops->port_link_state)
593 err = chip->info->ops->port_link_state(chip, port, state);
594 else
595 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000596 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700597
598 return err;
599}
600
601static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
602 unsigned int mode,
603 const struct phylink_link_state *state)
604{
605 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200606 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700607
Marek Vasutd700ec42018-09-12 00:15:24 +0200608 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700609 return;
610
611 if (mode == MLO_AN_FIXED) {
612 link = LINK_FORCED_UP;
613 speed = state->speed;
614 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200615 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
616 link = state->link;
617 speed = state->speed;
618 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700619 } else {
620 speed = SPEED_UNFORCED;
621 duplex = DUPLEX_UNFORCED;
622 link = LINK_UNFORCED;
623 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700625
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700628 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000629 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700630
631 if (err && err != -EOPNOTSUPP)
632 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
633}
634
635static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
636{
637 struct mv88e6xxx_chip *chip = ds->priv;
638 int err;
639
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000640 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700641 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000642 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700643
644 if (err)
645 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
646}
647
648static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
649 unsigned int mode,
650 phy_interface_t interface)
651{
652 if (mode == MLO_AN_FIXED)
653 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
654}
655
656static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
657 unsigned int mode, phy_interface_t interface,
658 struct phy_device *phydev)
659{
660 if (mode == MLO_AN_FIXED)
661 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
662}
663
Andrew Lunna605a0f2016-11-21 23:26:58 +0100664static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 if (!chip->info->ops->stats_snapshot)
667 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000668
Andrew Lunna605a0f2016-11-21 23:26:58 +0100669 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000670}
671
Andrew Lunne413e7e2015-04-02 04:06:38 +0200672static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100673 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
674 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
675 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
676 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
677 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
678 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
679 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
680 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
681 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
682 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
683 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
684 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
685 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
686 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
687 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
688 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
689 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
690 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
691 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
692 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
693 { "single", 4, 0x14, STATS_TYPE_BANK0, },
694 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
695 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
696 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
697 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
698 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
699 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
700 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
701 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
702 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
703 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
704 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
705 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
706 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
707 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
708 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
709 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
710 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
711 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
712 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
713 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
714 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
715 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
716 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
717 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
718 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
719 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
720 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
721 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
722 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
723 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
724 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
725 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
726 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
727 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
728 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
729 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
730 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
731 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200732};
733
Vivien Didelotfad09c72016-06-21 12:28:20 -0400734static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100735 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100736 int port, u16 bank1_select,
737 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200738{
Andrew Lunn80c46272015-06-20 18:42:30 +0200739 u32 low;
740 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100741 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200742 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200743 u64 value;
744
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100745 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100746 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200747 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
748 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800749 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200750
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200751 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100752 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200753 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
754 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800755 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000756 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200757 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100758 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100759 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100761 /* fall through */
762 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100763 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100764 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100765 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100766 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500767 break;
768 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800769 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200770 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100771 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200772 return value;
773}
774
Andrew Lunn436fe172018-03-01 02:02:29 +0100775static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
776 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100777{
778 struct mv88e6xxx_hw_stat *stat;
779 int i, j;
780
781 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
782 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100783 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100784 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
785 ETH_GSTRING_LEN);
786 j++;
787 }
788 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100789
790 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100791}
792
Andrew Lunn436fe172018-03-01 02:02:29 +0100793static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
794 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100795{
Andrew Lunn436fe172018-03-01 02:02:29 +0100796 return mv88e6xxx_stats_get_strings(chip, data,
797 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100798}
799
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000800static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
801 uint8_t *data)
802{
803 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
804}
805
Andrew Lunn436fe172018-03-01 02:02:29 +0100806static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
807 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100808{
Andrew Lunn436fe172018-03-01 02:02:29 +0100809 return mv88e6xxx_stats_get_strings(chip, data,
810 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100811}
812
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
814 "atu_member_violation",
815 "atu_miss_violation",
816 "atu_full_violation",
817 "vtu_member_violation",
818 "vtu_miss_violation",
819};
820
821static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
822{
823 unsigned int i;
824
825 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
826 strlcpy(data + i * ETH_GSTRING_LEN,
827 mv88e6xxx_atu_vtu_stats_strings[i],
828 ETH_GSTRING_LEN);
829}
830
Andrew Lunndfafe442016-11-21 23:27:02 +0100831static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700832 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100833{
Vivien Didelot04bed142016-08-31 18:06:13 -0400834 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100835 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100836
Florian Fainelli89f09042018-04-25 12:12:50 -0700837 if (stringset != ETH_SS_STATS)
838 return;
839
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000840 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100841
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100843 count = chip->info->ops->stats_get_strings(chip, data);
844
845 if (chip->info->ops->serdes_get_strings) {
846 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100848 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100849
Andrew Lunn65f60e42018-03-28 23:50:28 +0200850 data += count * ETH_GSTRING_LEN;
851 mv88e6xxx_atu_vtu_get_strings(data);
852
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000853 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100854}
855
856static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
857 int types)
858{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 struct mv88e6xxx_hw_stat *stat;
860 int i, j;
861
862 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
863 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865 j++;
866 }
867 return j;
868}
869
Andrew Lunndfafe442016-11-21 23:27:02 +0100870static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
871{
872 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
873 STATS_TYPE_PORT);
874}
875
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000876static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
877{
878 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
879}
880
Andrew Lunndfafe442016-11-21 23:27:02 +0100881static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
882{
883 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
884 STATS_TYPE_BANK1);
885}
886
Florian Fainelli89f09042018-04-25 12:12:50 -0700887static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100888{
889 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 int serdes_count = 0;
891 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100892
Florian Fainelli89f09042018-04-25 12:12:50 -0700893 if (sset != ETH_SS_STATS)
894 return 0;
895
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000896 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100898 count = chip->info->ops->stats_get_sset_count(chip);
899 if (count < 0)
900 goto out;
901
902 if (chip->info->ops->serdes_get_sset_count)
903 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
904 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200905 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100906 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907 goto out;
908 }
909 count += serdes_count;
910 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000913 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Andrew Lunn436fe172018-03-01 02:02:29 +0100918static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
919 uint64_t *data, int types,
920 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100921{
922 struct mv88e6xxx_hw_stat *stat;
923 int i, j;
924
925 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
926 stat = &mv88e6xxx_hw_stats[i];
927 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000928 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100929 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
930 bank1_select,
931 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000932 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100933
Andrew Lunn052f9472016-11-21 23:27:03 +0100934 j++;
935 }
936 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100938}
939
Andrew Lunn436fe172018-03-01 02:02:29 +0100940static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
941 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100942{
943 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100944 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400945 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100946}
947
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000948static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
949 uint64_t *data)
950{
951 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
952 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
953}
954
Andrew Lunn436fe172018-03-01 02:02:29 +0100955static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
956 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100957{
958 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400960 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
961 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100962}
963
Andrew Lunn436fe172018-03-01 02:02:29 +0100964static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
965 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100966{
967 return mv88e6xxx_stats_get_stats(chip, port, data,
968 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400969 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
970 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100971}
972
Andrew Lunn65f60e42018-03-28 23:50:28 +0200973static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
974 uint64_t *data)
975{
976 *data++ = chip->ports[port].atu_member_violation;
977 *data++ = chip->ports[port].atu_miss_violation;
978 *data++ = chip->ports[port].atu_full_violation;
979 *data++ = chip->ports[port].vtu_member_violation;
980 *data++ = chip->ports[port].vtu_miss_violation;
981}
982
Andrew Lunn052f9472016-11-21 23:27:03 +0100983static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
985{
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 int count = 0;
987
Andrew Lunn052f9472016-11-21 23:27:03 +0100988 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 count = chip->info->ops->stats_get_stats(chip, port, data);
990
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000991 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 if (chip->info->ops->serdes_get_stats) {
993 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 data += count;
997 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000998 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100999}
1000
Vivien Didelotf81ec902016-05-09 13:22:58 -04001001static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1002 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003{
Vivien Didelot04bed142016-08-31 18:06:13 -04001004 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001006
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001008
Andrew Lunna605a0f2016-11-21 23:26:58 +01001009 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001011
1012 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001014
1015 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017}
Ben Hutchings98e67302011-11-25 14:36:19 +00001018
Vivien Didelotf81ec902016-05-09 13:22:58 -04001019static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001020{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001021 struct mv88e6xxx_chip *chip = ds->priv;
1022 int len;
1023
1024 len = 32 * sizeof(u16);
1025 if (chip->info->ops->serdes_get_regs_len)
1026 len += chip->info->ops->serdes_get_regs_len(chip, port);
1027
1028 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001029}
1030
Vivien Didelotf81ec902016-05-09 13:22:58 -04001031static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1032 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001033{
Vivien Didelot04bed142016-08-31 18:06:13 -04001034 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001035 int err;
1036 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037 u16 *p = _p;
1038 int i;
1039
Vivien Didelota5f39322018-12-17 16:05:21 -05001040 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001041
1042 memset(p, 0xff, 32 * sizeof(u16));
1043
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001044 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001045
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001046 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001048 err = mv88e6xxx_port_read(chip, port, i, &reg);
1049 if (!err)
1050 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001051 }
Vivien Didelot23062512016-05-09 13:22:45 -04001052
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001053 if (chip->info->ops->serdes_get_regs)
1054 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1055
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001056 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001057}
1058
Vivien Didelot08f50062017-08-01 16:32:41 -04001059static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1060 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061{
Vivien Didelot5480db62017-08-01 16:32:40 -04001062 /* Nothing to do on the port's MAC */
1063 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001064}
1065
Vivien Didelot08f50062017-08-01 16:32:41 -04001066static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1067 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001068{
Vivien Didelot5480db62017-08-01 16:32:40 -04001069 /* Nothing to do on the port's MAC */
1070 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001071}
1072
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001073/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001074static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001075{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001076 struct dsa_switch *ds = chip->ds;
1077 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001078 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001079 struct dsa_port *dp;
1080 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001081 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001082
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001083 list_for_each_entry(dp, &dst->ports, list) {
1084 if (dp->ds->index == dev && dp->index == port) {
1085 found = true;
1086 break;
1087 }
1088 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001089
Vivien Didelote5887a22017-03-30 17:37:11 -04001090 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001091 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001092 return 0;
1093
1094 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001095 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001096 return mv88e6xxx_port_mask(chip);
1097
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001098 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001099 pvlan = 0;
1100
1101 /* Frames from user ports can egress any local DSA links and CPU ports,
1102 * as well as any local member of their bridge group.
1103 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001104 list_for_each_entry(dp, &dst->ports, list)
1105 if (dp->ds == ds &&
1106 (dp->type == DSA_PORT_TYPE_CPU ||
1107 dp->type == DSA_PORT_TYPE_DSA ||
1108 (br && dp->bridge_dev == br)))
1109 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001110
1111 return pvlan;
1112}
1113
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001114static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001115{
1116 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001117
1118 /* prevent frames from going back out of the port they came in on */
1119 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001120
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001121 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001122}
1123
Vivien Didelotf81ec902016-05-09 13:22:58 -04001124static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1125 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001126{
Vivien Didelot04bed142016-08-31 18:06:13 -04001127 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001128 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001129
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001130 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001131 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001132 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001133
1134 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001135 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001136}
1137
Vivien Didelot93e18d62018-05-11 17:16:35 -04001138static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1139{
1140 int err;
1141
1142 if (chip->info->ops->ieee_pri_map) {
1143 err = chip->info->ops->ieee_pri_map(chip);
1144 if (err)
1145 return err;
1146 }
1147
1148 if (chip->info->ops->ip_pri_map) {
1149 err = chip->info->ops->ip_pri_map(chip);
1150 if (err)
1151 return err;
1152 }
1153
1154 return 0;
1155}
1156
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001157static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1158{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001159 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001160 int target, port;
1161 int err;
1162
1163 if (!chip->info->global2_addr)
1164 return 0;
1165
1166 /* Initialize the routing port to the 32 possible target devices */
1167 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001168 port = dsa_routing_port(ds, target);
1169 if (port == ds->num_ports)
1170 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001171
1172 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1173 if (err)
1174 return err;
1175 }
1176
Vivien Didelot02317e62018-05-09 11:38:49 -04001177 if (chip->info->ops->set_cascade_port) {
1178 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1179 err = chip->info->ops->set_cascade_port(chip, port);
1180 if (err)
1181 return err;
1182 }
1183
Vivien Didelot23c98912018-05-09 11:38:50 -04001184 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1185 if (err)
1186 return err;
1187
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001188 return 0;
1189}
1190
Vivien Didelotb28f8722018-04-26 21:56:44 -04001191static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1192{
1193 /* Clear all trunk masks and mapping */
1194 if (chip->info->global2_addr)
1195 return mv88e6xxx_g2_trunk_clear(chip);
1196
1197 return 0;
1198}
1199
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001200static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1201{
1202 if (chip->info->ops->rmu_disable)
1203 return chip->info->ops->rmu_disable(chip);
1204
1205 return 0;
1206}
1207
Vivien Didelot9e907d72017-07-17 13:03:43 -04001208static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1209{
1210 if (chip->info->ops->pot_clear)
1211 return chip->info->ops->pot_clear(chip);
1212
1213 return 0;
1214}
1215
Vivien Didelot51c901a2017-07-17 13:03:41 -04001216static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1217{
1218 if (chip->info->ops->mgmt_rsvd2cpu)
1219 return chip->info->ops->mgmt_rsvd2cpu(chip);
1220
1221 return 0;
1222}
1223
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001224static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1225{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001226 int err;
1227
Vivien Didelotdaefc942017-03-11 16:12:54 -05001228 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1229 if (err)
1230 return err;
1231
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001232 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1233 if (err)
1234 return err;
1235
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001236 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1237}
1238
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001239static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1240{
1241 int port;
1242 int err;
1243
1244 if (!chip->info->ops->irl_init_all)
1245 return 0;
1246
1247 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1248 /* Disable ingress rate limiting by resetting all per port
1249 * ingress rate limit resources to their initial state.
1250 */
1251 err = chip->info->ops->irl_init_all(chip, port);
1252 if (err)
1253 return err;
1254 }
1255
1256 return 0;
1257}
1258
Vivien Didelot04a69a12017-10-13 14:18:05 -04001259static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1260{
1261 if (chip->info->ops->set_switch_mac) {
1262 u8 addr[ETH_ALEN];
1263
1264 eth_random_addr(addr);
1265
1266 return chip->info->ops->set_switch_mac(chip, addr);
1267 }
1268
1269 return 0;
1270}
1271
Vivien Didelot17a15942017-03-30 17:37:09 -04001272static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1273{
1274 u16 pvlan = 0;
1275
1276 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001277 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001278
1279 /* Skip the local source device, which uses in-chip port VLAN */
1280 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001281 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001282
1283 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1284}
1285
Vivien Didelot81228992017-03-30 17:37:08 -04001286static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1287{
Vivien Didelot17a15942017-03-30 17:37:09 -04001288 int dev, port;
1289 int err;
1290
Vivien Didelot81228992017-03-30 17:37:08 -04001291 if (!mv88e6xxx_has_pvt(chip))
1292 return 0;
1293
1294 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1295 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1296 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001297 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1298 if (err)
1299 return err;
1300
1301 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1302 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1303 err = mv88e6xxx_pvt_map(chip, dev, port);
1304 if (err)
1305 return err;
1306 }
1307 }
1308
1309 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001310}
1311
Vivien Didelot749efcb2016-09-22 16:49:24 -04001312static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1313{
1314 struct mv88e6xxx_chip *chip = ds->priv;
1315 int err;
1316
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001317 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001318 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001319 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001320
1321 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001322 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001323}
1324
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001325static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1326{
1327 if (!chip->info->max_vid)
1328 return 0;
1329
1330 return mv88e6xxx_g1_vtu_flush(chip);
1331}
1332
Vivien Didelotf1394b782017-05-01 14:05:22 -04001333static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1334 struct mv88e6xxx_vtu_entry *entry)
1335{
1336 if (!chip->info->ops->vtu_getnext)
1337 return -EOPNOTSUPP;
1338
1339 return chip->info->ops->vtu_getnext(chip, entry);
1340}
1341
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001342static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1343 struct mv88e6xxx_vtu_entry *entry)
1344{
1345 if (!chip->info->ops->vtu_loadpurge)
1346 return -EOPNOTSUPP;
1347
1348 return chip->info->ops->vtu_loadpurge(chip, entry);
1349}
1350
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001351static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001352{
1353 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001354 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001355 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001356
1357 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1358
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001359 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001360 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001361 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001362 if (err)
1363 return err;
1364
1365 set_bit(*fid, fid_bitmap);
1366 }
1367
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001368 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001369 vlan.vid = chip->info->max_vid;
1370 vlan.valid = false;
1371
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001372 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001373 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001374 if (err)
1375 return err;
1376
1377 if (!vlan.valid)
1378 break;
1379
1380 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001381 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001382
1383 /* The reset value 0x000 is used to indicate that multiple address
1384 * databases are not needed. Return the next positive available.
1385 */
1386 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001387 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001388 return -ENOSPC;
1389
1390 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001391 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001392}
1393
Andrew Lunn23e8b472019-10-25 01:03:52 +02001394static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1395{
1396 if (chip->info->ops->atu_get_hash)
1397 return chip->info->ops->atu_get_hash(chip, hash);
1398
1399 return -EOPNOTSUPP;
1400}
1401
1402static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1403{
1404 if (chip->info->ops->atu_set_hash)
1405 return chip->info->ops->atu_set_hash(chip, hash);
1406
1407 return -EOPNOTSUPP;
1408}
1409
Vivien Didelotda9c3592016-02-12 12:09:40 -05001410static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1411 u16 vid_begin, u16 vid_end)
1412{
Vivien Didelot04bed142016-08-31 18:06:13 -04001413 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001414 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001415 int i, err;
1416
Andrew Lunndb06ae412017-09-25 23:32:20 +02001417 /* DSA and CPU ports have to be members of multiple vlans */
1418 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1419 return 0;
1420
Vivien Didelotda9c3592016-02-12 12:09:40 -05001421 if (!vid_begin)
1422 return -EOPNOTSUPP;
1423
Vivien Didelot425d2d32019-08-01 14:36:34 -04001424 vlan.vid = vid_begin - 1;
1425 vlan.valid = false;
1426
Vivien Didelotda9c3592016-02-12 12:09:40 -05001427 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001428 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001429 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001430 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001431
1432 if (!vlan.valid)
1433 break;
1434
1435 if (vlan.vid > vid_end)
1436 break;
1437
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001438 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001439 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1440 continue;
1441
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001442 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001443 continue;
1444
Vivien Didelotbd00e052017-05-01 14:05:11 -04001445 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001446 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001447 continue;
1448
Vivien Didelotc8652c82017-10-16 11:12:19 -04001449 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001450 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001451 break; /* same bridge, check next VLAN */
1452
Vivien Didelotc8652c82017-10-16 11:12:19 -04001453 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001454 continue;
1455
Andrew Lunn743fcc22017-11-09 22:29:54 +01001456 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1457 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001458 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001459 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001460 }
1461 } while (vlan.vid < vid_end);
1462
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001463 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001464}
1465
Vivien Didelotf81ec902016-05-09 13:22:58 -04001466static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1467 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001468{
Vivien Didelot04bed142016-08-31 18:06:13 -04001469 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001470 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1471 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001472 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001473
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001474 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001475 return -EOPNOTSUPP;
1476
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001477 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001478 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001479 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001480
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001481 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001482}
1483
Vivien Didelot57d32312016-06-20 13:13:58 -04001484static int
1485mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001486 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001487{
Vivien Didelot04bed142016-08-31 18:06:13 -04001488 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001489 int err;
1490
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001491 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001492 return -EOPNOTSUPP;
1493
Vivien Didelotda9c3592016-02-12 12:09:40 -05001494 /* If the requested port doesn't belong to the same bridge as the VLAN
1495 * members, do not support it (yet) and fallback to software VLAN.
1496 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001497 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001498 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1499 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001500 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001501
Vivien Didelot76e398a2015-11-01 12:33:55 -05001502 /* We don't need any dynamic resource from the kernel (yet),
1503 * so skip the prepare phase.
1504 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001505 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001506}
1507
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001508static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1509 const unsigned char *addr, u16 vid,
1510 u8 state)
1511{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001512 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001513 struct mv88e6xxx_vtu_entry vlan;
1514 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001515 int err;
1516
1517 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001518 if (vid == 0) {
1519 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1520 if (err)
1521 return err;
1522 } else {
1523 vlan.vid = vid - 1;
1524 vlan.valid = false;
1525
1526 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1527 if (err)
1528 return err;
1529
1530 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1531 if (vlan.vid != vid || !vlan.valid)
1532 return -EOPNOTSUPP;
1533
1534 fid = vlan.fid;
1535 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001536
Vivien Didelotd8291a92019-09-07 16:00:47 -04001537 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001538 ether_addr_copy(entry.mac, addr);
1539 eth_addr_dec(entry.mac);
1540
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001541 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001542 if (err)
1543 return err;
1544
1545 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001546 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001547 memset(&entry, 0, sizeof(entry));
1548 ether_addr_copy(entry.mac, addr);
1549 }
1550
1551 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001552 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001553 entry.portvec &= ~BIT(port);
1554 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001555 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001556 } else {
1557 entry.portvec |= BIT(port);
1558 entry.state = state;
1559 }
1560
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001561 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001562}
1563
Vivien Didelotda7dc872019-09-07 16:00:49 -04001564static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1565 const struct mv88e6xxx_policy *policy)
1566{
1567 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1568 enum mv88e6xxx_policy_action action = policy->action;
1569 const u8 *addr = policy->addr;
1570 u16 vid = policy->vid;
1571 u8 state;
1572 int err;
1573 int id;
1574
1575 if (!chip->info->ops->port_set_policy)
1576 return -EOPNOTSUPP;
1577
1578 switch (mapping) {
1579 case MV88E6XXX_POLICY_MAPPING_DA:
1580 case MV88E6XXX_POLICY_MAPPING_SA:
1581 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1582 state = 0; /* Dissociate the port and address */
1583 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1584 is_multicast_ether_addr(addr))
1585 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1586 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1587 is_unicast_ether_addr(addr))
1588 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1589 else
1590 return -EOPNOTSUPP;
1591
1592 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1593 state);
1594 if (err)
1595 return err;
1596 break;
1597 default:
1598 return -EOPNOTSUPP;
1599 }
1600
1601 /* Skip the port's policy clearing if the mapping is still in use */
1602 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1603 idr_for_each_entry(&chip->policies, policy, id)
1604 if (policy->port == port &&
1605 policy->mapping == mapping &&
1606 policy->action != action)
1607 return 0;
1608
1609 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1610}
1611
1612static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1613 struct ethtool_rx_flow_spec *fs)
1614{
1615 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1616 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1617 enum mv88e6xxx_policy_mapping mapping;
1618 enum mv88e6xxx_policy_action action;
1619 struct mv88e6xxx_policy *policy;
1620 u16 vid = 0;
1621 u8 *addr;
1622 int err;
1623 int id;
1624
1625 if (fs->location != RX_CLS_LOC_ANY)
1626 return -EINVAL;
1627
1628 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1629 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1630 else
1631 return -EOPNOTSUPP;
1632
1633 switch (fs->flow_type & ~FLOW_EXT) {
1634 case ETHER_FLOW:
1635 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1636 is_zero_ether_addr(mac_mask->h_source)) {
1637 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1638 addr = mac_entry->h_dest;
1639 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1640 !is_zero_ether_addr(mac_mask->h_source)) {
1641 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1642 addr = mac_entry->h_source;
1643 } else {
1644 /* Cannot support DA and SA mapping in the same rule */
1645 return -EOPNOTSUPP;
1646 }
1647 break;
1648 default:
1649 return -EOPNOTSUPP;
1650 }
1651
1652 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1653 if (fs->m_ext.vlan_tci != 0xffff)
1654 return -EOPNOTSUPP;
1655 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1656 }
1657
1658 idr_for_each_entry(&chip->policies, policy, id) {
1659 if (policy->port == port && policy->mapping == mapping &&
1660 policy->action == action && policy->vid == vid &&
1661 ether_addr_equal(policy->addr, addr))
1662 return -EEXIST;
1663 }
1664
1665 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1666 if (!policy)
1667 return -ENOMEM;
1668
1669 fs->location = 0;
1670 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1671 GFP_KERNEL);
1672 if (err) {
1673 devm_kfree(chip->dev, policy);
1674 return err;
1675 }
1676
1677 memcpy(&policy->fs, fs, sizeof(*fs));
1678 ether_addr_copy(policy->addr, addr);
1679 policy->mapping = mapping;
1680 policy->action = action;
1681 policy->port = port;
1682 policy->vid = vid;
1683
1684 err = mv88e6xxx_policy_apply(chip, port, policy);
1685 if (err) {
1686 idr_remove(&chip->policies, fs->location);
1687 devm_kfree(chip->dev, policy);
1688 return err;
1689 }
1690
1691 return 0;
1692}
1693
1694static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1695 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1696{
1697 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1698 struct mv88e6xxx_chip *chip = ds->priv;
1699 struct mv88e6xxx_policy *policy;
1700 int err;
1701 int id;
1702
1703 mv88e6xxx_reg_lock(chip);
1704
1705 switch (rxnfc->cmd) {
1706 case ETHTOOL_GRXCLSRLCNT:
1707 rxnfc->data = 0;
1708 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1709 rxnfc->rule_cnt = 0;
1710 idr_for_each_entry(&chip->policies, policy, id)
1711 if (policy->port == port)
1712 rxnfc->rule_cnt++;
1713 err = 0;
1714 break;
1715 case ETHTOOL_GRXCLSRULE:
1716 err = -ENOENT;
1717 policy = idr_find(&chip->policies, fs->location);
1718 if (policy) {
1719 memcpy(fs, &policy->fs, sizeof(*fs));
1720 err = 0;
1721 }
1722 break;
1723 case ETHTOOL_GRXCLSRLALL:
1724 rxnfc->data = 0;
1725 rxnfc->rule_cnt = 0;
1726 idr_for_each_entry(&chip->policies, policy, id)
1727 if (policy->port == port)
1728 rule_locs[rxnfc->rule_cnt++] = id;
1729 err = 0;
1730 break;
1731 default:
1732 err = -EOPNOTSUPP;
1733 break;
1734 }
1735
1736 mv88e6xxx_reg_unlock(chip);
1737
1738 return err;
1739}
1740
1741static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1742 struct ethtool_rxnfc *rxnfc)
1743{
1744 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1745 struct mv88e6xxx_chip *chip = ds->priv;
1746 struct mv88e6xxx_policy *policy;
1747 int err;
1748
1749 mv88e6xxx_reg_lock(chip);
1750
1751 switch (rxnfc->cmd) {
1752 case ETHTOOL_SRXCLSRLINS:
1753 err = mv88e6xxx_policy_insert(chip, port, fs);
1754 break;
1755 case ETHTOOL_SRXCLSRLDEL:
1756 err = -ENOENT;
1757 policy = idr_remove(&chip->policies, fs->location);
1758 if (policy) {
1759 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1760 err = mv88e6xxx_policy_apply(chip, port, policy);
1761 devm_kfree(chip->dev, policy);
1762 }
1763 break;
1764 default:
1765 err = -EOPNOTSUPP;
1766 break;
1767 }
1768
1769 mv88e6xxx_reg_unlock(chip);
1770
1771 return err;
1772}
1773
Andrew Lunn87fa8862017-11-09 22:29:56 +01001774static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1775 u16 vid)
1776{
1777 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1778 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1779
1780 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1781}
1782
1783static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1784{
1785 int port;
1786 int err;
1787
1788 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1789 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1790 if (err)
1791 return err;
1792 }
1793
1794 return 0;
1795}
1796
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001797static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001798 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001800 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001801 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001802 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001803
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001804 if (!vid)
1805 return -EOPNOTSUPP;
1806
1807 vlan.vid = vid - 1;
1808 vlan.valid = false;
1809
1810 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001811 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001812 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001813
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001814 if (vlan.vid != vid || !vlan.valid) {
1815 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001816
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001817 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1818 if (err)
1819 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001820
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001821 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1822 if (i == port)
1823 vlan.member[i] = member;
1824 else
1825 vlan.member[i] = non_member;
1826
1827 vlan.vid = vid;
1828 vlan.valid = true;
1829
1830 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1831 if (err)
1832 return err;
1833
1834 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1835 if (err)
1836 return err;
1837 } else if (vlan.member[port] != member) {
1838 vlan.member[port] = member;
1839
1840 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1841 if (err)
1842 return err;
1843 } else {
1844 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1845 port, vid);
1846 }
1847
1848 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001849}
1850
Vivien Didelotf81ec902016-05-09 13:22:58 -04001851static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001852 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001853{
Vivien Didelot04bed142016-08-31 18:06:13 -04001854 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001855 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1856 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001857 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001858 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001859
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001860 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001861 return;
1862
Vivien Didelotc91498e2017-06-07 18:12:13 -04001863 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001864 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001865 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001866 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001867 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001868 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001869
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001870 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001871
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001872 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001873 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001874 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1875 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001876
Vivien Didelot77064f32016-11-04 03:23:30 +01001877 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001878 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1879 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001880
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001881 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001882}
1883
Vivien Didelot521098922019-08-01 14:36:36 -04001884static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1885 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001886{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001887 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001888 int i, err;
1889
Vivien Didelot521098922019-08-01 14:36:36 -04001890 if (!vid)
1891 return -EOPNOTSUPP;
1892
1893 vlan.vid = vid - 1;
1894 vlan.valid = false;
1895
1896 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001897 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001898 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001899
Vivien Didelot521098922019-08-01 14:36:36 -04001900 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1901 * tell switchdev that this VLAN is likely handled in software.
1902 */
1903 if (vlan.vid != vid || !vlan.valid ||
1904 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001905 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001906
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001907 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001908
1909 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001910 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001911 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001912 if (vlan.member[i] !=
1913 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001914 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001915 break;
1916 }
1917 }
1918
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001919 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001920 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001921 return err;
1922
Vivien Didelote606ca32017-03-11 16:12:55 -05001923 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001924}
1925
Vivien Didelotf81ec902016-05-09 13:22:58 -04001926static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1927 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001928{
Vivien Didelot04bed142016-08-31 18:06:13 -04001929 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001930 u16 pvid, vid;
1931 int err = 0;
1932
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001933 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001934 return -EOPNOTSUPP;
1935
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001936 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001937
Vivien Didelot77064f32016-11-04 03:23:30 +01001938 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001939 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001940 goto unlock;
1941
Vivien Didelot76e398a2015-11-01 12:33:55 -05001942 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001943 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001944 if (err)
1945 goto unlock;
1946
1947 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001948 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001949 if (err)
1950 goto unlock;
1951 }
1952 }
1953
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001954unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001955 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001956
1957 return err;
1958}
1959
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001960static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1961 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001962{
Vivien Didelot04bed142016-08-31 18:06:13 -04001963 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001964 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001965
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001966 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001967 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1968 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001969 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001970
1971 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001972}
1973
Vivien Didelotf81ec902016-05-09 13:22:58 -04001974static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001975 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001976{
Vivien Didelot04bed142016-08-31 18:06:13 -04001977 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001978 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001979
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001980 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04001981 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001982 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001983
Vivien Didelot83dabd12016-08-31 11:50:04 -04001984 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001985}
1986
Vivien Didelot83dabd12016-08-31 11:50:04 -04001987static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1988 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001989 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001990{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001991 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001992 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001993 int err;
1994
Vivien Didelotd8291a92019-09-07 16:00:47 -04001995 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001996 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001997
1998 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001999 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002000 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002001 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002002
Vivien Didelotd8291a92019-09-07 16:00:47 -04002003 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002004 break;
2005
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002006 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002007 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002008
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002009 if (!is_unicast_ether_addr(addr.mac))
2010 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002011
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002012 is_static = (addr.state ==
2013 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2014 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002015 if (err)
2016 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002017 } while (!is_broadcast_ether_addr(addr.mac));
2018
2019 return err;
2020}
2021
Vivien Didelot83dabd12016-08-31 11:50:04 -04002022static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002023 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002024{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002025 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002026 u16 fid;
2027 int err;
2028
2029 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002030 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002031 if (err)
2032 return err;
2033
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002034 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002035 if (err)
2036 return err;
2037
2038 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002039 vlan.vid = chip->info->max_vid;
2040 vlan.valid = false;
2041
Vivien Didelot83dabd12016-08-31 11:50:04 -04002042 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002043 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002044 if (err)
2045 return err;
2046
2047 if (!vlan.valid)
2048 break;
2049
2050 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002051 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002052 if (err)
2053 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002054 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002055
2056 return err;
2057}
2058
Vivien Didelotf81ec902016-05-09 13:22:58 -04002059static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002060 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002061{
Vivien Didelot04bed142016-08-31 18:06:13 -04002062 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002063 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002064
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002065 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002066 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002067 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002068
2069 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002070}
2071
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002072static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2073 struct net_device *br)
2074{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002075 struct dsa_switch *ds = chip->ds;
2076 struct dsa_switch_tree *dst = ds->dst;
2077 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002078 int err;
2079
Vivien Didelotef2025e2019-10-21 16:51:27 -04002080 list_for_each_entry(dp, &dst->ports, list) {
2081 if (dp->bridge_dev == br) {
2082 if (dp->ds == ds) {
2083 /* This is a local bridge group member,
2084 * remap its Port VLAN Map.
2085 */
2086 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2087 if (err)
2088 return err;
2089 } else {
2090 /* This is an external bridge group member,
2091 * remap its cross-chip Port VLAN Table entry.
2092 */
2093 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2094 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002095 if (err)
2096 return err;
2097 }
2098 }
2099 }
2100
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002101 return 0;
2102}
2103
Vivien Didelotf81ec902016-05-09 13:22:58 -04002104static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002105 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002106{
Vivien Didelot04bed142016-08-31 18:06:13 -04002107 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002108 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002109
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002110 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002111 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002112 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002113
Vivien Didelot466dfa02016-02-26 13:16:05 -05002114 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002115}
2116
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002117static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2118 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002119{
Vivien Didelot04bed142016-08-31 18:06:13 -04002120 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002121
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002122 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002123 if (mv88e6xxx_bridge_map(chip, br) ||
2124 mv88e6xxx_port_vlan_map(chip, port))
2125 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002126 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002127}
2128
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002129static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2130 int port, struct net_device *br)
2131{
2132 struct mv88e6xxx_chip *chip = ds->priv;
2133 int err;
2134
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002135 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002136 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002137 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002138
2139 return err;
2140}
2141
2142static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2143 int port, struct net_device *br)
2144{
2145 struct mv88e6xxx_chip *chip = ds->priv;
2146
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002147 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002148 if (mv88e6xxx_pvt_map(chip, dev, port))
2149 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002150 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002151}
2152
Vivien Didelot17e708b2016-12-05 17:30:27 -05002153static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2154{
2155 if (chip->info->ops->reset)
2156 return chip->info->ops->reset(chip);
2157
2158 return 0;
2159}
2160
Vivien Didelot309eca62016-12-05 17:30:26 -05002161static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2162{
2163 struct gpio_desc *gpiod = chip->reset;
2164
2165 /* If there is a GPIO connected to the reset pin, toggle it */
2166 if (gpiod) {
2167 gpiod_set_value_cansleep(gpiod, 1);
2168 usleep_range(10000, 20000);
2169 gpiod_set_value_cansleep(gpiod, 0);
2170 usleep_range(10000, 20000);
2171 }
2172}
2173
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002174static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2175{
2176 int i, err;
2177
2178 /* Set all ports to the Disabled state */
2179 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002180 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002181 if (err)
2182 return err;
2183 }
2184
2185 /* Wait for transmit queues to drain,
2186 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2187 */
2188 usleep_range(2000, 4000);
2189
2190 return 0;
2191}
2192
Vivien Didelotfad09c72016-06-21 12:28:20 -04002193static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002194{
Vivien Didelota935c052016-09-29 12:21:53 -04002195 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002196
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002197 err = mv88e6xxx_disable_ports(chip);
2198 if (err)
2199 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002200
Vivien Didelot309eca62016-12-05 17:30:26 -05002201 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002202
Vivien Didelot17e708b2016-12-05 17:30:27 -05002203 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002204}
2205
Vivien Didelot43145572017-03-11 16:12:59 -05002206static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002207 enum mv88e6xxx_frame_mode frame,
2208 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002209{
2210 int err;
2211
Vivien Didelot43145572017-03-11 16:12:59 -05002212 if (!chip->info->ops->port_set_frame_mode)
2213 return -EOPNOTSUPP;
2214
2215 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002216 if (err)
2217 return err;
2218
Vivien Didelot43145572017-03-11 16:12:59 -05002219 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2220 if (err)
2221 return err;
2222
2223 if (chip->info->ops->port_set_ether_type)
2224 return chip->info->ops->port_set_ether_type(chip, port, etype);
2225
2226 return 0;
2227}
2228
2229static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2230{
2231 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002232 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002233 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002234}
2235
2236static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2237{
2238 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002239 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002240 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002241}
2242
2243static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2244{
2245 return mv88e6xxx_set_port_mode(chip, port,
2246 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002247 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2248 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002249}
2250
2251static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2252{
2253 if (dsa_is_dsa_port(chip->ds, port))
2254 return mv88e6xxx_set_port_mode_dsa(chip, port);
2255
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002256 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002257 return mv88e6xxx_set_port_mode_normal(chip, port);
2258
2259 /* Setup CPU port mode depending on its supported tag format */
2260 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2261 return mv88e6xxx_set_port_mode_dsa(chip, port);
2262
2263 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2264 return mv88e6xxx_set_port_mode_edsa(chip, port);
2265
2266 return -EINVAL;
2267}
2268
Vivien Didelotea698f42017-03-11 16:12:50 -05002269static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2270{
2271 bool message = dsa_is_dsa_port(chip->ds, port);
2272
2273 return mv88e6xxx_port_set_message_port(chip, port, message);
2274}
2275
Vivien Didelot601aeed2017-03-11 16:13:00 -05002276static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2277{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002278 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002279 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002280
David S. Miller407308f2019-06-15 13:35:29 -07002281 /* Upstream ports flood frames with unknown unicast or multicast DA */
2282 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2283 if (chip->info->ops->port_set_egress_floods)
2284 return chip->info->ops->port_set_egress_floods(chip, port,
2285 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002286
David S. Miller407308f2019-06-15 13:35:29 -07002287 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002288}
2289
Vivien Didelot45de77f2019-08-31 16:18:36 -04002290static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2291{
2292 struct mv88e6xxx_port *mvp = dev_id;
2293 struct mv88e6xxx_chip *chip = mvp->chip;
2294 irqreturn_t ret = IRQ_NONE;
2295 int port = mvp->port;
2296 u8 lane;
2297
2298 mv88e6xxx_reg_lock(chip);
2299 lane = mv88e6xxx_serdes_get_lane(chip, port);
2300 if (lane)
2301 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2302 mv88e6xxx_reg_unlock(chip);
2303
2304 return ret;
2305}
2306
2307static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2308 u8 lane)
2309{
2310 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2311 unsigned int irq;
2312 int err;
2313
2314 /* Nothing to request if this SERDES port has no IRQ */
2315 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2316 if (!irq)
2317 return 0;
2318
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002319 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2320 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2321
Vivien Didelot45de77f2019-08-31 16:18:36 -04002322 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2323 mv88e6xxx_reg_unlock(chip);
2324 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002325 IRQF_ONESHOT, dev_id->serdes_irq_name,
2326 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002327 mv88e6xxx_reg_lock(chip);
2328 if (err)
2329 return err;
2330
2331 dev_id->serdes_irq = irq;
2332
2333 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2334}
2335
2336static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2337 u8 lane)
2338{
2339 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2340 unsigned int irq = dev_id->serdes_irq;
2341 int err;
2342
2343 /* Nothing to free if no IRQ has been requested */
2344 if (!irq)
2345 return 0;
2346
2347 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2348
2349 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2350 mv88e6xxx_reg_unlock(chip);
2351 free_irq(irq, dev_id);
2352 mv88e6xxx_reg_lock(chip);
2353
2354 dev_id->serdes_irq = 0;
2355
2356 return err;
2357}
2358
Andrew Lunn6d917822017-05-26 01:03:21 +02002359static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2360 bool on)
2361{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002362 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002363 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002364
Vivien Didelotdc272f62019-08-31 16:18:33 -04002365 lane = mv88e6xxx_serdes_get_lane(chip, port);
2366 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002367 return 0;
2368
2369 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002370 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002371 if (err)
2372 return err;
2373
Vivien Didelot45de77f2019-08-31 16:18:36 -04002374 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002375 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002376 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2377 if (err)
2378 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002379
Vivien Didelotdc272f62019-08-31 16:18:33 -04002380 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002381 }
2382
2383 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002384}
2385
Vivien Didelotfa371c82017-12-05 15:34:10 -05002386static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2387{
2388 struct dsa_switch *ds = chip->ds;
2389 int upstream_port;
2390 int err;
2391
Vivien Didelot07073c72017-12-05 15:34:13 -05002392 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002393 if (chip->info->ops->port_set_upstream_port) {
2394 err = chip->info->ops->port_set_upstream_port(chip, port,
2395 upstream_port);
2396 if (err)
2397 return err;
2398 }
2399
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002400 if (port == upstream_port) {
2401 if (chip->info->ops->set_cpu_port) {
2402 err = chip->info->ops->set_cpu_port(chip,
2403 upstream_port);
2404 if (err)
2405 return err;
2406 }
2407
2408 if (chip->info->ops->set_egress_port) {
2409 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002410 MV88E6XXX_EGRESS_DIR_INGRESS,
2411 upstream_port);
2412 if (err)
2413 return err;
2414
2415 err = chip->info->ops->set_egress_port(chip,
2416 MV88E6XXX_EGRESS_DIR_EGRESS,
2417 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002418 if (err)
2419 return err;
2420 }
2421 }
2422
Vivien Didelotfa371c82017-12-05 15:34:10 -05002423 return 0;
2424}
2425
Vivien Didelotfad09c72016-06-21 12:28:20 -04002426static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002427{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002428 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002429 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002430 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002431
Andrew Lunn7b898462018-08-09 15:38:47 +02002432 chip->ports[port].chip = chip;
2433 chip->ports[port].port = port;
2434
Vivien Didelotd78343d2016-11-04 03:23:36 +01002435 /* MAC Forcing register: don't force link, speed, duplex or flow control
2436 * state to any particular values on physical ports, but force the CPU
2437 * port and all DSA ports to their maximum bandwidth and full duplex.
2438 */
2439 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2440 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2441 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002442 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002443 PHY_INTERFACE_MODE_NA);
2444 else
2445 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2446 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002447 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002448 PHY_INTERFACE_MODE_NA);
2449 if (err)
2450 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002451
2452 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2453 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2454 * tunneling, determine priority by looking at 802.1p and IP
2455 * priority fields (IP prio has precedence), and set STP state
2456 * to Forwarding.
2457 *
2458 * If this is the CPU link, use DSA or EDSA tagging depending
2459 * on which tagging mode was configured.
2460 *
2461 * If this is a link to another switch, use DSA tagging mode.
2462 *
2463 * If this is the upstream port for this switch, enable
2464 * forwarding of unknown unicasts and multicasts.
2465 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002466 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2467 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2468 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2469 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002470 if (err)
2471 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002472
Vivien Didelot601aeed2017-03-11 16:13:00 -05002473 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002474 if (err)
2475 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002476
Vivien Didelot601aeed2017-03-11 16:13:00 -05002477 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002478 if (err)
2479 return err;
2480
Vivien Didelot8efdda42015-08-13 12:52:23 -04002481 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002482 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002483 * untagged frames on this port, do a destination address lookup on all
2484 * received packets as usual, disable ARP mirroring and don't send a
2485 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002486 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002487 err = mv88e6xxx_port_set_map_da(chip, port);
2488 if (err)
2489 return err;
2490
Vivien Didelotfa371c82017-12-05 15:34:10 -05002491 err = mv88e6xxx_setup_upstream_port(chip, port);
2492 if (err)
2493 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002494
Andrew Lunna23b2962017-02-04 20:15:28 +01002495 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002496 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002497 if (err)
2498 return err;
2499
Vivien Didelotcd782652017-06-08 18:34:13 -04002500 if (chip->info->ops->port_set_jumbo_size) {
2501 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002502 if (err)
2503 return err;
2504 }
2505
Andrew Lunn54d792f2015-05-06 01:09:47 +02002506 /* Port Association Vector: when learning source addresses
2507 * of packets, add the address to the address database using
2508 * a port bitmap that has only the bit for this port set and
2509 * the other bits clear.
2510 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002511 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002512 /* Disable learning for CPU port */
2513 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002514 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002515
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002516 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2517 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002518 if (err)
2519 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002520
2521 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002522 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2523 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002524 if (err)
2525 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002526
Vivien Didelot08984322017-06-08 18:34:12 -04002527 if (chip->info->ops->port_pause_limit) {
2528 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002529 if (err)
2530 return err;
2531 }
2532
Vivien Didelotc8c94892017-03-11 16:13:01 -05002533 if (chip->info->ops->port_disable_learn_limit) {
2534 err = chip->info->ops->port_disable_learn_limit(chip, port);
2535 if (err)
2536 return err;
2537 }
2538
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002539 if (chip->info->ops->port_disable_pri_override) {
2540 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002541 if (err)
2542 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002543 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002544
Andrew Lunnef0a7312016-12-03 04:35:16 +01002545 if (chip->info->ops->port_tag_remap) {
2546 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002547 if (err)
2548 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002549 }
2550
Andrew Lunnef70b112016-12-03 04:45:18 +01002551 if (chip->info->ops->port_egress_rate_limiting) {
2552 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002553 if (err)
2554 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002555 }
2556
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002557 if (chip->info->ops->port_setup_message_port) {
2558 err = chip->info->ops->port_setup_message_port(chip, port);
2559 if (err)
2560 return err;
2561 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002562
Vivien Didelot207afda2016-04-14 14:42:09 -04002563 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002564 * database, and allow bidirectional communication between the
2565 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002566 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002567 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002568 if (err)
2569 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002570
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002571 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002572 if (err)
2573 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002574
2575 /* Default VLAN ID and priority: don't set a default VLAN
2576 * ID, and set the default packet priority to zero.
2577 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002578 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002579}
2580
Andrew Lunn04aca992017-05-26 01:03:24 +02002581static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2582 struct phy_device *phydev)
2583{
2584 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002585 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002586
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002587 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002588 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002589 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002590
2591 return err;
2592}
2593
Andrew Lunn75104db2019-02-24 20:44:43 +01002594static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002595{
2596 struct mv88e6xxx_chip *chip = ds->priv;
2597
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002598 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002599 if (mv88e6xxx_serdes_power(chip, port, false))
2600 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002601 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002602}
2603
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002604static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2605 unsigned int ageing_time)
2606{
Vivien Didelot04bed142016-08-31 18:06:13 -04002607 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002608 int err;
2609
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002610 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002611 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002612 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002613
2614 return err;
2615}
2616
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002617static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002618{
2619 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002620
Andrew Lunnde2273872016-11-21 23:27:01 +01002621 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002622 if (chip->info->ops->stats_set_histogram) {
2623 err = chip->info->ops->stats_set_histogram(chip);
2624 if (err)
2625 return err;
2626 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002627
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002628 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002629}
2630
Andrew Lunnea890982019-01-09 00:24:03 +01002631/* Check if the errata has already been applied. */
2632static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2633{
2634 int port;
2635 int err;
2636 u16 val;
2637
2638 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002639 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002640 if (err) {
2641 dev_err(chip->dev,
2642 "Error reading hidden register: %d\n", err);
2643 return false;
2644 }
2645 if (val != 0x01c0)
2646 return false;
2647 }
2648
2649 return true;
2650}
2651
2652/* The 6390 copper ports have an errata which require poking magic
2653 * values into undocumented hidden registers and then performing a
2654 * software reset.
2655 */
2656static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2657{
2658 int port;
2659 int err;
2660
2661 if (mv88e6390_setup_errata_applied(chip))
2662 return 0;
2663
2664 /* Set the ports into blocking mode */
2665 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2666 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2667 if (err)
2668 return err;
2669 }
2670
2671 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002672 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002673 if (err)
2674 return err;
2675 }
2676
2677 return mv88e6xxx_software_reset(chip);
2678}
2679
Andrew Lunn23e8b472019-10-25 01:03:52 +02002680enum mv88e6xxx_devlink_param_id {
2681 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2682 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2683};
2684
2685static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2686 struct devlink_param_gset_ctx *ctx)
2687{
2688 struct mv88e6xxx_chip *chip = ds->priv;
2689 int err;
2690
2691 mv88e6xxx_reg_lock(chip);
2692
2693 switch (id) {
2694 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2695 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2696 break;
2697 default:
2698 err = -EOPNOTSUPP;
2699 break;
2700 }
2701
2702 mv88e6xxx_reg_unlock(chip);
2703
2704 return err;
2705}
2706
2707static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2708 struct devlink_param_gset_ctx *ctx)
2709{
2710 struct mv88e6xxx_chip *chip = ds->priv;
2711 int err;
2712
2713 mv88e6xxx_reg_lock(chip);
2714
2715 switch (id) {
2716 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2717 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2718 break;
2719 default:
2720 err = -EOPNOTSUPP;
2721 break;
2722 }
2723
2724 mv88e6xxx_reg_unlock(chip);
2725
2726 return err;
2727}
2728
2729static const struct devlink_param mv88e6xxx_devlink_params[] = {
2730 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2731 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2732 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2733};
2734
2735static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2736{
2737 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2738 ARRAY_SIZE(mv88e6xxx_devlink_params));
2739}
2740
2741static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2742{
2743 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2744 ARRAY_SIZE(mv88e6xxx_devlink_params));
2745}
2746
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002747enum mv88e6xxx_devlink_resource_id {
2748 MV88E6XXX_RESOURCE_ID_ATU,
2749 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2750 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2751 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2752 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2753};
2754
2755static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2756 u16 bin)
2757{
2758 u16 occupancy = 0;
2759 int err;
2760
2761 mv88e6xxx_reg_lock(chip);
2762
2763 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2764 bin);
2765 if (err) {
2766 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2767 goto unlock;
2768 }
2769
2770 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2771 if (err) {
2772 dev_err(chip->dev, "failed to perform ATU get next\n");
2773 goto unlock;
2774 }
2775
2776 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2777 if (err) {
2778 dev_err(chip->dev, "failed to get ATU stats\n");
2779 goto unlock;
2780 }
2781
2782unlock:
2783 mv88e6xxx_reg_unlock(chip);
2784
2785 return occupancy;
2786}
2787
2788static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2789{
2790 struct mv88e6xxx_chip *chip = priv;
2791
2792 return mv88e6xxx_devlink_atu_bin_get(chip,
2793 MV88E6XXX_G2_ATU_STATS_BIN_0);
2794}
2795
2796static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2797{
2798 struct mv88e6xxx_chip *chip = priv;
2799
2800 return mv88e6xxx_devlink_atu_bin_get(chip,
2801 MV88E6XXX_G2_ATU_STATS_BIN_1);
2802}
2803
2804static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2805{
2806 struct mv88e6xxx_chip *chip = priv;
2807
2808 return mv88e6xxx_devlink_atu_bin_get(chip,
2809 MV88E6XXX_G2_ATU_STATS_BIN_2);
2810}
2811
2812static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2813{
2814 struct mv88e6xxx_chip *chip = priv;
2815
2816 return mv88e6xxx_devlink_atu_bin_get(chip,
2817 MV88E6XXX_G2_ATU_STATS_BIN_3);
2818}
2819
2820static u64 mv88e6xxx_devlink_atu_get(void *priv)
2821{
2822 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2823 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2824 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2825 mv88e6xxx_devlink_atu_bin_3_get(priv);
2826}
2827
2828static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2829{
2830 struct devlink_resource_size_params size_params;
2831 struct mv88e6xxx_chip *chip = ds->priv;
2832 int err;
2833
2834 devlink_resource_size_params_init(&size_params,
2835 mv88e6xxx_num_macs(chip),
2836 mv88e6xxx_num_macs(chip),
2837 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2838
2839 err = dsa_devlink_resource_register(ds, "ATU",
2840 mv88e6xxx_num_macs(chip),
2841 MV88E6XXX_RESOURCE_ID_ATU,
2842 DEVLINK_RESOURCE_ID_PARENT_TOP,
2843 &size_params);
2844 if (err)
2845 goto out;
2846
2847 devlink_resource_size_params_init(&size_params,
2848 mv88e6xxx_num_macs(chip) / 4,
2849 mv88e6xxx_num_macs(chip) / 4,
2850 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2851
2852 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2853 mv88e6xxx_num_macs(chip) / 4,
2854 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2855 MV88E6XXX_RESOURCE_ID_ATU,
2856 &size_params);
2857 if (err)
2858 goto out;
2859
2860 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2861 mv88e6xxx_num_macs(chip) / 4,
2862 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2863 MV88E6XXX_RESOURCE_ID_ATU,
2864 &size_params);
2865 if (err)
2866 goto out;
2867
2868 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2869 mv88e6xxx_num_macs(chip) / 4,
2870 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2871 MV88E6XXX_RESOURCE_ID_ATU,
2872 &size_params);
2873 if (err)
2874 goto out;
2875
2876 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2877 mv88e6xxx_num_macs(chip) / 4,
2878 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2879 MV88E6XXX_RESOURCE_ID_ATU,
2880 &size_params);
2881 if (err)
2882 goto out;
2883
2884 dsa_devlink_resource_occ_get_register(ds,
2885 MV88E6XXX_RESOURCE_ID_ATU,
2886 mv88e6xxx_devlink_atu_get,
2887 chip);
2888
2889 dsa_devlink_resource_occ_get_register(ds,
2890 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2891 mv88e6xxx_devlink_atu_bin_0_get,
2892 chip);
2893
2894 dsa_devlink_resource_occ_get_register(ds,
2895 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2896 mv88e6xxx_devlink_atu_bin_1_get,
2897 chip);
2898
2899 dsa_devlink_resource_occ_get_register(ds,
2900 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2901 mv88e6xxx_devlink_atu_bin_2_get,
2902 chip);
2903
2904 dsa_devlink_resource_occ_get_register(ds,
2905 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2906 mv88e6xxx_devlink_atu_bin_3_get,
2907 chip);
2908
2909 return 0;
2910
2911out:
2912 dsa_devlink_resources_unregister(ds);
2913 return err;
2914}
2915
Andrew Lunn23e8b472019-10-25 01:03:52 +02002916static void mv88e6xxx_teardown(struct dsa_switch *ds)
2917{
2918 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002919 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002920}
2921
Vivien Didelotf81ec902016-05-09 13:22:58 -04002922static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002923{
Vivien Didelot04bed142016-08-31 18:06:13 -04002924 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002925 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002926 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002927 int i;
2928
Vivien Didelotfad09c72016-06-21 12:28:20 -04002929 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002930 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002931
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002932 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002933
Andrew Lunnea890982019-01-09 00:24:03 +01002934 if (chip->info->ops->setup_errata) {
2935 err = chip->info->ops->setup_errata(chip);
2936 if (err)
2937 goto unlock;
2938 }
2939
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002940 /* Cache the cmode of each port. */
2941 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2942 if (chip->info->ops->port_get_cmode) {
2943 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2944 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002945 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002946
2947 chip->ports[i].cmode = cmode;
2948 }
2949 }
2950
Vivien Didelot97299342016-07-18 20:45:30 -04002951 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002952 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002953 if (dsa_is_unused_port(ds, i))
2954 continue;
2955
Hubert Feursteinc8574862019-07-31 10:23:48 +02002956 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002957 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002958 dev_err(chip->dev, "port %d is invalid\n", i);
2959 err = -EINVAL;
2960 goto unlock;
2961 }
2962
Vivien Didelot97299342016-07-18 20:45:30 -04002963 err = mv88e6xxx_setup_port(chip, i);
2964 if (err)
2965 goto unlock;
2966 }
2967
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002968 err = mv88e6xxx_irl_setup(chip);
2969 if (err)
2970 goto unlock;
2971
Vivien Didelot04a69a12017-10-13 14:18:05 -04002972 err = mv88e6xxx_mac_setup(chip);
2973 if (err)
2974 goto unlock;
2975
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002976 err = mv88e6xxx_phy_setup(chip);
2977 if (err)
2978 goto unlock;
2979
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002980 err = mv88e6xxx_vtu_setup(chip);
2981 if (err)
2982 goto unlock;
2983
Vivien Didelot81228992017-03-30 17:37:08 -04002984 err = mv88e6xxx_pvt_setup(chip);
2985 if (err)
2986 goto unlock;
2987
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002988 err = mv88e6xxx_atu_setup(chip);
2989 if (err)
2990 goto unlock;
2991
Andrew Lunn87fa8862017-11-09 22:29:56 +01002992 err = mv88e6xxx_broadcast_setup(chip, 0);
2993 if (err)
2994 goto unlock;
2995
Vivien Didelot9e907d72017-07-17 13:03:43 -04002996 err = mv88e6xxx_pot_setup(chip);
2997 if (err)
2998 goto unlock;
2999
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003000 err = mv88e6xxx_rmu_setup(chip);
3001 if (err)
3002 goto unlock;
3003
Vivien Didelot51c901a2017-07-17 13:03:41 -04003004 err = mv88e6xxx_rsvd2cpu_setup(chip);
3005 if (err)
3006 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003007
Vivien Didelotb28f8722018-04-26 21:56:44 -04003008 err = mv88e6xxx_trunk_setup(chip);
3009 if (err)
3010 goto unlock;
3011
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003012 err = mv88e6xxx_devmap_setup(chip);
3013 if (err)
3014 goto unlock;
3015
Vivien Didelot93e18d62018-05-11 17:16:35 -04003016 err = mv88e6xxx_pri_setup(chip);
3017 if (err)
3018 goto unlock;
3019
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003020 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003021 if (chip->info->ptp_support) {
3022 err = mv88e6xxx_ptp_setup(chip);
3023 if (err)
3024 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003025
3026 err = mv88e6xxx_hwtstamp_setup(chip);
3027 if (err)
3028 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003029 }
3030
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003031 err = mv88e6xxx_stats_setup(chip);
3032 if (err)
3033 goto unlock;
3034
Vivien Didelot6b17e862015-08-13 12:52:18 -04003035unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003036 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003037
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003038 if (err)
3039 return err;
3040
3041 /* Have to be called without holding the register lock, since
3042 * they take the devlink lock, and we later take the locks in
3043 * the reverse order when getting/setting parameters or
3044 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003045 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003046 err = mv88e6xxx_setup_devlink_resources(ds);
3047 if (err)
3048 return err;
3049
3050 err = mv88e6xxx_setup_devlink_params(ds);
3051 if (err)
3052 dsa_devlink_resources_unregister(ds);
3053
3054 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003055}
3056
Vivien Didelote57e5e72016-08-15 17:19:00 -04003057static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003058{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003059 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3060 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003061 u16 val;
3062 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003063
Andrew Lunnee26a222017-01-24 14:53:48 +01003064 if (!chip->info->ops->phy_read)
3065 return -EOPNOTSUPP;
3066
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003067 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003068 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003069 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003070
Andrew Lunnda9f3302017-02-01 03:40:05 +01003071 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003072 /* Some internal PHYs don't have a model number. */
3073 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3074 /* Then there is the 6165 family. It gets is
3075 * PHYs correct. But it can also have two
3076 * SERDES interfaces in the PHY address
3077 * space. And these don't have a model
3078 * number. But they are not PHYs, so we don't
3079 * want to give them something a PHY driver
3080 * will recognise.
3081 *
3082 * Use the mv88e6390 family model number
3083 * instead, for anything which really could be
3084 * a PHY,
3085 */
3086 if (!(val & 0x3f0))
3087 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003088 }
3089
Vivien Didelote57e5e72016-08-15 17:19:00 -04003090 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003091}
3092
Vivien Didelote57e5e72016-08-15 17:19:00 -04003093static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003094{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003095 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3096 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003097 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003098
Andrew Lunnee26a222017-01-24 14:53:48 +01003099 if (!chip->info->ops->phy_write)
3100 return -EOPNOTSUPP;
3101
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003102 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003103 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003104 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003105
3106 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003107}
3108
Vivien Didelotfad09c72016-06-21 12:28:20 -04003109static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003110 struct device_node *np,
3111 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003112{
3113 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003114 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003115 struct mii_bus *bus;
3116 int err;
3117
Andrew Lunn2510bab2018-02-22 01:51:49 +01003118 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003119 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003120 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003121 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003122
3123 if (err)
3124 return err;
3125 }
3126
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003127 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003128 if (!bus)
3129 return -ENOMEM;
3130
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003131 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003132 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003133 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003134 INIT_LIST_HEAD(&mdio_bus->list);
3135 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003136
Andrew Lunnb516d452016-06-04 21:17:06 +02003137 if (np) {
3138 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003139 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003140 } else {
3141 bus->name = "mv88e6xxx SMI";
3142 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3143 }
3144
3145 bus->read = mv88e6xxx_mdio_read;
3146 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003147 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003148
Andrew Lunn6f882842018-03-17 20:32:05 +01003149 if (!external) {
3150 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3151 if (err)
3152 return err;
3153 }
3154
Florian Fainelli00e798c2018-05-15 16:56:19 -07003155 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003156 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003157 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003158 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003159 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003160 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003161
3162 if (external)
3163 list_add_tail(&mdio_bus->list, &chip->mdios);
3164 else
3165 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003166
3167 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003168}
3169
Andrew Lunna3c53be52017-01-24 14:53:50 +01003170static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3171 { .compatible = "marvell,mv88e6xxx-mdio-external",
3172 .data = (void *)true },
3173 { },
3174};
3175
Andrew Lunn3126aee2017-12-07 01:05:57 +01003176static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3177
3178{
3179 struct mv88e6xxx_mdio_bus *mdio_bus;
3180 struct mii_bus *bus;
3181
3182 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3183 bus = mdio_bus->bus;
3184
Andrew Lunn6f882842018-03-17 20:32:05 +01003185 if (!mdio_bus->external)
3186 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3187
Andrew Lunn3126aee2017-12-07 01:05:57 +01003188 mdiobus_unregister(bus);
3189 }
3190}
3191
Andrew Lunna3c53be52017-01-24 14:53:50 +01003192static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3193 struct device_node *np)
3194{
3195 const struct of_device_id *match;
3196 struct device_node *child;
3197 int err;
3198
3199 /* Always register one mdio bus for the internal/default mdio
3200 * bus. This maybe represented in the device tree, but is
3201 * optional.
3202 */
3203 child = of_get_child_by_name(np, "mdio");
3204 err = mv88e6xxx_mdio_register(chip, child, false);
3205 if (err)
3206 return err;
3207
3208 /* Walk the device tree, and see if there are any other nodes
3209 * which say they are compatible with the external mdio
3210 * bus.
3211 */
3212 for_each_available_child_of_node(np, child) {
3213 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3214 if (match) {
3215 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003216 if (err) {
3217 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303218 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003219 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003220 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003221 }
3222 }
3223
3224 return 0;
3225}
3226
Vivien Didelot855b1932016-07-20 18:18:35 -04003227static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3228{
Vivien Didelot04bed142016-08-31 18:06:13 -04003229 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003230
3231 return chip->eeprom_len;
3232}
3233
Vivien Didelot855b1932016-07-20 18:18:35 -04003234static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3235 struct ethtool_eeprom *eeprom, u8 *data)
3236{
Vivien Didelot04bed142016-08-31 18:06:13 -04003237 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003238 int err;
3239
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003240 if (!chip->info->ops->get_eeprom)
3241 return -EOPNOTSUPP;
3242
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003243 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003244 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003245 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003246
3247 if (err)
3248 return err;
3249
3250 eeprom->magic = 0xc3ec4951;
3251
3252 return 0;
3253}
3254
Vivien Didelot855b1932016-07-20 18:18:35 -04003255static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3256 struct ethtool_eeprom *eeprom, u8 *data)
3257{
Vivien Didelot04bed142016-08-31 18:06:13 -04003258 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003259 int err;
3260
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003261 if (!chip->info->ops->set_eeprom)
3262 return -EOPNOTSUPP;
3263
Vivien Didelot855b1932016-07-20 18:18:35 -04003264 if (eeprom->magic != 0xc3ec4951)
3265 return -EINVAL;
3266
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003267 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003268 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003269 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003270
3271 return err;
3272}
3273
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003274static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003275 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003276 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3277 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003278 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003279 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003280 .phy_read = mv88e6185_phy_ppu_read,
3281 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003282 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003283 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003284 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003285 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003286 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003287 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003288 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003289 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003290 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003291 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003292 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003293 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003294 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003295 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003296 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003297 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003298 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3299 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003300 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003301 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3302 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003303 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003304 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003305 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003306 .ppu_enable = mv88e6185_g1_ppu_enable,
3307 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003308 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003309 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003310 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003311 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003312 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003313};
3314
3315static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003316 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003317 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3318 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003319 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003320 .phy_read = mv88e6185_phy_ppu_read,
3321 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003322 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003323 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003324 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003325 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003326 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003327 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003328 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003329 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003330 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003331 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003332 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003333 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3334 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003335 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003336 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003337 .ppu_enable = mv88e6185_g1_ppu_enable,
3338 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003339 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003340 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003341 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003342 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003343};
3344
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003345static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003346 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003347 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3348 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003349 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003350 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3351 .phy_read = mv88e6xxx_g2_smi_phy_read,
3352 .phy_write = mv88e6xxx_g2_smi_phy_write,
3353 .port_set_link = mv88e6xxx_port_set_link,
3354 .port_set_duplex = mv88e6xxx_port_set_duplex,
3355 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003356 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003357 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003358 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003359 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003360 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003361 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003362 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003363 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003364 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003365 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003366 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003367 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003368 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003369 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003370 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3371 .stats_get_strings = mv88e6095_stats_get_strings,
3372 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003373 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3374 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003375 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003376 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003377 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003378 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003379 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003380 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003381 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003382 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003383};
3384
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003385static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003386 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003387 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3388 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003389 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003390 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003391 .phy_read = mv88e6xxx_g2_smi_phy_read,
3392 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003393 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003394 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003395 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003396 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003397 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003398 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003399 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003400 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003401 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003402 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003403 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003404 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003405 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3406 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003407 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003408 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3409 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003410 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003411 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003412 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003413 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003414 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3415 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003416 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003417 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003418 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003419};
3420
3421static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003422 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003423 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3424 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003425 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003426 .phy_read = mv88e6185_phy_ppu_read,
3427 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003428 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003429 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003430 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003431 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003432 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003433 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003434 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003435 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003436 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003437 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003438 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003439 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003440 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003441 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003442 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003443 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003444 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003445 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3446 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003447 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003448 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3449 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003450 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003451 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003452 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003453 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003454 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003455 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003456 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003457 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003458 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003459};
3460
Vivien Didelot990e27b2017-03-28 13:50:32 -04003461static const struct mv88e6xxx_ops mv88e6141_ops = {
3462 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003463 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3464 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003465 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003466 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3467 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3468 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3469 .phy_read = mv88e6xxx_g2_smi_phy_read,
3470 .phy_write = mv88e6xxx_g2_smi_phy_write,
3471 .port_set_link = mv88e6xxx_port_set_link,
3472 .port_set_duplex = mv88e6xxx_port_set_duplex,
3473 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003474 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003475 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003476 .port_tag_remap = mv88e6095_port_tag_remap,
3477 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3478 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3479 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003480 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003481 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003482 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003483 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3484 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003485 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003486 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003487 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003488 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003489 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003490 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003491 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3492 .stats_get_strings = mv88e6320_stats_get_strings,
3493 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003494 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3495 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003496 .watchdog_ops = &mv88e6390_watchdog_ops,
3497 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003498 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003499 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003500 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003501 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003502 .serdes_power = mv88e6390_serdes_power,
3503 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003504 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003505 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003506 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003507 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003508 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003509};
3510
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003511static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003512 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003513 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3514 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003515 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003516 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003517 .phy_read = mv88e6xxx_g2_smi_phy_read,
3518 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003519 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003520 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003521 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003522 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003523 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003524 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003525 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003526 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003527 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003528 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003529 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003530 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003531 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003532 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003533 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003534 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003535 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003536 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3537 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003538 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003539 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3540 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003541 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003542 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003543 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003544 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003545 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3546 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003547 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003548 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003549 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003550 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003551 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003552};
3553
3554static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003555 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003556 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3557 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003558 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003559 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003560 .phy_read = mv88e6165_phy_read,
3561 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003562 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003563 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003564 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003565 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003566 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003567 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003568 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003569 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003570 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003571 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003572 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3573 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003574 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003575 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3576 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003577 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003578 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003579 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003580 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003581 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3582 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003583 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003584 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003585 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003586 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003587 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003588};
3589
3590static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003591 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003592 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3593 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003594 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003595 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003596 .phy_read = mv88e6xxx_g2_smi_phy_read,
3597 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003598 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003599 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003600 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003601 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003602 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003603 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003604 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003605 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003606 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003607 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003608 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003609 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003610 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003611 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003612 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003613 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003614 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003615 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003616 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3617 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003618 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003619 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3620 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003621 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003622 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003623 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003624 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003625 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3626 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003627 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003628 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003629 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003630};
3631
3632static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003633 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003634 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3635 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003636 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003637 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3638 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003639 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003640 .phy_read = mv88e6xxx_g2_smi_phy_read,
3641 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003642 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003643 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003644 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003645 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003646 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003647 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003648 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003649 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003650 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003651 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003652 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003653 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003654 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003655 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003656 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003657 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003658 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003659 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003660 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003661 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3662 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003663 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003664 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3665 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003666 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003667 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003668 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003669 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003670 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003671 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3672 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003673 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003674 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003675 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003676 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003677 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3678 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003679 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003680 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003681};
3682
3683static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003684 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003685 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3686 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003687 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003688 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003689 .phy_read = mv88e6xxx_g2_smi_phy_read,
3690 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003691 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003692 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003693 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003694 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003695 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003696 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003697 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003698 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003699 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003700 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003701 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003702 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003703 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003704 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003705 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003706 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003707 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003708 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003709 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3710 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003711 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003712 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3713 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003714 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003715 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003716 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003717 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003718 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3719 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003720 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003721 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003722 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003723};
3724
3725static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003726 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003727 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3728 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003729 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003730 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3731 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003732 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003733 .phy_read = mv88e6xxx_g2_smi_phy_read,
3734 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003735 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003736 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003737 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003738 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003739 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003740 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003741 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003742 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003743 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003744 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003745 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003746 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003747 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003748 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003749 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003750 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003751 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003752 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003753 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003754 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3755 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003756 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003757 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3758 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003759 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003760 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003761 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003762 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003763 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003764 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3765 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003766 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003767 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003768 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003769 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003770 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003771 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003772 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003773 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3774 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003775 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003776 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003777};
3778
3779static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003780 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003781 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3782 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003783 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003784 .phy_read = mv88e6185_phy_ppu_read,
3785 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003786 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003787 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003788 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003789 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003790 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003791 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003792 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003793 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003794 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003795 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003796 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003797 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003798 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003799 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3800 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003801 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003802 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3803 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003804 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003805 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003806 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003807 .ppu_enable = mv88e6185_g1_ppu_enable,
3808 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003809 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003810 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003811 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003812 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003813};
3814
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003815static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003816 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003817 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003818 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003819 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3820 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003821 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3822 .phy_read = mv88e6xxx_g2_smi_phy_read,
3823 .phy_write = mv88e6xxx_g2_smi_phy_write,
3824 .port_set_link = mv88e6xxx_port_set_link,
3825 .port_set_duplex = mv88e6xxx_port_set_duplex,
3826 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3827 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003828 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003829 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003830 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003831 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003832 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003833 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003834 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003835 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003836 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003837 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003838 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003839 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003840 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003841 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003842 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003843 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3844 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003845 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003846 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3847 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003848 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003849 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003850 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003851 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003852 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003853 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3854 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003855 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3856 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003857 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003858 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003859 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003860 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003861 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003862 .serdes_get_strings = mv88e6390_serdes_get_strings,
3863 .serdes_get_stats = mv88e6390_serdes_get_stats,
3864 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003865 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003866 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003867};
3868
3869static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003870 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003871 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003872 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003873 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3874 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003875 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3876 .phy_read = mv88e6xxx_g2_smi_phy_read,
3877 .phy_write = mv88e6xxx_g2_smi_phy_write,
3878 .port_set_link = mv88e6xxx_port_set_link,
3879 .port_set_duplex = mv88e6xxx_port_set_duplex,
3880 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3881 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003882 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003883 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003884 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003885 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003886 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003887 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003888 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003889 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003890 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003891 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003892 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003893 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003894 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003895 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003896 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003897 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3898 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003899 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003900 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3901 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003902 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003903 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003904 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003905 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003906 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003907 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3908 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003909 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3910 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003911 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003912 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003913 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003914 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003915 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003916 .serdes_get_strings = mv88e6390_serdes_get_strings,
3917 .serdes_get_stats = mv88e6390_serdes_get_stats,
3918 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003919 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003920 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003921};
3922
3923static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003924 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003925 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003926 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003927 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3928 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003929 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3930 .phy_read = mv88e6xxx_g2_smi_phy_read,
3931 .phy_write = mv88e6xxx_g2_smi_phy_write,
3932 .port_set_link = mv88e6xxx_port_set_link,
3933 .port_set_duplex = mv88e6xxx_port_set_duplex,
3934 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3935 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003936 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003937 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003938 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003939 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003940 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003941 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003942 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003943 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003944 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003945 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003946 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003947 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003948 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003949 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003950 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3951 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003952 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003953 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3954 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003955 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003956 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003957 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003958 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003959 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003960 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3961 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003962 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3963 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003964 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003965 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003966 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003967 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003968 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003969 .serdes_get_strings = mv88e6390_serdes_get_strings,
3970 .serdes_get_stats = mv88e6390_serdes_get_stats,
3971 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003972 .avb_ops = &mv88e6390_avb_ops,
3973 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003974 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003975};
3976
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003977static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003978 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003979 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3980 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003981 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003982 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3983 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003984 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003985 .phy_read = mv88e6xxx_g2_smi_phy_read,
3986 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003987 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003988 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003989 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003990 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003991 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003992 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003993 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003994 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003995 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003996 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003997 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003998 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003999 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004000 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004001 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004002 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004003 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004004 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004005 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004006 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4007 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004008 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004009 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4010 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004011 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004012 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004013 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004014 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004015 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004016 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4017 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004018 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004019 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004020 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004021 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004022 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004023 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004024 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004025 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4026 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004027 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004028 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004029 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004030 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004031};
4032
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004033static const struct mv88e6xxx_ops mv88e6250_ops = {
4034 /* MV88E6XXX_FAMILY_6250 */
4035 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4036 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4037 .irl_init_all = mv88e6352_g2_irl_init_all,
4038 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4039 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4040 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4041 .phy_read = mv88e6xxx_g2_smi_phy_read,
4042 .phy_write = mv88e6xxx_g2_smi_phy_write,
4043 .port_set_link = mv88e6xxx_port_set_link,
4044 .port_set_duplex = mv88e6xxx_port_set_duplex,
4045 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4046 .port_set_speed = mv88e6250_port_set_speed,
4047 .port_tag_remap = mv88e6095_port_tag_remap,
4048 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4049 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4050 .port_set_ether_type = mv88e6351_port_set_ether_type,
4051 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4052 .port_pause_limit = mv88e6097_port_pause_limit,
4053 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4054 .port_link_state = mv88e6250_port_link_state,
4055 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4056 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4057 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4058 .stats_get_strings = mv88e6250_stats_get_strings,
4059 .stats_get_stats = mv88e6250_stats_get_stats,
4060 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4061 .set_egress_port = mv88e6095_g1_set_egress_port,
4062 .watchdog_ops = &mv88e6250_watchdog_ops,
4063 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4064 .pot_clear = mv88e6xxx_g2_pot_clear,
4065 .reset = mv88e6250_g1_reset,
4066 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4067 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004068 .avb_ops = &mv88e6352_avb_ops,
4069 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004070 .phylink_validate = mv88e6065_phylink_validate,
4071};
4072
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004073static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004074 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004075 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004076 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004077 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4078 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004079 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4080 .phy_read = mv88e6xxx_g2_smi_phy_read,
4081 .phy_write = mv88e6xxx_g2_smi_phy_write,
4082 .port_set_link = mv88e6xxx_port_set_link,
4083 .port_set_duplex = mv88e6xxx_port_set_duplex,
4084 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4085 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004086 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004087 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004088 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004089 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004090 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004091 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004092 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004093 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004094 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004095 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004096 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004097 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004098 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004099 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004100 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004101 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4102 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004103 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004104 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4105 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004106 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004107 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004108 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004109 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004110 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004111 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4112 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004113 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4114 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004115 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004116 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004117 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004118 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004119 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004120 .serdes_get_strings = mv88e6390_serdes_get_strings,
4121 .serdes_get_stats = mv88e6390_serdes_get_stats,
4122 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004123 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004124 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004125 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004126 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004127};
4128
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004129static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004130 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004131 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4132 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004133 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004134 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4135 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004136 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004137 .phy_read = mv88e6xxx_g2_smi_phy_read,
4138 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004139 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004140 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004141 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004142 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004143 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004144 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004145 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004146 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004147 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004148 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004149 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004150 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004151 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004152 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004153 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004154 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004155 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004156 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4157 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004158 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004159 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4160 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004161 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004162 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004163 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004164 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004165 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004166 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004167 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004168 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004169 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004170 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004171};
4172
4173static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004174 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004175 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4176 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004177 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004178 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4179 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004180 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004181 .phy_read = mv88e6xxx_g2_smi_phy_read,
4182 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004183 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004184 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004185 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004186 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004187 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004188 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004189 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004190 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004191 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004192 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004193 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004194 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004195 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004196 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004197 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004198 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004199 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004200 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4201 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004202 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004203 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4204 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004205 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004206 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004207 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004208 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004209 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004210 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004211 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004212 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004213};
4214
Vivien Didelot16e329a2017-03-28 13:50:33 -04004215static const struct mv88e6xxx_ops mv88e6341_ops = {
4216 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004217 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4218 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004219 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004220 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4221 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4222 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4223 .phy_read = mv88e6xxx_g2_smi_phy_read,
4224 .phy_write = mv88e6xxx_g2_smi_phy_write,
4225 .port_set_link = mv88e6xxx_port_set_link,
4226 .port_set_duplex = mv88e6xxx_port_set_duplex,
4227 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004228 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004229 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004230 .port_tag_remap = mv88e6095_port_tag_remap,
4231 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4232 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4233 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004234 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004235 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004236 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004237 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4238 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004239 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004240 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004241 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004242 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004243 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004244 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004245 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4246 .stats_get_strings = mv88e6320_stats_get_strings,
4247 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004248 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4249 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004250 .watchdog_ops = &mv88e6390_watchdog_ops,
4251 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004252 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004253 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004254 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004255 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004256 .serdes_power = mv88e6390_serdes_power,
4257 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004258 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004259 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004260 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004261 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004262 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004263 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004264 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004265};
4266
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004267static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004268 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004269 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4270 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004271 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004272 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004273 .phy_read = mv88e6xxx_g2_smi_phy_read,
4274 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004275 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004276 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004277 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004278 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004279 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004280 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004281 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004282 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004283 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004284 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004285 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004286 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004287 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004288 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004289 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004290 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004291 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004292 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004293 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4294 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004295 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004296 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4297 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004298 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004299 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004300 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004301 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004302 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4303 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004304 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004305 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004306 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004307};
4308
4309static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004310 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004311 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4312 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004313 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004314 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004315 .phy_read = mv88e6xxx_g2_smi_phy_read,
4316 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004317 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004318 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004319 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004320 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004321 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004322 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004323 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004324 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004325 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004326 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004327 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004328 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004329 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004330 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004331 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004332 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004333 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004334 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004335 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4336 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004337 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004338 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4339 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004340 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004341 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004342 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004343 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004344 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4345 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004346 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004347 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004348 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004349 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004350 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004351};
4352
4353static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004354 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004355 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4356 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004357 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004358 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4359 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004360 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004361 .phy_read = mv88e6xxx_g2_smi_phy_read,
4362 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004363 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004364 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004365 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004366 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004367 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004368 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004369 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004370 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004371 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004372 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004373 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004374 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004375 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004376 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004377 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004378 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004379 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004380 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004381 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004382 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4383 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004384 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004385 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4386 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004387 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004388 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004389 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004390 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004391 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004392 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4393 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004394 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004395 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004396 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004397 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004398 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004399 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004400 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004401 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004402 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004403 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004404 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4405 .serdes_get_strings = mv88e6352_serdes_get_strings,
4406 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004407 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4408 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004409 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004410};
4411
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004412static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004413 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004414 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004415 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004416 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4417 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004418 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4419 .phy_read = mv88e6xxx_g2_smi_phy_read,
4420 .phy_write = mv88e6xxx_g2_smi_phy_write,
4421 .port_set_link = mv88e6xxx_port_set_link,
4422 .port_set_duplex = mv88e6xxx_port_set_duplex,
4423 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4424 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004425 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004426 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004427 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004428 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004429 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004430 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004431 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004432 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004433 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004434 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004435 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004436 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004437 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004438 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004439 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004440 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004441 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004442 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4443 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004444 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004445 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4446 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004447 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004448 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004449 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004450 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004451 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004452 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4453 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004454 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4455 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004456 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004457 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004458 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004459 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004460 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004461 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004462 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004463 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004464 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4465 .serdes_get_strings = mv88e6390_serdes_get_strings,
4466 .serdes_get_stats = mv88e6390_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004467 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004468};
4469
4470static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004471 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004472 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004473 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004474 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4475 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004476 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4477 .phy_read = mv88e6xxx_g2_smi_phy_read,
4478 .phy_write = mv88e6xxx_g2_smi_phy_write,
4479 .port_set_link = mv88e6xxx_port_set_link,
4480 .port_set_duplex = mv88e6xxx_port_set_duplex,
4481 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4482 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004483 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004484 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004485 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004486 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004487 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004488 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004489 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004490 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004491 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004492 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004493 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004494 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004495 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004496 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004497 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004498 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004499 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004500 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4501 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004502 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004503 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4504 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004505 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004506 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004507 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004508 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004509 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004510 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4511 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004512 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4513 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004514 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004515 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004516 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004517 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004518 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004519 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4520 .serdes_get_strings = mv88e6390_serdes_get_strings,
4521 .serdes_get_stats = mv88e6390_serdes_get_stats,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004522 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004523 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004524 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004525 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004526};
4527
Vivien Didelotf81ec902016-05-09 13:22:58 -04004528static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4529 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004530 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004531 .family = MV88E6XXX_FAMILY_6097,
4532 .name = "Marvell 88E6085",
4533 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004534 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004535 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004536 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004537 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004538 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004539 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004540 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004541 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004542 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004543 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004544 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004545 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004546 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004547 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004548 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004549 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004550 },
4551
4552 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004553 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004554 .family = MV88E6XXX_FAMILY_6095,
4555 .name = "Marvell 88E6095/88E6095F",
4556 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004557 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004558 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004559 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004560 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004561 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004562 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004563 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004564 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004565 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004566 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004567 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004568 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004569 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004570 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004571 },
4572
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004573 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004574 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004575 .family = MV88E6XXX_FAMILY_6097,
4576 .name = "Marvell 88E6097/88E6097F",
4577 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004578 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004579 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004580 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004581 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004582 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004583 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004584 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004585 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004586 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004587 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004588 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004589 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004590 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004591 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004592 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004593 .ops = &mv88e6097_ops,
4594 },
4595
Vivien Didelotf81ec902016-05-09 13:22:58 -04004596 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004597 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004598 .family = MV88E6XXX_FAMILY_6165,
4599 .name = "Marvell 88E6123",
4600 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004601 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004602 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004603 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004604 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004605 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004606 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004607 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004608 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004609 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004610 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004611 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004612 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004613 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004614 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004615 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004616 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004617 },
4618
4619 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004620 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004621 .family = MV88E6XXX_FAMILY_6185,
4622 .name = "Marvell 88E6131",
4623 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004624 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004625 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004626 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004627 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004628 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004629 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004630 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004631 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004632 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004633 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004634 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004635 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004636 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004637 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004638 },
4639
Vivien Didelot990e27b2017-03-28 13:50:32 -04004640 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004641 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004642 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004643 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004644 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004645 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004646 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004647 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004648 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004649 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004650 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004651 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004652 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004653 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004654 .age_time_coeff = 3750,
4655 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004656 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004657 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004658 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004659 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004660 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004661 .ops = &mv88e6141_ops,
4662 },
4663
Vivien Didelotf81ec902016-05-09 13:22:58 -04004664 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004665 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 .family = MV88E6XXX_FAMILY_6165,
4667 .name = "Marvell 88E6161",
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 = 6,
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,
Andrew Lunndfa54342018-07-18 22:38:22 +02004684 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004685 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004686 },
4687
4688 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004689 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004690 .family = MV88E6XXX_FAMILY_6165,
4691 .name = "Marvell 88E6165",
4692 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004693 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004694 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004695 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004696 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004697 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004698 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004699 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004700 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004701 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004702 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004703 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004704 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004705 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004706 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004707 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004708 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004709 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004710 },
4711
4712 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004713 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004714 .family = MV88E6XXX_FAMILY_6351,
4715 .name = "Marvell 88E6171",
4716 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004717 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004718 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004719 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004720 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004721 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004722 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004723 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004724 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004725 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004726 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004727 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004728 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004729 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004730 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004731 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004732 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 },
4734
4735 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004736 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004737 .family = MV88E6XXX_FAMILY_6352,
4738 .name = "Marvell 88E6172",
4739 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004740 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004741 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004742 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004743 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004744 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004745 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004746 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004747 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004748 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004749 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004750 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004751 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004752 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004753 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004754 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004755 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004756 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004757 },
4758
4759 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004760 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004761 .family = MV88E6XXX_FAMILY_6351,
4762 .name = "Marvell 88E6175",
4763 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004764 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004765 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004766 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004767 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004768 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004769 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004770 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004771 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004772 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004773 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004774 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004775 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004776 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004777 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004778 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004779 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004780 },
4781
4782 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004783 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004784 .family = MV88E6XXX_FAMILY_6352,
4785 .name = "Marvell 88E6176",
4786 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004787 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004788 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004789 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004790 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004791 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004792 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004793 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004794 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004795 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004796 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004797 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004798 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004799 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004800 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004801 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004802 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004803 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004804 },
4805
4806 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004807 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004808 .family = MV88E6XXX_FAMILY_6185,
4809 .name = "Marvell 88E6185",
4810 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004811 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004812 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004813 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004814 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004815 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004816 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004817 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004818 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004819 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004820 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004821 .atu_move_port_mask = 0xf,
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 = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004825 },
4826
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004827 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004828 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004829 .family = MV88E6XXX_FAMILY_6390,
4830 .name = "Marvell 88E6190",
4831 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004832 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004833 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004834 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004835 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004836 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004837 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004838 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004839 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004840 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004841 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004842 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004843 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004844 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004845 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004846 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004847 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004848 .ops = &mv88e6190_ops,
4849 },
4850
4851 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004852 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004853 .family = MV88E6XXX_FAMILY_6390,
4854 .name = "Marvell 88E6190X",
4855 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004856 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004857 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004858 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004859 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004860 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004861 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004862 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004863 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004864 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004865 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004866 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004867 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004868 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004869 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004870 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004871 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004872 .ops = &mv88e6190x_ops,
4873 },
4874
4875 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004876 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004877 .family = MV88E6XXX_FAMILY_6390,
4878 .name = "Marvell 88E6191",
4879 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004880 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004881 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004882 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004883 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004884 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004885 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004886 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004887 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004888 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004889 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004890 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004891 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004892 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004893 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004894 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004895 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004896 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004897 },
4898
Hubert Feurstein49022642019-07-31 10:23:46 +02004899 [MV88E6220] = {
4900 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4901 .family = MV88E6XXX_FAMILY_6250,
4902 .name = "Marvell 88E6220",
4903 .num_databases = 64,
4904
4905 /* Ports 2-4 are not routed to pins
4906 * => usable ports 0, 1, 5, 6
4907 */
4908 .num_ports = 7,
4909 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004910 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004911 .max_vid = 4095,
4912 .port_base_addr = 0x08,
4913 .phy_base_addr = 0x00,
4914 .global1_addr = 0x0f,
4915 .global2_addr = 0x07,
4916 .age_time_coeff = 15000,
4917 .g1_irqs = 9,
4918 .g2_irqs = 10,
4919 .atu_move_port_mask = 0xf,
4920 .dual_chip = true,
4921 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004922 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004923 .ops = &mv88e6250_ops,
4924 },
4925
Vivien Didelotf81ec902016-05-09 13:22:58 -04004926 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004927 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004928 .family = MV88E6XXX_FAMILY_6352,
4929 .name = "Marvell 88E6240",
4930 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004931 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004932 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004933 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004934 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004935 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004936 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004937 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004938 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004939 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004940 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004941 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004942 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004943 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004944 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004945 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004946 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004947 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004948 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004949 },
4950
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004951 [MV88E6250] = {
4952 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4953 .family = MV88E6XXX_FAMILY_6250,
4954 .name = "Marvell 88E6250",
4955 .num_databases = 64,
4956 .num_ports = 7,
4957 .num_internal_phys = 5,
4958 .max_vid = 4095,
4959 .port_base_addr = 0x08,
4960 .phy_base_addr = 0x00,
4961 .global1_addr = 0x0f,
4962 .global2_addr = 0x07,
4963 .age_time_coeff = 15000,
4964 .g1_irqs = 9,
4965 .g2_irqs = 10,
4966 .atu_move_port_mask = 0xf,
4967 .dual_chip = true,
4968 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004969 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004970 .ops = &mv88e6250_ops,
4971 },
4972
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004973 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004974 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004975 .family = MV88E6XXX_FAMILY_6390,
4976 .name = "Marvell 88E6290",
4977 .num_databases = 4096,
4978 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004979 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004980 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004981 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004982 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004983 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004984 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004985 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004986 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004987 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004988 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004989 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004990 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004991 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004992 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004993 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004994 .ops = &mv88e6290_ops,
4995 },
4996
Vivien Didelotf81ec902016-05-09 13:22:58 -04004997 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004998 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004999 .family = MV88E6XXX_FAMILY_6320,
5000 .name = "Marvell 88E6320",
5001 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005002 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005003 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005004 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005005 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005006 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005007 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005008 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005009 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005010 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005011 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005012 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005013 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005014 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005015 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005016 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005017 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005018 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005019 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005020 },
5021
5022 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005023 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005024 .family = MV88E6XXX_FAMILY_6320,
5025 .name = "Marvell 88E6321",
5026 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005027 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005028 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005029 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005030 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005031 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005032 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005033 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005034 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005035 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005036 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005037 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005038 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005039 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005040 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005041 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005042 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005043 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005044 },
5045
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005046 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005047 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005048 .family = MV88E6XXX_FAMILY_6341,
5049 .name = "Marvell 88E6341",
5050 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005051 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005052 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005053 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005054 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005055 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005056 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005057 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005058 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005059 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005060 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005061 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005062 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005063 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005064 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005065 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005066 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005067 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005068 .ops = &mv88e6341_ops,
5069 },
5070
Vivien Didelotf81ec902016-05-09 13:22:58 -04005071 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005072 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005073 .family = MV88E6XXX_FAMILY_6351,
5074 .name = "Marvell 88E6350",
5075 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005076 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005077 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005078 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005079 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005080 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005081 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005082 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005083 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005084 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005085 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005086 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005087 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005088 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005089 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005090 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005091 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005092 },
5093
5094 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005095 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005096 .family = MV88E6XXX_FAMILY_6351,
5097 .name = "Marvell 88E6351",
5098 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005099 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005100 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005101 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005102 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005103 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005104 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005105 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005106 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005107 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005108 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005109 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005110 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005111 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005112 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005113 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005114 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005115 },
5116
5117 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005118 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005119 .family = MV88E6XXX_FAMILY_6352,
5120 .name = "Marvell 88E6352",
5121 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005122 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005123 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005124 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005125 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005126 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005127 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005128 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005129 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005130 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005131 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005132 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005133 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005134 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005135 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005136 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005137 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005138 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005139 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005140 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005141 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005142 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005143 .family = MV88E6XXX_FAMILY_6390,
5144 .name = "Marvell 88E6390",
5145 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005146 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005147 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005148 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005149 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005150 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005151 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005152 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005153 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005154 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005155 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005156 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005157 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005158 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005159 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005160 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005161 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005162 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005163 .ops = &mv88e6390_ops,
5164 },
5165 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005166 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005167 .family = MV88E6XXX_FAMILY_6390,
5168 .name = "Marvell 88E6390X",
5169 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005170 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005171 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005172 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005173 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005174 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005175 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005176 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005177 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005178 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005179 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005180 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005181 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005182 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005183 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005184 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005185 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005186 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005187 .ops = &mv88e6390x_ops,
5188 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005189};
5190
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005191static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005192{
Vivien Didelota439c062016-04-17 13:23:58 -04005193 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005194
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005195 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5196 if (mv88e6xxx_table[i].prod_num == prod_num)
5197 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005198
Vivien Didelotb9b37712015-10-30 19:39:48 -04005199 return NULL;
5200}
5201
Vivien Didelotfad09c72016-06-21 12:28:20 -04005202static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005203{
5204 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005205 unsigned int prod_num, rev;
5206 u16 id;
5207 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005208
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005209 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005210 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005211 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005212 if (err)
5213 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005214
Vivien Didelot107fcc12017-06-12 12:37:36 -04005215 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5216 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005217
5218 info = mv88e6xxx_lookup_info(prod_num);
5219 if (!info)
5220 return -ENODEV;
5221
Vivien Didelotcaac8542016-06-20 13:14:09 -04005222 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005223 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005224
Vivien Didelotca070c12016-09-02 14:45:34 -04005225 err = mv88e6xxx_g2_require(chip);
5226 if (err)
5227 return err;
5228
Vivien Didelotfad09c72016-06-21 12:28:20 -04005229 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5230 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005231
5232 return 0;
5233}
5234
Vivien Didelotfad09c72016-06-21 12:28:20 -04005235static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005236{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005237 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005238
Vivien Didelotfad09c72016-06-21 12:28:20 -04005239 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5240 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005241 return NULL;
5242
Vivien Didelotfad09c72016-06-21 12:28:20 -04005243 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005244
Vivien Didelotfad09c72016-06-21 12:28:20 -04005245 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005246 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005247 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005248
Vivien Didelotfad09c72016-06-21 12:28:20 -04005249 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005250}
5251
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005252static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005253 int port,
5254 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005255{
Vivien Didelot04bed142016-08-31 18:06:13 -04005256 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005257
Andrew Lunn443d5a12016-12-03 04:35:18 +01005258 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005259}
5260
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005261static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005262 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005263{
5264 /* We don't need any dynamic resource from the kernel (yet),
5265 * so skip the prepare phase.
5266 */
5267
5268 return 0;
5269}
5270
5271static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005272 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005273{
Vivien Didelot04bed142016-08-31 18:06:13 -04005274 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005275
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005276 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005277 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005278 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005279 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5280 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005281 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005282}
5283
5284static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5285 const struct switchdev_obj_port_mdb *mdb)
5286{
Vivien Didelot04bed142016-08-31 18:06:13 -04005287 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005288 int err;
5289
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005290 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005291 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005292 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005293
5294 return err;
5295}
5296
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005297static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5298 struct dsa_mall_mirror_tc_entry *mirror,
5299 bool ingress)
5300{
5301 enum mv88e6xxx_egress_direction direction = ingress ?
5302 MV88E6XXX_EGRESS_DIR_INGRESS :
5303 MV88E6XXX_EGRESS_DIR_EGRESS;
5304 struct mv88e6xxx_chip *chip = ds->priv;
5305 bool other_mirrors = false;
5306 int i;
5307 int err;
5308
5309 if (!chip->info->ops->set_egress_port)
5310 return -EOPNOTSUPP;
5311
5312 mutex_lock(&chip->reg_lock);
5313 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5314 mirror->to_local_port) {
5315 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5316 other_mirrors |= ingress ?
5317 chip->ports[i].mirror_ingress :
5318 chip->ports[i].mirror_egress;
5319
5320 /* Can't change egress port when other mirror is active */
5321 if (other_mirrors) {
5322 err = -EBUSY;
5323 goto out;
5324 }
5325
5326 err = chip->info->ops->set_egress_port(chip,
5327 direction,
5328 mirror->to_local_port);
5329 if (err)
5330 goto out;
5331 }
5332
5333 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5334out:
5335 mutex_unlock(&chip->reg_lock);
5336
5337 return err;
5338}
5339
5340static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5341 struct dsa_mall_mirror_tc_entry *mirror)
5342{
5343 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5344 MV88E6XXX_EGRESS_DIR_INGRESS :
5345 MV88E6XXX_EGRESS_DIR_EGRESS;
5346 struct mv88e6xxx_chip *chip = ds->priv;
5347 bool other_mirrors = false;
5348 int i;
5349
5350 mutex_lock(&chip->reg_lock);
5351 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5352 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5353
5354 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5355 other_mirrors |= mirror->ingress ?
5356 chip->ports[i].mirror_ingress :
5357 chip->ports[i].mirror_egress;
5358
5359 /* Reset egress port when no other mirror is active */
5360 if (!other_mirrors) {
5361 if (chip->info->ops->set_egress_port(chip,
5362 direction,
5363 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005364 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005365 dev_err(ds->dev, "failed to set egress port\n");
5366 }
5367
5368 mutex_unlock(&chip->reg_lock);
5369}
5370
Russell King4f859012019-02-20 15:35:05 -08005371static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5372 bool unicast, bool multicast)
5373{
5374 struct mv88e6xxx_chip *chip = ds->priv;
5375 int err = -EOPNOTSUPP;
5376
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005377 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005378 if (chip->info->ops->port_set_egress_floods)
5379 err = chip->info->ops->port_set_egress_floods(chip, port,
5380 unicast,
5381 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005382 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005383
5384 return err;
5385}
5386
Florian Fainellia82f67a2017-01-08 14:52:08 -08005387static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005388 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005389 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005390 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005391 .phylink_validate = mv88e6xxx_validate,
5392 .phylink_mac_link_state = mv88e6xxx_link_state,
5393 .phylink_mac_config = mv88e6xxx_mac_config,
5394 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5395 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005396 .get_strings = mv88e6xxx_get_strings,
5397 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5398 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005399 .port_enable = mv88e6xxx_port_enable,
5400 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005401 .get_mac_eee = mv88e6xxx_get_mac_eee,
5402 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005403 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005404 .get_eeprom = mv88e6xxx_get_eeprom,
5405 .set_eeprom = mv88e6xxx_set_eeprom,
5406 .get_regs_len = mv88e6xxx_get_regs_len,
5407 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005408 .get_rxnfc = mv88e6xxx_get_rxnfc,
5409 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005410 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005411 .port_bridge_join = mv88e6xxx_port_bridge_join,
5412 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005413 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005414 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005415 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005416 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5417 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5418 .port_vlan_add = mv88e6xxx_port_vlan_add,
5419 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005420 .port_fdb_add = mv88e6xxx_port_fdb_add,
5421 .port_fdb_del = mv88e6xxx_port_fdb_del,
5422 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005423 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5424 .port_mdb_add = mv88e6xxx_port_mdb_add,
5425 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005426 .port_mirror_add = mv88e6xxx_port_mirror_add,
5427 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005428 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5429 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005430 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5431 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5432 .port_txtstamp = mv88e6xxx_port_txtstamp,
5433 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5434 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005435 .devlink_param_get = mv88e6xxx_devlink_param_get,
5436 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005437};
5438
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005439static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005440{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005441 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005442 struct dsa_switch *ds;
5443
Vivien Didelot7e99e342019-10-21 16:51:30 -04005444 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005445 if (!ds)
5446 return -ENOMEM;
5447
Vivien Didelot7e99e342019-10-21 16:51:30 -04005448 ds->dev = dev;
5449 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005450 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005451 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005452 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005453 ds->ageing_time_min = chip->info->age_time_coeff;
5454 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005455
5456 dev_set_drvdata(dev, ds);
5457
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005458 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005459}
5460
Vivien Didelotfad09c72016-06-21 12:28:20 -04005461static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005462{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005463 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005464}
5465
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005466static const void *pdata_device_get_match_data(struct device *dev)
5467{
5468 const struct of_device_id *matches = dev->driver->of_match_table;
5469 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5470
5471 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5472 matches++) {
5473 if (!strcmp(pdata->compatible, matches->compatible))
5474 return matches->data;
5475 }
5476 return NULL;
5477}
5478
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005479/* There is no suspend to RAM support at DSA level yet, the switch configuration
5480 * would be lost after a power cycle so prevent it to be suspended.
5481 */
5482static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5483{
5484 return -EOPNOTSUPP;
5485}
5486
5487static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5488{
5489 return 0;
5490}
5491
5492static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5493
Vivien Didelot57d32312016-06-20 13:13:58 -04005494static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005495{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005496 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005497 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005498 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005499 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005500 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005501 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005502 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005503
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005504 if (!np && !pdata)
5505 return -EINVAL;
5506
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005507 if (np)
5508 compat_info = of_device_get_match_data(dev);
5509
5510 if (pdata) {
5511 compat_info = pdata_device_get_match_data(dev);
5512
5513 if (!pdata->netdev)
5514 return -EINVAL;
5515
5516 for (port = 0; port < DSA_MAX_PORTS; port++) {
5517 if (!(pdata->enabled_ports & (1 << port)))
5518 continue;
5519 if (strcmp(pdata->cd.port_names[port], "cpu"))
5520 continue;
5521 pdata->cd.netdev[port] = &pdata->netdev->dev;
5522 break;
5523 }
5524 }
5525
Vivien Didelotcaac8542016-06-20 13:14:09 -04005526 if (!compat_info)
5527 return -EINVAL;
5528
Vivien Didelotfad09c72016-06-21 12:28:20 -04005529 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005530 if (!chip) {
5531 err = -ENOMEM;
5532 goto out;
5533 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005534
Vivien Didelotfad09c72016-06-21 12:28:20 -04005535 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005536
Vivien Didelotfad09c72016-06-21 12:28:20 -04005537 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005538 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005539 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005540
Andrew Lunnb4308f02016-11-21 23:26:55 +01005541 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005542 if (IS_ERR(chip->reset)) {
5543 err = PTR_ERR(chip->reset);
5544 goto out;
5545 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005546 if (chip->reset)
5547 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005548
Vivien Didelotfad09c72016-06-21 12:28:20 -04005549 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005550 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005551 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005552
Vivien Didelote57e5e72016-08-15 17:19:00 -04005553 mv88e6xxx_phy_init(chip);
5554
Andrew Lunn00baabe2018-05-19 22:31:35 +02005555 if (chip->info->ops->get_eeprom) {
5556 if (np)
5557 of_property_read_u32(np, "eeprom-length",
5558 &chip->eeprom_len);
5559 else
5560 chip->eeprom_len = pdata->eeprom_len;
5561 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005562
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005563 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005564 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005565 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005566 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005567 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005568
Andrew Lunna27415d2019-05-01 00:10:50 +02005569 if (np) {
5570 chip->irq = of_irq_get(np, 0);
5571 if (chip->irq == -EPROBE_DEFER) {
5572 err = chip->irq;
5573 goto out;
5574 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005575 }
5576
Andrew Lunna27415d2019-05-01 00:10:50 +02005577 if (pdata)
5578 chip->irq = pdata->irq;
5579
Andrew Lunn294d7112018-02-22 22:58:32 +01005580 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005581 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005582 * controllers
5583 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005584 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005585 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005586 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005587 else
5588 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005589 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005590
Andrew Lunn294d7112018-02-22 22:58:32 +01005591 if (err)
5592 goto out;
5593
5594 if (chip->info->g2_irqs > 0) {
5595 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005596 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005597 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005598 }
5599
Andrew Lunn294d7112018-02-22 22:58:32 +01005600 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5601 if (err)
5602 goto out_g2_irq;
5603
5604 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5605 if (err)
5606 goto out_g1_atu_prob_irq;
5607
Andrew Lunna3c53be52017-01-24 14:53:50 +01005608 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005609 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005610 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005611
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005612 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005613 if (err)
5614 goto out_mdio;
5615
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005616 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005617
5618out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005619 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005620out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005621 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005622out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005623 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005624out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005625 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005626 mv88e6xxx_g2_irq_free(chip);
5627out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005628 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005629 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005630 else
5631 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005632out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005633 if (pdata)
5634 dev_put(pdata->netdev);
5635
Andrew Lunndc30c352016-10-16 19:56:49 +02005636 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005637}
5638
5639static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5640{
5641 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005642 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005643
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005644 if (chip->info->ptp_support) {
5645 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005646 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005647 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005648
Andrew Lunn930188c2016-08-22 16:01:03 +02005649 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005650 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005651 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005652
Andrew Lunn76f38f12018-03-17 20:21:09 +01005653 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5654 mv88e6xxx_g1_atu_prob_irq_free(chip);
5655
5656 if (chip->info->g2_irqs > 0)
5657 mv88e6xxx_g2_irq_free(chip);
5658
Andrew Lunn76f38f12018-03-17 20:21:09 +01005659 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005660 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005661 else
5662 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005663}
5664
5665static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005666 {
5667 .compatible = "marvell,mv88e6085",
5668 .data = &mv88e6xxx_table[MV88E6085],
5669 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005670 {
5671 .compatible = "marvell,mv88e6190",
5672 .data = &mv88e6xxx_table[MV88E6190],
5673 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005674 {
5675 .compatible = "marvell,mv88e6250",
5676 .data = &mv88e6xxx_table[MV88E6250],
5677 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005678 { /* sentinel */ },
5679};
5680
5681MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5682
5683static struct mdio_driver mv88e6xxx_driver = {
5684 .probe = mv88e6xxx_probe,
5685 .remove = mv88e6xxx_remove,
5686 .mdiodrv.driver = {
5687 .name = "mv88e6085",
5688 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005689 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005690 },
5691};
5692
Andrew Lunn7324d502019-04-27 19:19:10 +02005693mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005694
5695MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5696MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5697MODULE_LICENSE("GPL");