blob: 34c7f3e588ec8eb472682f1d096979524697df72 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Russell King64d47d52020-03-14 10:15:38 +0000400static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
401 int port, phy_interface_t interface)
402{
403 int err;
404
405 if (chip->info->ops->port_set_rgmii_delay) {
406 err = chip->info->ops->port_set_rgmii_delay(chip, port,
407 interface);
408 if (err && err != -EOPNOTSUPP)
409 return err;
410 }
411
412 if (chip->info->ops->port_set_cmode) {
413 err = chip->info->ops->port_set_cmode(chip, port,
414 interface);
415 if (err && err != -EOPNOTSUPP)
416 return err;
417 }
418
419 return 0;
420}
421
Russell Kinga5a68582020-03-14 10:15:43 +0000422static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
423 int link, int speed, int duplex, int pause,
424 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425{
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100427 int err;
428
429 if (!chip->info->ops->port_set_link)
430 return 0;
431
Andrew Lunna26deec2019-04-18 03:11:39 +0200432 if (!chip->info->ops->port_link_state)
433 return 0;
434
435 err = chip->info->ops->port_link_state(chip, port, &state);
436 if (err)
437 return err;
438
439 /* Has anything actually changed? We don't expect the
440 * interface mode to change without one of the other
441 * parameters also changing
442 */
443 if (state.link == link &&
444 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200445 state.duplex == duplex &&
446 (state.interface == mode ||
447 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200448 return 0;
449
Vivien Didelotd78343d2016-11-04 03:23:36 +0100450 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200451 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100452 if (err)
453 return err;
454
Russell Kingf365c6f2020-03-14 10:15:53 +0000455 if (chip->info->ops->port_set_speed_duplex) {
456 err = chip->info->ops->port_set_speed_duplex(chip, port,
457 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100458 if (err && err != -EOPNOTSUPP)
459 goto restore_link;
460 }
461
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100462 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
463 mode = chip->info->ops->port_max_speed_mode(port);
464
Andrew Lunn54186b92018-08-09 15:38:37 +0200465 if (chip->info->ops->port_set_pause) {
466 err = chip->info->ops->port_set_pause(chip, port, pause);
467 if (err)
468 goto restore_link;
469 }
470
Russell King64d47d52020-03-14 10:15:38 +0000471 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100472restore_link:
473 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400474 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100475
476 return err;
477}
478
Marek Vasutd700ec42018-09-12 00:15:24 +0200479static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
480{
481 struct mv88e6xxx_chip *chip = ds->priv;
482
483 return port < chip->info->num_internal_phys;
484}
485
Russell Kinga5a68582020-03-14 10:15:43 +0000486static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
487 struct phylink_link_state *state)
488{
489 struct mv88e6xxx_chip *chip = ds->priv;
490 u8 lane;
491 int err;
492
493 mv88e6xxx_reg_lock(chip);
494 lane = mv88e6xxx_serdes_get_lane(chip, port);
495 if (lane && chip->info->ops->serdes_pcs_get_state)
496 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
497 state);
498 else
499 err = -EOPNOTSUPP;
500 mv88e6xxx_reg_unlock(chip);
501
502 return err;
503}
504
505static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
506 unsigned int mode,
507 phy_interface_t interface,
508 const unsigned long *advertise)
509{
510 const struct mv88e6xxx_ops *ops = chip->info->ops;
511 u8 lane;
512
513 if (ops->serdes_pcs_config) {
514 lane = mv88e6xxx_serdes_get_lane(chip, port);
515 if (lane)
516 return ops->serdes_pcs_config(chip, port, lane, mode,
517 interface, advertise);
518 }
519
520 return 0;
521}
522
523static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
524{
525 struct mv88e6xxx_chip *chip = ds->priv;
526 const struct mv88e6xxx_ops *ops;
527 int err = 0;
528 u8 lane;
529
530 ops = chip->info->ops;
531
532 if (ops->serdes_pcs_an_restart) {
533 mv88e6xxx_reg_lock(chip);
534 lane = mv88e6xxx_serdes_get_lane(chip, port);
535 if (lane)
536 err = ops->serdes_pcs_an_restart(chip, port, lane);
537 mv88e6xxx_reg_unlock(chip);
538
539 if (err)
540 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
541 }
542}
543
544static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
545 unsigned int mode,
546 int speed, int duplex)
547{
548 const struct mv88e6xxx_ops *ops = chip->info->ops;
549 u8 lane;
550
551 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
552 lane = mv88e6xxx_serdes_get_lane(chip, port);
553 if (lane)
554 return ops->serdes_pcs_link_up(chip, port, lane,
555 speed, duplex);
556 }
557
558 return 0;
559}
560
Russell King6c422e32018-08-09 15:38:39 +0200561static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
562 unsigned long *mask,
563 struct phylink_link_state *state)
564{
565 if (!phy_interface_mode_is_8023z(state->interface)) {
566 /* 10M and 100M are only supported in non-802.3z mode */
567 phylink_set(mask, 10baseT_Half);
568 phylink_set(mask, 10baseT_Full);
569 phylink_set(mask, 100baseT_Half);
570 phylink_set(mask, 100baseT_Full);
571 }
572}
573
574static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
575 unsigned long *mask,
576 struct phylink_link_state *state)
577{
578 /* FIXME: if the port is in 1000Base-X mode, then it only supports
579 * 1000M FD speeds. In this case, CMODE will indicate 5.
580 */
581 phylink_set(mask, 1000baseT_Full);
582 phylink_set(mask, 1000baseX_Full);
583
584 mv88e6065_phylink_validate(chip, port, mask, state);
585}
586
Marek Behúne3af71a2019-02-25 12:39:55 +0100587static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
588 unsigned long *mask,
589 struct phylink_link_state *state)
590{
591 if (port >= 5)
592 phylink_set(mask, 2500baseX_Full);
593
594 /* No ethtool bits for 200Mbps */
595 phylink_set(mask, 1000baseT_Full);
596 phylink_set(mask, 1000baseX_Full);
597
598 mv88e6065_phylink_validate(chip, port, mask, state);
599}
600
Russell King6c422e32018-08-09 15:38:39 +0200601static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
602 unsigned long *mask,
603 struct phylink_link_state *state)
604{
605 /* No ethtool bits for 200Mbps */
606 phylink_set(mask, 1000baseT_Full);
607 phylink_set(mask, 1000baseX_Full);
608
609 mv88e6065_phylink_validate(chip, port, mask, state);
610}
611
612static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
613 unsigned long *mask,
614 struct phylink_link_state *state)
615{
Andrew Lunnec260162019-02-08 22:25:44 +0100616 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200617 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100618 phylink_set(mask, 2500baseT_Full);
619 }
Russell King6c422e32018-08-09 15:38:39 +0200620
621 /* No ethtool bits for 200Mbps */
622 phylink_set(mask, 1000baseT_Full);
623 phylink_set(mask, 1000baseX_Full);
624
625 mv88e6065_phylink_validate(chip, port, mask, state);
626}
627
628static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
629 unsigned long *mask,
630 struct phylink_link_state *state)
631{
632 if (port >= 9) {
633 phylink_set(mask, 10000baseT_Full);
634 phylink_set(mask, 10000baseKR_Full);
635 }
636
637 mv88e6390_phylink_validate(chip, port, mask, state);
638}
639
Russell Kingc9a23562018-05-10 13:17:35 -0700640static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
641 unsigned long *supported,
642 struct phylink_link_state *state)
643{
Russell King6c422e32018-08-09 15:38:39 +0200644 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
645 struct mv88e6xxx_chip *chip = ds->priv;
646
647 /* Allow all the expected bits */
648 phylink_set(mask, Autoneg);
649 phylink_set(mask, Pause);
650 phylink_set_port_modes(mask);
651
652 if (chip->info->ops->phylink_validate)
653 chip->info->ops->phylink_validate(chip, port, mask, state);
654
655 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
656 bitmap_and(state->advertising, state->advertising, mask,
657 __ETHTOOL_LINK_MODE_MASK_NBITS);
658
659 /* We can only operate at 2500BaseX or 1000BaseX. If requested
660 * to advertise both, only report advertising at 2500BaseX.
661 */
662 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700663}
664
Russell Kingc9a23562018-05-10 13:17:35 -0700665static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
666 unsigned int mode,
667 const struct phylink_link_state *state)
668{
669 struct mv88e6xxx_chip *chip = ds->priv;
Russell King64d47d52020-03-14 10:15:38 +0000670 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700671
Russell King64d47d52020-03-14 10:15:38 +0000672 /* FIXME: is this the correct test? If we're in fixed mode on an
673 * internal port, why should we process this any different from
674 * PHY mode? On the other hand, the port may be automedia between
675 * an internal PHY and the serdes...
676 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200677 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700678 return;
679
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000680 mv88e6xxx_reg_lock(chip);
Russell King64d47d52020-03-14 10:15:38 +0000681 /* FIXME: should we force the link down here - but if we do, how
682 * do we restore the link force/unforce state? The driver layering
683 * gets in the way.
684 */
685 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000686 if (err && err != -EOPNOTSUPP)
687 goto err_unlock;
688
689 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
690 state->advertising);
691 /* FIXME: we should restart negotiation if something changed - which
692 * is something we get if we convert to using phylinks PCS operations.
693 */
694 if (err > 0)
695 err = 0;
696
697err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000698 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700699
700 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000701 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700702}
703
Russell Kingc9a23562018-05-10 13:17:35 -0700704static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
705 unsigned int mode,
706 phy_interface_t interface)
707{
Russell King30c4a5b2020-02-26 10:23:51 +0000708 struct mv88e6xxx_chip *chip = ds->priv;
709 const struct mv88e6xxx_ops *ops;
710 int err = 0;
711
712 ops = chip->info->ops;
713
714 /* Internal PHYs propagate their configuration directly to the MAC.
715 * External PHYs depend on whether the PPU is enabled for this port.
716 * FIXME: we should be using the PPU enable state here. What about
717 * an automedia port?
718 */
719 if (!mv88e6xxx_phy_is_internal(ds, port) && ops->port_set_link) {
720 mv88e6xxx_reg_lock(chip);
721 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
722 mv88e6xxx_reg_unlock(chip);
723
724 if (err)
725 dev_err(chip->dev,
726 "p%d: failed to force MAC link down\n", port);
727 }
Russell Kingc9a23562018-05-10 13:17:35 -0700728}
729
730static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
731 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000732 struct phy_device *phydev,
733 int speed, int duplex,
734 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700735{
Russell King30c4a5b2020-02-26 10:23:51 +0000736 struct mv88e6xxx_chip *chip = ds->priv;
737 const struct mv88e6xxx_ops *ops;
738 int err = 0;
739
740 ops = chip->info->ops;
741
742 /* Internal PHYs propagate their configuration directly to the MAC.
743 * External PHYs depend on whether the PPU is enabled for this port.
744 * FIXME: we should be using the PPU enable state here. What about
745 * an automedia port?
746 */
747 if (!mv88e6xxx_phy_is_internal(ds, port)) {
748 mv88e6xxx_reg_lock(chip);
749 /* FIXME: for an automedia port, should we force the link
750 * down here - what if the link comes up due to "other" media
751 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000752 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000753 * shared between internal PHY and Serdes.
754 */
Russell Kinga5a68582020-03-14 10:15:43 +0000755 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
756 duplex);
757 if (err)
758 goto error;
759
Russell Kingf365c6f2020-03-14 10:15:53 +0000760 if (ops->port_set_speed_duplex) {
761 err = ops->port_set_speed_duplex(chip, port,
762 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000763 if (err && err != -EOPNOTSUPP)
764 goto error;
765 }
766
767 if (ops->port_set_link)
768 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
769error:
770 mv88e6xxx_reg_unlock(chip);
771
772 if (err && err != -EOPNOTSUPP)
773 dev_err(ds->dev,
774 "p%d: failed to configure MAC link up\n", port);
775 }
Russell Kingc9a23562018-05-10 13:17:35 -0700776}
777
Andrew Lunna605a0f2016-11-21 23:26:58 +0100778static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000779{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100780 if (!chip->info->ops->stats_snapshot)
781 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782
Andrew Lunna605a0f2016-11-21 23:26:58 +0100783 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000784}
785
Andrew Lunne413e7e2015-04-02 04:06:38 +0200786static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100787 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
788 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
789 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
790 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
791 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
792 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
793 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
794 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
795 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
796 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
797 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
798 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
799 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
800 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
801 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
802 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
803 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
804 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
805 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
806 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
807 { "single", 4, 0x14, STATS_TYPE_BANK0, },
808 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
809 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
810 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
811 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
812 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
813 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
814 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
815 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
816 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
817 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
818 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
819 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
820 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
821 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
822 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
823 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
824 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
825 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
826 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
827 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
828 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
829 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
830 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
831 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
832 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
833 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
834 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
835 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
836 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
837 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
838 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
839 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
840 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
841 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
842 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
843 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
844 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
845 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200846};
847
Vivien Didelotfad09c72016-06-21 12:28:20 -0400848static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100849 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100850 int port, u16 bank1_select,
851 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200852{
Andrew Lunn80c46272015-06-20 18:42:30 +0200853 u32 low;
854 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100855 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200856 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 u64 value;
858
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100860 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200861 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
862 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800863 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200864
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100866 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200867 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
868 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800869 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000870 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200871 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100872 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100874 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100875 /* fall through */
876 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100877 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100878 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100879 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100880 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500881 break;
882 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800883 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200884 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100885 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200886 return value;
887}
888
Andrew Lunn436fe172018-03-01 02:02:29 +0100889static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
890 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891{
892 struct mv88e6xxx_hw_stat *stat;
893 int i, j;
894
895 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
896 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100898 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
899 ETH_GSTRING_LEN);
900 j++;
901 }
902 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100903
904 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100905}
906
Andrew Lunn436fe172018-03-01 02:02:29 +0100907static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
908 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100909{
Andrew Lunn436fe172018-03-01 02:02:29 +0100910 return mv88e6xxx_stats_get_strings(chip, data,
911 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100912}
913
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000914static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
915 uint8_t *data)
916{
917 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
918}
919
Andrew Lunn436fe172018-03-01 02:02:29 +0100920static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
921 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100922{
Andrew Lunn436fe172018-03-01 02:02:29 +0100923 return mv88e6xxx_stats_get_strings(chip, data,
924 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100925}
926
Andrew Lunn65f60e42018-03-28 23:50:28 +0200927static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
928 "atu_member_violation",
929 "atu_miss_violation",
930 "atu_full_violation",
931 "vtu_member_violation",
932 "vtu_miss_violation",
933};
934
935static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
936{
937 unsigned int i;
938
939 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
940 strlcpy(data + i * ETH_GSTRING_LEN,
941 mv88e6xxx_atu_vtu_stats_strings[i],
942 ETH_GSTRING_LEN);
943}
944
Andrew Lunndfafe442016-11-21 23:27:02 +0100945static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700946 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100947{
Vivien Didelot04bed142016-08-31 18:06:13 -0400948 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100950
Florian Fainelli89f09042018-04-25 12:12:50 -0700951 if (stringset != ETH_SS_STATS)
952 return;
953
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000954 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100955
Andrew Lunndfafe442016-11-21 23:27:02 +0100956 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100957 count = chip->info->ops->stats_get_strings(chip, data);
958
959 if (chip->info->ops->serdes_get_strings) {
960 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200961 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100962 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100963
Andrew Lunn65f60e42018-03-28 23:50:28 +0200964 data += count * ETH_GSTRING_LEN;
965 mv88e6xxx_atu_vtu_get_strings(data);
966
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000967 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100968}
969
970static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
971 int types)
972{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100973 struct mv88e6xxx_hw_stat *stat;
974 int i, j;
975
976 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
977 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100978 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100979 j++;
980 }
981 return j;
982}
983
Andrew Lunndfafe442016-11-21 23:27:02 +0100984static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
985{
986 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
987 STATS_TYPE_PORT);
988}
989
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000990static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
991{
992 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
993}
994
Andrew Lunndfafe442016-11-21 23:27:02 +0100995static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
996{
997 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
998 STATS_TYPE_BANK1);
999}
1000
Florian Fainelli89f09042018-04-25 12:12:50 -07001001static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001002{
1003 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001004 int serdes_count = 0;
1005 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001006
Florian Fainelli89f09042018-04-25 12:12:50 -07001007 if (sset != ETH_SS_STATS)
1008 return 0;
1009
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001011 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001012 count = chip->info->ops->stats_get_sset_count(chip);
1013 if (count < 0)
1014 goto out;
1015
1016 if (chip->info->ops->serdes_get_sset_count)
1017 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1018 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001019 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001020 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001021 goto out;
1022 }
1023 count += serdes_count;
1024 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1025
Andrew Lunn436fe172018-03-01 02:02:29 +01001026out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001027 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001028
Andrew Lunn436fe172018-03-01 02:02:29 +01001029 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001030}
1031
Andrew Lunn436fe172018-03-01 02:02:29 +01001032static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1033 uint64_t *data, int types,
1034 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001035{
1036 struct mv88e6xxx_hw_stat *stat;
1037 int i, j;
1038
1039 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1040 stat = &mv88e6xxx_hw_stats[i];
1041 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001042 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001043 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1044 bank1_select,
1045 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001047
Andrew Lunn052f9472016-11-21 23:27:03 +01001048 j++;
1049 }
1050 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001051 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001052}
1053
Andrew Lunn436fe172018-03-01 02:02:29 +01001054static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1055 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001056{
1057 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001058 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001059 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001060}
1061
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001062static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1063 uint64_t *data)
1064{
1065 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1066 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1067}
1068
Andrew Lunn436fe172018-03-01 02:02:29 +01001069static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1070 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001071{
1072 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001073 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001074 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1075 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001076}
1077
Andrew Lunn436fe172018-03-01 02:02:29 +01001078static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1079 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001080{
1081 return mv88e6xxx_stats_get_stats(chip, port, data,
1082 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001083 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1084 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001085}
1086
Andrew Lunn65f60e42018-03-28 23:50:28 +02001087static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1088 uint64_t *data)
1089{
1090 *data++ = chip->ports[port].atu_member_violation;
1091 *data++ = chip->ports[port].atu_miss_violation;
1092 *data++ = chip->ports[port].atu_full_violation;
1093 *data++ = chip->ports[port].vtu_member_violation;
1094 *data++ = chip->ports[port].vtu_miss_violation;
1095}
1096
Andrew Lunn052f9472016-11-21 23:27:03 +01001097static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1098 uint64_t *data)
1099{
Andrew Lunn436fe172018-03-01 02:02:29 +01001100 int count = 0;
1101
Andrew Lunn052f9472016-11-21 23:27:03 +01001102 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001103 count = chip->info->ops->stats_get_stats(chip, port, data);
1104
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001105 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001106 if (chip->info->ops->serdes_get_stats) {
1107 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001108 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001109 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001110 data += count;
1111 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001112 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001113}
1114
Vivien Didelotf81ec902016-05-09 13:22:58 -04001115static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1116 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001117{
Vivien Didelot04bed142016-08-31 18:06:13 -04001118 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001119 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001120
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001121 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001122
Andrew Lunna605a0f2016-11-21 23:26:58 +01001123 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001124 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001125
1126 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001127 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001128
1129 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001130
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001131}
Ben Hutchings98e67302011-11-25 14:36:19 +00001132
Vivien Didelotf81ec902016-05-09 13:22:58 -04001133static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001135 struct mv88e6xxx_chip *chip = ds->priv;
1136 int len;
1137
1138 len = 32 * sizeof(u16);
1139 if (chip->info->ops->serdes_get_regs_len)
1140 len += chip->info->ops->serdes_get_regs_len(chip, port);
1141
1142 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001143}
1144
Vivien Didelotf81ec902016-05-09 13:22:58 -04001145static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1146 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147{
Vivien Didelot04bed142016-08-31 18:06:13 -04001148 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001149 int err;
1150 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151 u16 *p = _p;
1152 int i;
1153
Vivien Didelota5f39322018-12-17 16:05:21 -05001154 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001155
1156 memset(p, 0xff, 32 * sizeof(u16));
1157
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001158 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001159
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001160 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001161
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001162 err = mv88e6xxx_port_read(chip, port, i, &reg);
1163 if (!err)
1164 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001165 }
Vivien Didelot23062512016-05-09 13:22:45 -04001166
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001167 if (chip->info->ops->serdes_get_regs)
1168 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1169
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001170 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001171}
1172
Vivien Didelot08f50062017-08-01 16:32:41 -04001173static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1174 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001175{
Vivien Didelot5480db62017-08-01 16:32:40 -04001176 /* Nothing to do on the port's MAC */
1177 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001178}
1179
Vivien Didelot08f50062017-08-01 16:32:41 -04001180static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1181 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001182{
Vivien Didelot5480db62017-08-01 16:32:40 -04001183 /* Nothing to do on the port's MAC */
1184 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001185}
1186
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001187/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001188static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001189{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001190 struct dsa_switch *ds = chip->ds;
1191 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001192 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001193 struct dsa_port *dp;
1194 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001195 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001196
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001197 list_for_each_entry(dp, &dst->ports, list) {
1198 if (dp->ds->index == dev && dp->index == port) {
1199 found = true;
1200 break;
1201 }
1202 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001203
Vivien Didelote5887a22017-03-30 17:37:11 -04001204 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001205 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001206 return 0;
1207
1208 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001209 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001210 return mv88e6xxx_port_mask(chip);
1211
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001212 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001213 pvlan = 0;
1214
1215 /* Frames from user ports can egress any local DSA links and CPU ports,
1216 * as well as any local member of their bridge group.
1217 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001218 list_for_each_entry(dp, &dst->ports, list)
1219 if (dp->ds == ds &&
1220 (dp->type == DSA_PORT_TYPE_CPU ||
1221 dp->type == DSA_PORT_TYPE_DSA ||
1222 (br && dp->bridge_dev == br)))
1223 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001224
1225 return pvlan;
1226}
1227
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001228static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001229{
1230 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001231
1232 /* prevent frames from going back out of the port they came in on */
1233 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001234
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001235 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001236}
1237
Vivien Didelotf81ec902016-05-09 13:22:58 -04001238static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1239 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001240{
Vivien Didelot04bed142016-08-31 18:06:13 -04001241 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001242 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001243
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001244 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001245 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001246 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001247
1248 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001249 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001250}
1251
Vivien Didelot93e18d62018-05-11 17:16:35 -04001252static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1253{
1254 int err;
1255
1256 if (chip->info->ops->ieee_pri_map) {
1257 err = chip->info->ops->ieee_pri_map(chip);
1258 if (err)
1259 return err;
1260 }
1261
1262 if (chip->info->ops->ip_pri_map) {
1263 err = chip->info->ops->ip_pri_map(chip);
1264 if (err)
1265 return err;
1266 }
1267
1268 return 0;
1269}
1270
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001271static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1272{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001273 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001274 int target, port;
1275 int err;
1276
1277 if (!chip->info->global2_addr)
1278 return 0;
1279
1280 /* Initialize the routing port to the 32 possible target devices */
1281 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001282 port = dsa_routing_port(ds, target);
1283 if (port == ds->num_ports)
1284 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001285
1286 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1287 if (err)
1288 return err;
1289 }
1290
Vivien Didelot02317e62018-05-09 11:38:49 -04001291 if (chip->info->ops->set_cascade_port) {
1292 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1293 err = chip->info->ops->set_cascade_port(chip, port);
1294 if (err)
1295 return err;
1296 }
1297
Vivien Didelot23c98912018-05-09 11:38:50 -04001298 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1299 if (err)
1300 return err;
1301
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001302 return 0;
1303}
1304
Vivien Didelotb28f8722018-04-26 21:56:44 -04001305static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1306{
1307 /* Clear all trunk masks and mapping */
1308 if (chip->info->global2_addr)
1309 return mv88e6xxx_g2_trunk_clear(chip);
1310
1311 return 0;
1312}
1313
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001314static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1315{
1316 if (chip->info->ops->rmu_disable)
1317 return chip->info->ops->rmu_disable(chip);
1318
1319 return 0;
1320}
1321
Vivien Didelot9e907d72017-07-17 13:03:43 -04001322static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1323{
1324 if (chip->info->ops->pot_clear)
1325 return chip->info->ops->pot_clear(chip);
1326
1327 return 0;
1328}
1329
Vivien Didelot51c901a2017-07-17 13:03:41 -04001330static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1331{
1332 if (chip->info->ops->mgmt_rsvd2cpu)
1333 return chip->info->ops->mgmt_rsvd2cpu(chip);
1334
1335 return 0;
1336}
1337
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001338static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1339{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001340 int err;
1341
Vivien Didelotdaefc942017-03-11 16:12:54 -05001342 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1343 if (err)
1344 return err;
1345
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001346 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1347 if (err)
1348 return err;
1349
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001350 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1351}
1352
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001353static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1354{
1355 int port;
1356 int err;
1357
1358 if (!chip->info->ops->irl_init_all)
1359 return 0;
1360
1361 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1362 /* Disable ingress rate limiting by resetting all per port
1363 * ingress rate limit resources to their initial state.
1364 */
1365 err = chip->info->ops->irl_init_all(chip, port);
1366 if (err)
1367 return err;
1368 }
1369
1370 return 0;
1371}
1372
Vivien Didelot04a69a12017-10-13 14:18:05 -04001373static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1374{
1375 if (chip->info->ops->set_switch_mac) {
1376 u8 addr[ETH_ALEN];
1377
1378 eth_random_addr(addr);
1379
1380 return chip->info->ops->set_switch_mac(chip, addr);
1381 }
1382
1383 return 0;
1384}
1385
Vivien Didelot17a15942017-03-30 17:37:09 -04001386static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1387{
1388 u16 pvlan = 0;
1389
1390 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001391 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001392
1393 /* Skip the local source device, which uses in-chip port VLAN */
1394 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001395 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001396
1397 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1398}
1399
Vivien Didelot81228992017-03-30 17:37:08 -04001400static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1401{
Vivien Didelot17a15942017-03-30 17:37:09 -04001402 int dev, port;
1403 int err;
1404
Vivien Didelot81228992017-03-30 17:37:08 -04001405 if (!mv88e6xxx_has_pvt(chip))
1406 return 0;
1407
1408 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1409 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1410 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001411 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1412 if (err)
1413 return err;
1414
1415 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1416 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1417 err = mv88e6xxx_pvt_map(chip, dev, port);
1418 if (err)
1419 return err;
1420 }
1421 }
1422
1423 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001424}
1425
Vivien Didelot749efcb2016-09-22 16:49:24 -04001426static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1427{
1428 struct mv88e6xxx_chip *chip = ds->priv;
1429 int err;
1430
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001431 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001432 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001433 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001434
1435 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001436 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001437}
1438
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001439static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1440{
1441 if (!chip->info->max_vid)
1442 return 0;
1443
1444 return mv88e6xxx_g1_vtu_flush(chip);
1445}
1446
Vivien Didelotf1394b782017-05-01 14:05:22 -04001447static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1448 struct mv88e6xxx_vtu_entry *entry)
1449{
1450 if (!chip->info->ops->vtu_getnext)
1451 return -EOPNOTSUPP;
1452
1453 return chip->info->ops->vtu_getnext(chip, entry);
1454}
1455
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001456static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1457 struct mv88e6xxx_vtu_entry *entry)
1458{
1459 if (!chip->info->ops->vtu_loadpurge)
1460 return -EOPNOTSUPP;
1461
1462 return chip->info->ops->vtu_loadpurge(chip, entry);
1463}
1464
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001465static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001466{
1467 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001468 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001469 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001470
1471 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1472
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001473 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001474 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001475 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001476 if (err)
1477 return err;
1478
1479 set_bit(*fid, fid_bitmap);
1480 }
1481
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001482 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001483 vlan.vid = chip->info->max_vid;
1484 vlan.valid = false;
1485
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001486 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001487 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001488 if (err)
1489 return err;
1490
1491 if (!vlan.valid)
1492 break;
1493
1494 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001495 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001496
1497 /* The reset value 0x000 is used to indicate that multiple address
1498 * databases are not needed. Return the next positive available.
1499 */
1500 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001501 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001502 return -ENOSPC;
1503
1504 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001505 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001506}
1507
Andrew Lunn23e8b472019-10-25 01:03:52 +02001508static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1509{
1510 if (chip->info->ops->atu_get_hash)
1511 return chip->info->ops->atu_get_hash(chip, hash);
1512
1513 return -EOPNOTSUPP;
1514}
1515
1516static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1517{
1518 if (chip->info->ops->atu_set_hash)
1519 return chip->info->ops->atu_set_hash(chip, hash);
1520
1521 return -EOPNOTSUPP;
1522}
1523
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1525 u16 vid_begin, u16 vid_end)
1526{
Vivien Didelot04bed142016-08-31 18:06:13 -04001527 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001528 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 int i, err;
1530
Andrew Lunndb06ae412017-09-25 23:32:20 +02001531 /* DSA and CPU ports have to be members of multiple vlans */
1532 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1533 return 0;
1534
Vivien Didelotda9c3592016-02-12 12:09:40 -05001535 if (!vid_begin)
1536 return -EOPNOTSUPP;
1537
Vivien Didelot425d2d32019-08-01 14:36:34 -04001538 vlan.vid = vid_begin - 1;
1539 vlan.valid = false;
1540
Vivien Didelotda9c3592016-02-12 12:09:40 -05001541 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001542 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001543 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001544 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545
1546 if (!vlan.valid)
1547 break;
1548
1549 if (vlan.vid > vid_end)
1550 break;
1551
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001552 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001553 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1554 continue;
1555
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001556 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001557 continue;
1558
Vivien Didelotbd00e052017-05-01 14:05:11 -04001559 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001560 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 continue;
1562
Vivien Didelotc8652c82017-10-16 11:12:19 -04001563 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001564 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565 break; /* same bridge, check next VLAN */
1566
Vivien Didelotc8652c82017-10-16 11:12:19 -04001567 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001568 continue;
1569
Andrew Lunn743fcc22017-11-09 22:29:54 +01001570 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1571 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001572 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001573 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001574 }
1575 } while (vlan.vid < vid_end);
1576
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001577 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001578}
1579
Vivien Didelotf81ec902016-05-09 13:22:58 -04001580static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1581 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582{
Vivien Didelot04bed142016-08-31 18:06:13 -04001583 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001584 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1585 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001586 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001587
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001588 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001589 return -EOPNOTSUPP;
1590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001591 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001592 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001593 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001594
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001595 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001596}
1597
Vivien Didelot57d32312016-06-20 13:13:58 -04001598static int
1599mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001600 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001601{
Vivien Didelot04bed142016-08-31 18:06:13 -04001602 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001603 int err;
1604
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001605 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001606 return -EOPNOTSUPP;
1607
Vivien Didelotda9c3592016-02-12 12:09:40 -05001608 /* If the requested port doesn't belong to the same bridge as the VLAN
1609 * members, do not support it (yet) and fallback to software VLAN.
1610 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001611 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001612 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1613 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001614 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001615
Vivien Didelot76e398a2015-11-01 12:33:55 -05001616 /* We don't need any dynamic resource from the kernel (yet),
1617 * so skip the prepare phase.
1618 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001619 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620}
1621
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001622static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1623 const unsigned char *addr, u16 vid,
1624 u8 state)
1625{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001626 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001627 struct mv88e6xxx_vtu_entry vlan;
1628 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001629 int err;
1630
1631 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001632 if (vid == 0) {
1633 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1634 if (err)
1635 return err;
1636 } else {
1637 vlan.vid = vid - 1;
1638 vlan.valid = false;
1639
1640 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1641 if (err)
1642 return err;
1643
1644 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1645 if (vlan.vid != vid || !vlan.valid)
1646 return -EOPNOTSUPP;
1647
1648 fid = vlan.fid;
1649 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001650
Vivien Didelotd8291a92019-09-07 16:00:47 -04001651 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001652 ether_addr_copy(entry.mac, addr);
1653 eth_addr_dec(entry.mac);
1654
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001655 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001656 if (err)
1657 return err;
1658
1659 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001660 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001661 memset(&entry, 0, sizeof(entry));
1662 ether_addr_copy(entry.mac, addr);
1663 }
1664
1665 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001666 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001667 entry.portvec &= ~BIT(port);
1668 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001669 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001670 } else {
1671 entry.portvec |= BIT(port);
1672 entry.state = state;
1673 }
1674
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001675 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001676}
1677
Vivien Didelotda7dc872019-09-07 16:00:49 -04001678static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1679 const struct mv88e6xxx_policy *policy)
1680{
1681 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1682 enum mv88e6xxx_policy_action action = policy->action;
1683 const u8 *addr = policy->addr;
1684 u16 vid = policy->vid;
1685 u8 state;
1686 int err;
1687 int id;
1688
1689 if (!chip->info->ops->port_set_policy)
1690 return -EOPNOTSUPP;
1691
1692 switch (mapping) {
1693 case MV88E6XXX_POLICY_MAPPING_DA:
1694 case MV88E6XXX_POLICY_MAPPING_SA:
1695 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1696 state = 0; /* Dissociate the port and address */
1697 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1698 is_multicast_ether_addr(addr))
1699 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1700 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1701 is_unicast_ether_addr(addr))
1702 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1703 else
1704 return -EOPNOTSUPP;
1705
1706 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1707 state);
1708 if (err)
1709 return err;
1710 break;
1711 default:
1712 return -EOPNOTSUPP;
1713 }
1714
1715 /* Skip the port's policy clearing if the mapping is still in use */
1716 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1717 idr_for_each_entry(&chip->policies, policy, id)
1718 if (policy->port == port &&
1719 policy->mapping == mapping &&
1720 policy->action != action)
1721 return 0;
1722
1723 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1724}
1725
1726static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1727 struct ethtool_rx_flow_spec *fs)
1728{
1729 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1730 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1731 enum mv88e6xxx_policy_mapping mapping;
1732 enum mv88e6xxx_policy_action action;
1733 struct mv88e6xxx_policy *policy;
1734 u16 vid = 0;
1735 u8 *addr;
1736 int err;
1737 int id;
1738
1739 if (fs->location != RX_CLS_LOC_ANY)
1740 return -EINVAL;
1741
1742 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1743 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1744 else
1745 return -EOPNOTSUPP;
1746
1747 switch (fs->flow_type & ~FLOW_EXT) {
1748 case ETHER_FLOW:
1749 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1750 is_zero_ether_addr(mac_mask->h_source)) {
1751 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1752 addr = mac_entry->h_dest;
1753 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1754 !is_zero_ether_addr(mac_mask->h_source)) {
1755 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1756 addr = mac_entry->h_source;
1757 } else {
1758 /* Cannot support DA and SA mapping in the same rule */
1759 return -EOPNOTSUPP;
1760 }
1761 break;
1762 default:
1763 return -EOPNOTSUPP;
1764 }
1765
1766 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1767 if (fs->m_ext.vlan_tci != 0xffff)
1768 return -EOPNOTSUPP;
1769 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1770 }
1771
1772 idr_for_each_entry(&chip->policies, policy, id) {
1773 if (policy->port == port && policy->mapping == mapping &&
1774 policy->action == action && policy->vid == vid &&
1775 ether_addr_equal(policy->addr, addr))
1776 return -EEXIST;
1777 }
1778
1779 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1780 if (!policy)
1781 return -ENOMEM;
1782
1783 fs->location = 0;
1784 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1785 GFP_KERNEL);
1786 if (err) {
1787 devm_kfree(chip->dev, policy);
1788 return err;
1789 }
1790
1791 memcpy(&policy->fs, fs, sizeof(*fs));
1792 ether_addr_copy(policy->addr, addr);
1793 policy->mapping = mapping;
1794 policy->action = action;
1795 policy->port = port;
1796 policy->vid = vid;
1797
1798 err = mv88e6xxx_policy_apply(chip, port, policy);
1799 if (err) {
1800 idr_remove(&chip->policies, fs->location);
1801 devm_kfree(chip->dev, policy);
1802 return err;
1803 }
1804
1805 return 0;
1806}
1807
1808static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1809 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1810{
1811 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1812 struct mv88e6xxx_chip *chip = ds->priv;
1813 struct mv88e6xxx_policy *policy;
1814 int err;
1815 int id;
1816
1817 mv88e6xxx_reg_lock(chip);
1818
1819 switch (rxnfc->cmd) {
1820 case ETHTOOL_GRXCLSRLCNT:
1821 rxnfc->data = 0;
1822 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1823 rxnfc->rule_cnt = 0;
1824 idr_for_each_entry(&chip->policies, policy, id)
1825 if (policy->port == port)
1826 rxnfc->rule_cnt++;
1827 err = 0;
1828 break;
1829 case ETHTOOL_GRXCLSRULE:
1830 err = -ENOENT;
1831 policy = idr_find(&chip->policies, fs->location);
1832 if (policy) {
1833 memcpy(fs, &policy->fs, sizeof(*fs));
1834 err = 0;
1835 }
1836 break;
1837 case ETHTOOL_GRXCLSRLALL:
1838 rxnfc->data = 0;
1839 rxnfc->rule_cnt = 0;
1840 idr_for_each_entry(&chip->policies, policy, id)
1841 if (policy->port == port)
1842 rule_locs[rxnfc->rule_cnt++] = id;
1843 err = 0;
1844 break;
1845 default:
1846 err = -EOPNOTSUPP;
1847 break;
1848 }
1849
1850 mv88e6xxx_reg_unlock(chip);
1851
1852 return err;
1853}
1854
1855static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1856 struct ethtool_rxnfc *rxnfc)
1857{
1858 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1859 struct mv88e6xxx_chip *chip = ds->priv;
1860 struct mv88e6xxx_policy *policy;
1861 int err;
1862
1863 mv88e6xxx_reg_lock(chip);
1864
1865 switch (rxnfc->cmd) {
1866 case ETHTOOL_SRXCLSRLINS:
1867 err = mv88e6xxx_policy_insert(chip, port, fs);
1868 break;
1869 case ETHTOOL_SRXCLSRLDEL:
1870 err = -ENOENT;
1871 policy = idr_remove(&chip->policies, fs->location);
1872 if (policy) {
1873 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1874 err = mv88e6xxx_policy_apply(chip, port, policy);
1875 devm_kfree(chip->dev, policy);
1876 }
1877 break;
1878 default:
1879 err = -EOPNOTSUPP;
1880 break;
1881 }
1882
1883 mv88e6xxx_reg_unlock(chip);
1884
1885 return err;
1886}
1887
Andrew Lunn87fa8862017-11-09 22:29:56 +01001888static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1889 u16 vid)
1890{
1891 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1892 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1893
1894 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1895}
1896
1897static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1898{
1899 int port;
1900 int err;
1901
1902 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1903 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1904 if (err)
1905 return err;
1906 }
1907
1908 return 0;
1909}
1910
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001911static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001912 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001913{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001914 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001915 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001916 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001917
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001918 if (!vid)
1919 return -EOPNOTSUPP;
1920
1921 vlan.vid = vid - 1;
1922 vlan.valid = false;
1923
1924 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001925 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001926 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001927
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001928 if (vlan.vid != vid || !vlan.valid) {
1929 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001930
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001931 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1932 if (err)
1933 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001934
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001935 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1936 if (i == port)
1937 vlan.member[i] = member;
1938 else
1939 vlan.member[i] = non_member;
1940
1941 vlan.vid = vid;
1942 vlan.valid = true;
1943
1944 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1945 if (err)
1946 return err;
1947
1948 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1949 if (err)
1950 return err;
1951 } else if (vlan.member[port] != member) {
1952 vlan.member[port] = member;
1953
1954 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1955 if (err)
1956 return err;
Russell King933b4422020-02-26 17:14:26 +00001957 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001958 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1959 port, vid);
1960 }
1961
1962 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001963}
1964
Vivien Didelotf81ec902016-05-09 13:22:58 -04001965static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001966 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001967{
Vivien Didelot04bed142016-08-31 18:06:13 -04001968 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001969 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1970 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001971 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001972 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001973 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001974
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001975 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001976 return;
1977
Vivien Didelotc91498e2017-06-07 18:12:13 -04001978 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001979 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001980 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001981 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001982 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001983 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001984
Russell King933b4422020-02-26 17:14:26 +00001985 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1986 * and then the CPU port. Do not warn for duplicates for the CPU port.
1987 */
1988 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1989
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001990 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001991
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001992 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001993 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001994 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1995 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001996
Vivien Didelot77064f32016-11-04 03:23:30 +01001997 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001998 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1999 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002000
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002001 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002002}
2003
Vivien Didelot521098922019-08-01 14:36:36 -04002004static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2005 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002006{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002007 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002008 int i, err;
2009
Vivien Didelot521098922019-08-01 14:36:36 -04002010 if (!vid)
2011 return -EOPNOTSUPP;
2012
2013 vlan.vid = vid - 1;
2014 vlan.valid = false;
2015
2016 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002017 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002018 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002019
Vivien Didelot521098922019-08-01 14:36:36 -04002020 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2021 * tell switchdev that this VLAN is likely handled in software.
2022 */
2023 if (vlan.vid != vid || !vlan.valid ||
2024 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002025 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002026
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002027 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002028
2029 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002030 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002031 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002032 if (vlan.member[i] !=
2033 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002034 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002035 break;
2036 }
2037 }
2038
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002039 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002040 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002041 return err;
2042
Vivien Didelote606ca32017-03-11 16:12:55 -05002043 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002044}
2045
Vivien Didelotf81ec902016-05-09 13:22:58 -04002046static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2047 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002048{
Vivien Didelot04bed142016-08-31 18:06:13 -04002049 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002050 u16 pvid, vid;
2051 int err = 0;
2052
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002053 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002054 return -EOPNOTSUPP;
2055
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002056 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002057
Vivien Didelot77064f32016-11-04 03:23:30 +01002058 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002059 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002060 goto unlock;
2061
Vivien Didelot76e398a2015-11-01 12:33:55 -05002062 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002063 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002064 if (err)
2065 goto unlock;
2066
2067 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002068 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002069 if (err)
2070 goto unlock;
2071 }
2072 }
2073
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002074unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002075 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002076
2077 return err;
2078}
2079
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002080static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2081 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002082{
Vivien Didelot04bed142016-08-31 18:06:13 -04002083 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002084 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002085
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002086 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002087 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2088 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002089 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002090
2091 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002092}
2093
Vivien Didelotf81ec902016-05-09 13:22:58 -04002094static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002095 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002096{
Vivien Didelot04bed142016-08-31 18:06:13 -04002097 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002098 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002099
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002100 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002101 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002102 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002103
Vivien Didelot83dabd12016-08-31 11:50:04 -04002104 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002105}
2106
Vivien Didelot83dabd12016-08-31 11:50:04 -04002107static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2108 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002109 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002110{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002111 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002112 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002113 int err;
2114
Vivien Didelotd8291a92019-09-07 16:00:47 -04002115 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002116 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002117
2118 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002119 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002120 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002121 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002122
Vivien Didelotd8291a92019-09-07 16:00:47 -04002123 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002124 break;
2125
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002126 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002127 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002128
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002129 if (!is_unicast_ether_addr(addr.mac))
2130 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002131
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002132 is_static = (addr.state ==
2133 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2134 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002135 if (err)
2136 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002137 } while (!is_broadcast_ether_addr(addr.mac));
2138
2139 return err;
2140}
2141
Vivien Didelot83dabd12016-08-31 11:50:04 -04002142static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002143 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002144{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002145 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002146 u16 fid;
2147 int err;
2148
2149 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002150 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002151 if (err)
2152 return err;
2153
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002154 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002155 if (err)
2156 return err;
2157
2158 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002159 vlan.vid = chip->info->max_vid;
2160 vlan.valid = false;
2161
Vivien Didelot83dabd12016-08-31 11:50:04 -04002162 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002163 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002164 if (err)
2165 return err;
2166
2167 if (!vlan.valid)
2168 break;
2169
2170 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002171 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002172 if (err)
2173 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002174 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002175
2176 return err;
2177}
2178
Vivien Didelotf81ec902016-05-09 13:22:58 -04002179static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002180 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002181{
Vivien Didelot04bed142016-08-31 18:06:13 -04002182 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002183 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002184
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002185 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002186 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002187 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002188
2189 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002190}
2191
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002192static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2193 struct net_device *br)
2194{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002195 struct dsa_switch *ds = chip->ds;
2196 struct dsa_switch_tree *dst = ds->dst;
2197 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002198 int err;
2199
Vivien Didelotef2025e2019-10-21 16:51:27 -04002200 list_for_each_entry(dp, &dst->ports, list) {
2201 if (dp->bridge_dev == br) {
2202 if (dp->ds == ds) {
2203 /* This is a local bridge group member,
2204 * remap its Port VLAN Map.
2205 */
2206 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2207 if (err)
2208 return err;
2209 } else {
2210 /* This is an external bridge group member,
2211 * remap its cross-chip Port VLAN Table entry.
2212 */
2213 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2214 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002215 if (err)
2216 return err;
2217 }
2218 }
2219 }
2220
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002221 return 0;
2222}
2223
Vivien Didelotf81ec902016-05-09 13:22:58 -04002224static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002225 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002226{
Vivien Didelot04bed142016-08-31 18:06:13 -04002227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002228 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002229
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002230 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002231 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002232 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002233
Vivien Didelot466dfa02016-02-26 13:16:05 -05002234 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002235}
2236
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002237static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2238 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002239{
Vivien Didelot04bed142016-08-31 18:06:13 -04002240 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002241
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002242 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002243 if (mv88e6xxx_bridge_map(chip, br) ||
2244 mv88e6xxx_port_vlan_map(chip, port))
2245 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002246 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002247}
2248
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002249static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2250 int port, struct net_device *br)
2251{
2252 struct mv88e6xxx_chip *chip = ds->priv;
2253 int err;
2254
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002255 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002256 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002257 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002258
2259 return err;
2260}
2261
2262static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2263 int port, struct net_device *br)
2264{
2265 struct mv88e6xxx_chip *chip = ds->priv;
2266
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002267 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002268 if (mv88e6xxx_pvt_map(chip, dev, port))
2269 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002270 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002271}
2272
Vivien Didelot17e708b2016-12-05 17:30:27 -05002273static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2274{
2275 if (chip->info->ops->reset)
2276 return chip->info->ops->reset(chip);
2277
2278 return 0;
2279}
2280
Vivien Didelot309eca62016-12-05 17:30:26 -05002281static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2282{
2283 struct gpio_desc *gpiod = chip->reset;
2284
2285 /* If there is a GPIO connected to the reset pin, toggle it */
2286 if (gpiod) {
2287 gpiod_set_value_cansleep(gpiod, 1);
2288 usleep_range(10000, 20000);
2289 gpiod_set_value_cansleep(gpiod, 0);
2290 usleep_range(10000, 20000);
2291 }
2292}
2293
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002294static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2295{
2296 int i, err;
2297
2298 /* Set all ports to the Disabled state */
2299 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002300 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002301 if (err)
2302 return err;
2303 }
2304
2305 /* Wait for transmit queues to drain,
2306 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2307 */
2308 usleep_range(2000, 4000);
2309
2310 return 0;
2311}
2312
Vivien Didelotfad09c72016-06-21 12:28:20 -04002313static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002314{
Vivien Didelota935c052016-09-29 12:21:53 -04002315 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002316
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002317 err = mv88e6xxx_disable_ports(chip);
2318 if (err)
2319 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002320
Vivien Didelot309eca62016-12-05 17:30:26 -05002321 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002322
Vivien Didelot17e708b2016-12-05 17:30:27 -05002323 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002324}
2325
Vivien Didelot43145572017-03-11 16:12:59 -05002326static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002327 enum mv88e6xxx_frame_mode frame,
2328 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002329{
2330 int err;
2331
Vivien Didelot43145572017-03-11 16:12:59 -05002332 if (!chip->info->ops->port_set_frame_mode)
2333 return -EOPNOTSUPP;
2334
2335 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002336 if (err)
2337 return err;
2338
Vivien Didelot43145572017-03-11 16:12:59 -05002339 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2340 if (err)
2341 return err;
2342
2343 if (chip->info->ops->port_set_ether_type)
2344 return chip->info->ops->port_set_ether_type(chip, port, etype);
2345
2346 return 0;
2347}
2348
2349static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2350{
2351 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002352 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002353 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002354}
2355
2356static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2357{
2358 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002359 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002360 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002361}
2362
2363static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2364{
2365 return mv88e6xxx_set_port_mode(chip, port,
2366 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002367 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2368 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002369}
2370
2371static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2372{
2373 if (dsa_is_dsa_port(chip->ds, port))
2374 return mv88e6xxx_set_port_mode_dsa(chip, port);
2375
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002376 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002377 return mv88e6xxx_set_port_mode_normal(chip, port);
2378
2379 /* Setup CPU port mode depending on its supported tag format */
2380 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2381 return mv88e6xxx_set_port_mode_dsa(chip, port);
2382
2383 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2384 return mv88e6xxx_set_port_mode_edsa(chip, port);
2385
2386 return -EINVAL;
2387}
2388
Vivien Didelotea698f42017-03-11 16:12:50 -05002389static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2390{
2391 bool message = dsa_is_dsa_port(chip->ds, port);
2392
2393 return mv88e6xxx_port_set_message_port(chip, port, message);
2394}
2395
Vivien Didelot601aeed2017-03-11 16:13:00 -05002396static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2397{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002398 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002399 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002400
David S. Miller407308f2019-06-15 13:35:29 -07002401 /* Upstream ports flood frames with unknown unicast or multicast DA */
2402 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2403 if (chip->info->ops->port_set_egress_floods)
2404 return chip->info->ops->port_set_egress_floods(chip, port,
2405 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002406
David S. Miller407308f2019-06-15 13:35:29 -07002407 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002408}
2409
Vivien Didelot45de77f2019-08-31 16:18:36 -04002410static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2411{
2412 struct mv88e6xxx_port *mvp = dev_id;
2413 struct mv88e6xxx_chip *chip = mvp->chip;
2414 irqreturn_t ret = IRQ_NONE;
2415 int port = mvp->port;
2416 u8 lane;
2417
2418 mv88e6xxx_reg_lock(chip);
2419 lane = mv88e6xxx_serdes_get_lane(chip, port);
2420 if (lane)
2421 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2422 mv88e6xxx_reg_unlock(chip);
2423
2424 return ret;
2425}
2426
2427static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2428 u8 lane)
2429{
2430 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2431 unsigned int irq;
2432 int err;
2433
2434 /* Nothing to request if this SERDES port has no IRQ */
2435 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2436 if (!irq)
2437 return 0;
2438
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002439 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2440 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2441
Vivien Didelot45de77f2019-08-31 16:18:36 -04002442 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2443 mv88e6xxx_reg_unlock(chip);
2444 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002445 IRQF_ONESHOT, dev_id->serdes_irq_name,
2446 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002447 mv88e6xxx_reg_lock(chip);
2448 if (err)
2449 return err;
2450
2451 dev_id->serdes_irq = irq;
2452
2453 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2454}
2455
2456static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2457 u8 lane)
2458{
2459 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2460 unsigned int irq = dev_id->serdes_irq;
2461 int err;
2462
2463 /* Nothing to free if no IRQ has been requested */
2464 if (!irq)
2465 return 0;
2466
2467 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2468
2469 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2470 mv88e6xxx_reg_unlock(chip);
2471 free_irq(irq, dev_id);
2472 mv88e6xxx_reg_lock(chip);
2473
2474 dev_id->serdes_irq = 0;
2475
2476 return err;
2477}
2478
Andrew Lunn6d917822017-05-26 01:03:21 +02002479static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2480 bool on)
2481{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002482 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002483 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002484
Vivien Didelotdc272f62019-08-31 16:18:33 -04002485 lane = mv88e6xxx_serdes_get_lane(chip, port);
2486 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002487 return 0;
2488
2489 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002490 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002491 if (err)
2492 return err;
2493
Vivien Didelot45de77f2019-08-31 16:18:36 -04002494 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002495 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002496 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2497 if (err)
2498 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002499
Vivien Didelotdc272f62019-08-31 16:18:33 -04002500 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002501 }
2502
2503 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002504}
2505
Vivien Didelotfa371c82017-12-05 15:34:10 -05002506static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2507{
2508 struct dsa_switch *ds = chip->ds;
2509 int upstream_port;
2510 int err;
2511
Vivien Didelot07073c72017-12-05 15:34:13 -05002512 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002513 if (chip->info->ops->port_set_upstream_port) {
2514 err = chip->info->ops->port_set_upstream_port(chip, port,
2515 upstream_port);
2516 if (err)
2517 return err;
2518 }
2519
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002520 if (port == upstream_port) {
2521 if (chip->info->ops->set_cpu_port) {
2522 err = chip->info->ops->set_cpu_port(chip,
2523 upstream_port);
2524 if (err)
2525 return err;
2526 }
2527
2528 if (chip->info->ops->set_egress_port) {
2529 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002530 MV88E6XXX_EGRESS_DIR_INGRESS,
2531 upstream_port);
2532 if (err)
2533 return err;
2534
2535 err = chip->info->ops->set_egress_port(chip,
2536 MV88E6XXX_EGRESS_DIR_EGRESS,
2537 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002538 if (err)
2539 return err;
2540 }
2541 }
2542
Vivien Didelotfa371c82017-12-05 15:34:10 -05002543 return 0;
2544}
2545
Vivien Didelotfad09c72016-06-21 12:28:20 -04002546static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002547{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002548 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002549 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002550 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002551
Andrew Lunn7b898462018-08-09 15:38:47 +02002552 chip->ports[port].chip = chip;
2553 chip->ports[port].port = port;
2554
Vivien Didelotd78343d2016-11-04 03:23:36 +01002555 /* MAC Forcing register: don't force link, speed, duplex or flow control
2556 * state to any particular values on physical ports, but force the CPU
2557 * port and all DSA ports to their maximum bandwidth and full duplex.
2558 */
2559 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2560 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2561 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002562 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002563 PHY_INTERFACE_MODE_NA);
2564 else
2565 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2566 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002567 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002568 PHY_INTERFACE_MODE_NA);
2569 if (err)
2570 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002571
2572 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2573 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2574 * tunneling, determine priority by looking at 802.1p and IP
2575 * priority fields (IP prio has precedence), and set STP state
2576 * to Forwarding.
2577 *
2578 * If this is the CPU link, use DSA or EDSA tagging depending
2579 * on which tagging mode was configured.
2580 *
2581 * If this is a link to another switch, use DSA tagging mode.
2582 *
2583 * If this is the upstream port for this switch, enable
2584 * forwarding of unknown unicasts and multicasts.
2585 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002586 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2587 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2588 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2589 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002590 if (err)
2591 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002592
Vivien Didelot601aeed2017-03-11 16:13:00 -05002593 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002594 if (err)
2595 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002596
Vivien Didelot601aeed2017-03-11 16:13:00 -05002597 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002598 if (err)
2599 return err;
2600
Vivien Didelot8efdda42015-08-13 12:52:23 -04002601 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002602 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002603 * untagged frames on this port, do a destination address lookup on all
2604 * received packets as usual, disable ARP mirroring and don't send a
2605 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002606 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002607 err = mv88e6xxx_port_set_map_da(chip, port);
2608 if (err)
2609 return err;
2610
Vivien Didelotfa371c82017-12-05 15:34:10 -05002611 err = mv88e6xxx_setup_upstream_port(chip, port);
2612 if (err)
2613 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002614
Andrew Lunna23b2962017-02-04 20:15:28 +01002615 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002616 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002617 if (err)
2618 return err;
2619
Vivien Didelotcd782652017-06-08 18:34:13 -04002620 if (chip->info->ops->port_set_jumbo_size) {
2621 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002622 if (err)
2623 return err;
2624 }
2625
Andrew Lunn54d792f2015-05-06 01:09:47 +02002626 /* Port Association Vector: when learning source addresses
2627 * of packets, add the address to the address database using
2628 * a port bitmap that has only the bit for this port set and
2629 * the other bits clear.
2630 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002631 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002632 /* Disable learning for CPU port */
2633 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002634 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002635
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002636 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2637 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002638 if (err)
2639 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002640
2641 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002642 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2643 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002644 if (err)
2645 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002646
Vivien Didelot08984322017-06-08 18:34:12 -04002647 if (chip->info->ops->port_pause_limit) {
2648 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002649 if (err)
2650 return err;
2651 }
2652
Vivien Didelotc8c94892017-03-11 16:13:01 -05002653 if (chip->info->ops->port_disable_learn_limit) {
2654 err = chip->info->ops->port_disable_learn_limit(chip, port);
2655 if (err)
2656 return err;
2657 }
2658
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002659 if (chip->info->ops->port_disable_pri_override) {
2660 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002661 if (err)
2662 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002663 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002664
Andrew Lunnef0a7312016-12-03 04:35:16 +01002665 if (chip->info->ops->port_tag_remap) {
2666 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002667 if (err)
2668 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002669 }
2670
Andrew Lunnef70b112016-12-03 04:45:18 +01002671 if (chip->info->ops->port_egress_rate_limiting) {
2672 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002673 if (err)
2674 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002675 }
2676
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002677 if (chip->info->ops->port_setup_message_port) {
2678 err = chip->info->ops->port_setup_message_port(chip, port);
2679 if (err)
2680 return err;
2681 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002682
Vivien Didelot207afda2016-04-14 14:42:09 -04002683 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002684 * database, and allow bidirectional communication between the
2685 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002686 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002687 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002688 if (err)
2689 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002690
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002691 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002692 if (err)
2693 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002694
2695 /* Default VLAN ID and priority: don't set a default VLAN
2696 * ID, and set the default packet priority to zero.
2697 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002698 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002699}
2700
Andrew Lunn04aca992017-05-26 01:03:24 +02002701static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2702 struct phy_device *phydev)
2703{
2704 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002705 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002706
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002707 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002708 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002709 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002710
2711 return err;
2712}
2713
Andrew Lunn75104db2019-02-24 20:44:43 +01002714static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002715{
2716 struct mv88e6xxx_chip *chip = ds->priv;
2717
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002718 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002719 if (mv88e6xxx_serdes_power(chip, port, false))
2720 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002721 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002722}
2723
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002724static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2725 unsigned int ageing_time)
2726{
Vivien Didelot04bed142016-08-31 18:06:13 -04002727 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002728 int err;
2729
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002730 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002731 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002732 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002733
2734 return err;
2735}
2736
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002737static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002738{
2739 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002740
Andrew Lunnde2273872016-11-21 23:27:01 +01002741 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002742 if (chip->info->ops->stats_set_histogram) {
2743 err = chip->info->ops->stats_set_histogram(chip);
2744 if (err)
2745 return err;
2746 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002747
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002748 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002749}
2750
Andrew Lunnea890982019-01-09 00:24:03 +01002751/* Check if the errata has already been applied. */
2752static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2753{
2754 int port;
2755 int err;
2756 u16 val;
2757
2758 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002759 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002760 if (err) {
2761 dev_err(chip->dev,
2762 "Error reading hidden register: %d\n", err);
2763 return false;
2764 }
2765 if (val != 0x01c0)
2766 return false;
2767 }
2768
2769 return true;
2770}
2771
2772/* The 6390 copper ports have an errata which require poking magic
2773 * values into undocumented hidden registers and then performing a
2774 * software reset.
2775 */
2776static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2777{
2778 int port;
2779 int err;
2780
2781 if (mv88e6390_setup_errata_applied(chip))
2782 return 0;
2783
2784 /* Set the ports into blocking mode */
2785 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2786 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2787 if (err)
2788 return err;
2789 }
2790
2791 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002792 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002793 if (err)
2794 return err;
2795 }
2796
2797 return mv88e6xxx_software_reset(chip);
2798}
2799
Andrew Lunn23e8b472019-10-25 01:03:52 +02002800enum mv88e6xxx_devlink_param_id {
2801 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2802 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2803};
2804
2805static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2806 struct devlink_param_gset_ctx *ctx)
2807{
2808 struct mv88e6xxx_chip *chip = ds->priv;
2809 int err;
2810
2811 mv88e6xxx_reg_lock(chip);
2812
2813 switch (id) {
2814 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2815 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2816 break;
2817 default:
2818 err = -EOPNOTSUPP;
2819 break;
2820 }
2821
2822 mv88e6xxx_reg_unlock(chip);
2823
2824 return err;
2825}
2826
2827static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2828 struct devlink_param_gset_ctx *ctx)
2829{
2830 struct mv88e6xxx_chip *chip = ds->priv;
2831 int err;
2832
2833 mv88e6xxx_reg_lock(chip);
2834
2835 switch (id) {
2836 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2837 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2838 break;
2839 default:
2840 err = -EOPNOTSUPP;
2841 break;
2842 }
2843
2844 mv88e6xxx_reg_unlock(chip);
2845
2846 return err;
2847}
2848
2849static const struct devlink_param mv88e6xxx_devlink_params[] = {
2850 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2851 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2852 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2853};
2854
2855static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2856{
2857 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2858 ARRAY_SIZE(mv88e6xxx_devlink_params));
2859}
2860
2861static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2862{
2863 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2864 ARRAY_SIZE(mv88e6xxx_devlink_params));
2865}
2866
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002867enum mv88e6xxx_devlink_resource_id {
2868 MV88E6XXX_RESOURCE_ID_ATU,
2869 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2870 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2871 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2872 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2873};
2874
2875static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2876 u16 bin)
2877{
2878 u16 occupancy = 0;
2879 int err;
2880
2881 mv88e6xxx_reg_lock(chip);
2882
2883 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2884 bin);
2885 if (err) {
2886 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2887 goto unlock;
2888 }
2889
2890 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2891 if (err) {
2892 dev_err(chip->dev, "failed to perform ATU get next\n");
2893 goto unlock;
2894 }
2895
2896 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2897 if (err) {
2898 dev_err(chip->dev, "failed to get ATU stats\n");
2899 goto unlock;
2900 }
2901
Andrew Lunn012fc742020-03-11 21:02:31 +01002902 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2903
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002904unlock:
2905 mv88e6xxx_reg_unlock(chip);
2906
2907 return occupancy;
2908}
2909
2910static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2911{
2912 struct mv88e6xxx_chip *chip = priv;
2913
2914 return mv88e6xxx_devlink_atu_bin_get(chip,
2915 MV88E6XXX_G2_ATU_STATS_BIN_0);
2916}
2917
2918static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2919{
2920 struct mv88e6xxx_chip *chip = priv;
2921
2922 return mv88e6xxx_devlink_atu_bin_get(chip,
2923 MV88E6XXX_G2_ATU_STATS_BIN_1);
2924}
2925
2926static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2927{
2928 struct mv88e6xxx_chip *chip = priv;
2929
2930 return mv88e6xxx_devlink_atu_bin_get(chip,
2931 MV88E6XXX_G2_ATU_STATS_BIN_2);
2932}
2933
2934static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2935{
2936 struct mv88e6xxx_chip *chip = priv;
2937
2938 return mv88e6xxx_devlink_atu_bin_get(chip,
2939 MV88E6XXX_G2_ATU_STATS_BIN_3);
2940}
2941
2942static u64 mv88e6xxx_devlink_atu_get(void *priv)
2943{
2944 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2945 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2946 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2947 mv88e6xxx_devlink_atu_bin_3_get(priv);
2948}
2949
2950static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2951{
2952 struct devlink_resource_size_params size_params;
2953 struct mv88e6xxx_chip *chip = ds->priv;
2954 int err;
2955
2956 devlink_resource_size_params_init(&size_params,
2957 mv88e6xxx_num_macs(chip),
2958 mv88e6xxx_num_macs(chip),
2959 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2960
2961 err = dsa_devlink_resource_register(ds, "ATU",
2962 mv88e6xxx_num_macs(chip),
2963 MV88E6XXX_RESOURCE_ID_ATU,
2964 DEVLINK_RESOURCE_ID_PARENT_TOP,
2965 &size_params);
2966 if (err)
2967 goto out;
2968
2969 devlink_resource_size_params_init(&size_params,
2970 mv88e6xxx_num_macs(chip) / 4,
2971 mv88e6xxx_num_macs(chip) / 4,
2972 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2973
2974 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2975 mv88e6xxx_num_macs(chip) / 4,
2976 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2977 MV88E6XXX_RESOURCE_ID_ATU,
2978 &size_params);
2979 if (err)
2980 goto out;
2981
2982 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2983 mv88e6xxx_num_macs(chip) / 4,
2984 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2985 MV88E6XXX_RESOURCE_ID_ATU,
2986 &size_params);
2987 if (err)
2988 goto out;
2989
2990 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2991 mv88e6xxx_num_macs(chip) / 4,
2992 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2993 MV88E6XXX_RESOURCE_ID_ATU,
2994 &size_params);
2995 if (err)
2996 goto out;
2997
2998 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2999 mv88e6xxx_num_macs(chip) / 4,
3000 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3001 MV88E6XXX_RESOURCE_ID_ATU,
3002 &size_params);
3003 if (err)
3004 goto out;
3005
3006 dsa_devlink_resource_occ_get_register(ds,
3007 MV88E6XXX_RESOURCE_ID_ATU,
3008 mv88e6xxx_devlink_atu_get,
3009 chip);
3010
3011 dsa_devlink_resource_occ_get_register(ds,
3012 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
3013 mv88e6xxx_devlink_atu_bin_0_get,
3014 chip);
3015
3016 dsa_devlink_resource_occ_get_register(ds,
3017 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3018 mv88e6xxx_devlink_atu_bin_1_get,
3019 chip);
3020
3021 dsa_devlink_resource_occ_get_register(ds,
3022 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3023 mv88e6xxx_devlink_atu_bin_2_get,
3024 chip);
3025
3026 dsa_devlink_resource_occ_get_register(ds,
3027 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3028 mv88e6xxx_devlink_atu_bin_3_get,
3029 chip);
3030
3031 return 0;
3032
3033out:
3034 dsa_devlink_resources_unregister(ds);
3035 return err;
3036}
3037
Andrew Lunn23e8b472019-10-25 01:03:52 +02003038static void mv88e6xxx_teardown(struct dsa_switch *ds)
3039{
3040 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003041 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003042}
3043
Vivien Didelotf81ec902016-05-09 13:22:58 -04003044static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003045{
Vivien Didelot04bed142016-08-31 18:06:13 -04003046 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003047 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003048 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003049 int i;
3050
Vivien Didelotfad09c72016-06-21 12:28:20 -04003051 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003052 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003053
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003054 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003055
Andrew Lunnea890982019-01-09 00:24:03 +01003056 if (chip->info->ops->setup_errata) {
3057 err = chip->info->ops->setup_errata(chip);
3058 if (err)
3059 goto unlock;
3060 }
3061
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003062 /* Cache the cmode of each port. */
3063 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3064 if (chip->info->ops->port_get_cmode) {
3065 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3066 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003067 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003068
3069 chip->ports[i].cmode = cmode;
3070 }
3071 }
3072
Vivien Didelot97299342016-07-18 20:45:30 -04003073 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003074 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003075 if (dsa_is_unused_port(ds, i))
3076 continue;
3077
Hubert Feursteinc8574862019-07-31 10:23:48 +02003078 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003079 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003080 dev_err(chip->dev, "port %d is invalid\n", i);
3081 err = -EINVAL;
3082 goto unlock;
3083 }
3084
Vivien Didelot97299342016-07-18 20:45:30 -04003085 err = mv88e6xxx_setup_port(chip, i);
3086 if (err)
3087 goto unlock;
3088 }
3089
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003090 err = mv88e6xxx_irl_setup(chip);
3091 if (err)
3092 goto unlock;
3093
Vivien Didelot04a69a12017-10-13 14:18:05 -04003094 err = mv88e6xxx_mac_setup(chip);
3095 if (err)
3096 goto unlock;
3097
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003098 err = mv88e6xxx_phy_setup(chip);
3099 if (err)
3100 goto unlock;
3101
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003102 err = mv88e6xxx_vtu_setup(chip);
3103 if (err)
3104 goto unlock;
3105
Vivien Didelot81228992017-03-30 17:37:08 -04003106 err = mv88e6xxx_pvt_setup(chip);
3107 if (err)
3108 goto unlock;
3109
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003110 err = mv88e6xxx_atu_setup(chip);
3111 if (err)
3112 goto unlock;
3113
Andrew Lunn87fa8862017-11-09 22:29:56 +01003114 err = mv88e6xxx_broadcast_setup(chip, 0);
3115 if (err)
3116 goto unlock;
3117
Vivien Didelot9e907d72017-07-17 13:03:43 -04003118 err = mv88e6xxx_pot_setup(chip);
3119 if (err)
3120 goto unlock;
3121
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003122 err = mv88e6xxx_rmu_setup(chip);
3123 if (err)
3124 goto unlock;
3125
Vivien Didelot51c901a2017-07-17 13:03:41 -04003126 err = mv88e6xxx_rsvd2cpu_setup(chip);
3127 if (err)
3128 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003129
Vivien Didelotb28f8722018-04-26 21:56:44 -04003130 err = mv88e6xxx_trunk_setup(chip);
3131 if (err)
3132 goto unlock;
3133
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003134 err = mv88e6xxx_devmap_setup(chip);
3135 if (err)
3136 goto unlock;
3137
Vivien Didelot93e18d62018-05-11 17:16:35 -04003138 err = mv88e6xxx_pri_setup(chip);
3139 if (err)
3140 goto unlock;
3141
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003142 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003143 if (chip->info->ptp_support) {
3144 err = mv88e6xxx_ptp_setup(chip);
3145 if (err)
3146 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003147
3148 err = mv88e6xxx_hwtstamp_setup(chip);
3149 if (err)
3150 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003151 }
3152
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003153 err = mv88e6xxx_stats_setup(chip);
3154 if (err)
3155 goto unlock;
3156
Vivien Didelot6b17e862015-08-13 12:52:18 -04003157unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003158 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003159
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003160 if (err)
3161 return err;
3162
3163 /* Have to be called without holding the register lock, since
3164 * they take the devlink lock, and we later take the locks in
3165 * the reverse order when getting/setting parameters or
3166 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003167 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003168 err = mv88e6xxx_setup_devlink_resources(ds);
3169 if (err)
3170 return err;
3171
3172 err = mv88e6xxx_setup_devlink_params(ds);
3173 if (err)
3174 dsa_devlink_resources_unregister(ds);
3175
3176 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003177}
3178
Vivien Didelote57e5e72016-08-15 17:19:00 -04003179static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003180{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003181 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3182 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003183 u16 val;
3184 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003185
Andrew Lunnee26a222017-01-24 14:53:48 +01003186 if (!chip->info->ops->phy_read)
3187 return -EOPNOTSUPP;
3188
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003189 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003190 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003191 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003192
Andrew Lunnda9f3302017-02-01 03:40:05 +01003193 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003194 /* Some internal PHYs don't have a model number. */
3195 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3196 /* Then there is the 6165 family. It gets is
3197 * PHYs correct. But it can also have two
3198 * SERDES interfaces in the PHY address
3199 * space. And these don't have a model
3200 * number. But they are not PHYs, so we don't
3201 * want to give them something a PHY driver
3202 * will recognise.
3203 *
3204 * Use the mv88e6390 family model number
3205 * instead, for anything which really could be
3206 * a PHY,
3207 */
3208 if (!(val & 0x3f0))
3209 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003210 }
3211
Vivien Didelote57e5e72016-08-15 17:19:00 -04003212 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003213}
3214
Vivien Didelote57e5e72016-08-15 17:19:00 -04003215static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003216{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003217 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3218 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003219 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003220
Andrew Lunnee26a222017-01-24 14:53:48 +01003221 if (!chip->info->ops->phy_write)
3222 return -EOPNOTSUPP;
3223
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003224 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003225 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003226 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003227
3228 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003229}
3230
Vivien Didelotfad09c72016-06-21 12:28:20 -04003231static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003232 struct device_node *np,
3233 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003234{
3235 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003236 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003237 struct mii_bus *bus;
3238 int err;
3239
Andrew Lunn2510bab2018-02-22 01:51:49 +01003240 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003241 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003242 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003243 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003244
3245 if (err)
3246 return err;
3247 }
3248
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003249 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003250 if (!bus)
3251 return -ENOMEM;
3252
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003253 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003254 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003255 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003256 INIT_LIST_HEAD(&mdio_bus->list);
3257 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003258
Andrew Lunnb516d452016-06-04 21:17:06 +02003259 if (np) {
3260 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003261 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003262 } else {
3263 bus->name = "mv88e6xxx SMI";
3264 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3265 }
3266
3267 bus->read = mv88e6xxx_mdio_read;
3268 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003269 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003270
Andrew Lunn6f882842018-03-17 20:32:05 +01003271 if (!external) {
3272 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3273 if (err)
3274 return err;
3275 }
3276
Florian Fainelli00e798c2018-05-15 16:56:19 -07003277 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003278 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003279 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003280 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003281 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003282 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003283
3284 if (external)
3285 list_add_tail(&mdio_bus->list, &chip->mdios);
3286 else
3287 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003288
3289 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003290}
3291
Andrew Lunna3c53be52017-01-24 14:53:50 +01003292static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3293 { .compatible = "marvell,mv88e6xxx-mdio-external",
3294 .data = (void *)true },
3295 { },
3296};
3297
Andrew Lunn3126aee2017-12-07 01:05:57 +01003298static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3299
3300{
3301 struct mv88e6xxx_mdio_bus *mdio_bus;
3302 struct mii_bus *bus;
3303
3304 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3305 bus = mdio_bus->bus;
3306
Andrew Lunn6f882842018-03-17 20:32:05 +01003307 if (!mdio_bus->external)
3308 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3309
Andrew Lunn3126aee2017-12-07 01:05:57 +01003310 mdiobus_unregister(bus);
3311 }
3312}
3313
Andrew Lunna3c53be52017-01-24 14:53:50 +01003314static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3315 struct device_node *np)
3316{
3317 const struct of_device_id *match;
3318 struct device_node *child;
3319 int err;
3320
3321 /* Always register one mdio bus for the internal/default mdio
3322 * bus. This maybe represented in the device tree, but is
3323 * optional.
3324 */
3325 child = of_get_child_by_name(np, "mdio");
3326 err = mv88e6xxx_mdio_register(chip, child, false);
3327 if (err)
3328 return err;
3329
3330 /* Walk the device tree, and see if there are any other nodes
3331 * which say they are compatible with the external mdio
3332 * bus.
3333 */
3334 for_each_available_child_of_node(np, child) {
3335 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3336 if (match) {
3337 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003338 if (err) {
3339 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303340 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003341 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003342 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003343 }
3344 }
3345
3346 return 0;
3347}
3348
Vivien Didelot855b1932016-07-20 18:18:35 -04003349static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3350{
Vivien Didelot04bed142016-08-31 18:06:13 -04003351 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003352
3353 return chip->eeprom_len;
3354}
3355
Vivien Didelot855b1932016-07-20 18:18:35 -04003356static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3357 struct ethtool_eeprom *eeprom, u8 *data)
3358{
Vivien Didelot04bed142016-08-31 18:06:13 -04003359 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003360 int err;
3361
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003362 if (!chip->info->ops->get_eeprom)
3363 return -EOPNOTSUPP;
3364
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003365 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003366 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003367 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003368
3369 if (err)
3370 return err;
3371
3372 eeprom->magic = 0xc3ec4951;
3373
3374 return 0;
3375}
3376
Vivien Didelot855b1932016-07-20 18:18:35 -04003377static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3378 struct ethtool_eeprom *eeprom, u8 *data)
3379{
Vivien Didelot04bed142016-08-31 18:06:13 -04003380 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003381 int err;
3382
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003383 if (!chip->info->ops->set_eeprom)
3384 return -EOPNOTSUPP;
3385
Vivien Didelot855b1932016-07-20 18:18:35 -04003386 if (eeprom->magic != 0xc3ec4951)
3387 return -EINVAL;
3388
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003389 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003390 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003391 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003392
3393 return err;
3394}
3395
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003396static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003397 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003398 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3399 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003400 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003401 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003402 .phy_read = mv88e6185_phy_ppu_read,
3403 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003404 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003405 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003406 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003407 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003408 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003409 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003410 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003411 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003412 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003413 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003414 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003415 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003416 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003417 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003418 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003419 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3420 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003421 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003422 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3423 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003424 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003425 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003426 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003427 .ppu_enable = mv88e6185_g1_ppu_enable,
3428 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003429 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003430 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003431 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003432 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003433 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003434};
3435
3436static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003437 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003438 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3439 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003440 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003441 .phy_read = mv88e6185_phy_ppu_read,
3442 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003443 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003444 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003445 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003446 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003447 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003448 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003449 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003450 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003451 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003452 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003453 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3454 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003455 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003456 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003457 .ppu_enable = mv88e6185_g1_ppu_enable,
3458 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003459 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003460 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003461 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003462 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003463};
3464
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003465static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003466 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003467 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3468 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003469 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003470 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3471 .phy_read = mv88e6xxx_g2_smi_phy_read,
3472 .phy_write = mv88e6xxx_g2_smi_phy_write,
3473 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003474 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003475 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003476 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003477 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003478 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003479 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003480 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003481 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003482 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003483 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003484 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003485 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003486 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003487 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003488 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003489 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3490 .stats_get_strings = mv88e6095_stats_get_strings,
3491 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003492 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3493 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003494 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003495 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003496 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003497 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003498 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003499 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003500 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003501 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003502};
3503
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003504static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003505 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003506 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3507 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003508 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003509 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003510 .phy_read = mv88e6xxx_g2_smi_phy_read,
3511 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003512 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003513 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003514 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003515 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003516 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003517 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003518 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003519 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003520 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003521 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003522 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003523 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3524 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003525 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003526 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3527 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003528 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003529 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003530 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003531 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003532 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3533 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003534 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003535 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003536 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003537};
3538
3539static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003540 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003541 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3542 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003543 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003544 .phy_read = mv88e6185_phy_ppu_read,
3545 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003546 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003547 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003548 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003549 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003550 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003551 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003552 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003553 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003554 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003555 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003556 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003557 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003558 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003559 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003560 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003561 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003562 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3563 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003564 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003565 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3566 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003567 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003568 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003569 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003570 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003571 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003572 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003573 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003574 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003575 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003576};
3577
Vivien Didelot990e27b2017-03-28 13:50:32 -04003578static const struct mv88e6xxx_ops mv88e6141_ops = {
3579 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003580 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3581 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003582 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003583 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3584 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3585 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3586 .phy_read = mv88e6xxx_g2_smi_phy_read,
3587 .phy_write = mv88e6xxx_g2_smi_phy_write,
3588 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003589 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003590 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003591 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003592 .port_tag_remap = mv88e6095_port_tag_remap,
3593 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3594 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3595 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003596 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003597 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003598 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003599 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3600 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003601 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003602 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003603 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003604 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003605 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003606 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003607 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3608 .stats_get_strings = mv88e6320_stats_get_strings,
3609 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003610 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3611 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003612 .watchdog_ops = &mv88e6390_watchdog_ops,
3613 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003614 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003615 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003616 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003617 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003618 .serdes_power = mv88e6390_serdes_power,
3619 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003620 /* Check status register pause & lpa register */
3621 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3622 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3623 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3624 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003625 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003626 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003627 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003628 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003629 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003630};
3631
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003632static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003633 /* MV88E6XXX_FAMILY_6165 */
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 Didelotb073d4e2016-09-29 12:22:01 -04003637 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003638 .phy_read = mv88e6xxx_g2_smi_phy_read,
3639 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003640 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003641 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003642 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003643 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003644 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003645 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003646 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003647 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003648 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003649 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003650 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003651 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003652 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003653 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003654 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003655 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003656 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3657 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003658 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003659 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3660 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003661 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003662 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003663 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003664 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003665 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3666 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003667 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003668 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003669 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003670 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003671 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003672};
3673
3674static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003675 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003676 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3677 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003678 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003679 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003680 .phy_read = mv88e6165_phy_read,
3681 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003682 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003683 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003684 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003685 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003686 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003687 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003688 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003689 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003690 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003691 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3692 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003693 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003694 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3695 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003696 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003697 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003698 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003699 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003700 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3701 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003702 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003703 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003704 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003705 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003706 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003707};
3708
3709static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003710 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003711 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3712 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003713 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003714 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003715 .phy_read = mv88e6xxx_g2_smi_phy_read,
3716 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003717 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003718 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003719 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003720 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003721 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003722 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003723 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003724 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003725 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003726 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003727 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003728 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003729 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003730 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003731 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003732 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003733 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003734 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3735 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003736 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003737 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3738 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003739 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003740 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003741 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003742 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003743 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3744 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003745 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003746 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003747 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003748};
3749
3750static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003751 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003752 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3753 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003754 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003755 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3756 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003757 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003758 .phy_read = mv88e6xxx_g2_smi_phy_read,
3759 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003760 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003761 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003762 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003763 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003764 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003765 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003766 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003767 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003768 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003769 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003770 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003771 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003772 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003773 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003774 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003775 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003776 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003777 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003778 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3779 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003780 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003781 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3782 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003783 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003784 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003785 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003786 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003787 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003788 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3789 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003790 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003791 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003792 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003793 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3794 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3795 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3796 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003797 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003798 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3799 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003800 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003801 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003802};
3803
3804static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003805 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003806 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3807 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003808 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003809 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003810 .phy_read = mv88e6xxx_g2_smi_phy_read,
3811 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003812 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003813 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003814 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003815 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003816 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003817 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003818 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003819 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003820 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003821 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003822 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003823 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003824 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003825 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003827 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003828 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003829 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3830 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003831 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003832 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3833 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003834 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003835 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003837 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003838 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3839 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003840 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003841 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003842 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003843};
3844
3845static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003846 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003847 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3848 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003849 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003850 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3851 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003852 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003853 .phy_read = mv88e6xxx_g2_smi_phy_read,
3854 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003855 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003856 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003857 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003858 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003859 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003860 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003861 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003862 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003863 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003864 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003865 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003866 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003867 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003868 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003869 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003870 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003871 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003872 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003873 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3874 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003875 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003876 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3877 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003878 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003879 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003880 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003881 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003882 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003883 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3884 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003885 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003886 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003887 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003888 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3889 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3890 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3891 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003892 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003893 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003894 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003895 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003896 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3897 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003898 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003899 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003900};
3901
3902static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003903 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003904 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3905 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003906 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003907 .phy_read = mv88e6185_phy_ppu_read,
3908 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003909 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003910 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003911 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003912 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003913 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003914 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003915 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003916 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003917 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003918 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003919 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003920 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003921 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3922 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003923 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003924 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3925 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003926 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003927 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003928 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003929 .ppu_enable = mv88e6185_g1_ppu_enable,
3930 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003931 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003932 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003933 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003934 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003935};
3936
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003937static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003938 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003939 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003940 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003941 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3942 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003943 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3944 .phy_read = mv88e6xxx_g2_smi_phy_read,
3945 .phy_write = mv88e6xxx_g2_smi_phy_write,
3946 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003947 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003948 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003949 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003950 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003951 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003952 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003953 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003954 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003955 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003956 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003957 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003958 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003959 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003960 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003961 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003962 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003963 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003964 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3965 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003966 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003967 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3968 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003969 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003970 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003971 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003972 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003973 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003974 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3975 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003976 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3977 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003978 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003979 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003980 /* Check status register pause & lpa register */
3981 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3982 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3983 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3984 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003985 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003986 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003987 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003988 .serdes_get_strings = mv88e6390_serdes_get_strings,
3989 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003990 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3991 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003992 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003993 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003994 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003995};
3996
3997static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003998 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003999 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004000 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004001 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4002 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004003 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4004 .phy_read = mv88e6xxx_g2_smi_phy_read,
4005 .phy_write = mv88e6xxx_g2_smi_phy_write,
4006 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004007 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004008 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004009 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004010 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004011 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004012 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004013 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004014 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004015 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004016 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004017 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004018 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004019 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004020 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004021 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004022 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004023 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004024 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4025 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004026 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004027 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4028 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004029 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004030 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004031 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004032 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004033 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004034 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4035 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004036 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4037 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004038 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004039 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004040 /* Check status register pause & lpa register */
4041 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4042 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4043 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4044 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004045 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004046 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004047 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004048 .serdes_get_strings = mv88e6390_serdes_get_strings,
4049 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004050 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4051 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004052 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004053 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004054 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004055};
4056
4057static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004058 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004059 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004060 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004061 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4062 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4064 .phy_read = mv88e6xxx_g2_smi_phy_read,
4065 .phy_write = mv88e6xxx_g2_smi_phy_write,
4066 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004067 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004068 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004069 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004070 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004071 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004072 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004073 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004074 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004075 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004076 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004077 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004078 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004079 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004080 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004081 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004082 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004083 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4084 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004085 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004086 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4087 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004088 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004089 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004090 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004091 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004092 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004093 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4094 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004095 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4096 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004097 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004098 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004099 /* Check status register pause & lpa register */
4100 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4101 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4102 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4103 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004104 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004105 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004106 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004107 .serdes_get_strings = mv88e6390_serdes_get_strings,
4108 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004109 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4110 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004111 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004112 .avb_ops = &mv88e6390_avb_ops,
4113 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004114 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004115};
4116
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004117static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004118 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004119 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4120 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004121 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004122 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4123 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004124 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004125 .phy_read = mv88e6xxx_g2_smi_phy_read,
4126 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004127 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004128 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004129 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004130 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004131 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004132 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004133 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004134 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004135 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004136 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004137 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004138 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004139 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004140 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004141 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004142 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004143 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004144 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004145 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4146 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004147 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004148 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4149 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004150 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004151 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004152 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004153 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004154 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004155 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4156 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004157 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004158 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004159 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004160 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4161 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4162 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4163 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004164 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004165 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004166 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004167 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004168 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4169 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004170 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004171 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004172 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004173 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004174};
4175
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004176static const struct mv88e6xxx_ops mv88e6250_ops = {
4177 /* MV88E6XXX_FAMILY_6250 */
4178 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4179 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4180 .irl_init_all = mv88e6352_g2_irl_init_all,
4181 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4182 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4183 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4184 .phy_read = mv88e6xxx_g2_smi_phy_read,
4185 .phy_write = mv88e6xxx_g2_smi_phy_write,
4186 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004187 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004188 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004189 .port_tag_remap = mv88e6095_port_tag_remap,
4190 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4191 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4192 .port_set_ether_type = mv88e6351_port_set_ether_type,
4193 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4194 .port_pause_limit = mv88e6097_port_pause_limit,
4195 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4196 .port_link_state = mv88e6250_port_link_state,
4197 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4198 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4199 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4200 .stats_get_strings = mv88e6250_stats_get_strings,
4201 .stats_get_stats = mv88e6250_stats_get_stats,
4202 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4203 .set_egress_port = mv88e6095_g1_set_egress_port,
4204 .watchdog_ops = &mv88e6250_watchdog_ops,
4205 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4206 .pot_clear = mv88e6xxx_g2_pot_clear,
4207 .reset = mv88e6250_g1_reset,
4208 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4209 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004210 .avb_ops = &mv88e6352_avb_ops,
4211 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004212 .phylink_validate = mv88e6065_phylink_validate,
4213};
4214
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004215static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004216 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004217 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004218 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004219 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4220 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4222 .phy_read = mv88e6xxx_g2_smi_phy_read,
4223 .phy_write = mv88e6xxx_g2_smi_phy_write,
4224 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004225 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004226 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004227 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004228 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004229 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004230 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004231 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004232 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004233 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004234 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004235 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004236 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004237 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004238 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004239 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004240 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004241 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004242 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4243 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004244 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004245 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4246 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004247 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004248 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004249 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004250 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004251 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004252 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4253 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004254 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4255 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004256 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004257 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004258 /* Check status register pause & lpa register */
4259 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4260 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4261 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4262 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004263 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004264 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004265 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004266 .serdes_get_strings = mv88e6390_serdes_get_strings,
4267 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004268 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4269 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004270 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004271 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004272 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004273 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004274 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004275};
4276
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004277static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004278 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004279 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4280 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004281 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004282 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4283 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004284 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004285 .phy_read = mv88e6xxx_g2_smi_phy_read,
4286 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004287 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004288 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004289 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004290 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004291 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004292 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004293 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004294 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004295 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004296 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004297 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004298 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004299 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004300 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004301 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004302 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004303 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4304 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004305 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004306 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4307 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004308 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004309 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004310 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004311 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004312 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004313 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004314 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004315 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004316 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004317 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004318};
4319
4320static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004321 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004322 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4323 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004324 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004325 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4326 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004327 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004328 .phy_read = mv88e6xxx_g2_smi_phy_read,
4329 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004330 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004331 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004332 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004333 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004334 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004335 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004336 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004337 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004338 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004339 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004340 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004341 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004342 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004343 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004344 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004345 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004346 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4347 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004348 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004349 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4350 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004351 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004352 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004353 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004354 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004355 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004356 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004357 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004358 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004359};
4360
Vivien Didelot16e329a2017-03-28 13:50:33 -04004361static const struct mv88e6xxx_ops mv88e6341_ops = {
4362 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004363 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4364 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004365 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004366 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4367 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4368 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4369 .phy_read = mv88e6xxx_g2_smi_phy_read,
4370 .phy_write = mv88e6xxx_g2_smi_phy_write,
4371 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004372 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004373 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004374 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004375 .port_tag_remap = mv88e6095_port_tag_remap,
4376 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4377 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4378 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004379 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004380 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004381 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004382 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4383 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004384 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004385 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004386 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004387 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004388 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004389 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004390 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4391 .stats_get_strings = mv88e6320_stats_get_strings,
4392 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004393 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4394 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004395 .watchdog_ops = &mv88e6390_watchdog_ops,
4396 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004397 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004398 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004399 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004400 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004401 .serdes_power = mv88e6390_serdes_power,
4402 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004403 /* Check status register pause & lpa register */
4404 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4405 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4406 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4407 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004408 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004409 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004410 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004411 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004412 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004413 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004414 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004415};
4416
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004417static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004418 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004419 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4420 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004421 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004422 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004423 .phy_read = mv88e6xxx_g2_smi_phy_read,
4424 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004425 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004426 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004427 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004428 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004429 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004430 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004431 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004432 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004433 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004434 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004435 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004436 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004437 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004438 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004439 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004440 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004441 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004442 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4443 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004444 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004445 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4446 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004447 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004448 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004449 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004450 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004451 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4452 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004453 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004454 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004455 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004456};
4457
4458static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004459 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004460 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4461 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004462 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004463 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004464 .phy_read = mv88e6xxx_g2_smi_phy_read,
4465 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004466 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004467 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004468 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004469 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004470 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004471 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004472 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004473 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004474 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004475 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004476 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004477 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004478 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004479 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004480 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004481 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004482 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004483 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4484 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004485 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004486 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4487 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004488 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004489 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004490 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004491 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004492 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4493 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004494 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004495 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004496 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004497 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004498 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004499};
4500
4501static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004502 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004503 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4504 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004505 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004506 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4507 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004508 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004509 .phy_read = mv88e6xxx_g2_smi_phy_read,
4510 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004511 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004512 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004513 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004514 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004515 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004516 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004517 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004518 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004519 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004520 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004521 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004522 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004523 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004524 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004525 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004526 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004527 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004528 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004529 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4530 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004531 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004532 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4533 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004534 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004535 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004536 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004537 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004538 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004539 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4540 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004541 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004542 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004543 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004544 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4545 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4546 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4547 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004548 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004549 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004550 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004551 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004552 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004553 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004554 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004555 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4556 .serdes_get_strings = mv88e6352_serdes_get_strings,
4557 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004558 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4559 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004560 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004561};
4562
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004563static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004564 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004565 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004566 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004567 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4568 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004569 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4570 .phy_read = mv88e6xxx_g2_smi_phy_read,
4571 .phy_write = mv88e6xxx_g2_smi_phy_write,
4572 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004573 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004574 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004575 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004576 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004577 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004578 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004579 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004580 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004581 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004582 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004583 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004584 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004585 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004586 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004587 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004588 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004589 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004590 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004591 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004592 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4593 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004594 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004595 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4596 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004597 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004598 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004599 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004600 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004601 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004602 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4603 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004604 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4605 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004606 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004607 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004608 /* Check status register pause & lpa register */
4609 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4610 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4611 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4612 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004613 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004614 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004615 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004616 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004617 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004618 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004619 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4620 .serdes_get_strings = mv88e6390_serdes_get_strings,
4621 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004622 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4623 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004624 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004625};
4626
4627static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004628 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004629 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004630 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004631 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4632 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004633 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4634 .phy_read = mv88e6xxx_g2_smi_phy_read,
4635 .phy_write = mv88e6xxx_g2_smi_phy_write,
4636 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004637 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004638 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004639 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004640 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004641 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004642 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004643 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004644 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004645 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004646 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004647 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004648 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004649 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004650 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004651 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004652 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004653 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004654 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004655 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004656 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4657 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004658 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004659 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4660 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004661 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004662 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004663 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004664 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004665 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004666 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4667 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004668 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4669 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004670 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004671 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004672 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4673 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4674 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4675 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004676 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004677 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004678 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004679 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4680 .serdes_get_strings = mv88e6390_serdes_get_strings,
4681 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004682 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4683 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004684 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004685 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004686 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004687 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004688};
4689
Vivien Didelotf81ec902016-05-09 13:22:58 -04004690static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4691 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004692 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004693 .family = MV88E6XXX_FAMILY_6097,
4694 .name = "Marvell 88E6085",
4695 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004696 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004697 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004698 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004699 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004700 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004701 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004702 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004703 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004704 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004705 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004706 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004707 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004708 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004709 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004710 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004711 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004712 },
4713
4714 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004715 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004716 .family = MV88E6XXX_FAMILY_6095,
4717 .name = "Marvell 88E6095/88E6095F",
4718 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004719 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004720 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004721 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004722 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004723 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004724 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004725 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004726 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004727 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004728 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004729 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004730 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004731 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004732 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 },
4734
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004735 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004736 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004737 .family = MV88E6XXX_FAMILY_6097,
4738 .name = "Marvell 88E6097/88E6097F",
4739 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004740 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004741 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004742 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004743 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004744 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004745 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004746 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004747 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004748 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004749 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004750 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004751 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004752 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004753 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004754 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004755 .ops = &mv88e6097_ops,
4756 },
4757
Vivien Didelotf81ec902016-05-09 13:22:58 -04004758 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004759 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004760 .family = MV88E6XXX_FAMILY_6165,
4761 .name = "Marvell 88E6123",
4762 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004763 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004764 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004765 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004766 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004767 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004768 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004769 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004770 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004771 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004772 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004773 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004774 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004775 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004776 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004777 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004778 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004779 },
4780
4781 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004782 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004783 .family = MV88E6XXX_FAMILY_6185,
4784 .name = "Marvell 88E6131",
4785 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004786 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004787 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004788 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004789 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004790 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004791 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004792 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004793 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004794 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004795 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004796 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004797 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004798 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004799 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004800 },
4801
Vivien Didelot990e27b2017-03-28 13:50:32 -04004802 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004803 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004804 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004805 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004806 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004807 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004808 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004809 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004810 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004811 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004812 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004813 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004814 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004815 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004816 .age_time_coeff = 3750,
4817 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004818 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004819 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004820 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004821 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004822 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004823 .ops = &mv88e6141_ops,
4824 },
4825
Vivien Didelotf81ec902016-05-09 13:22:58 -04004826 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004827 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004828 .family = MV88E6XXX_FAMILY_6165,
4829 .name = "Marvell 88E6161",
4830 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004831 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004832 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004833 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004834 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004835 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004836 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004837 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004838 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004839 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004840 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004841 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004842 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004843 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004844 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004845 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004846 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004847 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004848 },
4849
4850 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004851 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004852 .family = MV88E6XXX_FAMILY_6165,
4853 .name = "Marvell 88E6165",
4854 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004855 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004856 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004857 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004858 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004859 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004860 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004861 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004862 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004863 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004864 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004865 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004866 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004867 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004868 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004869 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004870 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004871 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004872 },
4873
4874 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004875 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004876 .family = MV88E6XXX_FAMILY_6351,
4877 .name = "Marvell 88E6171",
4878 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004879 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004880 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004881 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004882 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004883 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004884 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004885 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004886 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004887 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004888 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004889 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004890 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004891 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004892 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004893 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004894 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004895 },
4896
4897 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004898 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004899 .family = MV88E6XXX_FAMILY_6352,
4900 .name = "Marvell 88E6172",
4901 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004902 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004903 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004904 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004905 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004906 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004907 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004908 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004909 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004910 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004911 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004912 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004913 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004914 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004915 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004916 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004917 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004918 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004919 },
4920
4921 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004922 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004923 .family = MV88E6XXX_FAMILY_6351,
4924 .name = "Marvell 88E6175",
4925 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004926 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004927 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004928 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004929 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004930 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004931 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004932 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004933 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004934 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004935 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004936 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004937 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004938 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004939 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004940 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004941 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004942 },
4943
4944 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004946 .family = MV88E6XXX_FAMILY_6352,
4947 .name = "Marvell 88E6176",
4948 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004949 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004950 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004951 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004952 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004953 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004954 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004955 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004956 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004957 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004958 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004959 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004960 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004961 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004962 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004963 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004964 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004965 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004966 },
4967
4968 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004969 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004970 .family = MV88E6XXX_FAMILY_6185,
4971 .name = "Marvell 88E6185",
4972 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004973 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004974 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004975 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004976 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004977 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004978 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004979 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004980 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004981 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004982 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004983 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004984 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004985 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004986 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004987 },
4988
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004989 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004990 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004991 .family = MV88E6XXX_FAMILY_6390,
4992 .name = "Marvell 88E6190",
4993 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004994 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004995 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004996 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004997 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004998 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004999 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005000 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005001 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005002 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005003 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005004 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005005 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005006 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04005007 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005008 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05005009 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005010 .ops = &mv88e6190_ops,
5011 },
5012
5013 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005014 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005015 .family = MV88E6XXX_FAMILY_6390,
5016 .name = "Marvell 88E6190X",
5017 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005018 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005019 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005020 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005021 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005022 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005023 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005024 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005025 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005026 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005027 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005028 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005029 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005030 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005031 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005032 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005033 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005034 .ops = &mv88e6190x_ops,
5035 },
5036
5037 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005038 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005039 .family = MV88E6XXX_FAMILY_6390,
5040 .name = "Marvell 88E6191",
5041 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005042 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005043 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005044 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005045 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005046 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005047 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005048 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005049 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005050 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005051 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005052 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005053 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005054 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005055 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005056 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005057 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005058 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005059 },
5060
Hubert Feurstein49022642019-07-31 10:23:46 +02005061 [MV88E6220] = {
5062 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5063 .family = MV88E6XXX_FAMILY_6250,
5064 .name = "Marvell 88E6220",
5065 .num_databases = 64,
5066
5067 /* Ports 2-4 are not routed to pins
5068 * => usable ports 0, 1, 5, 6
5069 */
5070 .num_ports = 7,
5071 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005072 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005073 .max_vid = 4095,
5074 .port_base_addr = 0x08,
5075 .phy_base_addr = 0x00,
5076 .global1_addr = 0x0f,
5077 .global2_addr = 0x07,
5078 .age_time_coeff = 15000,
5079 .g1_irqs = 9,
5080 .g2_irqs = 10,
5081 .atu_move_port_mask = 0xf,
5082 .dual_chip = true,
5083 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005084 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005085 .ops = &mv88e6250_ops,
5086 },
5087
Vivien Didelotf81ec902016-05-09 13:22:58 -04005088 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005089 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005090 .family = MV88E6XXX_FAMILY_6352,
5091 .name = "Marvell 88E6240",
5092 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005093 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005094 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005095 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005096 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005097 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005098 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005099 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005100 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005101 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005102 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005103 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005104 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005105 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005106 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005107 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005108 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005109 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005110 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005111 },
5112
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005113 [MV88E6250] = {
5114 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5115 .family = MV88E6XXX_FAMILY_6250,
5116 .name = "Marvell 88E6250",
5117 .num_databases = 64,
5118 .num_ports = 7,
5119 .num_internal_phys = 5,
5120 .max_vid = 4095,
5121 .port_base_addr = 0x08,
5122 .phy_base_addr = 0x00,
5123 .global1_addr = 0x0f,
5124 .global2_addr = 0x07,
5125 .age_time_coeff = 15000,
5126 .g1_irqs = 9,
5127 .g2_irqs = 10,
5128 .atu_move_port_mask = 0xf,
5129 .dual_chip = true,
5130 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005131 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005132 .ops = &mv88e6250_ops,
5133 },
5134
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005135 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005136 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005137 .family = MV88E6XXX_FAMILY_6390,
5138 .name = "Marvell 88E6290",
5139 .num_databases = 4096,
5140 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005141 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005142 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005143 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005144 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005145 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005146 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005147 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005148 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005149 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005150 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005151 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005152 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005153 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005154 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005155 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005156 .ops = &mv88e6290_ops,
5157 },
5158
Vivien Didelotf81ec902016-05-09 13:22:58 -04005159 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005160 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005161 .family = MV88E6XXX_FAMILY_6320,
5162 .name = "Marvell 88E6320",
5163 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005164 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005165 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005166 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005167 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005168 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005169 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005170 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005171 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005172 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005173 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005174 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005175 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005176 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005177 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005178 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005179 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005180 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005181 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005182 },
5183
5184 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005185 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005186 .family = MV88E6XXX_FAMILY_6320,
5187 .name = "Marvell 88E6321",
5188 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005189 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005190 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005191 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005192 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005193 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005194 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005195 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005196 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005197 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005198 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005199 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005200 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005201 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005202 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005203 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005204 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005205 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005206 },
5207
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005208 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005209 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005210 .family = MV88E6XXX_FAMILY_6341,
5211 .name = "Marvell 88E6341",
5212 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005213 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005214 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005215 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005216 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005217 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005218 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005219 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005220 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005221 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005222 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005223 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005224 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005225 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005226 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005227 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005228 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005229 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005230 .ops = &mv88e6341_ops,
5231 },
5232
Vivien Didelotf81ec902016-05-09 13:22:58 -04005233 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005234 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005235 .family = MV88E6XXX_FAMILY_6351,
5236 .name = "Marvell 88E6350",
5237 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005238 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005239 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005240 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005241 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005242 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005243 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005244 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005245 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005246 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005247 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005248 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005249 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005250 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005251 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005252 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005253 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005254 },
5255
5256 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005257 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005258 .family = MV88E6XXX_FAMILY_6351,
5259 .name = "Marvell 88E6351",
5260 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005261 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005262 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005263 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005264 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005265 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005266 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005267 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005268 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005269 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005270 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005271 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005272 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005273 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005274 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005275 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005276 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005277 },
5278
5279 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005280 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005281 .family = MV88E6XXX_FAMILY_6352,
5282 .name = "Marvell 88E6352",
5283 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005284 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005285 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005286 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005287 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005288 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005289 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005290 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005291 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005292 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005293 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005294 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005295 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005296 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005297 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005298 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005299 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005300 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005301 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005302 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005303 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005304 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005305 .family = MV88E6XXX_FAMILY_6390,
5306 .name = "Marvell 88E6390",
5307 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005308 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005309 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005310 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005311 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005312 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005313 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005314 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005315 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005316 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005317 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005318 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005319 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005320 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005321 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005322 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005323 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005324 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005325 .ops = &mv88e6390_ops,
5326 },
5327 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005328 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005329 .family = MV88E6XXX_FAMILY_6390,
5330 .name = "Marvell 88E6390X",
5331 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005332 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005333 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005334 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005335 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005336 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005337 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005338 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005339 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005340 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005341 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005342 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005343 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005344 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005345 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005346 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005347 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005348 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005349 .ops = &mv88e6390x_ops,
5350 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005351};
5352
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005353static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005354{
Vivien Didelota439c062016-04-17 13:23:58 -04005355 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005356
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005357 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5358 if (mv88e6xxx_table[i].prod_num == prod_num)
5359 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005360
Vivien Didelotb9b37712015-10-30 19:39:48 -04005361 return NULL;
5362}
5363
Vivien Didelotfad09c72016-06-21 12:28:20 -04005364static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005365{
5366 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005367 unsigned int prod_num, rev;
5368 u16 id;
5369 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005370
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005371 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005372 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005373 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005374 if (err)
5375 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005376
Vivien Didelot107fcc12017-06-12 12:37:36 -04005377 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5378 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005379
5380 info = mv88e6xxx_lookup_info(prod_num);
5381 if (!info)
5382 return -ENODEV;
5383
Vivien Didelotcaac8542016-06-20 13:14:09 -04005384 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005385 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005386
Vivien Didelotca070c12016-09-02 14:45:34 -04005387 err = mv88e6xxx_g2_require(chip);
5388 if (err)
5389 return err;
5390
Vivien Didelotfad09c72016-06-21 12:28:20 -04005391 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5392 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005393
5394 return 0;
5395}
5396
Vivien Didelotfad09c72016-06-21 12:28:20 -04005397static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005398{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005399 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005400
Vivien Didelotfad09c72016-06-21 12:28:20 -04005401 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5402 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005403 return NULL;
5404
Vivien Didelotfad09c72016-06-21 12:28:20 -04005405 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005406
Vivien Didelotfad09c72016-06-21 12:28:20 -04005407 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005408 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005409 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005410
Vivien Didelotfad09c72016-06-21 12:28:20 -04005411 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005412}
5413
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005414static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005415 int port,
5416 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005417{
Vivien Didelot04bed142016-08-31 18:06:13 -04005418 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005419
Andrew Lunn443d5a12016-12-03 04:35:18 +01005420 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005421}
5422
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005423static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005424 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005425{
5426 /* We don't need any dynamic resource from the kernel (yet),
5427 * so skip the prepare phase.
5428 */
5429
5430 return 0;
5431}
5432
5433static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005434 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005435{
Vivien Didelot04bed142016-08-31 18:06:13 -04005436 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005437
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005438 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005439 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005440 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005441 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5442 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005443 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005444}
5445
5446static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5447 const struct switchdev_obj_port_mdb *mdb)
5448{
Vivien Didelot04bed142016-08-31 18:06:13 -04005449 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005450 int err;
5451
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005452 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005453 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005454 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005455
5456 return err;
5457}
5458
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005459static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5460 struct dsa_mall_mirror_tc_entry *mirror,
5461 bool ingress)
5462{
5463 enum mv88e6xxx_egress_direction direction = ingress ?
5464 MV88E6XXX_EGRESS_DIR_INGRESS :
5465 MV88E6XXX_EGRESS_DIR_EGRESS;
5466 struct mv88e6xxx_chip *chip = ds->priv;
5467 bool other_mirrors = false;
5468 int i;
5469 int err;
5470
5471 if (!chip->info->ops->set_egress_port)
5472 return -EOPNOTSUPP;
5473
5474 mutex_lock(&chip->reg_lock);
5475 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5476 mirror->to_local_port) {
5477 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5478 other_mirrors |= ingress ?
5479 chip->ports[i].mirror_ingress :
5480 chip->ports[i].mirror_egress;
5481
5482 /* Can't change egress port when other mirror is active */
5483 if (other_mirrors) {
5484 err = -EBUSY;
5485 goto out;
5486 }
5487
5488 err = chip->info->ops->set_egress_port(chip,
5489 direction,
5490 mirror->to_local_port);
5491 if (err)
5492 goto out;
5493 }
5494
5495 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5496out:
5497 mutex_unlock(&chip->reg_lock);
5498
5499 return err;
5500}
5501
5502static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5503 struct dsa_mall_mirror_tc_entry *mirror)
5504{
5505 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5506 MV88E6XXX_EGRESS_DIR_INGRESS :
5507 MV88E6XXX_EGRESS_DIR_EGRESS;
5508 struct mv88e6xxx_chip *chip = ds->priv;
5509 bool other_mirrors = false;
5510 int i;
5511
5512 mutex_lock(&chip->reg_lock);
5513 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5514 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5515
5516 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5517 other_mirrors |= mirror->ingress ?
5518 chip->ports[i].mirror_ingress :
5519 chip->ports[i].mirror_egress;
5520
5521 /* Reset egress port when no other mirror is active */
5522 if (!other_mirrors) {
5523 if (chip->info->ops->set_egress_port(chip,
5524 direction,
5525 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005526 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005527 dev_err(ds->dev, "failed to set egress port\n");
5528 }
5529
5530 mutex_unlock(&chip->reg_lock);
5531}
5532
Russell King4f859012019-02-20 15:35:05 -08005533static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5534 bool unicast, bool multicast)
5535{
5536 struct mv88e6xxx_chip *chip = ds->priv;
5537 int err = -EOPNOTSUPP;
5538
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005539 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005540 if (chip->info->ops->port_set_egress_floods)
5541 err = chip->info->ops->port_set_egress_floods(chip, port,
5542 unicast,
5543 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005544 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005545
5546 return err;
5547}
5548
Florian Fainellia82f67a2017-01-08 14:52:08 -08005549static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005550 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005551 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005552 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005553 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005554 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005555 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005556 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005557 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5558 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005559 .get_strings = mv88e6xxx_get_strings,
5560 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5561 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005562 .port_enable = mv88e6xxx_port_enable,
5563 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005564 .get_mac_eee = mv88e6xxx_get_mac_eee,
5565 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005566 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005567 .get_eeprom = mv88e6xxx_get_eeprom,
5568 .set_eeprom = mv88e6xxx_set_eeprom,
5569 .get_regs_len = mv88e6xxx_get_regs_len,
5570 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005571 .get_rxnfc = mv88e6xxx_get_rxnfc,
5572 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005573 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005574 .port_bridge_join = mv88e6xxx_port_bridge_join,
5575 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005576 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005577 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005578 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005579 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5580 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5581 .port_vlan_add = mv88e6xxx_port_vlan_add,
5582 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005583 .port_fdb_add = mv88e6xxx_port_fdb_add,
5584 .port_fdb_del = mv88e6xxx_port_fdb_del,
5585 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005586 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5587 .port_mdb_add = mv88e6xxx_port_mdb_add,
5588 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005589 .port_mirror_add = mv88e6xxx_port_mirror_add,
5590 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005591 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5592 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005593 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5594 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5595 .port_txtstamp = mv88e6xxx_port_txtstamp,
5596 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5597 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005598 .devlink_param_get = mv88e6xxx_devlink_param_get,
5599 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005600};
5601
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005602static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005603{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005604 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005605 struct dsa_switch *ds;
5606
Vivien Didelot7e99e342019-10-21 16:51:30 -04005607 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005608 if (!ds)
5609 return -ENOMEM;
5610
Vivien Didelot7e99e342019-10-21 16:51:30 -04005611 ds->dev = dev;
5612 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005613 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005614 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005615 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005616 ds->ageing_time_min = chip->info->age_time_coeff;
5617 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005618
5619 dev_set_drvdata(dev, ds);
5620
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005621 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005622}
5623
Vivien Didelotfad09c72016-06-21 12:28:20 -04005624static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005625{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005626 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005627}
5628
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005629static const void *pdata_device_get_match_data(struct device *dev)
5630{
5631 const struct of_device_id *matches = dev->driver->of_match_table;
5632 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5633
5634 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5635 matches++) {
5636 if (!strcmp(pdata->compatible, matches->compatible))
5637 return matches->data;
5638 }
5639 return NULL;
5640}
5641
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005642/* There is no suspend to RAM support at DSA level yet, the switch configuration
5643 * would be lost after a power cycle so prevent it to be suspended.
5644 */
5645static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5646{
5647 return -EOPNOTSUPP;
5648}
5649
5650static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5651{
5652 return 0;
5653}
5654
5655static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5656
Vivien Didelot57d32312016-06-20 13:13:58 -04005657static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005658{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005659 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005660 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005661 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005662 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005663 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005664 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005665 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005666
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005667 if (!np && !pdata)
5668 return -EINVAL;
5669
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005670 if (np)
5671 compat_info = of_device_get_match_data(dev);
5672
5673 if (pdata) {
5674 compat_info = pdata_device_get_match_data(dev);
5675
5676 if (!pdata->netdev)
5677 return -EINVAL;
5678
5679 for (port = 0; port < DSA_MAX_PORTS; port++) {
5680 if (!(pdata->enabled_ports & (1 << port)))
5681 continue;
5682 if (strcmp(pdata->cd.port_names[port], "cpu"))
5683 continue;
5684 pdata->cd.netdev[port] = &pdata->netdev->dev;
5685 break;
5686 }
5687 }
5688
Vivien Didelotcaac8542016-06-20 13:14:09 -04005689 if (!compat_info)
5690 return -EINVAL;
5691
Vivien Didelotfad09c72016-06-21 12:28:20 -04005692 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005693 if (!chip) {
5694 err = -ENOMEM;
5695 goto out;
5696 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005697
Vivien Didelotfad09c72016-06-21 12:28:20 -04005698 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005699
Vivien Didelotfad09c72016-06-21 12:28:20 -04005700 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005701 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005702 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005703
Andrew Lunnb4308f02016-11-21 23:26:55 +01005704 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005705 if (IS_ERR(chip->reset)) {
5706 err = PTR_ERR(chip->reset);
5707 goto out;
5708 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005709 if (chip->reset)
5710 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005711
Vivien Didelotfad09c72016-06-21 12:28:20 -04005712 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005713 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005714 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005715
Vivien Didelote57e5e72016-08-15 17:19:00 -04005716 mv88e6xxx_phy_init(chip);
5717
Andrew Lunn00baabe2018-05-19 22:31:35 +02005718 if (chip->info->ops->get_eeprom) {
5719 if (np)
5720 of_property_read_u32(np, "eeprom-length",
5721 &chip->eeprom_len);
5722 else
5723 chip->eeprom_len = pdata->eeprom_len;
5724 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005725
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005726 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005727 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005728 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005729 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005730 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005731
Andrew Lunna27415d2019-05-01 00:10:50 +02005732 if (np) {
5733 chip->irq = of_irq_get(np, 0);
5734 if (chip->irq == -EPROBE_DEFER) {
5735 err = chip->irq;
5736 goto out;
5737 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005738 }
5739
Andrew Lunna27415d2019-05-01 00:10:50 +02005740 if (pdata)
5741 chip->irq = pdata->irq;
5742
Andrew Lunn294d7112018-02-22 22:58:32 +01005743 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005744 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005745 * controllers
5746 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005747 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005748 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005749 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005750 else
5751 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005752 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005753
Andrew Lunn294d7112018-02-22 22:58:32 +01005754 if (err)
5755 goto out;
5756
5757 if (chip->info->g2_irqs > 0) {
5758 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005759 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005760 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005761 }
5762
Andrew Lunn294d7112018-02-22 22:58:32 +01005763 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5764 if (err)
5765 goto out_g2_irq;
5766
5767 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5768 if (err)
5769 goto out_g1_atu_prob_irq;
5770
Andrew Lunna3c53be52017-01-24 14:53:50 +01005771 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005772 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005773 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005774
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005775 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005776 if (err)
5777 goto out_mdio;
5778
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005779 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005780
5781out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005782 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005783out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005784 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005785out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005786 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005787out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005788 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005789 mv88e6xxx_g2_irq_free(chip);
5790out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005791 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005792 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005793 else
5794 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005795out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005796 if (pdata)
5797 dev_put(pdata->netdev);
5798
Andrew Lunndc30c352016-10-16 19:56:49 +02005799 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005800}
5801
5802static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5803{
5804 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005805 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005806
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005807 if (chip->info->ptp_support) {
5808 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005809 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005810 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005811
Andrew Lunn930188c2016-08-22 16:01:03 +02005812 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005813 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005814 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005815
Andrew Lunn76f38f12018-03-17 20:21:09 +01005816 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5817 mv88e6xxx_g1_atu_prob_irq_free(chip);
5818
5819 if (chip->info->g2_irqs > 0)
5820 mv88e6xxx_g2_irq_free(chip);
5821
Andrew Lunn76f38f12018-03-17 20:21:09 +01005822 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005823 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005824 else
5825 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005826}
5827
5828static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005829 {
5830 .compatible = "marvell,mv88e6085",
5831 .data = &mv88e6xxx_table[MV88E6085],
5832 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005833 {
5834 .compatible = "marvell,mv88e6190",
5835 .data = &mv88e6xxx_table[MV88E6190],
5836 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005837 {
5838 .compatible = "marvell,mv88e6250",
5839 .data = &mv88e6xxx_table[MV88E6250],
5840 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005841 { /* sentinel */ },
5842};
5843
5844MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5845
5846static struct mdio_driver mv88e6xxx_driver = {
5847 .probe = mv88e6xxx_probe,
5848 .remove = mv88e6xxx_remove,
5849 .mdiodrv.driver = {
5850 .name = "mv88e6085",
5851 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005852 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005853 },
5854};
5855
Andrew Lunn7324d502019-04-27 19:19:10 +02005856mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005857
5858MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5859MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5860MODULE_LICENSE("GPL");