blob: bd61d0d3a245b41cd2b1e5c5bdd5767a13d3a83d [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
Barry Grussling19b2f972013-01-08 16:05:54 +000013#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070014#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020015#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070016#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020017#include <linux/interrupt.h>
18#include <linux/irq.h>
19#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000020#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000021#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020022#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000023#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040024#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020025#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020026#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020027#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000028#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010029#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070030#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000031#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040032
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040033#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040034#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040035#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010036#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020037#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010038#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010039#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020040#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040041#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000042
Vivien Didelotfad09c72016-06-21 12:28:20 -040043static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040044{
Vivien Didelotfad09c72016-06-21 12:28:20 -040045 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
46 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040047 dump_stack();
48 }
49}
50
Vivien Didelotec561272016-09-02 14:45:33 -040051int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040052{
53 int err;
54
Vivien Didelotfad09c72016-06-21 12:28:20 -040055 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040056
Vivien Didelotfad09c72016-06-21 12:28:20 -040057 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040058 if (err)
59 return err;
60
Vivien Didelotfad09c72016-06-21 12:28:20 -040061 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040062 addr, reg, *val);
63
64 return 0;
65}
66
Vivien Didelotec561272016-09-02 14:45:33 -040067int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040068{
69 int err;
70
Vivien Didelotfad09c72016-06-21 12:28:20 -040071 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040072
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074 if (err)
75 return err;
76
Vivien Didelotfad09c72016-06-21 12:28:20 -040077 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040078 addr, reg, val);
79
80 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000081}
82
Vivien Didelot683f2242019-08-09 18:47:54 -040083int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
84 u16 mask, u16 val)
85{
86 u16 data;
87 int err;
88 int i;
89
90 /* There's no bus specific operation to wait for a mask */
91 for (i = 0; i < 16; i++) {
92 err = mv88e6xxx_read(chip, addr, reg, &data);
93 if (err)
94 return err;
95
96 if ((data & mask) == val)
97 return 0;
98
99 usleep_range(1000, 2000);
100 }
101
102 dev_err(chip->dev, "Timeout while waiting for switch\n");
103 return -ETIMEDOUT;
104}
105
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200106struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100107{
108 struct mv88e6xxx_mdio_bus *mdio_bus;
109
110 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
111 list);
112 if (!mdio_bus)
113 return NULL;
114
115 return mdio_bus->bus;
116}
117
Andrew Lunndc30c352016-10-16 19:56:49 +0200118static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
119{
120 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
121 unsigned int n = d->hwirq;
122
123 chip->g1_irq.masked |= (1 << n);
124}
125
126static void mv88e6xxx_g1_irq_unmask(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
Andrew Lunn294d7112018-02-22 22:58:32 +0100134static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200135{
Andrew Lunndc30c352016-10-16 19:56:49 +0200136 unsigned int nhandled = 0;
137 unsigned int sub_irq;
138 unsigned int n;
139 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500140 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200141 int err;
142
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000143 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400144 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000145 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200146
147 if (err)
148 goto out;
149
John David Anglin7c0db242019-02-11 13:40:21 -0500150 do {
151 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
152 if (reg & (1 << n)) {
153 sub_irq = irq_find_mapping(chip->g1_irq.domain,
154 n);
155 handle_nested_irq(sub_irq);
156 ++nhandled;
157 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200158 }
John David Anglin7c0db242019-02-11 13:40:21 -0500159
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000160 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500161 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
162 if (err)
163 goto unlock;
164 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
165unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000166 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500167 if (err)
168 goto out;
169 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
170 } while (reg & ctl1);
171
Andrew Lunndc30c352016-10-16 19:56:49 +0200172out:
173 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
174}
175
Andrew Lunn294d7112018-02-22 22:58:32 +0100176static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
177{
178 struct mv88e6xxx_chip *chip = dev_id;
179
180 return mv88e6xxx_g1_irq_thread_work(chip);
181}
182
Andrew Lunndc30c352016-10-16 19:56:49 +0200183static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
184{
185 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
186
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000187 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200188}
189
190static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
191{
192 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
193 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
194 u16 reg;
195 int err;
196
Vivien Didelotd77f4322017-06-15 12:14:03 -0400197 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200198 if (err)
199 goto out;
200
201 reg &= ~mask;
202 reg |= (~chip->g1_irq.masked & mask);
203
Vivien Didelotd77f4322017-06-15 12:14:03 -0400204 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200205 if (err)
206 goto out;
207
208out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000209 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200210}
211
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530212static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 .name = "mv88e6xxx-g1",
214 .irq_mask = mv88e6xxx_g1_irq_mask,
215 .irq_unmask = mv88e6xxx_g1_irq_unmask,
216 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
217 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
218};
219
220static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
221 unsigned int irq,
222 irq_hw_number_t hwirq)
223{
224 struct mv88e6xxx_chip *chip = d->host_data;
225
226 irq_set_chip_data(irq, d->host_data);
227 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
228 irq_set_noprobe(irq);
229
230 return 0;
231}
232
233static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
234 .map = mv88e6xxx_g1_irq_domain_map,
235 .xlate = irq_domain_xlate_twocell,
236};
237
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200238/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100239static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200240{
241 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100242 u16 mask;
243
Vivien Didelotd77f4322017-06-15 12:14:03 -0400244 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100245 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400246 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100247
Andreas Färber5edef2f2016-11-27 23:26:28 +0100248 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100249 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200250 irq_dispose_mapping(virq);
251 }
252
Andrew Lunna3db3d32016-11-20 20:14:14 +0100253 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200254}
255
Andrew Lunn294d7112018-02-22 22:58:32 +0100256static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
257{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200258 /*
259 * free_irq must be called without reg_lock taken because the irq
260 * handler takes this lock, too.
261 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100262 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200263
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000264 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200265 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000266 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100267}
268
269static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200270{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100271 int err, irq, virq;
272 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200273
274 chip->g1_irq.nirqs = chip->info->g1_irqs;
275 chip->g1_irq.domain = irq_domain_add_simple(
276 NULL, chip->g1_irq.nirqs, 0,
277 &mv88e6xxx_g1_irq_domain_ops, chip);
278 if (!chip->g1_irq.domain)
279 return -ENOMEM;
280
281 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
282 irq_create_mapping(chip->g1_irq.domain, irq);
283
284 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
285 chip->g1_irq.masked = ~0;
286
Vivien Didelotd77f4322017-06-15 12:14:03 -0400287 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200288 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100289 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200290
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100291 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200292
Vivien Didelotd77f4322017-06-15 12:14:03 -0400293 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200294 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100295 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200296
297 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400298 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200299 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100300 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200301
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 return 0;
303
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100304out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100305 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400306 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100307
308out_mapping:
309 for (irq = 0; irq < 16; irq++) {
310 virq = irq_find_mapping(chip->g1_irq.domain, irq);
311 irq_dispose_mapping(virq);
312 }
313
314 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200315
316 return err;
317}
318
Andrew Lunn294d7112018-02-22 22:58:32 +0100319static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
320{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100321 static struct lock_class_key lock_key;
322 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100323 int err;
324
325 err = mv88e6xxx_g1_irq_setup_common(chip);
326 if (err)
327 return err;
328
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 /* These lock classes tells lockdep that global 1 irqs are in
330 * a different category than their parent GPIO, so it won't
331 * report false recursion.
332 */
333 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
334
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000335 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100336 err = request_threaded_irq(chip->irq, NULL,
337 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200338 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100339 dev_name(chip->dev), chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000340 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100341 if (err)
342 mv88e6xxx_g1_irq_free_common(chip);
343
344 return err;
345}
346
347static void mv88e6xxx_irq_poll(struct kthread_work *work)
348{
349 struct mv88e6xxx_chip *chip = container_of(work,
350 struct mv88e6xxx_chip,
351 irq_poll_work.work);
352 mv88e6xxx_g1_irq_thread_work(chip);
353
354 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
355 msecs_to_jiffies(100));
356}
357
358static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
359{
360 int err;
361
362 err = mv88e6xxx_g1_irq_setup_common(chip);
363 if (err)
364 return err;
365
366 kthread_init_delayed_work(&chip->irq_poll_work,
367 mv88e6xxx_irq_poll);
368
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800369 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100370 if (IS_ERR(chip->kworker))
371 return PTR_ERR(chip->kworker);
372
373 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
374 msecs_to_jiffies(100));
375
376 return 0;
377}
378
379static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
380{
381 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
382 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200383
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000384 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200385 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000386 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100387}
388
Vivien Didelotec561272016-09-02 14:45:33 -0400389int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400390{
Vivien Didelot683f2242019-08-09 18:47:54 -0400391 return mv88e6xxx_wait_mask(chip, addr, reg, mask, 0x0000);
Vivien Didelot2d79af62016-08-15 17:18:57 -0400392}
393
Vivien Didelotf22ab642016-07-18 20:45:31 -0400394/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400395int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400396{
397 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200398 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400399
400 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200401 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
402 if (err)
403 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400404
405 /* Set the Update bit to trigger a write operation */
406 val = BIT(15) | update;
407
408 return mv88e6xxx_write(chip, addr, reg, val);
409}
410
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100411int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
412 int speed, int duplex, int pause,
413 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100414{
Andrew Lunna26deec2019-04-18 03:11:39 +0200415 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100416 int err;
417
418 if (!chip->info->ops->port_set_link)
419 return 0;
420
Andrew Lunna26deec2019-04-18 03:11:39 +0200421 if (!chip->info->ops->port_link_state)
422 return 0;
423
424 err = chip->info->ops->port_link_state(chip, port, &state);
425 if (err)
426 return err;
427
428 /* Has anything actually changed? We don't expect the
429 * interface mode to change without one of the other
430 * parameters also changing
431 */
432 if (state.link == link &&
433 state.speed == speed &&
434 state.duplex == duplex)
435 return 0;
436
Vivien Didelotd78343d2016-11-04 03:23:36 +0100437 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200438 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100439 if (err)
440 return err;
441
442 if (chip->info->ops->port_set_speed) {
443 err = chip->info->ops->port_set_speed(chip, port, speed);
444 if (err && err != -EOPNOTSUPP)
445 goto restore_link;
446 }
447
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100448 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
449 mode = chip->info->ops->port_max_speed_mode(port);
450
Andrew Lunn54186b92018-08-09 15:38:37 +0200451 if (chip->info->ops->port_set_pause) {
452 err = chip->info->ops->port_set_pause(chip, port, pause);
453 if (err)
454 goto restore_link;
455 }
456
Vivien Didelotd78343d2016-11-04 03:23:36 +0100457 if (chip->info->ops->port_set_duplex) {
458 err = chip->info->ops->port_set_duplex(chip, port, duplex);
459 if (err && err != -EOPNOTSUPP)
460 goto restore_link;
461 }
462
463 if (chip->info->ops->port_set_rgmii_delay) {
464 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
465 if (err && err != -EOPNOTSUPP)
466 goto restore_link;
467 }
468
Andrew Lunnf39908d2017-02-04 20:02:50 +0100469 if (chip->info->ops->port_set_cmode) {
470 err = chip->info->ops->port_set_cmode(chip, port, mode);
471 if (err && err != -EOPNOTSUPP)
472 goto restore_link;
473 }
474
Vivien Didelotd78343d2016-11-04 03:23:36 +0100475 err = 0;
476restore_link:
477 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400478 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100479
480 return err;
481}
482
Marek Vasutd700ec42018-09-12 00:15:24 +0200483static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
484{
485 struct mv88e6xxx_chip *chip = ds->priv;
486
487 return port < chip->info->num_internal_phys;
488}
489
Russell King6c422e32018-08-09 15:38:39 +0200490static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
491 unsigned long *mask,
492 struct phylink_link_state *state)
493{
494 if (!phy_interface_mode_is_8023z(state->interface)) {
495 /* 10M and 100M are only supported in non-802.3z mode */
496 phylink_set(mask, 10baseT_Half);
497 phylink_set(mask, 10baseT_Full);
498 phylink_set(mask, 100baseT_Half);
499 phylink_set(mask, 100baseT_Full);
500 }
501}
502
503static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
504 unsigned long *mask,
505 struct phylink_link_state *state)
506{
507 /* FIXME: if the port is in 1000Base-X mode, then it only supports
508 * 1000M FD speeds. In this case, CMODE will indicate 5.
509 */
510 phylink_set(mask, 1000baseT_Full);
511 phylink_set(mask, 1000baseX_Full);
512
513 mv88e6065_phylink_validate(chip, port, mask, state);
514}
515
Marek Behúne3af71a2019-02-25 12:39:55 +0100516static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
517 unsigned long *mask,
518 struct phylink_link_state *state)
519{
520 if (port >= 5)
521 phylink_set(mask, 2500baseX_Full);
522
523 /* No ethtool bits for 200Mbps */
524 phylink_set(mask, 1000baseT_Full);
525 phylink_set(mask, 1000baseX_Full);
526
527 mv88e6065_phylink_validate(chip, port, mask, state);
528}
529
Russell King6c422e32018-08-09 15:38:39 +0200530static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
531 unsigned long *mask,
532 struct phylink_link_state *state)
533{
534 /* No ethtool bits for 200Mbps */
535 phylink_set(mask, 1000baseT_Full);
536 phylink_set(mask, 1000baseX_Full);
537
538 mv88e6065_phylink_validate(chip, port, mask, state);
539}
540
541static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
542 unsigned long *mask,
543 struct phylink_link_state *state)
544{
Andrew Lunnec260162019-02-08 22:25:44 +0100545 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200546 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100547 phylink_set(mask, 2500baseT_Full);
548 }
Russell King6c422e32018-08-09 15:38:39 +0200549
550 /* No ethtool bits for 200Mbps */
551 phylink_set(mask, 1000baseT_Full);
552 phylink_set(mask, 1000baseX_Full);
553
554 mv88e6065_phylink_validate(chip, port, mask, state);
555}
556
557static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
558 unsigned long *mask,
559 struct phylink_link_state *state)
560{
561 if (port >= 9) {
562 phylink_set(mask, 10000baseT_Full);
563 phylink_set(mask, 10000baseKR_Full);
564 }
565
566 mv88e6390_phylink_validate(chip, port, mask, state);
567}
568
Russell Kingc9a23562018-05-10 13:17:35 -0700569static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
570 unsigned long *supported,
571 struct phylink_link_state *state)
572{
Russell King6c422e32018-08-09 15:38:39 +0200573 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
574 struct mv88e6xxx_chip *chip = ds->priv;
575
576 /* Allow all the expected bits */
577 phylink_set(mask, Autoneg);
578 phylink_set(mask, Pause);
579 phylink_set_port_modes(mask);
580
581 if (chip->info->ops->phylink_validate)
582 chip->info->ops->phylink_validate(chip, port, mask, state);
583
584 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
585 bitmap_and(state->advertising, state->advertising, mask,
586 __ETHTOOL_LINK_MODE_MASK_NBITS);
587
588 /* We can only operate at 2500BaseX or 1000BaseX. If requested
589 * to advertise both, only report advertising at 2500BaseX.
590 */
591 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700592}
593
594static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
595 struct phylink_link_state *state)
596{
597 struct mv88e6xxx_chip *chip = ds->priv;
598 int err;
599
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000600 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200601 if (chip->info->ops->port_link_state)
602 err = chip->info->ops->port_link_state(chip, port, state);
603 else
604 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000605 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700606
607 return err;
608}
609
610static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
611 unsigned int mode,
612 const struct phylink_link_state *state)
613{
614 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200615 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700616
Marek Vasutd700ec42018-09-12 00:15:24 +0200617 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700618 return;
619
620 if (mode == MLO_AN_FIXED) {
621 link = LINK_FORCED_UP;
622 speed = state->speed;
623 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200624 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
625 link = state->link;
626 speed = state->speed;
627 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700628 } else {
629 speed = SPEED_UNFORCED;
630 duplex = DUPLEX_UNFORCED;
631 link = LINK_UNFORCED;
632 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200633 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700634
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000635 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200636 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700637 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000638 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700639
640 if (err && err != -EOPNOTSUPP)
641 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
642}
643
644static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
645{
646 struct mv88e6xxx_chip *chip = ds->priv;
647 int err;
648
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000649 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700650 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000651 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700652
653 if (err)
654 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
655}
656
657static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
658 unsigned int mode,
659 phy_interface_t interface)
660{
661 if (mode == MLO_AN_FIXED)
662 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
663}
664
665static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
666 unsigned int mode, phy_interface_t interface,
667 struct phy_device *phydev)
668{
669 if (mode == MLO_AN_FIXED)
670 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
671}
672
Andrew Lunna605a0f2016-11-21 23:26:58 +0100673static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000674{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100675 if (!chip->info->ops->stats_snapshot)
676 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000677
Andrew Lunna605a0f2016-11-21 23:26:58 +0100678 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000679}
680
Andrew Lunne413e7e2015-04-02 04:06:38 +0200681static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100682 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
683 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
684 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
685 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
686 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
687 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
688 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
689 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
690 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
691 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
692 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
693 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
694 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
695 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
696 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
697 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
698 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
699 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
700 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
701 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
702 { "single", 4, 0x14, STATS_TYPE_BANK0, },
703 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
704 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
705 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
706 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
707 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
708 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
709 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
710 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
711 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
712 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
713 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
714 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
715 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
716 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
717 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
718 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
719 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
720 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
721 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
722 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
723 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
724 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
725 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
726 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
727 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
728 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
729 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
730 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
731 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
732 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
733 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
734 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
735 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
736 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
737 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
738 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
739 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
740 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200741};
742
Vivien Didelotfad09c72016-06-21 12:28:20 -0400743static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100744 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100745 int port, u16 bank1_select,
746 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200747{
Andrew Lunn80c46272015-06-20 18:42:30 +0200748 u32 low;
749 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100750 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200751 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200752 u64 value;
753
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100754 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100755 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200756 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
757 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800758 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200759
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200760 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100761 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200762 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
763 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800764 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000765 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200766 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100767 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100768 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100769 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100770 /* fall through */
771 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100772 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100773 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100774 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100775 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500776 break;
777 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800778 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200779 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100780 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200781 return value;
782}
783
Andrew Lunn436fe172018-03-01 02:02:29 +0100784static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
785 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100786{
787 struct mv88e6xxx_hw_stat *stat;
788 int i, j;
789
790 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
791 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100792 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100793 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
794 ETH_GSTRING_LEN);
795 j++;
796 }
797 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100798
799 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100800}
801
Andrew Lunn436fe172018-03-01 02:02:29 +0100802static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
803 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100804{
Andrew Lunn436fe172018-03-01 02:02:29 +0100805 return mv88e6xxx_stats_get_strings(chip, data,
806 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100807}
808
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000809static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
810 uint8_t *data)
811{
812 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
813}
814
Andrew Lunn436fe172018-03-01 02:02:29 +0100815static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
816 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100817{
Andrew Lunn436fe172018-03-01 02:02:29 +0100818 return mv88e6xxx_stats_get_strings(chip, data,
819 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100820}
821
Andrew Lunn65f60e42018-03-28 23:50:28 +0200822static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
823 "atu_member_violation",
824 "atu_miss_violation",
825 "atu_full_violation",
826 "vtu_member_violation",
827 "vtu_miss_violation",
828};
829
830static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
831{
832 unsigned int i;
833
834 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
835 strlcpy(data + i * ETH_GSTRING_LEN,
836 mv88e6xxx_atu_vtu_stats_strings[i],
837 ETH_GSTRING_LEN);
838}
839
Andrew Lunndfafe442016-11-21 23:27:02 +0100840static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700841 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100842{
Vivien Didelot04bed142016-08-31 18:06:13 -0400843 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100844 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100845
Florian Fainelli89f09042018-04-25 12:12:50 -0700846 if (stringset != ETH_SS_STATS)
847 return;
848
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000849 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100850
Andrew Lunndfafe442016-11-21 23:27:02 +0100851 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100852 count = chip->info->ops->stats_get_strings(chip, data);
853
854 if (chip->info->ops->serdes_get_strings) {
855 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200856 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100857 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100858
Andrew Lunn65f60e42018-03-28 23:50:28 +0200859 data += count * ETH_GSTRING_LEN;
860 mv88e6xxx_atu_vtu_get_strings(data);
861
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000862 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100863}
864
865static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
866 int types)
867{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100868 struct mv88e6xxx_hw_stat *stat;
869 int i, j;
870
871 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
872 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100874 j++;
875 }
876 return j;
877}
878
Andrew Lunndfafe442016-11-21 23:27:02 +0100879static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
880{
881 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
882 STATS_TYPE_PORT);
883}
884
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000885static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
886{
887 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
888}
889
Andrew Lunndfafe442016-11-21 23:27:02 +0100890static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
891{
892 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
893 STATS_TYPE_BANK1);
894}
895
Florian Fainelli89f09042018-04-25 12:12:50 -0700896static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100897{
898 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100899 int serdes_count = 0;
900 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100901
Florian Fainelli89f09042018-04-25 12:12:50 -0700902 if (sset != ETH_SS_STATS)
903 return 0;
904
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000905 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100906 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100907 count = chip->info->ops->stats_get_sset_count(chip);
908 if (count < 0)
909 goto out;
910
911 if (chip->info->ops->serdes_get_sset_count)
912 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
913 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200914 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200916 goto out;
917 }
918 count += serdes_count;
919 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
920
Andrew Lunn436fe172018-03-01 02:02:29 +0100921out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000922 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100923
Andrew Lunn436fe172018-03-01 02:02:29 +0100924 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100925}
926
Andrew Lunn436fe172018-03-01 02:02:29 +0100927static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
928 uint64_t *data, int types,
929 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100930{
931 struct mv88e6xxx_hw_stat *stat;
932 int i, j;
933
934 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
935 stat = &mv88e6xxx_hw_stats[i];
936 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000937 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100938 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
939 bank1_select,
940 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000941 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100942
Andrew Lunn052f9472016-11-21 23:27:03 +0100943 j++;
944 }
945 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100946 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100947}
948
Andrew Lunn436fe172018-03-01 02:02:29 +0100949static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
950 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100951{
952 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100953 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400954 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100955}
956
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000957static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
958 uint64_t *data)
959{
960 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
961 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
962}
963
Andrew Lunn436fe172018-03-01 02:02:29 +0100964static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
965 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100966{
967 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100968 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400969 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
970 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100971}
972
Andrew Lunn436fe172018-03-01 02:02:29 +0100973static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
974 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100975{
976 return mv88e6xxx_stats_get_stats(chip, port, data,
977 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400978 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
979 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100980}
981
Andrew Lunn65f60e42018-03-28 23:50:28 +0200982static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
983 uint64_t *data)
984{
985 *data++ = chip->ports[port].atu_member_violation;
986 *data++ = chip->ports[port].atu_miss_violation;
987 *data++ = chip->ports[port].atu_full_violation;
988 *data++ = chip->ports[port].vtu_member_violation;
989 *data++ = chip->ports[port].vtu_miss_violation;
990}
991
Andrew Lunn052f9472016-11-21 23:27:03 +0100992static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
993 uint64_t *data)
994{
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 int count = 0;
996
Andrew Lunn052f9472016-11-21 23:27:03 +0100997 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100998 count = chip->info->ops->stats_get_stats(chip, port, data);
999
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001000 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001001 if (chip->info->ops->serdes_get_stats) {
1002 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001003 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001004 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001005 data += count;
1006 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001008}
1009
Vivien Didelotf81ec902016-05-09 13:22:58 -04001010static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1011 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001012{
Vivien Didelot04bed142016-08-31 18:06:13 -04001013 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001014 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001015
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001016 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017
Andrew Lunna605a0f2016-11-21 23:26:58 +01001018 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001019 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001020
1021 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001022 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001023
1024 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001025
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001026}
Ben Hutchings98e67302011-11-25 14:36:19 +00001027
Vivien Didelotf81ec902016-05-09 13:22:58 -04001028static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001029{
1030 return 32 * sizeof(u16);
1031}
1032
Vivien Didelotf81ec902016-05-09 13:22:58 -04001033static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1034 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001035{
Vivien Didelot04bed142016-08-31 18:06:13 -04001036 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001037 int err;
1038 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001039 u16 *p = _p;
1040 int i;
1041
Vivien Didelota5f39322018-12-17 16:05:21 -05001042 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001043
1044 memset(p, 0xff, 32 * sizeof(u16));
1045
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001047
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001048 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001049
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001050 err = mv88e6xxx_port_read(chip, port, i, &reg);
1051 if (!err)
1052 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001053 }
Vivien Didelot23062512016-05-09 13:22:45 -04001054
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001055 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001056}
1057
Vivien Didelot08f50062017-08-01 16:32:41 -04001058static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1059 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001060{
Vivien Didelot5480db62017-08-01 16:32:40 -04001061 /* Nothing to do on the port's MAC */
1062 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001063}
1064
Vivien Didelot08f50062017-08-01 16:32:41 -04001065static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1066 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001067{
Vivien Didelot5480db62017-08-01 16:32:40 -04001068 /* Nothing to do on the port's MAC */
1069 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001070}
1071
Vivien Didelote5887a22017-03-30 17:37:11 -04001072static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001073{
Vivien Didelote5887a22017-03-30 17:37:11 -04001074 struct dsa_switch *ds = NULL;
1075 struct net_device *br;
1076 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001077 int i;
1078
Vivien Didelote5887a22017-03-30 17:37:11 -04001079 if (dev < DSA_MAX_SWITCHES)
1080 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001081
Vivien Didelote5887a22017-03-30 17:37:11 -04001082 /* Prevent frames from unknown switch or port */
1083 if (!ds || port >= ds->num_ports)
1084 return 0;
1085
1086 /* Frames from DSA links and CPU ports can egress any local port */
1087 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1088 return mv88e6xxx_port_mask(chip);
1089
1090 br = ds->ports[port].bridge_dev;
1091 pvlan = 0;
1092
1093 /* Frames from user ports can egress any local DSA links and CPU ports,
1094 * as well as any local member of their bridge group.
1095 */
1096 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1097 if (dsa_is_cpu_port(chip->ds, i) ||
1098 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001099 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001100 pvlan |= BIT(i);
1101
1102 return pvlan;
1103}
1104
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001105static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001106{
1107 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001108
1109 /* prevent frames from going back out of the port they came in on */
1110 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001111
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001112 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001113}
1114
Vivien Didelotf81ec902016-05-09 13:22:58 -04001115static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1116 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001117{
Vivien Didelot04bed142016-08-31 18:06:13 -04001118 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001119 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001120
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001121 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001122 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001123 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001124
1125 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001126 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001127}
1128
Vivien Didelot93e18d62018-05-11 17:16:35 -04001129static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1130{
1131 int err;
1132
1133 if (chip->info->ops->ieee_pri_map) {
1134 err = chip->info->ops->ieee_pri_map(chip);
1135 if (err)
1136 return err;
1137 }
1138
1139 if (chip->info->ops->ip_pri_map) {
1140 err = chip->info->ops->ip_pri_map(chip);
1141 if (err)
1142 return err;
1143 }
1144
1145 return 0;
1146}
1147
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001148static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1149{
1150 int target, port;
1151 int err;
1152
1153 if (!chip->info->global2_addr)
1154 return 0;
1155
1156 /* Initialize the routing port to the 32 possible target devices */
1157 for (target = 0; target < 32; target++) {
1158 port = 0x1f;
1159 if (target < DSA_MAX_SWITCHES)
1160 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1161 port = chip->ds->rtable[target];
1162
1163 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1164 if (err)
1165 return err;
1166 }
1167
Vivien Didelot02317e62018-05-09 11:38:49 -04001168 if (chip->info->ops->set_cascade_port) {
1169 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1170 err = chip->info->ops->set_cascade_port(chip, port);
1171 if (err)
1172 return err;
1173 }
1174
Vivien Didelot23c98912018-05-09 11:38:50 -04001175 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1176 if (err)
1177 return err;
1178
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001179 return 0;
1180}
1181
Vivien Didelotb28f8722018-04-26 21:56:44 -04001182static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1183{
1184 /* Clear all trunk masks and mapping */
1185 if (chip->info->global2_addr)
1186 return mv88e6xxx_g2_trunk_clear(chip);
1187
1188 return 0;
1189}
1190
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001191static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1192{
1193 if (chip->info->ops->rmu_disable)
1194 return chip->info->ops->rmu_disable(chip);
1195
1196 return 0;
1197}
1198
Vivien Didelot9e907d72017-07-17 13:03:43 -04001199static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1200{
1201 if (chip->info->ops->pot_clear)
1202 return chip->info->ops->pot_clear(chip);
1203
1204 return 0;
1205}
1206
Vivien Didelot51c901a2017-07-17 13:03:41 -04001207static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1208{
1209 if (chip->info->ops->mgmt_rsvd2cpu)
1210 return chip->info->ops->mgmt_rsvd2cpu(chip);
1211
1212 return 0;
1213}
1214
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001215static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1216{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001217 int err;
1218
Vivien Didelotdaefc942017-03-11 16:12:54 -05001219 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1220 if (err)
1221 return err;
1222
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001223 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1224 if (err)
1225 return err;
1226
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001227 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1228}
1229
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001230static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1231{
1232 int port;
1233 int err;
1234
1235 if (!chip->info->ops->irl_init_all)
1236 return 0;
1237
1238 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1239 /* Disable ingress rate limiting by resetting all per port
1240 * ingress rate limit resources to their initial state.
1241 */
1242 err = chip->info->ops->irl_init_all(chip, port);
1243 if (err)
1244 return err;
1245 }
1246
1247 return 0;
1248}
1249
Vivien Didelot04a69a12017-10-13 14:18:05 -04001250static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1251{
1252 if (chip->info->ops->set_switch_mac) {
1253 u8 addr[ETH_ALEN];
1254
1255 eth_random_addr(addr);
1256
1257 return chip->info->ops->set_switch_mac(chip, addr);
1258 }
1259
1260 return 0;
1261}
1262
Vivien Didelot17a15942017-03-30 17:37:09 -04001263static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1264{
1265 u16 pvlan = 0;
1266
1267 if (!mv88e6xxx_has_pvt(chip))
1268 return -EOPNOTSUPP;
1269
1270 /* Skip the local source device, which uses in-chip port VLAN */
1271 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001272 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001273
1274 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1275}
1276
Vivien Didelot81228992017-03-30 17:37:08 -04001277static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1278{
Vivien Didelot17a15942017-03-30 17:37:09 -04001279 int dev, port;
1280 int err;
1281
Vivien Didelot81228992017-03-30 17:37:08 -04001282 if (!mv88e6xxx_has_pvt(chip))
1283 return 0;
1284
1285 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1286 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1287 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001288 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1289 if (err)
1290 return err;
1291
1292 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1293 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1294 err = mv88e6xxx_pvt_map(chip, dev, port);
1295 if (err)
1296 return err;
1297 }
1298 }
1299
1300 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001301}
1302
Vivien Didelot749efcb2016-09-22 16:49:24 -04001303static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1304{
1305 struct mv88e6xxx_chip *chip = ds->priv;
1306 int err;
1307
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001308 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001309 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001310 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001311
1312 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001313 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001314}
1315
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001316static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1317{
1318 if (!chip->info->max_vid)
1319 return 0;
1320
1321 return mv88e6xxx_g1_vtu_flush(chip);
1322}
1323
Vivien Didelotf1394b782017-05-01 14:05:22 -04001324static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1325 struct mv88e6xxx_vtu_entry *entry)
1326{
1327 if (!chip->info->ops->vtu_getnext)
1328 return -EOPNOTSUPP;
1329
1330 return chip->info->ops->vtu_getnext(chip, entry);
1331}
1332
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001333static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1334 struct mv88e6xxx_vtu_entry *entry)
1335{
1336 if (!chip->info->ops->vtu_loadpurge)
1337 return -EOPNOTSUPP;
1338
1339 return chip->info->ops->vtu_loadpurge(chip, entry);
1340}
1341
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001342static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001343{
1344 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001345 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001346 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001347
1348 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1349
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001350 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001351 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001352 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001353 if (err)
1354 return err;
1355
1356 set_bit(*fid, fid_bitmap);
1357 }
1358
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001359 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001360 vlan.vid = chip->info->max_vid;
1361 vlan.valid = false;
1362
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001363 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001364 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001365 if (err)
1366 return err;
1367
1368 if (!vlan.valid)
1369 break;
1370
1371 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001372 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001373
1374 /* The reset value 0x000 is used to indicate that multiple address
1375 * databases are not needed. Return the next positive available.
1376 */
1377 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001378 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001379 return -ENOSPC;
1380
1381 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001382 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001383}
1384
Vivien Didelotda9c3592016-02-12 12:09:40 -05001385static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1386 u16 vid_begin, u16 vid_end)
1387{
Vivien Didelot04bed142016-08-31 18:06:13 -04001388 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001389 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001390 int i, err;
1391
Andrew Lunndb06ae412017-09-25 23:32:20 +02001392 /* DSA and CPU ports have to be members of multiple vlans */
1393 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1394 return 0;
1395
Vivien Didelotda9c3592016-02-12 12:09:40 -05001396 if (!vid_begin)
1397 return -EOPNOTSUPP;
1398
Vivien Didelot425d2d32019-08-01 14:36:34 -04001399 vlan.vid = vid_begin - 1;
1400 vlan.valid = false;
1401
Vivien Didelotda9c3592016-02-12 12:09:40 -05001402 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001403 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001404 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001405 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001406
1407 if (!vlan.valid)
1408 break;
1409
1410 if (vlan.vid > vid_end)
1411 break;
1412
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001413 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001414 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1415 continue;
1416
Andrew Lunncd886462017-11-09 22:29:53 +01001417 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001418 continue;
1419
Vivien Didelotbd00e052017-05-01 14:05:11 -04001420 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001421 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001422 continue;
1423
Vivien Didelotc8652c82017-10-16 11:12:19 -04001424 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001425 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001426 break; /* same bridge, check next VLAN */
1427
Vivien Didelotc8652c82017-10-16 11:12:19 -04001428 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001429 continue;
1430
Andrew Lunn743fcc22017-11-09 22:29:54 +01001431 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1432 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001433 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001434 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001435 }
1436 } while (vlan.vid < vid_end);
1437
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001438 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001439}
1440
Vivien Didelotf81ec902016-05-09 13:22:58 -04001441static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1442 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001443{
Vivien Didelot04bed142016-08-31 18:06:13 -04001444 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001445 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1446 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001447 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001448
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001449 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001450 return -EOPNOTSUPP;
1451
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001452 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001453 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001454 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001455
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001456 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001457}
1458
Vivien Didelot57d32312016-06-20 13:13:58 -04001459static int
1460mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001461 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001462{
Vivien Didelot04bed142016-08-31 18:06:13 -04001463 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001464 int err;
1465
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001466 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001467 return -EOPNOTSUPP;
1468
Vivien Didelotda9c3592016-02-12 12:09:40 -05001469 /* If the requested port doesn't belong to the same bridge as the VLAN
1470 * members, do not support it (yet) and fallback to software VLAN.
1471 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001472 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001473 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1474 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001475 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001476
Vivien Didelot76e398a2015-11-01 12:33:55 -05001477 /* We don't need any dynamic resource from the kernel (yet),
1478 * so skip the prepare phase.
1479 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001480 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001481}
1482
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001483static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1484 const unsigned char *addr, u16 vid,
1485 u8 state)
1486{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001487 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001488 struct mv88e6xxx_vtu_entry vlan;
1489 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001490 int err;
1491
1492 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001493 if (vid == 0) {
1494 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1495 if (err)
1496 return err;
1497 } else {
1498 vlan.vid = vid - 1;
1499 vlan.valid = false;
1500
1501 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1502 if (err)
1503 return err;
1504
1505 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1506 if (vlan.vid != vid || !vlan.valid)
1507 return -EOPNOTSUPP;
1508
1509 fid = vlan.fid;
1510 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001511
1512 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1513 ether_addr_copy(entry.mac, addr);
1514 eth_addr_dec(entry.mac);
1515
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001516 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001517 if (err)
1518 return err;
1519
1520 /* Initialize a fresh ATU entry if it isn't found */
1521 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1522 !ether_addr_equal(entry.mac, addr)) {
1523 memset(&entry, 0, sizeof(entry));
1524 ether_addr_copy(entry.mac, addr);
1525 }
1526
1527 /* Purge the ATU entry only if no port is using it anymore */
1528 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1529 entry.portvec &= ~BIT(port);
1530 if (!entry.portvec)
1531 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1532 } else {
1533 entry.portvec |= BIT(port);
1534 entry.state = state;
1535 }
1536
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001537 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001538}
1539
Andrew Lunn87fa8862017-11-09 22:29:56 +01001540static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1541 u16 vid)
1542{
1543 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1544 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1545
1546 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1547}
1548
1549static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1550{
1551 int port;
1552 int err;
1553
1554 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1555 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1556 if (err)
1557 return err;
1558 }
1559
1560 return 0;
1561}
1562
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001563static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001564 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001565{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001566 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001567 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001568 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001569
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001570 if (!vid)
1571 return -EOPNOTSUPP;
1572
1573 vlan.vid = vid - 1;
1574 vlan.valid = false;
1575
1576 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001577 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001578 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001579
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001580 if (vlan.vid != vid || !vlan.valid) {
1581 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001582
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001583 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1584 if (err)
1585 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001586
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001587 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1588 if (i == port)
1589 vlan.member[i] = member;
1590 else
1591 vlan.member[i] = non_member;
1592
1593 vlan.vid = vid;
1594 vlan.valid = true;
1595
1596 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1597 if (err)
1598 return err;
1599
1600 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1601 if (err)
1602 return err;
1603 } else if (vlan.member[port] != member) {
1604 vlan.member[port] = member;
1605
1606 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1607 if (err)
1608 return err;
1609 } else {
1610 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1611 port, vid);
1612 }
1613
1614 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001615}
1616
Vivien Didelotf81ec902016-05-09 13:22:58 -04001617static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001618 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001619{
Vivien Didelot04bed142016-08-31 18:06:13 -04001620 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001621 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1622 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001623 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001624 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001625
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001626 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001627 return;
1628
Vivien Didelotc91498e2017-06-07 18:12:13 -04001629 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001630 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001631 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001632 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001633 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001634 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001635
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001636 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001637
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001638 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001639 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001640 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1641 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001642
Vivien Didelot77064f32016-11-04 03:23:30 +01001643 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001644 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1645 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001646
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001647 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001648}
1649
Vivien Didelot521098922019-08-01 14:36:36 -04001650static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1651 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001652{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001653 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001654 int i, err;
1655
Vivien Didelot521098922019-08-01 14:36:36 -04001656 if (!vid)
1657 return -EOPNOTSUPP;
1658
1659 vlan.vid = vid - 1;
1660 vlan.valid = false;
1661
1662 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001663 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001664 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001665
Vivien Didelot521098922019-08-01 14:36:36 -04001666 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1667 * tell switchdev that this VLAN is likely handled in software.
1668 */
1669 if (vlan.vid != vid || !vlan.valid ||
1670 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001671 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001672
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001673 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001674
1675 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001676 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001677 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001678 if (vlan.member[i] !=
1679 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001680 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001681 break;
1682 }
1683 }
1684
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001685 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001686 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001687 return err;
1688
Vivien Didelote606ca32017-03-11 16:12:55 -05001689 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001690}
1691
Vivien Didelotf81ec902016-05-09 13:22:58 -04001692static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1693 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001694{
Vivien Didelot04bed142016-08-31 18:06:13 -04001695 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001696 u16 pvid, vid;
1697 int err = 0;
1698
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001699 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001700 return -EOPNOTSUPP;
1701
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001702 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703
Vivien Didelot77064f32016-11-04 03:23:30 +01001704 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001705 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001706 goto unlock;
1707
Vivien Didelot76e398a2015-11-01 12:33:55 -05001708 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001709 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001710 if (err)
1711 goto unlock;
1712
1713 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001714 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001715 if (err)
1716 goto unlock;
1717 }
1718 }
1719
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001720unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001721 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001722
1723 return err;
1724}
1725
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001726static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1727 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001728{
Vivien Didelot04bed142016-08-31 18:06:13 -04001729 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001730 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001731
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001732 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001733 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1734 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001735 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001736
1737 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001738}
1739
Vivien Didelotf81ec902016-05-09 13:22:58 -04001740static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001741 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001742{
Vivien Didelot04bed142016-08-31 18:06:13 -04001743 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001744 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001745
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001746 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001747 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001748 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001749 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001750
Vivien Didelot83dabd12016-08-31 11:50:04 -04001751 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001752}
1753
Vivien Didelot83dabd12016-08-31 11:50:04 -04001754static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1755 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001756 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001757{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001758 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001759 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001760 int err;
1761
Vivien Didelot27c0e602017-06-15 12:14:01 -04001762 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001763 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001764
1765 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001766 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001767 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001768 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001769
Vivien Didelot27c0e602017-06-15 12:14:01 -04001770 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001771 break;
1772
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001773 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001774 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001775
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001776 if (!is_unicast_ether_addr(addr.mac))
1777 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001778
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001779 is_static = (addr.state ==
1780 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1781 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001782 if (err)
1783 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001784 } while (!is_broadcast_ether_addr(addr.mac));
1785
1786 return err;
1787}
1788
Vivien Didelot83dabd12016-08-31 11:50:04 -04001789static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001790 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001791{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001792 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001793 u16 fid;
1794 int err;
1795
1796 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001797 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001798 if (err)
1799 return err;
1800
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001801 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001802 if (err)
1803 return err;
1804
1805 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001806 vlan.vid = chip->info->max_vid;
1807 vlan.valid = false;
1808
Vivien Didelot83dabd12016-08-31 11:50:04 -04001809 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001810 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001811 if (err)
1812 return err;
1813
1814 if (!vlan.valid)
1815 break;
1816
1817 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001818 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001819 if (err)
1820 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001821 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001822
1823 return err;
1824}
1825
Vivien Didelotf81ec902016-05-09 13:22:58 -04001826static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001827 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001828{
Vivien Didelot04bed142016-08-31 18:06:13 -04001829 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04001830 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001831
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001832 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001833 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001834 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001835
1836 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001837}
1838
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001839static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1840 struct net_device *br)
1841{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001842 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001843 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001844 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001845 int err;
1846
1847 /* Remap the Port VLAN of each local bridge group member */
1848 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1849 if (chip->ds->ports[port].bridge_dev == br) {
1850 err = mv88e6xxx_port_vlan_map(chip, port);
1851 if (err)
1852 return err;
1853 }
1854 }
1855
Vivien Didelote96a6e02017-03-30 17:37:13 -04001856 if (!mv88e6xxx_has_pvt(chip))
1857 return 0;
1858
1859 /* Remap the Port VLAN of each cross-chip bridge group member */
1860 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1861 ds = chip->ds->dst->ds[dev];
1862 if (!ds)
1863 break;
1864
1865 for (port = 0; port < ds->num_ports; ++port) {
1866 if (ds->ports[port].bridge_dev == br) {
1867 err = mv88e6xxx_pvt_map(chip, dev, port);
1868 if (err)
1869 return err;
1870 }
1871 }
1872 }
1873
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001874 return 0;
1875}
1876
Vivien Didelotf81ec902016-05-09 13:22:58 -04001877static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001878 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001879{
Vivien Didelot04bed142016-08-31 18:06:13 -04001880 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001881 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001882
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001883 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001884 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001885 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05001886
Vivien Didelot466dfa02016-02-26 13:16:05 -05001887 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001888}
1889
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001890static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1891 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001892{
Vivien Didelot04bed142016-08-31 18:06:13 -04001893 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001894
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001895 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001896 if (mv88e6xxx_bridge_map(chip, br) ||
1897 mv88e6xxx_port_vlan_map(chip, port))
1898 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001899 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001900}
1901
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001902static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1903 int port, struct net_device *br)
1904{
1905 struct mv88e6xxx_chip *chip = ds->priv;
1906 int err;
1907
1908 if (!mv88e6xxx_has_pvt(chip))
1909 return 0;
1910
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001911 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001912 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001913 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001914
1915 return err;
1916}
1917
1918static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1919 int port, struct net_device *br)
1920{
1921 struct mv88e6xxx_chip *chip = ds->priv;
1922
1923 if (!mv88e6xxx_has_pvt(chip))
1924 return;
1925
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001926 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001927 if (mv88e6xxx_pvt_map(chip, dev, port))
1928 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001929 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001930}
1931
Vivien Didelot17e708b2016-12-05 17:30:27 -05001932static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1933{
1934 if (chip->info->ops->reset)
1935 return chip->info->ops->reset(chip);
1936
1937 return 0;
1938}
1939
Vivien Didelot309eca62016-12-05 17:30:26 -05001940static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1941{
1942 struct gpio_desc *gpiod = chip->reset;
1943
1944 /* If there is a GPIO connected to the reset pin, toggle it */
1945 if (gpiod) {
1946 gpiod_set_value_cansleep(gpiod, 1);
1947 usleep_range(10000, 20000);
1948 gpiod_set_value_cansleep(gpiod, 0);
1949 usleep_range(10000, 20000);
1950 }
1951}
1952
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001953static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1954{
1955 int i, err;
1956
1957 /* Set all ports to the Disabled state */
1958 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001959 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001960 if (err)
1961 return err;
1962 }
1963
1964 /* Wait for transmit queues to drain,
1965 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1966 */
1967 usleep_range(2000, 4000);
1968
1969 return 0;
1970}
1971
Vivien Didelotfad09c72016-06-21 12:28:20 -04001972static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001973{
Vivien Didelota935c052016-09-29 12:21:53 -04001974 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001975
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001976 err = mv88e6xxx_disable_ports(chip);
1977 if (err)
1978 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001979
Vivien Didelot309eca62016-12-05 17:30:26 -05001980 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001981
Vivien Didelot17e708b2016-12-05 17:30:27 -05001982 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001983}
1984
Vivien Didelot43145572017-03-11 16:12:59 -05001985static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001986 enum mv88e6xxx_frame_mode frame,
1987 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001988{
1989 int err;
1990
Vivien Didelot43145572017-03-11 16:12:59 -05001991 if (!chip->info->ops->port_set_frame_mode)
1992 return -EOPNOTSUPP;
1993
1994 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001995 if (err)
1996 return err;
1997
Vivien Didelot43145572017-03-11 16:12:59 -05001998 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1999 if (err)
2000 return err;
2001
2002 if (chip->info->ops->port_set_ether_type)
2003 return chip->info->ops->port_set_ether_type(chip, port, etype);
2004
2005 return 0;
2006}
2007
2008static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2009{
2010 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002011 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002012 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002013}
2014
2015static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2016{
2017 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002018 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002019 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002020}
2021
2022static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2023{
2024 return mv88e6xxx_set_port_mode(chip, port,
2025 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002026 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2027 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002028}
2029
2030static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2031{
2032 if (dsa_is_dsa_port(chip->ds, port))
2033 return mv88e6xxx_set_port_mode_dsa(chip, port);
2034
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002035 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002036 return mv88e6xxx_set_port_mode_normal(chip, port);
2037
2038 /* Setup CPU port mode depending on its supported tag format */
2039 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2040 return mv88e6xxx_set_port_mode_dsa(chip, port);
2041
2042 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2043 return mv88e6xxx_set_port_mode_edsa(chip, port);
2044
2045 return -EINVAL;
2046}
2047
Vivien Didelotea698f42017-03-11 16:12:50 -05002048static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2049{
2050 bool message = dsa_is_dsa_port(chip->ds, port);
2051
2052 return mv88e6xxx_port_set_message_port(chip, port, message);
2053}
2054
Vivien Didelot601aeed2017-03-11 16:13:00 -05002055static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2056{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002057 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002058 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002059
David S. Miller407308f2019-06-15 13:35:29 -07002060 /* Upstream ports flood frames with unknown unicast or multicast DA */
2061 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2062 if (chip->info->ops->port_set_egress_floods)
2063 return chip->info->ops->port_set_egress_floods(chip, port,
2064 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002065
David S. Miller407308f2019-06-15 13:35:29 -07002066 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002067}
2068
Andrew Lunn6d917822017-05-26 01:03:21 +02002069static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2070 bool on)
2071{
Vivien Didelot523a8902017-05-26 18:02:42 -04002072 if (chip->info->ops->serdes_power)
2073 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002074
Vivien Didelot523a8902017-05-26 18:02:42 -04002075 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002076}
2077
Vivien Didelotfa371c82017-12-05 15:34:10 -05002078static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2079{
2080 struct dsa_switch *ds = chip->ds;
2081 int upstream_port;
2082 int err;
2083
Vivien Didelot07073c72017-12-05 15:34:13 -05002084 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002085 if (chip->info->ops->port_set_upstream_port) {
2086 err = chip->info->ops->port_set_upstream_port(chip, port,
2087 upstream_port);
2088 if (err)
2089 return err;
2090 }
2091
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002092 if (port == upstream_port) {
2093 if (chip->info->ops->set_cpu_port) {
2094 err = chip->info->ops->set_cpu_port(chip,
2095 upstream_port);
2096 if (err)
2097 return err;
2098 }
2099
2100 if (chip->info->ops->set_egress_port) {
2101 err = chip->info->ops->set_egress_port(chip,
2102 upstream_port);
2103 if (err)
2104 return err;
2105 }
2106 }
2107
Vivien Didelotfa371c82017-12-05 15:34:10 -05002108 return 0;
2109}
2110
Vivien Didelotfad09c72016-06-21 12:28:20 -04002111static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002112{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002113 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002114 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002115 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002116
Andrew Lunn7b898462018-08-09 15:38:47 +02002117 chip->ports[port].chip = chip;
2118 chip->ports[port].port = port;
2119
Vivien Didelotd78343d2016-11-04 03:23:36 +01002120 /* MAC Forcing register: don't force link, speed, duplex or flow control
2121 * state to any particular values on physical ports, but force the CPU
2122 * port and all DSA ports to their maximum bandwidth and full duplex.
2123 */
2124 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2125 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2126 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002127 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002128 PHY_INTERFACE_MODE_NA);
2129 else
2130 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2131 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002132 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002133 PHY_INTERFACE_MODE_NA);
2134 if (err)
2135 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002136
2137 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2138 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2139 * tunneling, determine priority by looking at 802.1p and IP
2140 * priority fields (IP prio has precedence), and set STP state
2141 * to Forwarding.
2142 *
2143 * If this is the CPU link, use DSA or EDSA tagging depending
2144 * on which tagging mode was configured.
2145 *
2146 * If this is a link to another switch, use DSA tagging mode.
2147 *
2148 * If this is the upstream port for this switch, enable
2149 * forwarding of unknown unicasts and multicasts.
2150 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002151 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2152 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2153 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2154 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002155 if (err)
2156 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002157
Vivien Didelot601aeed2017-03-11 16:13:00 -05002158 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002159 if (err)
2160 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002161
Vivien Didelot601aeed2017-03-11 16:13:00 -05002162 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002163 if (err)
2164 return err;
2165
Andrew Lunn04aca992017-05-26 01:03:24 +02002166 /* Enable the SERDES interface for DSA and CPU ports. Normal
2167 * ports SERDES are enabled when the port is enabled, thus
2168 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002169 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002170 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2171 err = mv88e6xxx_serdes_power(chip, port, true);
2172 if (err)
2173 return err;
2174 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002175
Vivien Didelot8efdda42015-08-13 12:52:23 -04002176 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002177 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002178 * untagged frames on this port, do a destination address lookup on all
2179 * received packets as usual, disable ARP mirroring and don't send a
2180 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002181 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002182 err = mv88e6xxx_port_set_map_da(chip, port);
2183 if (err)
2184 return err;
2185
Vivien Didelotfa371c82017-12-05 15:34:10 -05002186 err = mv88e6xxx_setup_upstream_port(chip, port);
2187 if (err)
2188 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002189
Andrew Lunna23b2962017-02-04 20:15:28 +01002190 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002191 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002192 if (err)
2193 return err;
2194
Vivien Didelotcd782652017-06-08 18:34:13 -04002195 if (chip->info->ops->port_set_jumbo_size) {
2196 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002197 if (err)
2198 return err;
2199 }
2200
Andrew Lunn54d792f2015-05-06 01:09:47 +02002201 /* Port Association Vector: when learning source addresses
2202 * of packets, add the address to the address database using
2203 * a port bitmap that has only the bit for this port set and
2204 * the other bits clear.
2205 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002206 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002207 /* Disable learning for CPU port */
2208 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002209 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002210
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002211 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2212 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002213 if (err)
2214 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002215
2216 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002217 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2218 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002219 if (err)
2220 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002221
Vivien Didelot08984322017-06-08 18:34:12 -04002222 if (chip->info->ops->port_pause_limit) {
2223 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002224 if (err)
2225 return err;
2226 }
2227
Vivien Didelotc8c94892017-03-11 16:13:01 -05002228 if (chip->info->ops->port_disable_learn_limit) {
2229 err = chip->info->ops->port_disable_learn_limit(chip, port);
2230 if (err)
2231 return err;
2232 }
2233
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002234 if (chip->info->ops->port_disable_pri_override) {
2235 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002236 if (err)
2237 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002238 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002239
Andrew Lunnef0a7312016-12-03 04:35:16 +01002240 if (chip->info->ops->port_tag_remap) {
2241 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002242 if (err)
2243 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002244 }
2245
Andrew Lunnef70b112016-12-03 04:45:18 +01002246 if (chip->info->ops->port_egress_rate_limiting) {
2247 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002248 if (err)
2249 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002250 }
2251
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002252 if (chip->info->ops->port_setup_message_port) {
2253 err = chip->info->ops->port_setup_message_port(chip, port);
2254 if (err)
2255 return err;
2256 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002257
Vivien Didelot207afda2016-04-14 14:42:09 -04002258 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002259 * database, and allow bidirectional communication between the
2260 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002261 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002262 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002263 if (err)
2264 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002265
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002266 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002267 if (err)
2268 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002269
2270 /* Default VLAN ID and priority: don't set a default VLAN
2271 * ID, and set the default packet priority to zero.
2272 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002273 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002274}
2275
Andrew Lunn04aca992017-05-26 01:03:24 +02002276static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2277 struct phy_device *phydev)
2278{
2279 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002280 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002281
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002282 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002283
Vivien Didelot523a8902017-05-26 18:02:42 -04002284 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002285
2286 if (!err && chip->info->ops->serdes_irq_setup)
2287 err = chip->info->ops->serdes_irq_setup(chip, port);
2288
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002289 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002290
2291 return err;
2292}
2293
Andrew Lunn75104db2019-02-24 20:44:43 +01002294static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002295{
2296 struct mv88e6xxx_chip *chip = ds->priv;
2297
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002298 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002299
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002300 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2301 dev_err(chip->dev, "failed to disable port\n");
2302
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002303 if (chip->info->ops->serdes_irq_free)
2304 chip->info->ops->serdes_irq_free(chip, port);
2305
Vivien Didelot523a8902017-05-26 18:02:42 -04002306 if (mv88e6xxx_serdes_power(chip, port, false))
2307 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002308
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002309 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002310}
2311
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002312static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2313 unsigned int ageing_time)
2314{
Vivien Didelot04bed142016-08-31 18:06:13 -04002315 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002316 int err;
2317
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002318 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002319 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002320 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002321
2322 return err;
2323}
2324
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002325static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002326{
2327 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002328
Andrew Lunnde2273872016-11-21 23:27:01 +01002329 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002330 if (chip->info->ops->stats_set_histogram) {
2331 err = chip->info->ops->stats_set_histogram(chip);
2332 if (err)
2333 return err;
2334 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002335
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002336 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002337}
2338
Andrew Lunnea890982019-01-09 00:24:03 +01002339/* The mv88e6390 has some hidden registers used for debug and
2340 * development. The errata also makes use of them.
2341 */
2342static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2343 int reg, u16 val)
2344{
2345 u16 ctrl;
2346 int err;
2347
2348 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2349 PORT_RESERVED_1A, val);
2350 if (err)
2351 return err;
2352
2353 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2354 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2355 reg;
2356
2357 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2358 PORT_RESERVED_1A, ctrl);
2359}
2360
2361static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2362{
2363 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2364 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2365}
2366
2367
2368static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2369 int reg, u16 *val)
2370{
2371 u16 ctrl;
2372 int err;
2373
2374 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2375 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2376 reg;
2377
2378 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2379 PORT_RESERVED_1A, ctrl);
2380 if (err)
2381 return err;
2382
2383 err = mv88e6390_hidden_wait(chip);
2384 if (err)
2385 return err;
2386
2387 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2388 PORT_RESERVED_1A, val);
2389}
2390
2391/* Check if the errata has already been applied. */
2392static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2393{
2394 int port;
2395 int err;
2396 u16 val;
2397
2398 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2399 err = mv88e6390_hidden_read(chip, port, 0, &val);
2400 if (err) {
2401 dev_err(chip->dev,
2402 "Error reading hidden register: %d\n", err);
2403 return false;
2404 }
2405 if (val != 0x01c0)
2406 return false;
2407 }
2408
2409 return true;
2410}
2411
2412/* The 6390 copper ports have an errata which require poking magic
2413 * values into undocumented hidden registers and then performing a
2414 * software reset.
2415 */
2416static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2417{
2418 int port;
2419 int err;
2420
2421 if (mv88e6390_setup_errata_applied(chip))
2422 return 0;
2423
2424 /* Set the ports into blocking mode */
2425 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2426 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2427 if (err)
2428 return err;
2429 }
2430
2431 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2432 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2433 if (err)
2434 return err;
2435 }
2436
2437 return mv88e6xxx_software_reset(chip);
2438}
2439
Vivien Didelotf81ec902016-05-09 13:22:58 -04002440static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002441{
Vivien Didelot04bed142016-08-31 18:06:13 -04002442 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002443 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002444 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002445 int i;
2446
Vivien Didelotfad09c72016-06-21 12:28:20 -04002447 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002448 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002449
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002450 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002451
Andrew Lunnea890982019-01-09 00:24:03 +01002452 if (chip->info->ops->setup_errata) {
2453 err = chip->info->ops->setup_errata(chip);
2454 if (err)
2455 goto unlock;
2456 }
2457
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002458 /* Cache the cmode of each port. */
2459 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2460 if (chip->info->ops->port_get_cmode) {
2461 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2462 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002463 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002464
2465 chip->ports[i].cmode = cmode;
2466 }
2467 }
2468
Vivien Didelot97299342016-07-18 20:45:30 -04002469 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002470 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002471 /* Prevent the use of an invalid port. */
2472 if (mv88e6xxx_is_invalid_port(chip, i) &&
2473 !dsa_is_unused_port(ds, i)) {
2474 dev_err(chip->dev, "port %d is invalid\n", i);
2475 err = -EINVAL;
2476 goto unlock;
2477 }
2478
Andrew Lunn100a9b92019-05-01 00:08:31 +02002479 if (dsa_is_unused_port(ds, i)) {
2480 err = mv88e6xxx_port_set_state(chip, i,
2481 BR_STATE_DISABLED);
2482 if (err)
2483 goto unlock;
2484
2485 err = mv88e6xxx_serdes_power(chip, i, false);
2486 if (err)
2487 goto unlock;
2488
Vivien Didelot91dee142017-10-26 11:22:52 -04002489 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002490 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002491
Vivien Didelot97299342016-07-18 20:45:30 -04002492 err = mv88e6xxx_setup_port(chip, i);
2493 if (err)
2494 goto unlock;
2495 }
2496
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002497 err = mv88e6xxx_irl_setup(chip);
2498 if (err)
2499 goto unlock;
2500
Vivien Didelot04a69a12017-10-13 14:18:05 -04002501 err = mv88e6xxx_mac_setup(chip);
2502 if (err)
2503 goto unlock;
2504
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002505 err = mv88e6xxx_phy_setup(chip);
2506 if (err)
2507 goto unlock;
2508
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002509 err = mv88e6xxx_vtu_setup(chip);
2510 if (err)
2511 goto unlock;
2512
Vivien Didelot81228992017-03-30 17:37:08 -04002513 err = mv88e6xxx_pvt_setup(chip);
2514 if (err)
2515 goto unlock;
2516
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002517 err = mv88e6xxx_atu_setup(chip);
2518 if (err)
2519 goto unlock;
2520
Andrew Lunn87fa8862017-11-09 22:29:56 +01002521 err = mv88e6xxx_broadcast_setup(chip, 0);
2522 if (err)
2523 goto unlock;
2524
Vivien Didelot9e907d72017-07-17 13:03:43 -04002525 err = mv88e6xxx_pot_setup(chip);
2526 if (err)
2527 goto unlock;
2528
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002529 err = mv88e6xxx_rmu_setup(chip);
2530 if (err)
2531 goto unlock;
2532
Vivien Didelot51c901a2017-07-17 13:03:41 -04002533 err = mv88e6xxx_rsvd2cpu_setup(chip);
2534 if (err)
2535 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002536
Vivien Didelotb28f8722018-04-26 21:56:44 -04002537 err = mv88e6xxx_trunk_setup(chip);
2538 if (err)
2539 goto unlock;
2540
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002541 err = mv88e6xxx_devmap_setup(chip);
2542 if (err)
2543 goto unlock;
2544
Vivien Didelot93e18d62018-05-11 17:16:35 -04002545 err = mv88e6xxx_pri_setup(chip);
2546 if (err)
2547 goto unlock;
2548
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002549 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002550 if (chip->info->ptp_support) {
2551 err = mv88e6xxx_ptp_setup(chip);
2552 if (err)
2553 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002554
2555 err = mv88e6xxx_hwtstamp_setup(chip);
2556 if (err)
2557 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002558 }
2559
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002560 err = mv88e6xxx_stats_setup(chip);
2561 if (err)
2562 goto unlock;
2563
Vivien Didelot6b17e862015-08-13 12:52:18 -04002564unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002565 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002566
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002567 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002568}
2569
Vivien Didelote57e5e72016-08-15 17:19:00 -04002570static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002571{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002572 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2573 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002574 u16 val;
2575 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002576
Andrew Lunnee26a222017-01-24 14:53:48 +01002577 if (!chip->info->ops->phy_read)
2578 return -EOPNOTSUPP;
2579
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002580 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002581 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002582 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002583
Andrew Lunnda9f3302017-02-01 03:40:05 +01002584 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002585 /* Some internal PHYs don't have a model number. */
2586 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2587 /* Then there is the 6165 family. It gets is
2588 * PHYs correct. But it can also have two
2589 * SERDES interfaces in the PHY address
2590 * space. And these don't have a model
2591 * number. But they are not PHYs, so we don't
2592 * want to give them something a PHY driver
2593 * will recognise.
2594 *
2595 * Use the mv88e6390 family model number
2596 * instead, for anything which really could be
2597 * a PHY,
2598 */
2599 if (!(val & 0x3f0))
2600 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002601 }
2602
Vivien Didelote57e5e72016-08-15 17:19:00 -04002603 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002604}
2605
Vivien Didelote57e5e72016-08-15 17:19:00 -04002606static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002607{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002608 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2609 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002610 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002611
Andrew Lunnee26a222017-01-24 14:53:48 +01002612 if (!chip->info->ops->phy_write)
2613 return -EOPNOTSUPP;
2614
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002615 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002616 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002617 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002618
2619 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002620}
2621
Vivien Didelotfad09c72016-06-21 12:28:20 -04002622static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002623 struct device_node *np,
2624 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002625{
2626 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002627 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002628 struct mii_bus *bus;
2629 int err;
2630
Andrew Lunn2510bab2018-02-22 01:51:49 +01002631 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002632 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002633 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002634 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002635
2636 if (err)
2637 return err;
2638 }
2639
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002640 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002641 if (!bus)
2642 return -ENOMEM;
2643
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002644 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002645 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002646 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002647 INIT_LIST_HEAD(&mdio_bus->list);
2648 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002649
Andrew Lunnb516d452016-06-04 21:17:06 +02002650 if (np) {
2651 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002652 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002653 } else {
2654 bus->name = "mv88e6xxx SMI";
2655 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2656 }
2657
2658 bus->read = mv88e6xxx_mdio_read;
2659 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002660 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002661
Andrew Lunn6f882842018-03-17 20:32:05 +01002662 if (!external) {
2663 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2664 if (err)
2665 return err;
2666 }
2667
Florian Fainelli00e798c2018-05-15 16:56:19 -07002668 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002669 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002670 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002671 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002672 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002673 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002674
2675 if (external)
2676 list_add_tail(&mdio_bus->list, &chip->mdios);
2677 else
2678 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002679
2680 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002681}
2682
Andrew Lunna3c53be52017-01-24 14:53:50 +01002683static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2684 { .compatible = "marvell,mv88e6xxx-mdio-external",
2685 .data = (void *)true },
2686 { },
2687};
2688
Andrew Lunn3126aee2017-12-07 01:05:57 +01002689static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2690
2691{
2692 struct mv88e6xxx_mdio_bus *mdio_bus;
2693 struct mii_bus *bus;
2694
2695 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2696 bus = mdio_bus->bus;
2697
Andrew Lunn6f882842018-03-17 20:32:05 +01002698 if (!mdio_bus->external)
2699 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2700
Andrew Lunn3126aee2017-12-07 01:05:57 +01002701 mdiobus_unregister(bus);
2702 }
2703}
2704
Andrew Lunna3c53be52017-01-24 14:53:50 +01002705static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2706 struct device_node *np)
2707{
2708 const struct of_device_id *match;
2709 struct device_node *child;
2710 int err;
2711
2712 /* Always register one mdio bus for the internal/default mdio
2713 * bus. This maybe represented in the device tree, but is
2714 * optional.
2715 */
2716 child = of_get_child_by_name(np, "mdio");
2717 err = mv88e6xxx_mdio_register(chip, child, false);
2718 if (err)
2719 return err;
2720
2721 /* Walk the device tree, and see if there are any other nodes
2722 * which say they are compatible with the external mdio
2723 * bus.
2724 */
2725 for_each_available_child_of_node(np, child) {
2726 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2727 if (match) {
2728 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002729 if (err) {
2730 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05302731 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002732 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002733 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002734 }
2735 }
2736
2737 return 0;
2738}
2739
Vivien Didelot855b1932016-07-20 18:18:35 -04002740static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2741{
Vivien Didelot04bed142016-08-31 18:06:13 -04002742 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002743
2744 return chip->eeprom_len;
2745}
2746
Vivien Didelot855b1932016-07-20 18:18:35 -04002747static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2748 struct ethtool_eeprom *eeprom, u8 *data)
2749{
Vivien Didelot04bed142016-08-31 18:06:13 -04002750 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002751 int err;
2752
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002753 if (!chip->info->ops->get_eeprom)
2754 return -EOPNOTSUPP;
2755
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002756 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002757 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002758 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002759
2760 if (err)
2761 return err;
2762
2763 eeprom->magic = 0xc3ec4951;
2764
2765 return 0;
2766}
2767
Vivien Didelot855b1932016-07-20 18:18:35 -04002768static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2769 struct ethtool_eeprom *eeprom, u8 *data)
2770{
Vivien Didelot04bed142016-08-31 18:06:13 -04002771 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002772 int err;
2773
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002774 if (!chip->info->ops->set_eeprom)
2775 return -EOPNOTSUPP;
2776
Vivien Didelot855b1932016-07-20 18:18:35 -04002777 if (eeprom->magic != 0xc3ec4951)
2778 return -EINVAL;
2779
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002780 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002781 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002782 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002783
2784 return err;
2785}
2786
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002787static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002788 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002789 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2790 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002791 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002792 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002793 .phy_read = mv88e6185_phy_ppu_read,
2794 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002795 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002796 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002797 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002798 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002799 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002800 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002801 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002802 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002803 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002804 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002805 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002806 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002807 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002808 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002809 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002810 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002811 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2812 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002813 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002814 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2815 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002816 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002817 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002818 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002819 .ppu_enable = mv88e6185_g1_ppu_enable,
2820 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002821 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002822 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002823 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002824 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002825 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002826};
2827
2828static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002829 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002830 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2831 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002832 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002833 .phy_read = mv88e6185_phy_ppu_read,
2834 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002835 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002836 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002837 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002838 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002839 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002840 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002841 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002842 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002843 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002844 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002845 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002846 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2847 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002848 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002849 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002850 .ppu_enable = mv88e6185_g1_ppu_enable,
2851 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002852 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002853 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002854 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002855 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002856};
2857
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002858static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002859 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002860 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2861 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002862 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002863 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2864 .phy_read = mv88e6xxx_g2_smi_phy_read,
2865 .phy_write = mv88e6xxx_g2_smi_phy_write,
2866 .port_set_link = mv88e6xxx_port_set_link,
2867 .port_set_duplex = mv88e6xxx_port_set_duplex,
2868 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002869 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002870 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002871 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002872 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002873 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002874 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002875 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002876 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002877 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002878 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002879 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002880 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002881 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002882 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002883 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2884 .stats_get_strings = mv88e6095_stats_get_strings,
2885 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002886 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2887 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002888 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002889 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002890 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002891 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002892 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002893 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002894 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002895 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002896};
2897
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002898static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002899 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002900 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2901 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002902 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002903 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002904 .phy_read = mv88e6xxx_g2_smi_phy_read,
2905 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002906 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002907 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002908 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002909 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002910 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002911 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002912 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002913 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002914 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002915 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002916 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002917 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002918 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2919 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002920 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002921 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2922 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002923 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002924 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002925 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002926 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002927 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002928 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002929 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002930};
2931
2932static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002933 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002934 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2935 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002936 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002937 .phy_read = mv88e6185_phy_ppu_read,
2938 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002939 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002940 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002941 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002942 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002943 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002944 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002945 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002946 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002947 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002948 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002949 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002950 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002951 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002952 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002953 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002954 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002955 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002956 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2957 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002958 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002959 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2960 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002961 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002962 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002963 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002964 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002965 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002966 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002967 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002968 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002969 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002970};
2971
Vivien Didelot990e27b2017-03-28 13:50:32 -04002972static const struct mv88e6xxx_ops mv88e6141_ops = {
2973 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002974 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2975 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002976 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002977 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2978 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2979 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2980 .phy_read = mv88e6xxx_g2_smi_phy_read,
2981 .phy_write = mv88e6xxx_g2_smi_phy_write,
2982 .port_set_link = mv88e6xxx_port_set_link,
2983 .port_set_duplex = mv88e6xxx_port_set_duplex,
2984 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002985 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002986 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002987 .port_tag_remap = mv88e6095_port_tag_remap,
2988 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2989 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2990 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002991 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002992 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002993 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002994 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2995 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002996 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002997 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002998 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002999 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003000 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003001 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3002 .stats_get_strings = mv88e6320_stats_get_strings,
3003 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003004 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3005 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003006 .watchdog_ops = &mv88e6390_watchdog_ops,
3007 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003008 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003009 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003010 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003011 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003012 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003013 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003014 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003015};
3016
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003017static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003018 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003019 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3020 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003021 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003022 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003023 .phy_read = mv88e6xxx_g2_smi_phy_read,
3024 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003025 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003026 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003027 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003028 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003029 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003030 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003031 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003032 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003033 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003034 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003035 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003036 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003037 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003038 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003039 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003040 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003041 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003042 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3043 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003044 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003045 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3046 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003047 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003048 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003049 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003050 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003051 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003052 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003053 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003054 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003055 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003056};
3057
3058static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003059 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003060 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3061 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003062 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003064 .phy_read = mv88e6165_phy_read,
3065 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003066 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003067 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003068 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003069 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003070 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003071 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003072 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003073 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003074 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003075 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003076 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3077 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003078 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003079 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3080 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003081 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003082 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003083 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003084 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003085 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003086 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003087 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003088 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003089 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003090};
3091
3092static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003093 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003094 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3095 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003096 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003097 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003098 .phy_read = mv88e6xxx_g2_smi_phy_read,
3099 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003100 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003101 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003102 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003103 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003104 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003105 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003106 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003107 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003108 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003109 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003110 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003111 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003112 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003113 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003114 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003115 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003116 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003117 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003118 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3119 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003120 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003121 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3122 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003123 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003124 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003125 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003126 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003127 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003128 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003129 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003130};
3131
3132static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003133 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003134 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3135 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003136 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003137 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3138 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003139 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003140 .phy_read = mv88e6xxx_g2_smi_phy_read,
3141 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003142 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003143 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003144 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003145 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003146 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003147 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003148 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003149 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003150 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003151 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003152 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003153 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003154 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003155 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003156 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003157 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003158 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003159 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003160 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3161 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003162 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003163 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3164 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003165 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003166 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003167 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003168 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003169 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003170 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003171 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003172 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003173 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003174 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003175};
3176
3177static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003178 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003179 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3180 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003181 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003182 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003183 .phy_read = mv88e6xxx_g2_smi_phy_read,
3184 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003185 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003186 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003187 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003188 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003189 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003190 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003191 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003192 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003193 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003194 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003195 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003196 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003197 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003198 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003199 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003200 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003201 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003202 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003203 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3204 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003205 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003206 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3207 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003208 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003209 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003210 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003211 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003212 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003213 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003214 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003215};
3216
3217static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003218 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003219 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3220 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003221 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003222 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3223 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003224 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003225 .phy_read = mv88e6xxx_g2_smi_phy_read,
3226 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003227 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003228 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003229 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003230 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003231 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003232 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003233 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003234 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003235 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003236 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003237 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003238 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003239 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003240 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003241 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003242 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003243 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003244 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003245 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3246 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003247 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003248 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3249 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003250 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003251 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003252 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003253 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003254 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003255 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003256 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003257 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003258 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3259 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003260 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003261 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003262};
3263
3264static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003265 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003266 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3267 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003268 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003269 .phy_read = mv88e6185_phy_ppu_read,
3270 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003271 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003272 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003273 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003274 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003275 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003276 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003277 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003278 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003279 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003280 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003281 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003282 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003283 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003284 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3285 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003286 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003287 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3288 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003289 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003290 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003291 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003292 .ppu_enable = mv88e6185_g1_ppu_enable,
3293 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003294 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003295 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003296 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003297 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003298};
3299
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003300static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003301 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003302 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003303 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003304 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3305 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003306 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3307 .phy_read = mv88e6xxx_g2_smi_phy_read,
3308 .phy_write = mv88e6xxx_g2_smi_phy_write,
3309 .port_set_link = mv88e6xxx_port_set_link,
3310 .port_set_duplex = mv88e6xxx_port_set_duplex,
3311 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3312 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003313 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003314 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003315 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003316 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003317 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003318 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003319 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003320 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003321 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003322 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003323 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003324 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003325 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003326 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003327 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3328 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003329 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003330 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3331 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003332 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003333 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003334 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003335 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003336 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003337 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3338 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003339 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003340 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3341 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003342 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003343 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003344};
3345
3346static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003347 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003348 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003349 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003350 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3351 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003352 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3353 .phy_read = mv88e6xxx_g2_smi_phy_read,
3354 .phy_write = mv88e6xxx_g2_smi_phy_write,
3355 .port_set_link = mv88e6xxx_port_set_link,
3356 .port_set_duplex = mv88e6xxx_port_set_duplex,
3357 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3358 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003359 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003360 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003361 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003362 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003363 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003364 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003365 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003366 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003367 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003368 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003369 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003370 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003371 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003372 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003373 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3374 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003375 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003376 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3377 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003378 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003379 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003380 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003381 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003382 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003383 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3384 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003385 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003386 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3387 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003388 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003389 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003390};
3391
3392static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003393 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003394 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003395 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003396 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3397 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003398 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3399 .phy_read = mv88e6xxx_g2_smi_phy_read,
3400 .phy_write = mv88e6xxx_g2_smi_phy_write,
3401 .port_set_link = mv88e6xxx_port_set_link,
3402 .port_set_duplex = mv88e6xxx_port_set_duplex,
3403 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3404 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003405 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003406 .port_tag_remap = mv88e6390_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,
Vivien Didelot08984322017-06-08 18:34:12 -04003410 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003411 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003412 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003413 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003414 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003415 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003416 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003417 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003418 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003419 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3420 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003421 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003422 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3423 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003424 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003425 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003426 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003427 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003428 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003429 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3430 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003431 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003432 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3433 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003434 .avb_ops = &mv88e6390_avb_ops,
3435 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003436 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003437};
3438
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003439static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003440 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003441 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3442 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003443 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003444 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3445 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003446 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003447 .phy_read = mv88e6xxx_g2_smi_phy_read,
3448 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003449 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003450 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003451 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003452 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003453 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003454 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003455 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003456 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003457 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003458 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003459 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003460 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003461 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003462 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003463 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003464 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003465 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003466 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003467 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3468 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003469 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003470 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3471 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003472 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003473 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003474 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003475 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003476 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003477 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003478 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003479 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003480 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3481 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003482 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003483 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003484 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003485 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003486};
3487
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003488static const struct mv88e6xxx_ops mv88e6250_ops = {
3489 /* MV88E6XXX_FAMILY_6250 */
3490 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3491 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3492 .irl_init_all = mv88e6352_g2_irl_init_all,
3493 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3494 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3495 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3496 .phy_read = mv88e6xxx_g2_smi_phy_read,
3497 .phy_write = mv88e6xxx_g2_smi_phy_write,
3498 .port_set_link = mv88e6xxx_port_set_link,
3499 .port_set_duplex = mv88e6xxx_port_set_duplex,
3500 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3501 .port_set_speed = mv88e6250_port_set_speed,
3502 .port_tag_remap = mv88e6095_port_tag_remap,
3503 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3504 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3505 .port_set_ether_type = mv88e6351_port_set_ether_type,
3506 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3507 .port_pause_limit = mv88e6097_port_pause_limit,
3508 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3509 .port_link_state = mv88e6250_port_link_state,
3510 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3511 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3512 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3513 .stats_get_strings = mv88e6250_stats_get_strings,
3514 .stats_get_stats = mv88e6250_stats_get_stats,
3515 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3516 .set_egress_port = mv88e6095_g1_set_egress_port,
3517 .watchdog_ops = &mv88e6250_watchdog_ops,
3518 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3519 .pot_clear = mv88e6xxx_g2_pot_clear,
3520 .reset = mv88e6250_g1_reset,
3521 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3522 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02003523 .avb_ops = &mv88e6352_avb_ops,
3524 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003525 .phylink_validate = mv88e6065_phylink_validate,
3526};
3527
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003528static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003529 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003530 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003531 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003532 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3533 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003534 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3535 .phy_read = mv88e6xxx_g2_smi_phy_read,
3536 .phy_write = mv88e6xxx_g2_smi_phy_write,
3537 .port_set_link = mv88e6xxx_port_set_link,
3538 .port_set_duplex = mv88e6xxx_port_set_duplex,
3539 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3540 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003541 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003542 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003543 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003544 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003545 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003546 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003547 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003548 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003549 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003550 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003551 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003552 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003553 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003554 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003555 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3556 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003557 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003558 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3559 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003560 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003561 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003562 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003563 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003564 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003565 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3566 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003567 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003568 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3569 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003570 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003571 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003572 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003573 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003574};
3575
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003576static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003577 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003578 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3579 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003580 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003581 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3582 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003583 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003584 .phy_read = mv88e6xxx_g2_smi_phy_read,
3585 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003586 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003587 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003588 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003589 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003590 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003591 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003592 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003593 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003594 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003595 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003596 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003597 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003598 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003599 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003600 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003601 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003602 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003603 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3604 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003605 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003606 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3607 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003608 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003609 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003610 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003611 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003612 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003613 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003614 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003615 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003616 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003617 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618};
3619
3620static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003621 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003622 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3623 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003624 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003625 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3626 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003627 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628 .phy_read = mv88e6xxx_g2_smi_phy_read,
3629 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003630 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003631 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003632 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003633 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003635 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003636 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003637 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003638 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003639 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003640 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003641 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003642 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003643 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003644 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003645 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003646 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003647 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3648 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003649 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003650 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3651 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003652 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003653 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003654 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003655 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003656 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003657 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003658 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003659 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003660};
3661
Vivien Didelot16e329a2017-03-28 13:50:33 -04003662static const struct mv88e6xxx_ops mv88e6341_ops = {
3663 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003664 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3665 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003666 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003667 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3668 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3669 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3670 .phy_read = mv88e6xxx_g2_smi_phy_read,
3671 .phy_write = mv88e6xxx_g2_smi_phy_write,
3672 .port_set_link = mv88e6xxx_port_set_link,
3673 .port_set_duplex = mv88e6xxx_port_set_duplex,
3674 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003675 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003676 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003677 .port_tag_remap = mv88e6095_port_tag_remap,
3678 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3679 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3680 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003681 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003682 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003683 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003684 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3685 .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 = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003688 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003689 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003690 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003691 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3692 .stats_get_strings = mv88e6320_stats_get_strings,
3693 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003694 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3695 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003696 .watchdog_ops = &mv88e6390_watchdog_ops,
3697 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003698 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003699 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003700 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003701 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003702 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003703 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003704 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003705 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003706 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003707};
3708
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003709static const struct mv88e6xxx_ops mv88e6350_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,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003718 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003719 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003720 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003721 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003722 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003723 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003724 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003725 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003726 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003727 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003728 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003729 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003730 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003731 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003732 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003733 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003734 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003735 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3736 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003737 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003738 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3739 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003740 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003741 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003742 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003743 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003744 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003745 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003746 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003747};
3748
3749static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003750 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003751 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3752 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003753 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003754 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003755 .phy_read = mv88e6xxx_g2_smi_phy_read,
3756 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003757 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003758 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003759 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003760 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003761 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003762 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003763 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003764 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003765 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003766 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003767 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003768 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003769 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003770 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003771 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003772 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003773 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003774 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003775 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3776 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003777 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003778 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3779 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003780 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003781 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003782 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003783 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003784 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003785 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003786 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003787 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003788 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003789};
3790
3791static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003792 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003793 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3794 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003795 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003796 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3797 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003798 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003799 .phy_read = mv88e6xxx_g2_smi_phy_read,
3800 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003801 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003802 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003803 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003804 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003805 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003806 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003807 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003808 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003809 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003810 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003811 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003812 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003813 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003814 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003815 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003816 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003817 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003818 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003819 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3820 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003821 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003822 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3823 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003824 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003825 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003826 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003827 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003828 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003829 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003830 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003831 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003832 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3833 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003834 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003835 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003836 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003837 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3838 .serdes_get_strings = mv88e6352_serdes_get_strings,
3839 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003840 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003841};
3842
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003843static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003844 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003845 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003846 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003847 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3848 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003849 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3850 .phy_read = mv88e6xxx_g2_smi_phy_read,
3851 .phy_write = mv88e6xxx_g2_smi_phy_write,
3852 .port_set_link = mv88e6xxx_port_set_link,
3853 .port_set_duplex = mv88e6xxx_port_set_duplex,
3854 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3855 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003856 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003857 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003858 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003859 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003860 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003861 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003862 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003863 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003864 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003865 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003866 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003867 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003868 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003869 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003870 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003871 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003872 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3873 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003874 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003875 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3876 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003877 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003878 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003879 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003880 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003881 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003882 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3883 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003884 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003885 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3886 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003887 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003888 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003889 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003890 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003891};
3892
3893static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003894 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003895 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003896 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003897 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3898 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003899 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3900 .phy_read = mv88e6xxx_g2_smi_phy_read,
3901 .phy_write = mv88e6xxx_g2_smi_phy_write,
3902 .port_set_link = mv88e6xxx_port_set_link,
3903 .port_set_duplex = mv88e6xxx_port_set_duplex,
3904 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3905 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003906 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003907 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003908 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003909 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003910 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003911 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003912 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003913 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003914 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003915 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003916 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003917 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003918 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003919 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003920 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003921 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003922 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3923 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003924 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003925 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3926 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003927 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003928 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003929 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003930 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003931 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003932 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3933 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003934 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003935 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3936 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003937 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003938 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003939 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003940 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003941};
3942
Vivien Didelotf81ec902016-05-09 13:22:58 -04003943static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3944 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003946 .family = MV88E6XXX_FAMILY_6097,
3947 .name = "Marvell 88E6085",
3948 .num_databases = 4096,
3949 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003950 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003951 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003952 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003953 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003954 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003955 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003956 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003957 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003958 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003959 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003960 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003961 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003962 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003963 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003964 },
3965
3966 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003967 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003968 .family = MV88E6XXX_FAMILY_6095,
3969 .name = "Marvell 88E6095/88E6095F",
3970 .num_databases = 256,
3971 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003972 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003973 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003974 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003975 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003976 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003977 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003978 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003979 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003980 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003981 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003982 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003983 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 },
3985
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003986 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003987 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003988 .family = MV88E6XXX_FAMILY_6097,
3989 .name = "Marvell 88E6097/88E6097F",
3990 .num_databases = 4096,
3991 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003992 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003993 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003994 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003995 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003996 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003997 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003998 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003999 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004000 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004001 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004002 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004003 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004004 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004005 .ops = &mv88e6097_ops,
4006 },
4007
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004009 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004010 .family = MV88E6XXX_FAMILY_6165,
4011 .name = "Marvell 88E6123",
4012 .num_databases = 4096,
4013 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004014 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004015 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004016 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004017 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004018 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004019 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004020 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004021 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004022 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004023 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004024 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004025 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004026 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004027 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004028 },
4029
4030 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004031 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004032 .family = MV88E6XXX_FAMILY_6185,
4033 .name = "Marvell 88E6131",
4034 .num_databases = 256,
4035 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004036 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004037 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004038 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004039 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004040 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004041 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004042 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004043 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004044 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004045 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004046 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004047 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004048 },
4049
Vivien Didelot990e27b2017-03-28 13:50:32 -04004050 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004051 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004052 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004053 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004054 .num_databases = 4096,
4055 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004056 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004057 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004058 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004059 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004060 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004061 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004062 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004063 .age_time_coeff = 3750,
4064 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004065 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004066 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004067 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004068 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004069 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004070 .ops = &mv88e6141_ops,
4071 },
4072
Vivien Didelotf81ec902016-05-09 13:22:58 -04004073 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004074 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004075 .family = MV88E6XXX_FAMILY_6165,
4076 .name = "Marvell 88E6161",
4077 .num_databases = 4096,
4078 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004079 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004080 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004081 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004082 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004083 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004084 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004085 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004086 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004087 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004088 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004089 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004090 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004091 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004092 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004093 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004094 },
4095
4096 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004097 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004098 .family = MV88E6XXX_FAMILY_6165,
4099 .name = "Marvell 88E6165",
4100 .num_databases = 4096,
4101 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004102 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004103 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004104 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004105 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004106 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004107 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004108 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004109 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004110 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004111 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004112 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004113 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004114 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004115 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004116 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004117 },
4118
4119 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004120 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121 .family = MV88E6XXX_FAMILY_6351,
4122 .name = "Marvell 88E6171",
4123 .num_databases = 4096,
4124 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004125 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004126 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004127 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004128 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004129 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004130 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004131 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004132 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004133 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004134 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004135 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004136 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004137 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004138 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004139 },
4140
4141 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004142 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004143 .family = MV88E6XXX_FAMILY_6352,
4144 .name = "Marvell 88E6172",
4145 .num_databases = 4096,
4146 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004147 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004148 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004149 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004150 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004151 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004152 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004153 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004154 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004155 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004156 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004157 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004158 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004159 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004160 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004161 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004162 },
4163
4164 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004165 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004166 .family = MV88E6XXX_FAMILY_6351,
4167 .name = "Marvell 88E6175",
4168 .num_databases = 4096,
4169 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004170 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004171 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004172 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004173 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004174 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004175 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004176 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004177 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004178 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004179 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004180 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004181 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004182 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004183 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004184 },
4185
4186 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004187 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004188 .family = MV88E6XXX_FAMILY_6352,
4189 .name = "Marvell 88E6176",
4190 .num_databases = 4096,
4191 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004192 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004193 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004194 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004195 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004196 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004197 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004198 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004199 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004200 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004201 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004202 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004203 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004204 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004205 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004206 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004207 },
4208
4209 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004210 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004211 .family = MV88E6XXX_FAMILY_6185,
4212 .name = "Marvell 88E6185",
4213 .num_databases = 256,
4214 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004215 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004216 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004217 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004218 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004219 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004220 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004221 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004222 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004223 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004224 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004225 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004226 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004227 },
4228
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004229 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004230 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004231 .family = MV88E6XXX_FAMILY_6390,
4232 .name = "Marvell 88E6190",
4233 .num_databases = 4096,
4234 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004235 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004236 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004237 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004238 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004239 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004240 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004241 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004242 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004243 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004244 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004245 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004246 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004247 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004248 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004249 .ops = &mv88e6190_ops,
4250 },
4251
4252 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004253 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004254 .family = MV88E6XXX_FAMILY_6390,
4255 .name = "Marvell 88E6190X",
4256 .num_databases = 4096,
4257 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004258 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004259 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004260 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004261 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004262 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004263 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004264 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004265 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004266 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004267 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004268 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004269 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004270 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004271 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004272 .ops = &mv88e6190x_ops,
4273 },
4274
4275 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004276 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004277 .family = MV88E6XXX_FAMILY_6390,
4278 .name = "Marvell 88E6191",
4279 .num_databases = 4096,
4280 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004281 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004282 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004283 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004284 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004285 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004286 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004287 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004288 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004289 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004290 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004291 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004292 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004293 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004294 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004295 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004296 },
4297
Hubert Feurstein49022642019-07-31 10:23:46 +02004298 [MV88E6220] = {
4299 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4300 .family = MV88E6XXX_FAMILY_6250,
4301 .name = "Marvell 88E6220",
4302 .num_databases = 64,
4303
4304 /* Ports 2-4 are not routed to pins
4305 * => usable ports 0, 1, 5, 6
4306 */
4307 .num_ports = 7,
4308 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004309 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004310 .max_vid = 4095,
4311 .port_base_addr = 0x08,
4312 .phy_base_addr = 0x00,
4313 .global1_addr = 0x0f,
4314 .global2_addr = 0x07,
4315 .age_time_coeff = 15000,
4316 .g1_irqs = 9,
4317 .g2_irqs = 10,
4318 .atu_move_port_mask = 0xf,
4319 .dual_chip = true,
4320 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004321 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004322 .ops = &mv88e6250_ops,
4323 },
4324
Vivien Didelotf81ec902016-05-09 13:22:58 -04004325 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004326 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004327 .family = MV88E6XXX_FAMILY_6352,
4328 .name = "Marvell 88E6240",
4329 .num_databases = 4096,
4330 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004331 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004332 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004333 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004334 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004335 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004336 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004337 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004338 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004339 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004340 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004341 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004342 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004343 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004344 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004345 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004346 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004347 },
4348
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004349 [MV88E6250] = {
4350 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4351 .family = MV88E6XXX_FAMILY_6250,
4352 .name = "Marvell 88E6250",
4353 .num_databases = 64,
4354 .num_ports = 7,
4355 .num_internal_phys = 5,
4356 .max_vid = 4095,
4357 .port_base_addr = 0x08,
4358 .phy_base_addr = 0x00,
4359 .global1_addr = 0x0f,
4360 .global2_addr = 0x07,
4361 .age_time_coeff = 15000,
4362 .g1_irqs = 9,
4363 .g2_irqs = 10,
4364 .atu_move_port_mask = 0xf,
4365 .dual_chip = true,
4366 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004367 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004368 .ops = &mv88e6250_ops,
4369 },
4370
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004371 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004372 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004373 .family = MV88E6XXX_FAMILY_6390,
4374 .name = "Marvell 88E6290",
4375 .num_databases = 4096,
4376 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004377 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004378 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004379 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004380 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004381 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004382 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004383 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004384 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004385 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004386 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004387 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004388 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004389 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004390 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004391 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004392 .ops = &mv88e6290_ops,
4393 },
4394
Vivien Didelotf81ec902016-05-09 13:22:58 -04004395 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004396 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004397 .family = MV88E6XXX_FAMILY_6320,
4398 .name = "Marvell 88E6320",
4399 .num_databases = 4096,
4400 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004401 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004402 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004403 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004404 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004405 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004406 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004407 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004408 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004409 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004410 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004411 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004412 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004413 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004414 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004415 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004416 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004417 },
4418
4419 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004420 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004421 .family = MV88E6XXX_FAMILY_6320,
4422 .name = "Marvell 88E6321",
4423 .num_databases = 4096,
4424 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004425 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004426 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004427 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004428 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004429 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004430 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004431 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004432 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004433 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004434 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004435 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004436 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004437 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004438 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004439 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004440 },
4441
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004442 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004443 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004444 .family = MV88E6XXX_FAMILY_6341,
4445 .name = "Marvell 88E6341",
4446 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004447 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004448 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004449 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004450 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004451 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004452 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004453 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004454 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004455 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004456 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004457 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004458 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004459 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004460 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004461 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004462 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004463 .ops = &mv88e6341_ops,
4464 },
4465
Vivien Didelotf81ec902016-05-09 13:22:58 -04004466 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004467 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004468 .family = MV88E6XXX_FAMILY_6351,
4469 .name = "Marvell 88E6350",
4470 .num_databases = 4096,
4471 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004472 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004473 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004474 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004475 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004476 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004477 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004478 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004479 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004480 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004481 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004482 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004483 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004484 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004485 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004486 },
4487
4488 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004489 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004490 .family = MV88E6XXX_FAMILY_6351,
4491 .name = "Marvell 88E6351",
4492 .num_databases = 4096,
4493 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004494 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004495 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004496 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004497 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004498 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004499 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004500 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004501 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004502 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004503 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004504 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004505 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004506 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004507 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004508 },
4509
4510 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004511 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004512 .family = MV88E6XXX_FAMILY_6352,
4513 .name = "Marvell 88E6352",
4514 .num_databases = 4096,
4515 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004516 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004517 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004518 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004519 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004520 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004521 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004522 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004523 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004524 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004525 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004526 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004527 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004528 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004529 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004530 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004531 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004532 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004533 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004534 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004535 .family = MV88E6XXX_FAMILY_6390,
4536 .name = "Marvell 88E6390",
4537 .num_databases = 4096,
4538 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004539 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004540 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004541 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004542 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004543 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004544 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004545 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004546 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004547 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004548 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004549 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004550 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004551 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004552 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004553 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004554 .ops = &mv88e6390_ops,
4555 },
4556 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004557 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004558 .family = MV88E6XXX_FAMILY_6390,
4559 .name = "Marvell 88E6390X",
4560 .num_databases = 4096,
4561 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004562 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004563 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004564 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004565 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004566 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004567 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004568 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004569 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004570 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004571 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004572 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004573 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004574 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004575 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004576 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004577 .ops = &mv88e6390x_ops,
4578 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004579};
4580
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004581static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004582{
Vivien Didelota439c062016-04-17 13:23:58 -04004583 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004584
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004585 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4586 if (mv88e6xxx_table[i].prod_num == prod_num)
4587 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004588
Vivien Didelotb9b37712015-10-30 19:39:48 -04004589 return NULL;
4590}
4591
Vivien Didelotfad09c72016-06-21 12:28:20 -04004592static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004593{
4594 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004595 unsigned int prod_num, rev;
4596 u16 id;
4597 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004598
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004599 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004600 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004601 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004602 if (err)
4603 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004604
Vivien Didelot107fcc12017-06-12 12:37:36 -04004605 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4606 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004607
4608 info = mv88e6xxx_lookup_info(prod_num);
4609 if (!info)
4610 return -ENODEV;
4611
Vivien Didelotcaac8542016-06-20 13:14:09 -04004612 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004613 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004614
Vivien Didelotca070c12016-09-02 14:45:34 -04004615 err = mv88e6xxx_g2_require(chip);
4616 if (err)
4617 return err;
4618
Vivien Didelotfad09c72016-06-21 12:28:20 -04004619 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4620 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004621
4622 return 0;
4623}
4624
Vivien Didelotfad09c72016-06-21 12:28:20 -04004625static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004626{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004627 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004628
Vivien Didelotfad09c72016-06-21 12:28:20 -04004629 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4630 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004631 return NULL;
4632
Vivien Didelotfad09c72016-06-21 12:28:20 -04004633 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004634
Vivien Didelotfad09c72016-06-21 12:28:20 -04004635 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004636 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004637
Vivien Didelotfad09c72016-06-21 12:28:20 -04004638 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004639}
4640
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004641static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4642 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004643{
Vivien Didelot04bed142016-08-31 18:06:13 -04004644 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004645
Andrew Lunn443d5a12016-12-03 04:35:18 +01004646 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004647}
4648
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004649static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004650 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004651{
4652 /* We don't need any dynamic resource from the kernel (yet),
4653 * so skip the prepare phase.
4654 */
4655
4656 return 0;
4657}
4658
4659static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004660 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004661{
Vivien Didelot04bed142016-08-31 18:06:13 -04004662 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004663
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004664 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004665 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004666 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004667 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4668 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004669 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004670}
4671
4672static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4673 const struct switchdev_obj_port_mdb *mdb)
4674{
Vivien Didelot04bed142016-08-31 18:06:13 -04004675 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004676 int err;
4677
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004678 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004679 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004680 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004681 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004682
4683 return err;
4684}
4685
Russell King4f859012019-02-20 15:35:05 -08004686static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4687 bool unicast, bool multicast)
4688{
4689 struct mv88e6xxx_chip *chip = ds->priv;
4690 int err = -EOPNOTSUPP;
4691
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004692 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08004693 if (chip->info->ops->port_set_egress_floods)
4694 err = chip->info->ops->port_set_egress_floods(chip, port,
4695 unicast,
4696 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004697 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08004698
4699 return err;
4700}
4701
Florian Fainellia82f67a2017-01-08 14:52:08 -08004702static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004703 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004704 .setup = mv88e6xxx_setup,
Russell Kingc9a23562018-05-10 13:17:35 -07004705 .phylink_validate = mv88e6xxx_validate,
4706 .phylink_mac_link_state = mv88e6xxx_link_state,
4707 .phylink_mac_config = mv88e6xxx_mac_config,
4708 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4709 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004710 .get_strings = mv88e6xxx_get_strings,
4711 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4712 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004713 .port_enable = mv88e6xxx_port_enable,
4714 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004715 .get_mac_eee = mv88e6xxx_get_mac_eee,
4716 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004717 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004718 .get_eeprom = mv88e6xxx_get_eeprom,
4719 .set_eeprom = mv88e6xxx_set_eeprom,
4720 .get_regs_len = mv88e6xxx_get_regs_len,
4721 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004722 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723 .port_bridge_join = mv88e6xxx_port_bridge_join,
4724 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004725 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004726 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004727 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4729 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4730 .port_vlan_add = mv88e6xxx_port_vlan_add,
4731 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004732 .port_fdb_add = mv88e6xxx_port_fdb_add,
4733 .port_fdb_del = mv88e6xxx_port_fdb_del,
4734 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004735 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4736 .port_mdb_add = mv88e6xxx_port_mdb_add,
4737 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004738 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4739 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004740 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4741 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4742 .port_txtstamp = mv88e6xxx_port_txtstamp,
4743 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4744 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004745};
4746
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004747static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004748{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004749 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004750 struct dsa_switch *ds;
4751
Vivien Didelot73b12042017-03-30 17:37:10 -04004752 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004753 if (!ds)
4754 return -ENOMEM;
4755
Vivien Didelotfad09c72016-06-21 12:28:20 -04004756 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004757 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004758 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004759 ds->ageing_time_min = chip->info->age_time_coeff;
4760 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004761
4762 dev_set_drvdata(dev, ds);
4763
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004764 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004765}
4766
Vivien Didelotfad09c72016-06-21 12:28:20 -04004767static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004768{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004769 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004770}
4771
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004772static const void *pdata_device_get_match_data(struct device *dev)
4773{
4774 const struct of_device_id *matches = dev->driver->of_match_table;
4775 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4776
4777 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4778 matches++) {
4779 if (!strcmp(pdata->compatible, matches->compatible))
4780 return matches->data;
4781 }
4782 return NULL;
4783}
4784
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004785/* There is no suspend to RAM support at DSA level yet, the switch configuration
4786 * would be lost after a power cycle so prevent it to be suspended.
4787 */
4788static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4789{
4790 return -EOPNOTSUPP;
4791}
4792
4793static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4794{
4795 return 0;
4796}
4797
4798static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4799
Vivien Didelot57d32312016-06-20 13:13:58 -04004800static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004801{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004802 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004803 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004804 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004805 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004806 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004807 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004808 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004809
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004810 if (!np && !pdata)
4811 return -EINVAL;
4812
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004813 if (np)
4814 compat_info = of_device_get_match_data(dev);
4815
4816 if (pdata) {
4817 compat_info = pdata_device_get_match_data(dev);
4818
4819 if (!pdata->netdev)
4820 return -EINVAL;
4821
4822 for (port = 0; port < DSA_MAX_PORTS; port++) {
4823 if (!(pdata->enabled_ports & (1 << port)))
4824 continue;
4825 if (strcmp(pdata->cd.port_names[port], "cpu"))
4826 continue;
4827 pdata->cd.netdev[port] = &pdata->netdev->dev;
4828 break;
4829 }
4830 }
4831
Vivien Didelotcaac8542016-06-20 13:14:09 -04004832 if (!compat_info)
4833 return -EINVAL;
4834
Vivien Didelotfad09c72016-06-21 12:28:20 -04004835 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004836 if (!chip) {
4837 err = -ENOMEM;
4838 goto out;
4839 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004840
Vivien Didelotfad09c72016-06-21 12:28:20 -04004841 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004842
Vivien Didelotfad09c72016-06-21 12:28:20 -04004843 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004844 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004845 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004846
Andrew Lunnb4308f02016-11-21 23:26:55 +01004847 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004848 if (IS_ERR(chip->reset)) {
4849 err = PTR_ERR(chip->reset);
4850 goto out;
4851 }
Baruch Siach7b75e492019-06-27 21:17:39 +03004852 if (chip->reset)
4853 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01004854
Vivien Didelotfad09c72016-06-21 12:28:20 -04004855 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004856 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004857 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004858
Vivien Didelote57e5e72016-08-15 17:19:00 -04004859 mv88e6xxx_phy_init(chip);
4860
Andrew Lunn00baabe2018-05-19 22:31:35 +02004861 if (chip->info->ops->get_eeprom) {
4862 if (np)
4863 of_property_read_u32(np, "eeprom-length",
4864 &chip->eeprom_len);
4865 else
4866 chip->eeprom_len = pdata->eeprom_len;
4867 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004868
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004869 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004870 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004871 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02004872 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004873 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004874
Andrew Lunna27415d2019-05-01 00:10:50 +02004875 if (np) {
4876 chip->irq = of_irq_get(np, 0);
4877 if (chip->irq == -EPROBE_DEFER) {
4878 err = chip->irq;
4879 goto out;
4880 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004881 }
4882
Andrew Lunna27415d2019-05-01 00:10:50 +02004883 if (pdata)
4884 chip->irq = pdata->irq;
4885
Andrew Lunn294d7112018-02-22 22:58:32 +01004886 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004887 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004888 * controllers
4889 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004890 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004891 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004892 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004893 else
4894 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004895 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004896
Andrew Lunn294d7112018-02-22 22:58:32 +01004897 if (err)
4898 goto out;
4899
4900 if (chip->info->g2_irqs > 0) {
4901 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004902 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004903 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004904 }
4905
Andrew Lunn294d7112018-02-22 22:58:32 +01004906 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4907 if (err)
4908 goto out_g2_irq;
4909
4910 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4911 if (err)
4912 goto out_g1_atu_prob_irq;
4913
Andrew Lunna3c53be52017-01-24 14:53:50 +01004914 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004915 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004916 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004917
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004918 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004919 if (err)
4920 goto out_mdio;
4921
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004922 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004923
4924out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004925 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004926out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004927 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004928out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004929 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004930out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004931 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004932 mv88e6xxx_g2_irq_free(chip);
4933out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004934 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004935 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004936 else
4937 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004938out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004939 if (pdata)
4940 dev_put(pdata->netdev);
4941
Andrew Lunndc30c352016-10-16 19:56:49 +02004942 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004943}
4944
4945static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4946{
4947 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004948 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004949
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004950 if (chip->info->ptp_support) {
4951 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004952 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004953 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004954
Andrew Lunn930188c2016-08-22 16:01:03 +02004955 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004956 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004957 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004958
Andrew Lunn76f38f12018-03-17 20:21:09 +01004959 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4960 mv88e6xxx_g1_atu_prob_irq_free(chip);
4961
4962 if (chip->info->g2_irqs > 0)
4963 mv88e6xxx_g2_irq_free(chip);
4964
Andrew Lunn76f38f12018-03-17 20:21:09 +01004965 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004966 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004967 else
4968 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004969}
4970
4971static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004972 {
4973 .compatible = "marvell,mv88e6085",
4974 .data = &mv88e6xxx_table[MV88E6085],
4975 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004976 {
4977 .compatible = "marvell,mv88e6190",
4978 .data = &mv88e6xxx_table[MV88E6190],
4979 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004980 {
4981 .compatible = "marvell,mv88e6250",
4982 .data = &mv88e6xxx_table[MV88E6250],
4983 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004984 { /* sentinel */ },
4985};
4986
4987MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4988
4989static struct mdio_driver mv88e6xxx_driver = {
4990 .probe = mv88e6xxx_probe,
4991 .remove = mv88e6xxx_remove,
4992 .mdiodrv.driver = {
4993 .name = "mv88e6085",
4994 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004995 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004996 },
4997};
4998
Andrew Lunn7324d502019-04-27 19:19:10 +02004999mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005000
5001MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5002MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5003MODULE_LICENSE("GPL");