blob: 316758a42a672a49acbca52b706d9edc13e25c96 [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,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003677 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003678 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003679};
3680
3681static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003682 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003683 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3684 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003685 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003686 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003687 .phy_read = mv88e6xxx_g2_smi_phy_read,
3688 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003689 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003690 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003691 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003692 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003693 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003694 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003695 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003696 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003697 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003698 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003699 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003700 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003701 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003702 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003703 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003704 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003705 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003706 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003707 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3708 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003709 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003710 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3711 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003712 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003713 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003714 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003715 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003716 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3717 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003718 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003719 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003720 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003721};
3722
3723static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003724 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003725 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3726 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003727 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003728 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3729 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003730 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003731 .phy_read = mv88e6xxx_g2_smi_phy_read,
3732 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003733 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003734 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003735 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003736 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003737 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003738 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003739 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003740 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003741 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003742 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003743 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003744 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003745 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003746 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003747 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003748 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003749 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003750 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003751 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003752 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3753 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003754 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003755 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3756 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003757 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003758 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003759 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003760 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003761 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003762 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3763 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003764 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003765 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003766 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003767 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003768 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003769 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003770 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003771 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003772 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003773};
3774
3775static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003776 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003777 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3778 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003779 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003780 .phy_read = mv88e6185_phy_ppu_read,
3781 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003782 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003783 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003784 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003785 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003786 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003787 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003788 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003789 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003790 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003791 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003792 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003793 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003794 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003795 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3796 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003797 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003798 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3799 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003800 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003801 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003802 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003803 .ppu_enable = mv88e6185_g1_ppu_enable,
3804 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003805 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003806 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003807 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003808 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003809};
3810
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003811static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003812 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003813 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003814 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003815 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3816 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003817 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3818 .phy_read = mv88e6xxx_g2_smi_phy_read,
3819 .phy_write = mv88e6xxx_g2_smi_phy_write,
3820 .port_set_link = mv88e6xxx_port_set_link,
3821 .port_set_duplex = mv88e6xxx_port_set_duplex,
3822 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3823 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003824 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003825 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003826 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003827 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003828 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003829 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003830 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003831 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003832 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003833 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003834 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003835 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003836 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003837 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003838 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003839 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3840 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003841 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003842 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3843 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003844 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003845 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003846 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003847 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003848 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003849 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3850 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003851 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3852 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003853 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003854 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003855 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003856 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003857 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003858 .serdes_get_strings = mv88e6390_serdes_get_strings,
3859 .serdes_get_stats = mv88e6390_serdes_get_stats,
3860 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003861 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003862 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003863};
3864
3865static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003866 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003867 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003868 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003869 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3870 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003871 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3872 .phy_read = mv88e6xxx_g2_smi_phy_read,
3873 .phy_write = mv88e6xxx_g2_smi_phy_write,
3874 .port_set_link = mv88e6xxx_port_set_link,
3875 .port_set_duplex = mv88e6xxx_port_set_duplex,
3876 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3877 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003878 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003879 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003880 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003881 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003882 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003883 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003884 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003885 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003886 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003887 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003888 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003889 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003890 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003891 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003892 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003893 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3894 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003895 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003896 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3897 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003898 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003899 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003900 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003901 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003902 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003903 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3904 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003905 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3906 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003907 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003908 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003909 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003910 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003911 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003912 .serdes_get_strings = mv88e6390_serdes_get_strings,
3913 .serdes_get_stats = mv88e6390_serdes_get_stats,
3914 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003915 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003916 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003917};
3918
3919static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003920 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003921 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003922 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003923 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3924 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003925 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3926 .phy_read = mv88e6xxx_g2_smi_phy_read,
3927 .phy_write = mv88e6xxx_g2_smi_phy_write,
3928 .port_set_link = mv88e6xxx_port_set_link,
3929 .port_set_duplex = mv88e6xxx_port_set_duplex,
3930 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3931 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003932 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003933 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003934 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003935 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003936 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003937 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003938 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003939 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003940 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003941 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003942 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003943 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003944 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003945 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003946 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3947 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003948 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003949 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3950 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003951 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003952 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003953 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003954 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003955 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003956 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3957 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003958 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3959 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003960 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003961 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003962 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003963 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003964 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003965 .serdes_get_strings = mv88e6390_serdes_get_strings,
3966 .serdes_get_stats = mv88e6390_serdes_get_stats,
3967 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003968 .avb_ops = &mv88e6390_avb_ops,
3969 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003970 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003971};
3972
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003973static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003974 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003975 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3976 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003977 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003978 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3979 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003980 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003981 .phy_read = mv88e6xxx_g2_smi_phy_read,
3982 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003983 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003984 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003985 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003986 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003987 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003988 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003989 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003990 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003991 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003992 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003993 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003994 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003995 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003996 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003997 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003998 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003999 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004000 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004001 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004002 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4003 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004004 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004005 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4006 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004007 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004008 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004009 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004010 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004011 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004012 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4013 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004014 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004015 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004016 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004017 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004018 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004019 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004020 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004021 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004022 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004023 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004024 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004025};
4026
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004027static const struct mv88e6xxx_ops mv88e6250_ops = {
4028 /* MV88E6XXX_FAMILY_6250 */
4029 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4030 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4031 .irl_init_all = mv88e6352_g2_irl_init_all,
4032 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4033 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4034 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4035 .phy_read = mv88e6xxx_g2_smi_phy_read,
4036 .phy_write = mv88e6xxx_g2_smi_phy_write,
4037 .port_set_link = mv88e6xxx_port_set_link,
4038 .port_set_duplex = mv88e6xxx_port_set_duplex,
4039 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4040 .port_set_speed = mv88e6250_port_set_speed,
4041 .port_tag_remap = mv88e6095_port_tag_remap,
4042 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4043 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4044 .port_set_ether_type = mv88e6351_port_set_ether_type,
4045 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4046 .port_pause_limit = mv88e6097_port_pause_limit,
4047 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4048 .port_link_state = mv88e6250_port_link_state,
4049 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4050 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4051 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4052 .stats_get_strings = mv88e6250_stats_get_strings,
4053 .stats_get_stats = mv88e6250_stats_get_stats,
4054 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4055 .set_egress_port = mv88e6095_g1_set_egress_port,
4056 .watchdog_ops = &mv88e6250_watchdog_ops,
4057 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4058 .pot_clear = mv88e6xxx_g2_pot_clear,
4059 .reset = mv88e6250_g1_reset,
4060 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4061 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004062 .avb_ops = &mv88e6352_avb_ops,
4063 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004064 .phylink_validate = mv88e6065_phylink_validate,
4065};
4066
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004067static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004068 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004069 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004070 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004071 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4072 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004073 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4074 .phy_read = mv88e6xxx_g2_smi_phy_read,
4075 .phy_write = mv88e6xxx_g2_smi_phy_write,
4076 .port_set_link = mv88e6xxx_port_set_link,
4077 .port_set_duplex = mv88e6xxx_port_set_duplex,
4078 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4079 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004080 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004081 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004082 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004083 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004084 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004085 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004086 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004087 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004088 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004089 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004090 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004091 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004092 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004093 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004094 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004095 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4096 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004097 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004098 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4099 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004100 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004101 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004102 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004103 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004104 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004105 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4106 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004107 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4108 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004109 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004110 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004111 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004112 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004113 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004114 .serdes_get_strings = mv88e6390_serdes_get_strings,
4115 .serdes_get_stats = mv88e6390_serdes_get_stats,
4116 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004117 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004118 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004119 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004120 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004121};
4122
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004123static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004124 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004125 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4126 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004127 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004128 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4129 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004130 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004131 .phy_read = mv88e6xxx_g2_smi_phy_read,
4132 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004133 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004134 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004135 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004136 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004137 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004138 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004139 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004140 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004141 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004142 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004143 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004144 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004145 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004146 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004147 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004148 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004149 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004150 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4151 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004152 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004153 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4154 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004155 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004156 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004157 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004158 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004159 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004160 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004161 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004162 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004163 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004164 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004165};
4166
4167static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004168 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004169 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4170 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004171 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004172 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4173 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004174 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004175 .phy_read = mv88e6xxx_g2_smi_phy_read,
4176 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004177 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004178 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004179 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004180 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004181 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004182 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004183 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004184 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004185 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004186 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004187 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004188 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004189 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004190 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004191 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004192 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004193 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004194 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4195 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004196 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004197 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4198 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004199 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004200 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004201 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004202 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004203 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004204 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004205 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004206 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004207};
4208
Vivien Didelot16e329a2017-03-28 13:50:33 -04004209static const struct mv88e6xxx_ops mv88e6341_ops = {
4210 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004211 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4212 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004213 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004214 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4215 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4216 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4217 .phy_read = mv88e6xxx_g2_smi_phy_read,
4218 .phy_write = mv88e6xxx_g2_smi_phy_write,
4219 .port_set_link = mv88e6xxx_port_set_link,
4220 .port_set_duplex = mv88e6xxx_port_set_duplex,
4221 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004222 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004223 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004224 .port_tag_remap = mv88e6095_port_tag_remap,
4225 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4226 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4227 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004228 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004229 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004230 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004231 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4232 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004233 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004234 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004235 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004236 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004237 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004238 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004239 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4240 .stats_get_strings = mv88e6320_stats_get_strings,
4241 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004242 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4243 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004244 .watchdog_ops = &mv88e6390_watchdog_ops,
4245 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004246 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004247 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004248 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004249 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004250 .serdes_power = mv88e6390_serdes_power,
4251 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004252 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004253 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004254 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004255 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004256 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004257 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004258 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004259};
4260
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004261static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004262 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004263 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4264 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004265 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004266 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004267 .phy_read = mv88e6xxx_g2_smi_phy_read,
4268 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004269 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004270 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004271 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004272 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004273 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004274 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004275 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004276 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004277 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004278 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004279 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004280 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004281 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004282 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004283 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004284 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004285 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004286 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004287 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4288 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004289 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004290 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4291 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004292 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004293 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004294 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004295 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004296 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4297 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004298 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004299 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004300 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004301};
4302
4303static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004304 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004305 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4306 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004307 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004308 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004309 .phy_read = mv88e6xxx_g2_smi_phy_read,
4310 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004311 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004312 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004313 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004314 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004315 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004316 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004317 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004318 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004319 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004320 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004321 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004322 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004323 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004324 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004325 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004326 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004327 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004328 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004329 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4330 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004331 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004332 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4333 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004334 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004335 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004336 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004337 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004338 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4339 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004340 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004341 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004342 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004343 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004344 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004345};
4346
4347static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004348 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004349 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4350 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004351 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004352 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4353 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004354 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004355 .phy_read = mv88e6xxx_g2_smi_phy_read,
4356 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004357 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004358 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004359 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004360 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004361 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004362 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004363 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004364 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004365 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004366 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004367 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004368 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004369 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004370 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004371 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004372 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004373 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004374 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004375 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004376 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4377 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004378 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004379 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4380 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004381 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004382 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004383 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004384 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004385 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004386 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4387 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004388 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004389 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004390 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004391 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004392 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004393 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004394 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004395 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004396 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004397 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004398 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4399 .serdes_get_strings = mv88e6352_serdes_get_strings,
4400 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004401 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004402};
4403
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004404static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004405 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004406 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004407 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004408 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4409 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004410 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4411 .phy_read = mv88e6xxx_g2_smi_phy_read,
4412 .phy_write = mv88e6xxx_g2_smi_phy_write,
4413 .port_set_link = mv88e6xxx_port_set_link,
4414 .port_set_duplex = mv88e6xxx_port_set_duplex,
4415 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4416 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004417 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004418 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004419 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004420 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004421 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004422 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004423 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004424 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004425 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004426 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004427 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004428 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004429 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004430 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004431 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004432 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004433 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004434 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4435 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004436 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004437 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4438 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004439 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004440 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004441 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004442 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004443 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004444 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4445 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004446 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4447 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004448 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004449 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004450 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004451 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004452 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004453 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004454 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004455 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004456 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4457 .serdes_get_strings = mv88e6390_serdes_get_strings,
4458 .serdes_get_stats = mv88e6390_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004459 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004460};
4461
4462static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004463 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004464 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004465 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004466 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4467 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004468 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4469 .phy_read = mv88e6xxx_g2_smi_phy_read,
4470 .phy_write = mv88e6xxx_g2_smi_phy_write,
4471 .port_set_link = mv88e6xxx_port_set_link,
4472 .port_set_duplex = mv88e6xxx_port_set_duplex,
4473 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4474 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004475 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004476 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004477 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004478 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004479 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004480 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004481 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004482 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004483 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004484 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004485 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004486 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004487 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004488 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004489 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004490 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004491 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004492 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4493 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004494 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004495 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4496 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004497 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004498 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004499 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004500 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004501 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004502 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4503 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004504 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4505 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004506 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004507 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004508 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004509 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004510 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004511 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4512 .serdes_get_strings = mv88e6390_serdes_get_strings,
4513 .serdes_get_stats = mv88e6390_serdes_get_stats,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004514 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004515 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004516 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004517 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004518};
4519
Vivien Didelotf81ec902016-05-09 13:22:58 -04004520static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4521 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004522 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004523 .family = MV88E6XXX_FAMILY_6097,
4524 .name = "Marvell 88E6085",
4525 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004526 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004527 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004528 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004529 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004530 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004531 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004532 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004533 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004534 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004535 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004536 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004537 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004538 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004539 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004540 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004541 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004542 },
4543
4544 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004545 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004546 .family = MV88E6XXX_FAMILY_6095,
4547 .name = "Marvell 88E6095/88E6095F",
4548 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004549 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004550 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004551 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004552 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004553 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004554 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004555 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004556 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004557 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004558 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004559 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004560 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004561 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004562 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004563 },
4564
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004565 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004566 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004567 .family = MV88E6XXX_FAMILY_6097,
4568 .name = "Marvell 88E6097/88E6097F",
4569 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004570 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004571 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004572 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004573 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004574 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004575 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004576 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004577 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004578 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004579 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004580 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004581 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004582 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004583 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004584 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004585 .ops = &mv88e6097_ops,
4586 },
4587
Vivien Didelotf81ec902016-05-09 13:22:58 -04004588 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004589 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004590 .family = MV88E6XXX_FAMILY_6165,
4591 .name = "Marvell 88E6123",
4592 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004593 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004594 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004595 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004596 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004597 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004598 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004599 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004600 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004601 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004602 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004603 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004604 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004605 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004606 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004607 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004608 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004609 },
4610
4611 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004612 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004613 .family = MV88E6XXX_FAMILY_6185,
4614 .name = "Marvell 88E6131",
4615 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004616 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004617 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004618 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004619 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004620 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004621 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004622 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004623 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004624 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004625 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004626 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004627 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004628 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004629 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004630 },
4631
Vivien Didelot990e27b2017-03-28 13:50:32 -04004632 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004633 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004634 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004635 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004636 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004637 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004638 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004639 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004640 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004641 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004642 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004643 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004644 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004645 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004646 .age_time_coeff = 3750,
4647 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004648 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004649 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004650 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004651 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004652 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004653 .ops = &mv88e6141_ops,
4654 },
4655
Vivien Didelotf81ec902016-05-09 13:22:58 -04004656 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004657 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004658 .family = MV88E6XXX_FAMILY_6165,
4659 .name = "Marvell 88E6161",
4660 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004661 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004662 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004663 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004664 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004665 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004666 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004667 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004668 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004669 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004670 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004671 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004672 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004673 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004674 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004675 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004676 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004677 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004678 },
4679
4680 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004681 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004682 .family = MV88E6XXX_FAMILY_6165,
4683 .name = "Marvell 88E6165",
4684 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004685 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004686 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004687 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004688 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004689 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004690 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004691 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004692 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004693 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004694 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004695 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004696 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004697 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004698 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004699 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004700 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004701 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004702 },
4703
4704 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004705 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004706 .family = MV88E6XXX_FAMILY_6351,
4707 .name = "Marvell 88E6171",
4708 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004709 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004710 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004711 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004712 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004713 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004714 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004715 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004716 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004717 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004718 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004719 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004720 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004721 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004722 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004723 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004724 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004725 },
4726
4727 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004728 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004729 .family = MV88E6XXX_FAMILY_6352,
4730 .name = "Marvell 88E6172",
4731 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004732 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004734 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004735 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004736 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004737 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004738 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004739 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004740 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004741 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004742 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004743 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004744 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004745 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004746 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004747 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004748 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004749 },
4750
4751 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004752 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004753 .family = MV88E6XXX_FAMILY_6351,
4754 .name = "Marvell 88E6175",
4755 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004756 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004757 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004758 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004759 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004760 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004761 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004762 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004763 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004764 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004765 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004766 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004767 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004768 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004769 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004770 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004771 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004772 },
4773
4774 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004775 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004776 .family = MV88E6XXX_FAMILY_6352,
4777 .name = "Marvell 88E6176",
4778 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004779 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004780 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004781 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004782 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004783 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004784 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004785 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004786 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004787 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004788 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004789 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004790 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004791 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004792 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004793 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004794 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004795 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004796 },
4797
4798 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004799 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004800 .family = MV88E6XXX_FAMILY_6185,
4801 .name = "Marvell 88E6185",
4802 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004803 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004804 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004805 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004806 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004807 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004808 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004809 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004810 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004811 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004812 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004813 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004814 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004815 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004816 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004817 },
4818
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004819 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004820 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004821 .family = MV88E6XXX_FAMILY_6390,
4822 .name = "Marvell 88E6190",
4823 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004824 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004825 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004826 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004827 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004828 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004829 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004830 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004831 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004832 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004833 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004834 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004835 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004836 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004837 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004838 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004839 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004840 .ops = &mv88e6190_ops,
4841 },
4842
4843 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004844 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004845 .family = MV88E6XXX_FAMILY_6390,
4846 .name = "Marvell 88E6190X",
4847 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004848 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004849 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004850 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004851 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004852 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004853 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004854 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004855 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004856 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004857 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004858 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004859 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004860 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004861 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004862 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004863 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004864 .ops = &mv88e6190x_ops,
4865 },
4866
4867 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004868 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004869 .family = MV88E6XXX_FAMILY_6390,
4870 .name = "Marvell 88E6191",
4871 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004872 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004873 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004874 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004875 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004876 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004877 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004878 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004879 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004880 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004881 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004882 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004883 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004884 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004885 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004886 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004887 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004888 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004889 },
4890
Hubert Feurstein49022642019-07-31 10:23:46 +02004891 [MV88E6220] = {
4892 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4893 .family = MV88E6XXX_FAMILY_6250,
4894 .name = "Marvell 88E6220",
4895 .num_databases = 64,
4896
4897 /* Ports 2-4 are not routed to pins
4898 * => usable ports 0, 1, 5, 6
4899 */
4900 .num_ports = 7,
4901 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004902 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004903 .max_vid = 4095,
4904 .port_base_addr = 0x08,
4905 .phy_base_addr = 0x00,
4906 .global1_addr = 0x0f,
4907 .global2_addr = 0x07,
4908 .age_time_coeff = 15000,
4909 .g1_irqs = 9,
4910 .g2_irqs = 10,
4911 .atu_move_port_mask = 0xf,
4912 .dual_chip = true,
4913 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004914 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004915 .ops = &mv88e6250_ops,
4916 },
4917
Vivien Didelotf81ec902016-05-09 13:22:58 -04004918 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004919 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004920 .family = MV88E6XXX_FAMILY_6352,
4921 .name = "Marvell 88E6240",
4922 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004923 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004924 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004925 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004926 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004927 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004928 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004929 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004930 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004931 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004932 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004933 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004934 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004935 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004936 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004937 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004938 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004939 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004940 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004941 },
4942
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004943 [MV88E6250] = {
4944 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4945 .family = MV88E6XXX_FAMILY_6250,
4946 .name = "Marvell 88E6250",
4947 .num_databases = 64,
4948 .num_ports = 7,
4949 .num_internal_phys = 5,
4950 .max_vid = 4095,
4951 .port_base_addr = 0x08,
4952 .phy_base_addr = 0x00,
4953 .global1_addr = 0x0f,
4954 .global2_addr = 0x07,
4955 .age_time_coeff = 15000,
4956 .g1_irqs = 9,
4957 .g2_irqs = 10,
4958 .atu_move_port_mask = 0xf,
4959 .dual_chip = true,
4960 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004961 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004962 .ops = &mv88e6250_ops,
4963 },
4964
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004965 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004966 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004967 .family = MV88E6XXX_FAMILY_6390,
4968 .name = "Marvell 88E6290",
4969 .num_databases = 4096,
4970 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004971 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004972 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004973 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004974 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004975 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004976 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004977 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004978 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004979 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004980 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004981 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004982 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004983 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004984 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004985 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004986 .ops = &mv88e6290_ops,
4987 },
4988
Vivien Didelotf81ec902016-05-09 13:22:58 -04004989 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004990 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004991 .family = MV88E6XXX_FAMILY_6320,
4992 .name = "Marvell 88E6320",
4993 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004994 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004995 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004996 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004997 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004998 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004999 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005000 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005001 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005002 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005003 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005004 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005005 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005006 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005007 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005008 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005009 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005010 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005011 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005012 },
5013
5014 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005015 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005016 .family = MV88E6XXX_FAMILY_6320,
5017 .name = "Marvell 88E6321",
5018 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005019 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005020 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005021 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005022 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005023 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005024 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005025 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005026 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005027 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005028 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005029 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005030 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005031 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005032 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005033 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005034 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005035 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005036 },
5037
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005038 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005039 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005040 .family = MV88E6XXX_FAMILY_6341,
5041 .name = "Marvell 88E6341",
5042 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005043 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005044 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005045 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005046 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005047 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005048 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005049 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005050 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005051 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005052 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005053 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005054 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005055 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005056 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005057 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005058 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005059 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005060 .ops = &mv88e6341_ops,
5061 },
5062
Vivien Didelotf81ec902016-05-09 13:22:58 -04005063 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005064 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005065 .family = MV88E6XXX_FAMILY_6351,
5066 .name = "Marvell 88E6350",
5067 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005068 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005069 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005070 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005071 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005072 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005073 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005074 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005075 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005076 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005077 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005078 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005079 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005080 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005081 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005082 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005083 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005084 },
5085
5086 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005087 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005088 .family = MV88E6XXX_FAMILY_6351,
5089 .name = "Marvell 88E6351",
5090 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005091 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005092 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005093 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005094 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005095 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005096 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005097 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005098 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005099 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005100 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005101 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005102 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005103 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005104 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005105 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005106 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005107 },
5108
5109 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005110 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005111 .family = MV88E6XXX_FAMILY_6352,
5112 .name = "Marvell 88E6352",
5113 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005114 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005115 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005116 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005117 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005118 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005119 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005120 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005121 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005122 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005123 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005124 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005125 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005126 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005127 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005128 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005129 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005130 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005131 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005132 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005133 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005134 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005135 .family = MV88E6XXX_FAMILY_6390,
5136 .name = "Marvell 88E6390",
5137 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005138 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005139 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005140 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005141 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005142 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005143 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005144 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005145 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005146 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005147 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005148 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005149 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005150 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005151 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005152 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005153 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005154 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005155 .ops = &mv88e6390_ops,
5156 },
5157 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005158 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005159 .family = MV88E6XXX_FAMILY_6390,
5160 .name = "Marvell 88E6390X",
5161 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005162 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005163 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005164 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005165 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005166 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005167 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005168 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005169 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005170 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005171 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005172 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005173 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005174 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005175 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005176 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005177 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005178 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005179 .ops = &mv88e6390x_ops,
5180 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005181};
5182
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005183static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005184{
Vivien Didelota439c062016-04-17 13:23:58 -04005185 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005186
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005187 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5188 if (mv88e6xxx_table[i].prod_num == prod_num)
5189 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005190
Vivien Didelotb9b37712015-10-30 19:39:48 -04005191 return NULL;
5192}
5193
Vivien Didelotfad09c72016-06-21 12:28:20 -04005194static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005195{
5196 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005197 unsigned int prod_num, rev;
5198 u16 id;
5199 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005200
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005201 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005202 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005203 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005204 if (err)
5205 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005206
Vivien Didelot107fcc12017-06-12 12:37:36 -04005207 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5208 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005209
5210 info = mv88e6xxx_lookup_info(prod_num);
5211 if (!info)
5212 return -ENODEV;
5213
Vivien Didelotcaac8542016-06-20 13:14:09 -04005214 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005215 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005216
Vivien Didelotca070c12016-09-02 14:45:34 -04005217 err = mv88e6xxx_g2_require(chip);
5218 if (err)
5219 return err;
5220
Vivien Didelotfad09c72016-06-21 12:28:20 -04005221 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5222 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005223
5224 return 0;
5225}
5226
Vivien Didelotfad09c72016-06-21 12:28:20 -04005227static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005228{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005229 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005230
Vivien Didelotfad09c72016-06-21 12:28:20 -04005231 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5232 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005233 return NULL;
5234
Vivien Didelotfad09c72016-06-21 12:28:20 -04005235 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005236
Vivien Didelotfad09c72016-06-21 12:28:20 -04005237 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005238 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005239 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005240
Vivien Didelotfad09c72016-06-21 12:28:20 -04005241 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005242}
5243
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005244static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005245 int port,
5246 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005247{
Vivien Didelot04bed142016-08-31 18:06:13 -04005248 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005249
Andrew Lunn443d5a12016-12-03 04:35:18 +01005250 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005251}
5252
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005253static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005254 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005255{
5256 /* We don't need any dynamic resource from the kernel (yet),
5257 * so skip the prepare phase.
5258 */
5259
5260 return 0;
5261}
5262
5263static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005264 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005265{
Vivien Didelot04bed142016-08-31 18:06:13 -04005266 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005267
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005268 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005269 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005270 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005271 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5272 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005273 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005274}
5275
5276static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5277 const struct switchdev_obj_port_mdb *mdb)
5278{
Vivien Didelot04bed142016-08-31 18:06:13 -04005279 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005280 int err;
5281
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005282 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005283 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005284 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005285
5286 return err;
5287}
5288
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005289static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5290 struct dsa_mall_mirror_tc_entry *mirror,
5291 bool ingress)
5292{
5293 enum mv88e6xxx_egress_direction direction = ingress ?
5294 MV88E6XXX_EGRESS_DIR_INGRESS :
5295 MV88E6XXX_EGRESS_DIR_EGRESS;
5296 struct mv88e6xxx_chip *chip = ds->priv;
5297 bool other_mirrors = false;
5298 int i;
5299 int err;
5300
5301 if (!chip->info->ops->set_egress_port)
5302 return -EOPNOTSUPP;
5303
5304 mutex_lock(&chip->reg_lock);
5305 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5306 mirror->to_local_port) {
5307 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5308 other_mirrors |= ingress ?
5309 chip->ports[i].mirror_ingress :
5310 chip->ports[i].mirror_egress;
5311
5312 /* Can't change egress port when other mirror is active */
5313 if (other_mirrors) {
5314 err = -EBUSY;
5315 goto out;
5316 }
5317
5318 err = chip->info->ops->set_egress_port(chip,
5319 direction,
5320 mirror->to_local_port);
5321 if (err)
5322 goto out;
5323 }
5324
5325 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5326out:
5327 mutex_unlock(&chip->reg_lock);
5328
5329 return err;
5330}
5331
5332static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5333 struct dsa_mall_mirror_tc_entry *mirror)
5334{
5335 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5336 MV88E6XXX_EGRESS_DIR_INGRESS :
5337 MV88E6XXX_EGRESS_DIR_EGRESS;
5338 struct mv88e6xxx_chip *chip = ds->priv;
5339 bool other_mirrors = false;
5340 int i;
5341
5342 mutex_lock(&chip->reg_lock);
5343 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5344 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5345
5346 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5347 other_mirrors |= mirror->ingress ?
5348 chip->ports[i].mirror_ingress :
5349 chip->ports[i].mirror_egress;
5350
5351 /* Reset egress port when no other mirror is active */
5352 if (!other_mirrors) {
5353 if (chip->info->ops->set_egress_port(chip,
5354 direction,
5355 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005356 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005357 dev_err(ds->dev, "failed to set egress port\n");
5358 }
5359
5360 mutex_unlock(&chip->reg_lock);
5361}
5362
Russell King4f859012019-02-20 15:35:05 -08005363static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5364 bool unicast, bool multicast)
5365{
5366 struct mv88e6xxx_chip *chip = ds->priv;
5367 int err = -EOPNOTSUPP;
5368
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005369 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005370 if (chip->info->ops->port_set_egress_floods)
5371 err = chip->info->ops->port_set_egress_floods(chip, port,
5372 unicast,
5373 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005374 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005375
5376 return err;
5377}
5378
Florian Fainellia82f67a2017-01-08 14:52:08 -08005379static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005380 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005381 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005382 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005383 .phylink_validate = mv88e6xxx_validate,
5384 .phylink_mac_link_state = mv88e6xxx_link_state,
5385 .phylink_mac_config = mv88e6xxx_mac_config,
5386 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5387 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005388 .get_strings = mv88e6xxx_get_strings,
5389 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5390 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005391 .port_enable = mv88e6xxx_port_enable,
5392 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005393 .get_mac_eee = mv88e6xxx_get_mac_eee,
5394 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005395 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005396 .get_eeprom = mv88e6xxx_get_eeprom,
5397 .set_eeprom = mv88e6xxx_set_eeprom,
5398 .get_regs_len = mv88e6xxx_get_regs_len,
5399 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005400 .get_rxnfc = mv88e6xxx_get_rxnfc,
5401 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005402 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005403 .port_bridge_join = mv88e6xxx_port_bridge_join,
5404 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005405 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005406 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005407 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005408 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5409 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5410 .port_vlan_add = mv88e6xxx_port_vlan_add,
5411 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005412 .port_fdb_add = mv88e6xxx_port_fdb_add,
5413 .port_fdb_del = mv88e6xxx_port_fdb_del,
5414 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005415 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5416 .port_mdb_add = mv88e6xxx_port_mdb_add,
5417 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005418 .port_mirror_add = mv88e6xxx_port_mirror_add,
5419 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005420 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5421 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005422 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5423 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5424 .port_txtstamp = mv88e6xxx_port_txtstamp,
5425 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5426 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005427 .devlink_param_get = mv88e6xxx_devlink_param_get,
5428 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005429};
5430
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005431static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005432{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005433 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005434 struct dsa_switch *ds;
5435
Vivien Didelot7e99e342019-10-21 16:51:30 -04005436 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005437 if (!ds)
5438 return -ENOMEM;
5439
Vivien Didelot7e99e342019-10-21 16:51:30 -04005440 ds->dev = dev;
5441 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005442 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005443 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005444 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005445 ds->ageing_time_min = chip->info->age_time_coeff;
5446 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005447
5448 dev_set_drvdata(dev, ds);
5449
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005450 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005451}
5452
Vivien Didelotfad09c72016-06-21 12:28:20 -04005453static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005454{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005455 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005456}
5457
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005458static const void *pdata_device_get_match_data(struct device *dev)
5459{
5460 const struct of_device_id *matches = dev->driver->of_match_table;
5461 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5462
5463 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5464 matches++) {
5465 if (!strcmp(pdata->compatible, matches->compatible))
5466 return matches->data;
5467 }
5468 return NULL;
5469}
5470
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005471/* There is no suspend to RAM support at DSA level yet, the switch configuration
5472 * would be lost after a power cycle so prevent it to be suspended.
5473 */
5474static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5475{
5476 return -EOPNOTSUPP;
5477}
5478
5479static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5480{
5481 return 0;
5482}
5483
5484static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5485
Vivien Didelot57d32312016-06-20 13:13:58 -04005486static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005487{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005488 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005489 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005490 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005491 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005492 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005493 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005494 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005495
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005496 if (!np && !pdata)
5497 return -EINVAL;
5498
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005499 if (np)
5500 compat_info = of_device_get_match_data(dev);
5501
5502 if (pdata) {
5503 compat_info = pdata_device_get_match_data(dev);
5504
5505 if (!pdata->netdev)
5506 return -EINVAL;
5507
5508 for (port = 0; port < DSA_MAX_PORTS; port++) {
5509 if (!(pdata->enabled_ports & (1 << port)))
5510 continue;
5511 if (strcmp(pdata->cd.port_names[port], "cpu"))
5512 continue;
5513 pdata->cd.netdev[port] = &pdata->netdev->dev;
5514 break;
5515 }
5516 }
5517
Vivien Didelotcaac8542016-06-20 13:14:09 -04005518 if (!compat_info)
5519 return -EINVAL;
5520
Vivien Didelotfad09c72016-06-21 12:28:20 -04005521 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005522 if (!chip) {
5523 err = -ENOMEM;
5524 goto out;
5525 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005526
Vivien Didelotfad09c72016-06-21 12:28:20 -04005527 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005528
Vivien Didelotfad09c72016-06-21 12:28:20 -04005529 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005530 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005531 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005532
Andrew Lunnb4308f02016-11-21 23:26:55 +01005533 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005534 if (IS_ERR(chip->reset)) {
5535 err = PTR_ERR(chip->reset);
5536 goto out;
5537 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005538 if (chip->reset)
5539 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005540
Vivien Didelotfad09c72016-06-21 12:28:20 -04005541 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005542 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005543 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005544
Vivien Didelote57e5e72016-08-15 17:19:00 -04005545 mv88e6xxx_phy_init(chip);
5546
Andrew Lunn00baabe2018-05-19 22:31:35 +02005547 if (chip->info->ops->get_eeprom) {
5548 if (np)
5549 of_property_read_u32(np, "eeprom-length",
5550 &chip->eeprom_len);
5551 else
5552 chip->eeprom_len = pdata->eeprom_len;
5553 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005554
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005555 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005556 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005557 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005558 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005559 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005560
Andrew Lunna27415d2019-05-01 00:10:50 +02005561 if (np) {
5562 chip->irq = of_irq_get(np, 0);
5563 if (chip->irq == -EPROBE_DEFER) {
5564 err = chip->irq;
5565 goto out;
5566 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005567 }
5568
Andrew Lunna27415d2019-05-01 00:10:50 +02005569 if (pdata)
5570 chip->irq = pdata->irq;
5571
Andrew Lunn294d7112018-02-22 22:58:32 +01005572 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005573 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005574 * controllers
5575 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005576 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005577 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005578 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005579 else
5580 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005581 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005582
Andrew Lunn294d7112018-02-22 22:58:32 +01005583 if (err)
5584 goto out;
5585
5586 if (chip->info->g2_irqs > 0) {
5587 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005588 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005589 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005590 }
5591
Andrew Lunn294d7112018-02-22 22:58:32 +01005592 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5593 if (err)
5594 goto out_g2_irq;
5595
5596 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5597 if (err)
5598 goto out_g1_atu_prob_irq;
5599
Andrew Lunna3c53be52017-01-24 14:53:50 +01005600 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005601 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005602 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005603
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005604 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005605 if (err)
5606 goto out_mdio;
5607
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005608 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005609
5610out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005611 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005612out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005613 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005614out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005615 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005616out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005617 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005618 mv88e6xxx_g2_irq_free(chip);
5619out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005620 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005621 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005622 else
5623 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005624out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005625 if (pdata)
5626 dev_put(pdata->netdev);
5627
Andrew Lunndc30c352016-10-16 19:56:49 +02005628 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005629}
5630
5631static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5632{
5633 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005634 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005635
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005636 if (chip->info->ptp_support) {
5637 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005638 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005639 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005640
Andrew Lunn930188c2016-08-22 16:01:03 +02005641 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005642 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005643 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005644
Andrew Lunn76f38f12018-03-17 20:21:09 +01005645 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5646 mv88e6xxx_g1_atu_prob_irq_free(chip);
5647
5648 if (chip->info->g2_irqs > 0)
5649 mv88e6xxx_g2_irq_free(chip);
5650
Andrew Lunn76f38f12018-03-17 20:21:09 +01005651 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005652 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005653 else
5654 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005655}
5656
5657static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005658 {
5659 .compatible = "marvell,mv88e6085",
5660 .data = &mv88e6xxx_table[MV88E6085],
5661 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005662 {
5663 .compatible = "marvell,mv88e6190",
5664 .data = &mv88e6xxx_table[MV88E6190],
5665 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005666 {
5667 .compatible = "marvell,mv88e6250",
5668 .data = &mv88e6xxx_table[MV88E6250],
5669 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005670 { /* sentinel */ },
5671};
5672
5673MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5674
5675static struct mdio_driver mv88e6xxx_driver = {
5676 .probe = mv88e6xxx_probe,
5677 .remove = mv88e6xxx_remove,
5678 .mdiodrv.driver = {
5679 .name = "mv88e6085",
5680 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005681 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005682 },
5683};
5684
Andrew Lunn7324d502019-04-27 19:19:10 +02005685mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005686
5687MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5688MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5689MODULE_LICENSE("GPL");