blob: ae0134d854363292788c039983b16682ec3ca512 [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>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000030#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020084struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +010085{
86 struct mv88e6xxx_mdio_bus *mdio_bus;
87
88 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
89 list);
90 if (!mdio_bus)
91 return NULL;
92
93 return mdio_bus->bus;
94}
95
Andrew Lunndc30c352016-10-16 19:56:49 +020096static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
97{
98 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
99 unsigned int n = d->hwirq;
100
101 chip->g1_irq.masked |= (1 << n);
102}
103
104static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
105{
106 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
107 unsigned int n = d->hwirq;
108
109 chip->g1_irq.masked &= ~(1 << n);
110}
111
Andrew Lunn294d7112018-02-22 22:58:32 +0100112static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200113{
Andrew Lunndc30c352016-10-16 19:56:49 +0200114 unsigned int nhandled = 0;
115 unsigned int sub_irq;
116 unsigned int n;
117 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500118 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200119 int err;
120
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000121 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400122 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000123 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200124
125 if (err)
126 goto out;
127
John David Anglin7c0db242019-02-11 13:40:21 -0500128 do {
129 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
130 if (reg & (1 << n)) {
131 sub_irq = irq_find_mapping(chip->g1_irq.domain,
132 n);
133 handle_nested_irq(sub_irq);
134 ++nhandled;
135 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200136 }
John David Anglin7c0db242019-02-11 13:40:21 -0500137
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000138 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500139 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
140 if (err)
141 goto unlock;
142 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
143unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000144 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500145 if (err)
146 goto out;
147 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
148 } while (reg & ctl1);
149
Andrew Lunndc30c352016-10-16 19:56:49 +0200150out:
151 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
152}
153
Andrew Lunn294d7112018-02-22 22:58:32 +0100154static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
155{
156 struct mv88e6xxx_chip *chip = dev_id;
157
158 return mv88e6xxx_g1_irq_thread_work(chip);
159}
160
Andrew Lunndc30c352016-10-16 19:56:49 +0200161static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
162{
163 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
164
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000165 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200166}
167
168static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
169{
170 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
171 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
172 u16 reg;
173 int err;
174
Vivien Didelotd77f4322017-06-15 12:14:03 -0400175 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200176 if (err)
177 goto out;
178
179 reg &= ~mask;
180 reg |= (~chip->g1_irq.masked & mask);
181
Vivien Didelotd77f4322017-06-15 12:14:03 -0400182 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200183 if (err)
184 goto out;
185
186out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000187 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200188}
189
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530190static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200191 .name = "mv88e6xxx-g1",
192 .irq_mask = mv88e6xxx_g1_irq_mask,
193 .irq_unmask = mv88e6xxx_g1_irq_unmask,
194 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
195 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
196};
197
198static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
199 unsigned int irq,
200 irq_hw_number_t hwirq)
201{
202 struct mv88e6xxx_chip *chip = d->host_data;
203
204 irq_set_chip_data(irq, d->host_data);
205 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
206 irq_set_noprobe(irq);
207
208 return 0;
209}
210
211static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
212 .map = mv88e6xxx_g1_irq_domain_map,
213 .xlate = irq_domain_xlate_twocell,
214};
215
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200216/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100217static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200218{
219 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100220 u16 mask;
221
Vivien Didelotd77f4322017-06-15 12:14:03 -0400222 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100223 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400224 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100225
Andreas Färber5edef2f2016-11-27 23:26:28 +0100226 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100227 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200228 irq_dispose_mapping(virq);
229 }
230
Andrew Lunna3db3d32016-11-20 20:14:14 +0100231 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200232}
233
Andrew Lunn294d7112018-02-22 22:58:32 +0100234static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
235{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200236 /*
237 * free_irq must be called without reg_lock taken because the irq
238 * handler takes this lock, too.
239 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100240 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200241
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000242 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200243 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000244 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100245}
246
247static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100249 int err, irq, virq;
250 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200251
252 chip->g1_irq.nirqs = chip->info->g1_irqs;
253 chip->g1_irq.domain = irq_domain_add_simple(
254 NULL, chip->g1_irq.nirqs, 0,
255 &mv88e6xxx_g1_irq_domain_ops, chip);
256 if (!chip->g1_irq.domain)
257 return -ENOMEM;
258
259 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
260 irq_create_mapping(chip->g1_irq.domain, irq);
261
262 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
263 chip->g1_irq.masked = ~0;
264
Vivien Didelotd77f4322017-06-15 12:14:03 -0400265 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200266 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100267 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200268
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100269 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200270
Vivien Didelotd77f4322017-06-15 12:14:03 -0400271 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200272 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100273 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200274
275 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400276 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200277 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100278 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200279
Andrew Lunndc30c352016-10-16 19:56:49 +0200280 return 0;
281
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100282out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100283 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400284 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100285
286out_mapping:
287 for (irq = 0; irq < 16; irq++) {
288 virq = irq_find_mapping(chip->g1_irq.domain, irq);
289 irq_dispose_mapping(virq);
290 }
291
292 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200293
294 return err;
295}
296
Andrew Lunn294d7112018-02-22 22:58:32 +0100297static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
298{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100299 static struct lock_class_key lock_key;
300 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100301 int err;
302
303 err = mv88e6xxx_g1_irq_setup_common(chip);
304 if (err)
305 return err;
306
Andrew Lunnf6d97582019-02-23 17:43:56 +0100307 /* These lock classes tells lockdep that global 1 irqs are in
308 * a different category than their parent GPIO, so it won't
309 * report false recursion.
310 */
311 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
312
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000313 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100314 err = request_threaded_irq(chip->irq, NULL,
315 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200316 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100317 dev_name(chip->dev), chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000318 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100319 if (err)
320 mv88e6xxx_g1_irq_free_common(chip);
321
322 return err;
323}
324
325static void mv88e6xxx_irq_poll(struct kthread_work *work)
326{
327 struct mv88e6xxx_chip *chip = container_of(work,
328 struct mv88e6xxx_chip,
329 irq_poll_work.work);
330 mv88e6xxx_g1_irq_thread_work(chip);
331
332 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
333 msecs_to_jiffies(100));
334}
335
336static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
337{
338 int err;
339
340 err = mv88e6xxx_g1_irq_setup_common(chip);
341 if (err)
342 return err;
343
344 kthread_init_delayed_work(&chip->irq_poll_work,
345 mv88e6xxx_irq_poll);
346
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800347 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100348 if (IS_ERR(chip->kworker))
349 return PTR_ERR(chip->kworker);
350
351 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
352 msecs_to_jiffies(100));
353
354 return 0;
355}
356
357static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
358{
359 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
360 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200361
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000362 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200363 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000364 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100365}
366
Vivien Didelotec561272016-09-02 14:45:33 -0400367int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400368{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200369 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400370
Andrew Lunn6441e6692016-08-19 00:01:55 +0200371 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400372 u16 val;
373 int err;
374
375 err = mv88e6xxx_read(chip, addr, reg, &val);
376 if (err)
377 return err;
378
379 if (!(val & mask))
380 return 0;
381
382 usleep_range(1000, 2000);
383 }
384
Andrew Lunn30853552016-08-19 00:01:57 +0200385 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400386 return -ETIMEDOUT;
387}
388
Vivien Didelotf22ab642016-07-18 20:45:31 -0400389/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400390int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400391{
392 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200393 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400394
395 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200396 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
397 if (err)
398 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400399
400 /* Set the Update bit to trigger a write operation */
401 val = BIT(15) | update;
402
403 return mv88e6xxx_write(chip, addr, reg, val);
404}
405
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100406int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
407 int speed, int duplex, int pause,
408 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100409{
Andrew Lunna26deec2019-04-18 03:11:39 +0200410 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100411 int err;
412
413 if (!chip->info->ops->port_set_link)
414 return 0;
415
Andrew Lunna26deec2019-04-18 03:11:39 +0200416 if (!chip->info->ops->port_link_state)
417 return 0;
418
419 err = chip->info->ops->port_link_state(chip, port, &state);
420 if (err)
421 return err;
422
423 /* Has anything actually changed? We don't expect the
424 * interface mode to change without one of the other
425 * parameters also changing
426 */
427 if (state.link == link &&
428 state.speed == speed &&
429 state.duplex == duplex)
430 return 0;
431
Vivien Didelotd78343d2016-11-04 03:23:36 +0100432 /* Port's MAC control must not be changed unless the link is down */
433 err = chip->info->ops->port_set_link(chip, port, 0);
434 if (err)
435 return err;
436
437 if (chip->info->ops->port_set_speed) {
438 err = chip->info->ops->port_set_speed(chip, port, speed);
439 if (err && err != -EOPNOTSUPP)
440 goto restore_link;
441 }
442
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100443 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
444 mode = chip->info->ops->port_max_speed_mode(port);
445
Andrew Lunn54186b92018-08-09 15:38:37 +0200446 if (chip->info->ops->port_set_pause) {
447 err = chip->info->ops->port_set_pause(chip, port, pause);
448 if (err)
449 goto restore_link;
450 }
451
Vivien Didelotd78343d2016-11-04 03:23:36 +0100452 if (chip->info->ops->port_set_duplex) {
453 err = chip->info->ops->port_set_duplex(chip, port, duplex);
454 if (err && err != -EOPNOTSUPP)
455 goto restore_link;
456 }
457
458 if (chip->info->ops->port_set_rgmii_delay) {
459 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
460 if (err && err != -EOPNOTSUPP)
461 goto restore_link;
462 }
463
Andrew Lunnf39908d2017-02-04 20:02:50 +0100464 if (chip->info->ops->port_set_cmode) {
465 err = chip->info->ops->port_set_cmode(chip, port, mode);
466 if (err && err != -EOPNOTSUPP)
467 goto restore_link;
468 }
469
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470 err = 0;
471restore_link:
472 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400473 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100474
475 return err;
476}
477
Marek Vasutd700ec42018-09-12 00:15:24 +0200478static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
479{
480 struct mv88e6xxx_chip *chip = ds->priv;
481
482 return port < chip->info->num_internal_phys;
483}
484
Andrew Lunndea87022015-08-31 15:56:47 +0200485/* We expect the switch to perform auto negotiation if there is a real
486 * phy. However, in the case of a fixed link phy, we force the port
487 * settings from the fixed link settings.
488 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400489static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
490 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200491{
Vivien Didelot04bed142016-08-31 18:06:13 -0400492 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200493 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200494
Marek Vasutd700ec42018-09-12 00:15:24 +0200495 if (!phy_is_pseudo_fixed_link(phydev) &&
496 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200497 return;
498
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000499 mv88e6xxx_reg_lock(chip);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100500 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200501 phydev->duplex, phydev->pause,
502 phydev->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000503 mv88e6xxx_reg_unlock(chip);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100504
505 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400506 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200507}
508
Russell King6c422e32018-08-09 15:38:39 +0200509static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
510 unsigned long *mask,
511 struct phylink_link_state *state)
512{
513 if (!phy_interface_mode_is_8023z(state->interface)) {
514 /* 10M and 100M are only supported in non-802.3z mode */
515 phylink_set(mask, 10baseT_Half);
516 phylink_set(mask, 10baseT_Full);
517 phylink_set(mask, 100baseT_Half);
518 phylink_set(mask, 100baseT_Full);
519 }
520}
521
522static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
523 unsigned long *mask,
524 struct phylink_link_state *state)
525{
526 /* FIXME: if the port is in 1000Base-X mode, then it only supports
527 * 1000M FD speeds. In this case, CMODE will indicate 5.
528 */
529 phylink_set(mask, 1000baseT_Full);
530 phylink_set(mask, 1000baseX_Full);
531
532 mv88e6065_phylink_validate(chip, port, mask, state);
533}
534
Marek Behúne3af71a2019-02-25 12:39:55 +0100535static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
536 unsigned long *mask,
537 struct phylink_link_state *state)
538{
539 if (port >= 5)
540 phylink_set(mask, 2500baseX_Full);
541
542 /* No ethtool bits for 200Mbps */
543 phylink_set(mask, 1000baseT_Full);
544 phylink_set(mask, 1000baseX_Full);
545
546 mv88e6065_phylink_validate(chip, port, mask, state);
547}
548
Russell King6c422e32018-08-09 15:38:39 +0200549static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
550 unsigned long *mask,
551 struct phylink_link_state *state)
552{
553 /* No ethtool bits for 200Mbps */
554 phylink_set(mask, 1000baseT_Full);
555 phylink_set(mask, 1000baseX_Full);
556
557 mv88e6065_phylink_validate(chip, port, mask, state);
558}
559
560static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
561 unsigned long *mask,
562 struct phylink_link_state *state)
563{
Andrew Lunnec260162019-02-08 22:25:44 +0100564 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200565 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100566 phylink_set(mask, 2500baseT_Full);
567 }
Russell King6c422e32018-08-09 15:38:39 +0200568
569 /* No ethtool bits for 200Mbps */
570 phylink_set(mask, 1000baseT_Full);
571 phylink_set(mask, 1000baseX_Full);
572
573 mv88e6065_phylink_validate(chip, port, mask, state);
574}
575
576static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
577 unsigned long *mask,
578 struct phylink_link_state *state)
579{
580 if (port >= 9) {
581 phylink_set(mask, 10000baseT_Full);
582 phylink_set(mask, 10000baseKR_Full);
583 }
584
585 mv88e6390_phylink_validate(chip, port, mask, state);
586}
587
Russell Kingc9a23562018-05-10 13:17:35 -0700588static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
589 unsigned long *supported,
590 struct phylink_link_state *state)
591{
Russell King6c422e32018-08-09 15:38:39 +0200592 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
593 struct mv88e6xxx_chip *chip = ds->priv;
594
595 /* Allow all the expected bits */
596 phylink_set(mask, Autoneg);
597 phylink_set(mask, Pause);
598 phylink_set_port_modes(mask);
599
600 if (chip->info->ops->phylink_validate)
601 chip->info->ops->phylink_validate(chip, port, mask, state);
602
603 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
604 bitmap_and(state->advertising, state->advertising, mask,
605 __ETHTOOL_LINK_MODE_MASK_NBITS);
606
607 /* We can only operate at 2500BaseX or 1000BaseX. If requested
608 * to advertise both, only report advertising at 2500BaseX.
609 */
610 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700611}
612
613static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
614 struct phylink_link_state *state)
615{
616 struct mv88e6xxx_chip *chip = ds->priv;
617 int err;
618
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000619 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200620 if (chip->info->ops->port_link_state)
621 err = chip->info->ops->port_link_state(chip, port, state);
622 else
623 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000624 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700625
626 return err;
627}
628
629static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
630 unsigned int mode,
631 const struct phylink_link_state *state)
632{
633 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200634 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700635
Marek Vasutd700ec42018-09-12 00:15:24 +0200636 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700637 return;
638
639 if (mode == MLO_AN_FIXED) {
640 link = LINK_FORCED_UP;
641 speed = state->speed;
642 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200643 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
644 link = state->link;
645 speed = state->speed;
646 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700647 } else {
648 speed = SPEED_UNFORCED;
649 duplex = DUPLEX_UNFORCED;
650 link = LINK_UNFORCED;
651 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200652 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700653
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000654 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200655 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700656 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000657 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700658
659 if (err && err != -EOPNOTSUPP)
660 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
661}
662
663static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
664{
665 struct mv88e6xxx_chip *chip = ds->priv;
666 int err;
667
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000668 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700669 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000670 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700671
672 if (err)
673 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
674}
675
676static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
677 unsigned int mode,
678 phy_interface_t interface)
679{
680 if (mode == MLO_AN_FIXED)
681 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
682}
683
684static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
685 unsigned int mode, phy_interface_t interface,
686 struct phy_device *phydev)
687{
688 if (mode == MLO_AN_FIXED)
689 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
690}
691
Andrew Lunna605a0f2016-11-21 23:26:58 +0100692static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000693{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100694 if (!chip->info->ops->stats_snapshot)
695 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000696
Andrew Lunna605a0f2016-11-21 23:26:58 +0100697 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000698}
699
Andrew Lunne413e7e2015-04-02 04:06:38 +0200700static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100701 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
702 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
703 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
704 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
705 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
706 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
707 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
708 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
709 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
710 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
711 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
712 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
713 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
714 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
715 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
716 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
717 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
718 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
719 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
720 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
721 { "single", 4, 0x14, STATS_TYPE_BANK0, },
722 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
723 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
724 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
725 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
726 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
727 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
728 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
729 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
730 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
731 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
732 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
733 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
734 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
735 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
736 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
737 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
738 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
739 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
740 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
741 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
742 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
743 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
744 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
745 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
746 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
747 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
748 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
749 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
750 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
751 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
752 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
753 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
754 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
755 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
756 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
757 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
758 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
759 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200760};
761
Vivien Didelotfad09c72016-06-21 12:28:20 -0400762static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100763 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100764 int port, u16 bank1_select,
765 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200766{
Andrew Lunn80c46272015-06-20 18:42:30 +0200767 u32 low;
768 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100769 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200770 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200771 u64 value;
772
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100773 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100774 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200775 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
776 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800777 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200778
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200779 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100780 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200781 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
782 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800783 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000784 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200785 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100786 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100787 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100788 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100789 /* fall through */
790 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100791 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100792 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100793 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100794 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500795 break;
796 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800797 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200798 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100799 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200800 return value;
801}
802
Andrew Lunn436fe172018-03-01 02:02:29 +0100803static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
804 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100805{
806 struct mv88e6xxx_hw_stat *stat;
807 int i, j;
808
809 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
810 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100811 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100812 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
813 ETH_GSTRING_LEN);
814 j++;
815 }
816 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100817
818 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100819}
820
Andrew Lunn436fe172018-03-01 02:02:29 +0100821static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
822 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100823{
Andrew Lunn436fe172018-03-01 02:02:29 +0100824 return mv88e6xxx_stats_get_strings(chip, data,
825 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100826}
827
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000828static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
829 uint8_t *data)
830{
831 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
832}
833
Andrew Lunn436fe172018-03-01 02:02:29 +0100834static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
835 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100836{
Andrew Lunn436fe172018-03-01 02:02:29 +0100837 return mv88e6xxx_stats_get_strings(chip, data,
838 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100839}
840
Andrew Lunn65f60e42018-03-28 23:50:28 +0200841static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
842 "atu_member_violation",
843 "atu_miss_violation",
844 "atu_full_violation",
845 "vtu_member_violation",
846 "vtu_miss_violation",
847};
848
849static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
850{
851 unsigned int i;
852
853 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
854 strlcpy(data + i * ETH_GSTRING_LEN,
855 mv88e6xxx_atu_vtu_stats_strings[i],
856 ETH_GSTRING_LEN);
857}
858
Andrew Lunndfafe442016-11-21 23:27:02 +0100859static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700860 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100861{
Vivien Didelot04bed142016-08-31 18:06:13 -0400862 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100863 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100864
Florian Fainelli89f09042018-04-25 12:12:50 -0700865 if (stringset != ETH_SS_STATS)
866 return;
867
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000868 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100869
Andrew Lunndfafe442016-11-21 23:27:02 +0100870 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100871 count = chip->info->ops->stats_get_strings(chip, data);
872
873 if (chip->info->ops->serdes_get_strings) {
874 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200875 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100876 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100877
Andrew Lunn65f60e42018-03-28 23:50:28 +0200878 data += count * ETH_GSTRING_LEN;
879 mv88e6xxx_atu_vtu_get_strings(data);
880
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000881 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100882}
883
884static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
885 int types)
886{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100887 struct mv88e6xxx_hw_stat *stat;
888 int i, j;
889
890 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
891 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100892 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100893 j++;
894 }
895 return j;
896}
897
Andrew Lunndfafe442016-11-21 23:27:02 +0100898static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
899{
900 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
901 STATS_TYPE_PORT);
902}
903
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000904static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
905{
906 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
907}
908
Andrew Lunndfafe442016-11-21 23:27:02 +0100909static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
910{
911 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
912 STATS_TYPE_BANK1);
913}
914
Florian Fainelli89f09042018-04-25 12:12:50 -0700915static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100916{
917 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100918 int serdes_count = 0;
919 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100920
Florian Fainelli89f09042018-04-25 12:12:50 -0700921 if (sset != ETH_SS_STATS)
922 return 0;
923
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000924 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100925 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100926 count = chip->info->ops->stats_get_sset_count(chip);
927 if (count < 0)
928 goto out;
929
930 if (chip->info->ops->serdes_get_sset_count)
931 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
932 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200933 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100934 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200935 goto out;
936 }
937 count += serdes_count;
938 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
939
Andrew Lunn436fe172018-03-01 02:02:29 +0100940out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000941 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100942
Andrew Lunn436fe172018-03-01 02:02:29 +0100943 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100944}
945
Andrew Lunn436fe172018-03-01 02:02:29 +0100946static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
947 uint64_t *data, int types,
948 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100949{
950 struct mv88e6xxx_hw_stat *stat;
951 int i, j;
952
953 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
954 stat = &mv88e6xxx_hw_stats[i];
955 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000956 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100957 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
958 bank1_select,
959 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000960 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100961
Andrew Lunn052f9472016-11-21 23:27:03 +0100962 j++;
963 }
964 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100965 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100966}
967
Andrew Lunn436fe172018-03-01 02:02:29 +0100968static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
969 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100970{
971 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100972 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400973 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100974}
975
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000976static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
977 uint64_t *data)
978{
979 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
980 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
981}
982
Andrew Lunn436fe172018-03-01 02:02:29 +0100983static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100985{
986 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100987 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400988 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
989 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100990}
991
Andrew Lunn436fe172018-03-01 02:02:29 +0100992static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
993 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100994{
995 return mv88e6xxx_stats_get_stats(chip, port, data,
996 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400997 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
998 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100999}
1000
Andrew Lunn65f60e42018-03-28 23:50:28 +02001001static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1002 uint64_t *data)
1003{
1004 *data++ = chip->ports[port].atu_member_violation;
1005 *data++ = chip->ports[port].atu_miss_violation;
1006 *data++ = chip->ports[port].atu_full_violation;
1007 *data++ = chip->ports[port].vtu_member_violation;
1008 *data++ = chip->ports[port].vtu_miss_violation;
1009}
1010
Andrew Lunn052f9472016-11-21 23:27:03 +01001011static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1012 uint64_t *data)
1013{
Andrew Lunn436fe172018-03-01 02:02:29 +01001014 int count = 0;
1015
Andrew Lunn052f9472016-11-21 23:27:03 +01001016 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001017 count = chip->info->ops->stats_get_stats(chip, port, data);
1018
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001019 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001020 if (chip->info->ops->serdes_get_stats) {
1021 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001022 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001023 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001024 data += count;
1025 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001026 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001027}
1028
Vivien Didelotf81ec902016-05-09 13:22:58 -04001029static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1030 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001031{
Vivien Didelot04bed142016-08-31 18:06:13 -04001032 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001033 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001034
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001035 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001036
Andrew Lunna605a0f2016-11-21 23:26:58 +01001037 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001038 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001039
1040 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001041 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001042
1043 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001044
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001045}
Ben Hutchings98e67302011-11-25 14:36:19 +00001046
Vivien Didelotf81ec902016-05-09 13:22:58 -04001047static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001048{
1049 return 32 * sizeof(u16);
1050}
1051
Vivien Didelotf81ec902016-05-09 13:22:58 -04001052static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1053 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001054{
Vivien Didelot04bed142016-08-31 18:06:13 -04001055 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001056 int err;
1057 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001058 u16 *p = _p;
1059 int i;
1060
Vivien Didelota5f39322018-12-17 16:05:21 -05001061 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001062
1063 memset(p, 0xff, 32 * sizeof(u16));
1064
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001065 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001066
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001067 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001068
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001069 err = mv88e6xxx_port_read(chip, port, i, &reg);
1070 if (!err)
1071 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001072 }
Vivien Didelot23062512016-05-09 13:22:45 -04001073
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001074 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001075}
1076
Vivien Didelot08f50062017-08-01 16:32:41 -04001077static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1078 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001079{
Vivien Didelot5480db62017-08-01 16:32:40 -04001080 /* Nothing to do on the port's MAC */
1081 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001082}
1083
Vivien Didelot08f50062017-08-01 16:32:41 -04001084static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1085 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001086{
Vivien Didelot5480db62017-08-01 16:32:40 -04001087 /* Nothing to do on the port's MAC */
1088 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001089}
1090
Vivien Didelote5887a22017-03-30 17:37:11 -04001091static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001092{
Vivien Didelote5887a22017-03-30 17:37:11 -04001093 struct dsa_switch *ds = NULL;
1094 struct net_device *br;
1095 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001096 int i;
1097
Vivien Didelote5887a22017-03-30 17:37:11 -04001098 if (dev < DSA_MAX_SWITCHES)
1099 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001100
Vivien Didelote5887a22017-03-30 17:37:11 -04001101 /* Prevent frames from unknown switch or port */
1102 if (!ds || port >= ds->num_ports)
1103 return 0;
1104
1105 /* Frames from DSA links and CPU ports can egress any local port */
1106 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1107 return mv88e6xxx_port_mask(chip);
1108
1109 br = ds->ports[port].bridge_dev;
1110 pvlan = 0;
1111
1112 /* Frames from user ports can egress any local DSA links and CPU ports,
1113 * as well as any local member of their bridge group.
1114 */
1115 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1116 if (dsa_is_cpu_port(chip->ds, i) ||
1117 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001118 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001119 pvlan |= BIT(i);
1120
1121 return pvlan;
1122}
1123
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001124static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001125{
1126 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001127
1128 /* prevent frames from going back out of the port they came in on */
1129 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001130
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001131 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001132}
1133
Vivien Didelotf81ec902016-05-09 13:22:58 -04001134static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1135 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001136{
Vivien Didelot04bed142016-08-31 18:06:13 -04001137 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001138 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001139
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001140 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001141 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001142 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001143
1144 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001145 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001146}
1147
Vivien Didelot93e18d62018-05-11 17:16:35 -04001148static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1149{
1150 int err;
1151
1152 if (chip->info->ops->ieee_pri_map) {
1153 err = chip->info->ops->ieee_pri_map(chip);
1154 if (err)
1155 return err;
1156 }
1157
1158 if (chip->info->ops->ip_pri_map) {
1159 err = chip->info->ops->ip_pri_map(chip);
1160 if (err)
1161 return err;
1162 }
1163
1164 return 0;
1165}
1166
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001167static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1168{
1169 int target, port;
1170 int err;
1171
1172 if (!chip->info->global2_addr)
1173 return 0;
1174
1175 /* Initialize the routing port to the 32 possible target devices */
1176 for (target = 0; target < 32; target++) {
1177 port = 0x1f;
1178 if (target < DSA_MAX_SWITCHES)
1179 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1180 port = chip->ds->rtable[target];
1181
1182 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1183 if (err)
1184 return err;
1185 }
1186
Vivien Didelot02317e62018-05-09 11:38:49 -04001187 if (chip->info->ops->set_cascade_port) {
1188 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1189 err = chip->info->ops->set_cascade_port(chip, port);
1190 if (err)
1191 return err;
1192 }
1193
Vivien Didelot23c98912018-05-09 11:38:50 -04001194 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1195 if (err)
1196 return err;
1197
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001198 return 0;
1199}
1200
Vivien Didelotb28f8722018-04-26 21:56:44 -04001201static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1202{
1203 /* Clear all trunk masks and mapping */
1204 if (chip->info->global2_addr)
1205 return mv88e6xxx_g2_trunk_clear(chip);
1206
1207 return 0;
1208}
1209
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001210static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1211{
1212 if (chip->info->ops->rmu_disable)
1213 return chip->info->ops->rmu_disable(chip);
1214
1215 return 0;
1216}
1217
Vivien Didelot9e907d72017-07-17 13:03:43 -04001218static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1219{
1220 if (chip->info->ops->pot_clear)
1221 return chip->info->ops->pot_clear(chip);
1222
1223 return 0;
1224}
1225
Vivien Didelot51c901a2017-07-17 13:03:41 -04001226static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1227{
1228 if (chip->info->ops->mgmt_rsvd2cpu)
1229 return chip->info->ops->mgmt_rsvd2cpu(chip);
1230
1231 return 0;
1232}
1233
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001234static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1235{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001236 int err;
1237
Vivien Didelotdaefc942017-03-11 16:12:54 -05001238 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1239 if (err)
1240 return err;
1241
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001242 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1243 if (err)
1244 return err;
1245
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001246 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1247}
1248
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001249static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1250{
1251 int port;
1252 int err;
1253
1254 if (!chip->info->ops->irl_init_all)
1255 return 0;
1256
1257 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1258 /* Disable ingress rate limiting by resetting all per port
1259 * ingress rate limit resources to their initial state.
1260 */
1261 err = chip->info->ops->irl_init_all(chip, port);
1262 if (err)
1263 return err;
1264 }
1265
1266 return 0;
1267}
1268
Vivien Didelot04a69a12017-10-13 14:18:05 -04001269static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1270{
1271 if (chip->info->ops->set_switch_mac) {
1272 u8 addr[ETH_ALEN];
1273
1274 eth_random_addr(addr);
1275
1276 return chip->info->ops->set_switch_mac(chip, addr);
1277 }
1278
1279 return 0;
1280}
1281
Vivien Didelot17a15942017-03-30 17:37:09 -04001282static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1283{
1284 u16 pvlan = 0;
1285
1286 if (!mv88e6xxx_has_pvt(chip))
1287 return -EOPNOTSUPP;
1288
1289 /* Skip the local source device, which uses in-chip port VLAN */
1290 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001291 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001292
1293 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1294}
1295
Vivien Didelot81228992017-03-30 17:37:08 -04001296static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1297{
Vivien Didelot17a15942017-03-30 17:37:09 -04001298 int dev, port;
1299 int err;
1300
Vivien Didelot81228992017-03-30 17:37:08 -04001301 if (!mv88e6xxx_has_pvt(chip))
1302 return 0;
1303
1304 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1305 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1306 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001307 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1308 if (err)
1309 return err;
1310
1311 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1312 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1313 err = mv88e6xxx_pvt_map(chip, dev, port);
1314 if (err)
1315 return err;
1316 }
1317 }
1318
1319 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001320}
1321
Vivien Didelot749efcb2016-09-22 16:49:24 -04001322static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1323{
1324 struct mv88e6xxx_chip *chip = ds->priv;
1325 int err;
1326
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001327 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001328 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001329 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001330
1331 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001332 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001333}
1334
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001335static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1336{
1337 if (!chip->info->max_vid)
1338 return 0;
1339
1340 return mv88e6xxx_g1_vtu_flush(chip);
1341}
1342
Vivien Didelotf1394b782017-05-01 14:05:22 -04001343static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1344 struct mv88e6xxx_vtu_entry *entry)
1345{
1346 if (!chip->info->ops->vtu_getnext)
1347 return -EOPNOTSUPP;
1348
1349 return chip->info->ops->vtu_getnext(chip, entry);
1350}
1351
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001352static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1353 struct mv88e6xxx_vtu_entry *entry)
1354{
1355 if (!chip->info->ops->vtu_loadpurge)
1356 return -EOPNOTSUPP;
1357
1358 return chip->info->ops->vtu_loadpurge(chip, entry);
1359}
1360
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001361static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001362{
1363 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001364 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001365 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001366
1367 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1368
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001369 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001370 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001371 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001372 if (err)
1373 return err;
1374
1375 set_bit(*fid, fid_bitmap);
1376 }
1377
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001378 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001379 vlan.vid = chip->info->max_vid;
1380 vlan.valid = false;
1381
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001382 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001383 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001384 if (err)
1385 return err;
1386
1387 if (!vlan.valid)
1388 break;
1389
1390 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001391 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001392
1393 /* The reset value 0x000 is used to indicate that multiple address
1394 * databases are not needed. Return the next positive available.
1395 */
1396 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001397 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001398 return -ENOSPC;
1399
1400 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001401 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001402}
1403
Vivien Didelotda9c3592016-02-12 12:09:40 -05001404static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1405 u16 vid_begin, u16 vid_end)
1406{
Vivien Didelot04bed142016-08-31 18:06:13 -04001407 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001408 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001409 int i, err;
1410
Andrew Lunndb06ae412017-09-25 23:32:20 +02001411 /* DSA and CPU ports have to be members of multiple vlans */
1412 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1413 return 0;
1414
Vivien Didelotda9c3592016-02-12 12:09:40 -05001415 if (!vid_begin)
1416 return -EOPNOTSUPP;
1417
Vivien Didelot425d2d32019-08-01 14:36:34 -04001418 vlan.vid = vid_begin - 1;
1419 vlan.valid = false;
1420
Vivien Didelotda9c3592016-02-12 12:09:40 -05001421 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001422 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001423 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001424 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001425
1426 if (!vlan.valid)
1427 break;
1428
1429 if (vlan.vid > vid_end)
1430 break;
1431
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001432 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001433 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1434 continue;
1435
Andrew Lunncd886462017-11-09 22:29:53 +01001436 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001437 continue;
1438
Vivien Didelotbd00e052017-05-01 14:05:11 -04001439 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001440 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001441 continue;
1442
Vivien Didelotc8652c82017-10-16 11:12:19 -04001443 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001444 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001445 break; /* same bridge, check next VLAN */
1446
Vivien Didelotc8652c82017-10-16 11:12:19 -04001447 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001448 continue;
1449
Andrew Lunn743fcc22017-11-09 22:29:54 +01001450 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1451 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001452 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001453 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001454 }
1455 } while (vlan.vid < vid_end);
1456
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001457 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001458}
1459
Vivien Didelotf81ec902016-05-09 13:22:58 -04001460static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1461 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001462{
Vivien Didelot04bed142016-08-31 18:06:13 -04001463 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001464 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1465 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001466 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001467
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001468 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001469 return -EOPNOTSUPP;
1470
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001471 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001472 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001473 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001474
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001475 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001476}
1477
Vivien Didelot57d32312016-06-20 13:13:58 -04001478static int
1479mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001480 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001481{
Vivien Didelot04bed142016-08-31 18:06:13 -04001482 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001483 int err;
1484
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001485 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001486 return -EOPNOTSUPP;
1487
Vivien Didelotda9c3592016-02-12 12:09:40 -05001488 /* If the requested port doesn't belong to the same bridge as the VLAN
1489 * members, do not support it (yet) and fallback to software VLAN.
1490 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001491 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001492 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1493 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001494 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001495
Vivien Didelot76e398a2015-11-01 12:33:55 -05001496 /* We don't need any dynamic resource from the kernel (yet),
1497 * so skip the prepare phase.
1498 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001499 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001500}
1501
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001502static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1503 const unsigned char *addr, u16 vid,
1504 u8 state)
1505{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001506 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001507 struct mv88e6xxx_vtu_entry vlan;
1508 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001509 int err;
1510
1511 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001512 if (vid == 0) {
1513 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1514 if (err)
1515 return err;
1516 } else {
1517 vlan.vid = vid - 1;
1518 vlan.valid = false;
1519
1520 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1521 if (err)
1522 return err;
1523
1524 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1525 if (vlan.vid != vid || !vlan.valid)
1526 return -EOPNOTSUPP;
1527
1528 fid = vlan.fid;
1529 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001530
1531 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1532 ether_addr_copy(entry.mac, addr);
1533 eth_addr_dec(entry.mac);
1534
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001535 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001536 if (err)
1537 return err;
1538
1539 /* Initialize a fresh ATU entry if it isn't found */
1540 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1541 !ether_addr_equal(entry.mac, addr)) {
1542 memset(&entry, 0, sizeof(entry));
1543 ether_addr_copy(entry.mac, addr);
1544 }
1545
1546 /* Purge the ATU entry only if no port is using it anymore */
1547 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1548 entry.portvec &= ~BIT(port);
1549 if (!entry.portvec)
1550 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1551 } else {
1552 entry.portvec |= BIT(port);
1553 entry.state = state;
1554 }
1555
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001556 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001557}
1558
Andrew Lunn87fa8862017-11-09 22:29:56 +01001559static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1560 u16 vid)
1561{
1562 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1563 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1564
1565 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1566}
1567
1568static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1569{
1570 int port;
1571 int err;
1572
1573 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1574 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1575 if (err)
1576 return err;
1577 }
1578
1579 return 0;
1580}
1581
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001582static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001583 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001584{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001585 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001586 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001587 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001588
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001589 if (!vid)
1590 return -EOPNOTSUPP;
1591
1592 vlan.vid = vid - 1;
1593 vlan.valid = false;
1594
1595 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001596 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001597 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001598
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001599 if (vlan.vid != vid || !vlan.valid) {
1600 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001601
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001602 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1603 if (err)
1604 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001605
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001606 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1607 if (i == port)
1608 vlan.member[i] = member;
1609 else
1610 vlan.member[i] = non_member;
1611
1612 vlan.vid = vid;
1613 vlan.valid = true;
1614
1615 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1616 if (err)
1617 return err;
1618
1619 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1620 if (err)
1621 return err;
1622 } else if (vlan.member[port] != member) {
1623 vlan.member[port] = member;
1624
1625 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1626 if (err)
1627 return err;
1628 } else {
1629 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1630 port, vid);
1631 }
1632
1633 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001634}
1635
Vivien Didelotf81ec902016-05-09 13:22:58 -04001636static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001637 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001638{
Vivien Didelot04bed142016-08-31 18:06:13 -04001639 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001640 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1641 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001642 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001643 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001644
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001645 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001646 return;
1647
Vivien Didelotc91498e2017-06-07 18:12:13 -04001648 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001649 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001650 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001651 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001652 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001653 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001654
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001655 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001656
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001657 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001658 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001659 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1660 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001661
Vivien Didelot77064f32016-11-04 03:23:30 +01001662 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001663 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1664 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001665
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001666 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001667}
1668
Vivien Didelot521098922019-08-01 14:36:36 -04001669static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1670 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001671{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001672 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001673 int i, err;
1674
Vivien Didelot521098922019-08-01 14:36:36 -04001675 if (!vid)
1676 return -EOPNOTSUPP;
1677
1678 vlan.vid = vid - 1;
1679 vlan.valid = false;
1680
1681 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001682 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001683 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001684
Vivien Didelot521098922019-08-01 14:36:36 -04001685 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1686 * tell switchdev that this VLAN is likely handled in software.
1687 */
1688 if (vlan.vid != vid || !vlan.valid ||
1689 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001690 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001691
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001692 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001693
1694 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001695 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001696 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001697 if (vlan.member[i] !=
1698 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001699 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001700 break;
1701 }
1702 }
1703
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001704 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001705 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001706 return err;
1707
Vivien Didelote606ca32017-03-11 16:12:55 -05001708 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001709}
1710
Vivien Didelotf81ec902016-05-09 13:22:58 -04001711static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1712 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001713{
Vivien Didelot04bed142016-08-31 18:06:13 -04001714 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001715 u16 pvid, vid;
1716 int err = 0;
1717
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001718 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001719 return -EOPNOTSUPP;
1720
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001721 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001722
Vivien Didelot77064f32016-11-04 03:23:30 +01001723 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001724 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001725 goto unlock;
1726
Vivien Didelot76e398a2015-11-01 12:33:55 -05001727 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001728 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001729 if (err)
1730 goto unlock;
1731
1732 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001733 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001734 if (err)
1735 goto unlock;
1736 }
1737 }
1738
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001739unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001740 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001741
1742 return err;
1743}
1744
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001745static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1746 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001747{
Vivien Didelot04bed142016-08-31 18:06:13 -04001748 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001749 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001750
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001751 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001752 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1753 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001754 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001755
1756 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001757}
1758
Vivien Didelotf81ec902016-05-09 13:22:58 -04001759static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001760 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001761{
Vivien Didelot04bed142016-08-31 18:06:13 -04001762 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001763 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001764
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001765 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001766 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001767 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001768 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001769
Vivien Didelot83dabd12016-08-31 11:50:04 -04001770 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001771}
1772
Vivien Didelot83dabd12016-08-31 11:50:04 -04001773static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1774 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001775 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001776{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001777 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001778 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001779 int err;
1780
Vivien Didelot27c0e602017-06-15 12:14:01 -04001781 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001782 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001783
1784 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001785 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001786 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001787 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001788
Vivien Didelot27c0e602017-06-15 12:14:01 -04001789 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001790 break;
1791
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001792 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001793 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001794
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001795 if (!is_unicast_ether_addr(addr.mac))
1796 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001797
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001798 is_static = (addr.state ==
1799 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1800 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001801 if (err)
1802 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001803 } while (!is_broadcast_ether_addr(addr.mac));
1804
1805 return err;
1806}
1807
Vivien Didelot83dabd12016-08-31 11:50:04 -04001808static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001809 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001810{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001811 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001812 u16 fid;
1813 int err;
1814
1815 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001816 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001817 if (err)
1818 return err;
1819
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001820 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001821 if (err)
1822 return err;
1823
1824 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001825 vlan.vid = chip->info->max_vid;
1826 vlan.valid = false;
1827
Vivien Didelot83dabd12016-08-31 11:50:04 -04001828 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001829 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001830 if (err)
1831 return err;
1832
1833 if (!vlan.valid)
1834 break;
1835
1836 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001837 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001838 if (err)
1839 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001840 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001841
1842 return err;
1843}
1844
Vivien Didelotf81ec902016-05-09 13:22:58 -04001845static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001846 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001847{
Vivien Didelot04bed142016-08-31 18:06:13 -04001848 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04001849 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001850
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001851 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001852 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001853 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001854
1855 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001856}
1857
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001858static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1859 struct net_device *br)
1860{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001861 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001862 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001863 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001864 int err;
1865
1866 /* Remap the Port VLAN of each local bridge group member */
1867 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1868 if (chip->ds->ports[port].bridge_dev == br) {
1869 err = mv88e6xxx_port_vlan_map(chip, port);
1870 if (err)
1871 return err;
1872 }
1873 }
1874
Vivien Didelote96a6e02017-03-30 17:37:13 -04001875 if (!mv88e6xxx_has_pvt(chip))
1876 return 0;
1877
1878 /* Remap the Port VLAN of each cross-chip bridge group member */
1879 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1880 ds = chip->ds->dst->ds[dev];
1881 if (!ds)
1882 break;
1883
1884 for (port = 0; port < ds->num_ports; ++port) {
1885 if (ds->ports[port].bridge_dev == br) {
1886 err = mv88e6xxx_pvt_map(chip, dev, port);
1887 if (err)
1888 return err;
1889 }
1890 }
1891 }
1892
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001893 return 0;
1894}
1895
Vivien Didelotf81ec902016-05-09 13:22:58 -04001896static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001897 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001898{
Vivien Didelot04bed142016-08-31 18:06:13 -04001899 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001900 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001901
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001902 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001903 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001904 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05001905
Vivien Didelot466dfa02016-02-26 13:16:05 -05001906 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001907}
1908
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001909static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1910 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001911{
Vivien Didelot04bed142016-08-31 18:06:13 -04001912 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001913
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001914 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001915 if (mv88e6xxx_bridge_map(chip, br) ||
1916 mv88e6xxx_port_vlan_map(chip, port))
1917 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001918 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001919}
1920
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001921static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1922 int port, struct net_device *br)
1923{
1924 struct mv88e6xxx_chip *chip = ds->priv;
1925 int err;
1926
1927 if (!mv88e6xxx_has_pvt(chip))
1928 return 0;
1929
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001930 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001931 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001932 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001933
1934 return err;
1935}
1936
1937static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1938 int port, struct net_device *br)
1939{
1940 struct mv88e6xxx_chip *chip = ds->priv;
1941
1942 if (!mv88e6xxx_has_pvt(chip))
1943 return;
1944
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001945 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001946 if (mv88e6xxx_pvt_map(chip, dev, port))
1947 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001948 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001949}
1950
Vivien Didelot17e708b2016-12-05 17:30:27 -05001951static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1952{
1953 if (chip->info->ops->reset)
1954 return chip->info->ops->reset(chip);
1955
1956 return 0;
1957}
1958
Vivien Didelot309eca62016-12-05 17:30:26 -05001959static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1960{
1961 struct gpio_desc *gpiod = chip->reset;
1962
1963 /* If there is a GPIO connected to the reset pin, toggle it */
1964 if (gpiod) {
1965 gpiod_set_value_cansleep(gpiod, 1);
1966 usleep_range(10000, 20000);
1967 gpiod_set_value_cansleep(gpiod, 0);
1968 usleep_range(10000, 20000);
1969 }
1970}
1971
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001972static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1973{
1974 int i, err;
1975
1976 /* Set all ports to the Disabled state */
1977 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001978 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001979 if (err)
1980 return err;
1981 }
1982
1983 /* Wait for transmit queues to drain,
1984 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1985 */
1986 usleep_range(2000, 4000);
1987
1988 return 0;
1989}
1990
Vivien Didelotfad09c72016-06-21 12:28:20 -04001991static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001992{
Vivien Didelota935c052016-09-29 12:21:53 -04001993 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001994
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001995 err = mv88e6xxx_disable_ports(chip);
1996 if (err)
1997 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001998
Vivien Didelot309eca62016-12-05 17:30:26 -05001999 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002000
Vivien Didelot17e708b2016-12-05 17:30:27 -05002001 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002002}
2003
Vivien Didelot43145572017-03-11 16:12:59 -05002004static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002005 enum mv88e6xxx_frame_mode frame,
2006 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002007{
2008 int err;
2009
Vivien Didelot43145572017-03-11 16:12:59 -05002010 if (!chip->info->ops->port_set_frame_mode)
2011 return -EOPNOTSUPP;
2012
2013 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002014 if (err)
2015 return err;
2016
Vivien Didelot43145572017-03-11 16:12:59 -05002017 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2018 if (err)
2019 return err;
2020
2021 if (chip->info->ops->port_set_ether_type)
2022 return chip->info->ops->port_set_ether_type(chip, port, etype);
2023
2024 return 0;
2025}
2026
2027static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2028{
2029 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002030 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002031 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002032}
2033
2034static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2035{
2036 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002037 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002038 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002039}
2040
2041static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2042{
2043 return mv88e6xxx_set_port_mode(chip, port,
2044 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002045 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2046 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002047}
2048
2049static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2050{
2051 if (dsa_is_dsa_port(chip->ds, port))
2052 return mv88e6xxx_set_port_mode_dsa(chip, port);
2053
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002054 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002055 return mv88e6xxx_set_port_mode_normal(chip, port);
2056
2057 /* Setup CPU port mode depending on its supported tag format */
2058 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2059 return mv88e6xxx_set_port_mode_dsa(chip, port);
2060
2061 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2062 return mv88e6xxx_set_port_mode_edsa(chip, port);
2063
2064 return -EINVAL;
2065}
2066
Vivien Didelotea698f42017-03-11 16:12:50 -05002067static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2068{
2069 bool message = dsa_is_dsa_port(chip->ds, port);
2070
2071 return mv88e6xxx_port_set_message_port(chip, port, message);
2072}
2073
Vivien Didelot601aeed2017-03-11 16:13:00 -05002074static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2075{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002076 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002077 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002078
David S. Miller407308f2019-06-15 13:35:29 -07002079 /* Upstream ports flood frames with unknown unicast or multicast DA */
2080 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2081 if (chip->info->ops->port_set_egress_floods)
2082 return chip->info->ops->port_set_egress_floods(chip, port,
2083 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002084
David S. Miller407308f2019-06-15 13:35:29 -07002085 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002086}
2087
Andrew Lunn6d917822017-05-26 01:03:21 +02002088static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2089 bool on)
2090{
Vivien Didelot523a8902017-05-26 18:02:42 -04002091 if (chip->info->ops->serdes_power)
2092 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002093
Vivien Didelot523a8902017-05-26 18:02:42 -04002094 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002095}
2096
Vivien Didelotfa371c82017-12-05 15:34:10 -05002097static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2098{
2099 struct dsa_switch *ds = chip->ds;
2100 int upstream_port;
2101 int err;
2102
Vivien Didelot07073c72017-12-05 15:34:13 -05002103 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002104 if (chip->info->ops->port_set_upstream_port) {
2105 err = chip->info->ops->port_set_upstream_port(chip, port,
2106 upstream_port);
2107 if (err)
2108 return err;
2109 }
2110
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002111 if (port == upstream_port) {
2112 if (chip->info->ops->set_cpu_port) {
2113 err = chip->info->ops->set_cpu_port(chip,
2114 upstream_port);
2115 if (err)
2116 return err;
2117 }
2118
2119 if (chip->info->ops->set_egress_port) {
2120 err = chip->info->ops->set_egress_port(chip,
2121 upstream_port);
2122 if (err)
2123 return err;
2124 }
2125 }
2126
Vivien Didelotfa371c82017-12-05 15:34:10 -05002127 return 0;
2128}
2129
Vivien Didelotfad09c72016-06-21 12:28:20 -04002130static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002131{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002132 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002133 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002134 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002135
Andrew Lunn7b898462018-08-09 15:38:47 +02002136 chip->ports[port].chip = chip;
2137 chip->ports[port].port = port;
2138
Vivien Didelotd78343d2016-11-04 03:23:36 +01002139 /* MAC Forcing register: don't force link, speed, duplex or flow control
2140 * state to any particular values on physical ports, but force the CPU
2141 * port and all DSA ports to their maximum bandwidth and full duplex.
2142 */
2143 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2144 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2145 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002146 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002147 PHY_INTERFACE_MODE_NA);
2148 else
2149 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2150 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002151 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002152 PHY_INTERFACE_MODE_NA);
2153 if (err)
2154 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002155
2156 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2157 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2158 * tunneling, determine priority by looking at 802.1p and IP
2159 * priority fields (IP prio has precedence), and set STP state
2160 * to Forwarding.
2161 *
2162 * If this is the CPU link, use DSA or EDSA tagging depending
2163 * on which tagging mode was configured.
2164 *
2165 * If this is a link to another switch, use DSA tagging mode.
2166 *
2167 * If this is the upstream port for this switch, enable
2168 * forwarding of unknown unicasts and multicasts.
2169 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002170 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2171 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2172 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2173 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002174 if (err)
2175 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002176
Vivien Didelot601aeed2017-03-11 16:13:00 -05002177 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002178 if (err)
2179 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002180
Vivien Didelot601aeed2017-03-11 16:13:00 -05002181 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002182 if (err)
2183 return err;
2184
Andrew Lunn04aca992017-05-26 01:03:24 +02002185 /* Enable the SERDES interface for DSA and CPU ports. Normal
2186 * ports SERDES are enabled when the port is enabled, thus
2187 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002188 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002189 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2190 err = mv88e6xxx_serdes_power(chip, port, true);
2191 if (err)
2192 return err;
2193 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002194
Vivien Didelot8efdda42015-08-13 12:52:23 -04002195 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002196 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002197 * untagged frames on this port, do a destination address lookup on all
2198 * received packets as usual, disable ARP mirroring and don't send a
2199 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002200 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002201 err = mv88e6xxx_port_set_map_da(chip, port);
2202 if (err)
2203 return err;
2204
Vivien Didelotfa371c82017-12-05 15:34:10 -05002205 err = mv88e6xxx_setup_upstream_port(chip, port);
2206 if (err)
2207 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002208
Andrew Lunna23b2962017-02-04 20:15:28 +01002209 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002210 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002211 if (err)
2212 return err;
2213
Vivien Didelotcd782652017-06-08 18:34:13 -04002214 if (chip->info->ops->port_set_jumbo_size) {
2215 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002216 if (err)
2217 return err;
2218 }
2219
Andrew Lunn54d792f2015-05-06 01:09:47 +02002220 /* Port Association Vector: when learning source addresses
2221 * of packets, add the address to the address database using
2222 * a port bitmap that has only the bit for this port set and
2223 * the other bits clear.
2224 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002225 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002226 /* Disable learning for CPU port */
2227 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002228 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002229
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002230 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2231 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002232 if (err)
2233 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002234
2235 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002236 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2237 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002238 if (err)
2239 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002240
Vivien Didelot08984322017-06-08 18:34:12 -04002241 if (chip->info->ops->port_pause_limit) {
2242 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002243 if (err)
2244 return err;
2245 }
2246
Vivien Didelotc8c94892017-03-11 16:13:01 -05002247 if (chip->info->ops->port_disable_learn_limit) {
2248 err = chip->info->ops->port_disable_learn_limit(chip, port);
2249 if (err)
2250 return err;
2251 }
2252
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002253 if (chip->info->ops->port_disable_pri_override) {
2254 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002255 if (err)
2256 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002257 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002258
Andrew Lunnef0a7312016-12-03 04:35:16 +01002259 if (chip->info->ops->port_tag_remap) {
2260 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002261 if (err)
2262 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002263 }
2264
Andrew Lunnef70b112016-12-03 04:45:18 +01002265 if (chip->info->ops->port_egress_rate_limiting) {
2266 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002267 if (err)
2268 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002269 }
2270
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002271 if (chip->info->ops->port_setup_message_port) {
2272 err = chip->info->ops->port_setup_message_port(chip, port);
2273 if (err)
2274 return err;
2275 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002276
Vivien Didelot207afda2016-04-14 14:42:09 -04002277 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002278 * database, and allow bidirectional communication between the
2279 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002280 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002281 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002282 if (err)
2283 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002284
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002285 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002286 if (err)
2287 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002288
2289 /* Default VLAN ID and priority: don't set a default VLAN
2290 * ID, and set the default packet priority to zero.
2291 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002292 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002293}
2294
Andrew Lunn04aca992017-05-26 01:03:24 +02002295static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2296 struct phy_device *phydev)
2297{
2298 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002299 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002300
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002301 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002302
Vivien Didelot523a8902017-05-26 18:02:42 -04002303 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002304
2305 if (!err && chip->info->ops->serdes_irq_setup)
2306 err = chip->info->ops->serdes_irq_setup(chip, port);
2307
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002308 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002309
2310 return err;
2311}
2312
Andrew Lunn75104db2019-02-24 20:44:43 +01002313static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002314{
2315 struct mv88e6xxx_chip *chip = ds->priv;
2316
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002317 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002318
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002319 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2320 dev_err(chip->dev, "failed to disable port\n");
2321
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002322 if (chip->info->ops->serdes_irq_free)
2323 chip->info->ops->serdes_irq_free(chip, port);
2324
Vivien Didelot523a8902017-05-26 18:02:42 -04002325 if (mv88e6xxx_serdes_power(chip, port, false))
2326 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002327
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002328 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002329}
2330
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002331static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2332 unsigned int ageing_time)
2333{
Vivien Didelot04bed142016-08-31 18:06:13 -04002334 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002335 int err;
2336
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002337 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002338 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002339 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002340
2341 return err;
2342}
2343
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002344static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002345{
2346 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002347
Andrew Lunnde2273872016-11-21 23:27:01 +01002348 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002349 if (chip->info->ops->stats_set_histogram) {
2350 err = chip->info->ops->stats_set_histogram(chip);
2351 if (err)
2352 return err;
2353 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002354
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002355 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002356}
2357
Andrew Lunnea890982019-01-09 00:24:03 +01002358/* The mv88e6390 has some hidden registers used for debug and
2359 * development. The errata also makes use of them.
2360 */
2361static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2362 int reg, u16 val)
2363{
2364 u16 ctrl;
2365 int err;
2366
2367 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2368 PORT_RESERVED_1A, val);
2369 if (err)
2370 return err;
2371
2372 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2373 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2374 reg;
2375
2376 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2377 PORT_RESERVED_1A, ctrl);
2378}
2379
2380static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2381{
2382 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2383 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2384}
2385
2386
2387static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2388 int reg, u16 *val)
2389{
2390 u16 ctrl;
2391 int err;
2392
2393 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2394 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2395 reg;
2396
2397 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2398 PORT_RESERVED_1A, ctrl);
2399 if (err)
2400 return err;
2401
2402 err = mv88e6390_hidden_wait(chip);
2403 if (err)
2404 return err;
2405
2406 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2407 PORT_RESERVED_1A, val);
2408}
2409
2410/* Check if the errata has already been applied. */
2411static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2412{
2413 int port;
2414 int err;
2415 u16 val;
2416
2417 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2418 err = mv88e6390_hidden_read(chip, port, 0, &val);
2419 if (err) {
2420 dev_err(chip->dev,
2421 "Error reading hidden register: %d\n", err);
2422 return false;
2423 }
2424 if (val != 0x01c0)
2425 return false;
2426 }
2427
2428 return true;
2429}
2430
2431/* The 6390 copper ports have an errata which require poking magic
2432 * values into undocumented hidden registers and then performing a
2433 * software reset.
2434 */
2435static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2436{
2437 int port;
2438 int err;
2439
2440 if (mv88e6390_setup_errata_applied(chip))
2441 return 0;
2442
2443 /* Set the ports into blocking mode */
2444 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2445 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2446 if (err)
2447 return err;
2448 }
2449
2450 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2451 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2452 if (err)
2453 return err;
2454 }
2455
2456 return mv88e6xxx_software_reset(chip);
2457}
2458
Vivien Didelotf81ec902016-05-09 13:22:58 -04002459static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002460{
Vivien Didelot04bed142016-08-31 18:06:13 -04002461 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002462 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002463 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002464 int i;
2465
Vivien Didelotfad09c72016-06-21 12:28:20 -04002466 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002467 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002468
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002469 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002470
Andrew Lunnea890982019-01-09 00:24:03 +01002471 if (chip->info->ops->setup_errata) {
2472 err = chip->info->ops->setup_errata(chip);
2473 if (err)
2474 goto unlock;
2475 }
2476
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002477 /* Cache the cmode of each port. */
2478 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2479 if (chip->info->ops->port_get_cmode) {
2480 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2481 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002482 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002483
2484 chip->ports[i].cmode = cmode;
2485 }
2486 }
2487
Vivien Didelot97299342016-07-18 20:45:30 -04002488 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002489 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002490 /* Prevent the use of an invalid port. */
2491 if (mv88e6xxx_is_invalid_port(chip, i) &&
2492 !dsa_is_unused_port(ds, i)) {
2493 dev_err(chip->dev, "port %d is invalid\n", i);
2494 err = -EINVAL;
2495 goto unlock;
2496 }
2497
Andrew Lunn100a9b92019-05-01 00:08:31 +02002498 if (dsa_is_unused_port(ds, i)) {
2499 err = mv88e6xxx_port_set_state(chip, i,
2500 BR_STATE_DISABLED);
2501 if (err)
2502 goto unlock;
2503
2504 err = mv88e6xxx_serdes_power(chip, i, false);
2505 if (err)
2506 goto unlock;
2507
Vivien Didelot91dee142017-10-26 11:22:52 -04002508 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002509 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002510
Vivien Didelot97299342016-07-18 20:45:30 -04002511 err = mv88e6xxx_setup_port(chip, i);
2512 if (err)
2513 goto unlock;
2514 }
2515
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002516 err = mv88e6xxx_irl_setup(chip);
2517 if (err)
2518 goto unlock;
2519
Vivien Didelot04a69a12017-10-13 14:18:05 -04002520 err = mv88e6xxx_mac_setup(chip);
2521 if (err)
2522 goto unlock;
2523
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002524 err = mv88e6xxx_phy_setup(chip);
2525 if (err)
2526 goto unlock;
2527
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002528 err = mv88e6xxx_vtu_setup(chip);
2529 if (err)
2530 goto unlock;
2531
Vivien Didelot81228992017-03-30 17:37:08 -04002532 err = mv88e6xxx_pvt_setup(chip);
2533 if (err)
2534 goto unlock;
2535
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002536 err = mv88e6xxx_atu_setup(chip);
2537 if (err)
2538 goto unlock;
2539
Andrew Lunn87fa8862017-11-09 22:29:56 +01002540 err = mv88e6xxx_broadcast_setup(chip, 0);
2541 if (err)
2542 goto unlock;
2543
Vivien Didelot9e907d72017-07-17 13:03:43 -04002544 err = mv88e6xxx_pot_setup(chip);
2545 if (err)
2546 goto unlock;
2547
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002548 err = mv88e6xxx_rmu_setup(chip);
2549 if (err)
2550 goto unlock;
2551
Vivien Didelot51c901a2017-07-17 13:03:41 -04002552 err = mv88e6xxx_rsvd2cpu_setup(chip);
2553 if (err)
2554 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002555
Vivien Didelotb28f8722018-04-26 21:56:44 -04002556 err = mv88e6xxx_trunk_setup(chip);
2557 if (err)
2558 goto unlock;
2559
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002560 err = mv88e6xxx_devmap_setup(chip);
2561 if (err)
2562 goto unlock;
2563
Vivien Didelot93e18d62018-05-11 17:16:35 -04002564 err = mv88e6xxx_pri_setup(chip);
2565 if (err)
2566 goto unlock;
2567
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002568 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002569 if (chip->info->ptp_support) {
2570 err = mv88e6xxx_ptp_setup(chip);
2571 if (err)
2572 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002573
2574 err = mv88e6xxx_hwtstamp_setup(chip);
2575 if (err)
2576 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002577 }
2578
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002579 err = mv88e6xxx_stats_setup(chip);
2580 if (err)
2581 goto unlock;
2582
Vivien Didelot6b17e862015-08-13 12:52:18 -04002583unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002584 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002585
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002586 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002587}
2588
Vivien Didelote57e5e72016-08-15 17:19:00 -04002589static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002590{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002591 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2592 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002593 u16 val;
2594 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002595
Andrew Lunnee26a222017-01-24 14:53:48 +01002596 if (!chip->info->ops->phy_read)
2597 return -EOPNOTSUPP;
2598
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002599 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002600 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002601 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002602
Andrew Lunnda9f3302017-02-01 03:40:05 +01002603 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002604 /* Some internal PHYs don't have a model number. */
2605 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2606 /* Then there is the 6165 family. It gets is
2607 * PHYs correct. But it can also have two
2608 * SERDES interfaces in the PHY address
2609 * space. And these don't have a model
2610 * number. But they are not PHYs, so we don't
2611 * want to give them something a PHY driver
2612 * will recognise.
2613 *
2614 * Use the mv88e6390 family model number
2615 * instead, for anything which really could be
2616 * a PHY,
2617 */
2618 if (!(val & 0x3f0))
2619 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002620 }
2621
Vivien Didelote57e5e72016-08-15 17:19:00 -04002622 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002623}
2624
Vivien Didelote57e5e72016-08-15 17:19:00 -04002625static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002626{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002627 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2628 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002629 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002630
Andrew Lunnee26a222017-01-24 14:53:48 +01002631 if (!chip->info->ops->phy_write)
2632 return -EOPNOTSUPP;
2633
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002634 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002635 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002636 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002637
2638 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002639}
2640
Vivien Didelotfad09c72016-06-21 12:28:20 -04002641static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002642 struct device_node *np,
2643 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002644{
2645 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002646 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002647 struct mii_bus *bus;
2648 int err;
2649
Andrew Lunn2510bab2018-02-22 01:51:49 +01002650 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002651 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002652 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002653 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002654
2655 if (err)
2656 return err;
2657 }
2658
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002659 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002660 if (!bus)
2661 return -ENOMEM;
2662
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002663 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002664 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002665 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002666 INIT_LIST_HEAD(&mdio_bus->list);
2667 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002668
Andrew Lunnb516d452016-06-04 21:17:06 +02002669 if (np) {
2670 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002671 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002672 } else {
2673 bus->name = "mv88e6xxx SMI";
2674 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2675 }
2676
2677 bus->read = mv88e6xxx_mdio_read;
2678 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002679 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002680
Andrew Lunn6f882842018-03-17 20:32:05 +01002681 if (!external) {
2682 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2683 if (err)
2684 return err;
2685 }
2686
Florian Fainelli00e798c2018-05-15 16:56:19 -07002687 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002688 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002689 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002690 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002691 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002692 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002693
2694 if (external)
2695 list_add_tail(&mdio_bus->list, &chip->mdios);
2696 else
2697 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002698
2699 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002700}
2701
Andrew Lunna3c53be52017-01-24 14:53:50 +01002702static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2703 { .compatible = "marvell,mv88e6xxx-mdio-external",
2704 .data = (void *)true },
2705 { },
2706};
2707
Andrew Lunn3126aee2017-12-07 01:05:57 +01002708static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2709
2710{
2711 struct mv88e6xxx_mdio_bus *mdio_bus;
2712 struct mii_bus *bus;
2713
2714 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2715 bus = mdio_bus->bus;
2716
Andrew Lunn6f882842018-03-17 20:32:05 +01002717 if (!mdio_bus->external)
2718 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2719
Andrew Lunn3126aee2017-12-07 01:05:57 +01002720 mdiobus_unregister(bus);
2721 }
2722}
2723
Andrew Lunna3c53be52017-01-24 14:53:50 +01002724static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2725 struct device_node *np)
2726{
2727 const struct of_device_id *match;
2728 struct device_node *child;
2729 int err;
2730
2731 /* Always register one mdio bus for the internal/default mdio
2732 * bus. This maybe represented in the device tree, but is
2733 * optional.
2734 */
2735 child = of_get_child_by_name(np, "mdio");
2736 err = mv88e6xxx_mdio_register(chip, child, false);
2737 if (err)
2738 return err;
2739
2740 /* Walk the device tree, and see if there are any other nodes
2741 * which say they are compatible with the external mdio
2742 * bus.
2743 */
2744 for_each_available_child_of_node(np, child) {
2745 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2746 if (match) {
2747 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002748 if (err) {
2749 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002750 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002751 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002752 }
2753 }
2754
2755 return 0;
2756}
2757
Vivien Didelot855b1932016-07-20 18:18:35 -04002758static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2759{
Vivien Didelot04bed142016-08-31 18:06:13 -04002760 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002761
2762 return chip->eeprom_len;
2763}
2764
Vivien Didelot855b1932016-07-20 18:18:35 -04002765static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2766 struct ethtool_eeprom *eeprom, u8 *data)
2767{
Vivien Didelot04bed142016-08-31 18:06:13 -04002768 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002769 int err;
2770
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002771 if (!chip->info->ops->get_eeprom)
2772 return -EOPNOTSUPP;
2773
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002774 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002775 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002776 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002777
2778 if (err)
2779 return err;
2780
2781 eeprom->magic = 0xc3ec4951;
2782
2783 return 0;
2784}
2785
Vivien Didelot855b1932016-07-20 18:18:35 -04002786static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2787 struct ethtool_eeprom *eeprom, u8 *data)
2788{
Vivien Didelot04bed142016-08-31 18:06:13 -04002789 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002790 int err;
2791
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002792 if (!chip->info->ops->set_eeprom)
2793 return -EOPNOTSUPP;
2794
Vivien Didelot855b1932016-07-20 18:18:35 -04002795 if (eeprom->magic != 0xc3ec4951)
2796 return -EINVAL;
2797
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002798 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002799 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002800 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002801
2802 return err;
2803}
2804
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002805static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002806 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002807 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2808 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002809 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002810 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002811 .phy_read = mv88e6185_phy_ppu_read,
2812 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002813 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002814 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002815 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002816 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002817 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002818 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002819 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002820 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002821 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002822 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002823 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002824 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002825 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002827 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002828 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002829 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2830 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002831 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002832 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2833 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002834 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002835 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002837 .ppu_enable = mv88e6185_g1_ppu_enable,
2838 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002839 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002840 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002841 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002842 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002843 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002844};
2845
2846static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002847 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002848 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2849 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002850 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002851 .phy_read = mv88e6185_phy_ppu_read,
2852 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002853 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002854 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002855 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002856 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002857 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002858 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002859 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002860 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002861 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002862 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002863 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002864 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2865 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002866 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002867 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002868 .ppu_enable = mv88e6185_g1_ppu_enable,
2869 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002870 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002871 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002872 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002873 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002874};
2875
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002876static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002877 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002878 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2879 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002880 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002881 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2882 .phy_read = mv88e6xxx_g2_smi_phy_read,
2883 .phy_write = mv88e6xxx_g2_smi_phy_write,
2884 .port_set_link = mv88e6xxx_port_set_link,
2885 .port_set_duplex = mv88e6xxx_port_set_duplex,
2886 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002887 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002888 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002889 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002890 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002891 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002892 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002893 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002894 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002895 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002896 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002897 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002898 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002899 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002900 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002901 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2902 .stats_get_strings = mv88e6095_stats_get_strings,
2903 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002904 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2905 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002906 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002907 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002908 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002909 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002910 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002911 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002912 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002913 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002914};
2915
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002916static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002917 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002918 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2919 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002920 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002921 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002922 .phy_read = mv88e6xxx_g2_smi_phy_read,
2923 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002924 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002925 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002926 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002927 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002928 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002929 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002930 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002931 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002932 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002933 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002934 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002935 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002936 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2937 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002938 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002939 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2940 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002941 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002942 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002943 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002944 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002945 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002946 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002947 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002948};
2949
2950static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002951 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002952 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2953 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002954 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002955 .phy_read = mv88e6185_phy_ppu_read,
2956 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002957 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002958 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002959 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002960 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002961 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002962 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002963 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002964 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002965 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002966 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002967 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002968 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002969 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002970 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002971 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002972 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002973 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002974 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2975 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002976 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002977 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2978 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002979 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002980 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002981 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002982 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002983 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002984 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002985 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002986 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002987 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002988};
2989
Vivien Didelot990e27b2017-03-28 13:50:32 -04002990static const struct mv88e6xxx_ops mv88e6141_ops = {
2991 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002992 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2993 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002994 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002995 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2996 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2997 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2998 .phy_read = mv88e6xxx_g2_smi_phy_read,
2999 .phy_write = mv88e6xxx_g2_smi_phy_write,
3000 .port_set_link = mv88e6xxx_port_set_link,
3001 .port_set_duplex = mv88e6xxx_port_set_duplex,
3002 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003003 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003004 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003005 .port_tag_remap = mv88e6095_port_tag_remap,
3006 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3007 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3008 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003009 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003010 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003011 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003012 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3013 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003014 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003015 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003016 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003017 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003018 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003019 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3020 .stats_get_strings = mv88e6320_stats_get_strings,
3021 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003022 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3023 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003024 .watchdog_ops = &mv88e6390_watchdog_ops,
3025 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003026 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003027 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003028 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003029 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003030 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003031 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003032 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003033};
3034
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003035static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003036 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003037 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3038 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003039 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003040 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003041 .phy_read = mv88e6xxx_g2_smi_phy_read,
3042 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003043 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003044 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003045 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003046 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003047 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003048 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003049 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003050 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003051 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003052 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003053 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003054 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003055 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003056 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003057 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003058 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003059 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003060 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3061 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003062 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003063 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3064 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003065 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003066 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003067 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003068 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003069 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003070 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003071 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003072 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003073 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003074};
3075
3076static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003077 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003078 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3079 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003080 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003081 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003082 .phy_read = mv88e6165_phy_read,
3083 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003084 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003085 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003086 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003087 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003088 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003089 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003090 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003091 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003092 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003093 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003094 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3095 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003096 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003097 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3098 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003099 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003100 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003101 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003102 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003103 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003104 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003105 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003106 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003107 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003108};
3109
3110static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003111 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003112 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3113 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003114 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003115 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003116 .phy_read = mv88e6xxx_g2_smi_phy_read,
3117 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003118 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003119 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003120 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003121 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003122 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003123 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003124 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003125 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003126 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003127 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003128 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003129 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003130 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003131 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003132 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003133 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003134 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003135 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003136 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3137 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003138 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003139 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3140 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003141 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003142 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003143 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003144 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003145 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003146 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003147 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003148};
3149
3150static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003151 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003152 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3153 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003154 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003155 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3156 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003157 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003158 .phy_read = mv88e6xxx_g2_smi_phy_read,
3159 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003160 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003161 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003162 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003163 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003164 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003165 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003166 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003167 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003168 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003169 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003170 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003171 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003172 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003173 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003174 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003175 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003176 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003177 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003178 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3179 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003180 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003181 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3182 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003183 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003184 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003185 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003186 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003187 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003188 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003189 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003190 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003191 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003192 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003193};
3194
3195static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003196 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003197 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3198 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003199 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003200 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003201 .phy_read = mv88e6xxx_g2_smi_phy_read,
3202 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003203 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003204 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003205 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003206 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003207 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003208 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003209 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003210 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003211 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003212 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003213 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003214 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003215 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003216 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003217 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003218 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003219 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003220 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003221 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3222 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003223 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003224 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3225 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003226 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003227 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003228 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003229 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003230 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003231 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003232 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003233};
3234
3235static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003236 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003237 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3238 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003239 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003240 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3241 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003242 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003243 .phy_read = mv88e6xxx_g2_smi_phy_read,
3244 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003245 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003246 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003247 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003248 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003249 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003250 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003251 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003252 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003253 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003254 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003255 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003256 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003257 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003258 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003259 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003260 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003261 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003262 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003263 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3264 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003265 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003266 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3267 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003268 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003269 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003270 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003271 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003272 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003273 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003274 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003275 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003276 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3277 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003278 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003279 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003280};
3281
3282static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003283 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003284 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3285 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003286 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003287 .phy_read = mv88e6185_phy_ppu_read,
3288 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003289 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003290 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003291 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003292 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003293 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003294 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003295 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003296 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003297 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003298 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003299 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003300 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003301 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003302 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3303 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003304 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003305 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3306 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003307 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003308 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003309 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003310 .ppu_enable = mv88e6185_g1_ppu_enable,
3311 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003312 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003313 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003314 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003315 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003316};
3317
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003318static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003319 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003320 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003321 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003322 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3323 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003324 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3325 .phy_read = mv88e6xxx_g2_smi_phy_read,
3326 .phy_write = mv88e6xxx_g2_smi_phy_write,
3327 .port_set_link = mv88e6xxx_port_set_link,
3328 .port_set_duplex = mv88e6xxx_port_set_duplex,
3329 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3330 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003331 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003332 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003333 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003334 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003335 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003336 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003337 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003338 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003339 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003340 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003341 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003342 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003343 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003344 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003345 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3346 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003347 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003348 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3349 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003350 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003351 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003352 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003353 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003354 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003355 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3356 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003357 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003358 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3359 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003360 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003361 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003362};
3363
3364static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003365 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003366 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003367 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003368 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3369 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003370 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3371 .phy_read = mv88e6xxx_g2_smi_phy_read,
3372 .phy_write = mv88e6xxx_g2_smi_phy_write,
3373 .port_set_link = mv88e6xxx_port_set_link,
3374 .port_set_duplex = mv88e6xxx_port_set_duplex,
3375 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3376 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003377 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003378 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003379 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003380 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003381 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003382 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003383 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003384 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003385 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003386 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003387 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003388 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003389 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003390 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003391 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3392 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003393 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003394 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3395 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003396 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003397 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003398 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003399 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003400 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003401 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3402 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003403 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003404 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3405 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003406 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003407 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003408};
3409
3410static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003411 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003412 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003413 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003414 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3415 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003416 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3417 .phy_read = mv88e6xxx_g2_smi_phy_read,
3418 .phy_write = mv88e6xxx_g2_smi_phy_write,
3419 .port_set_link = mv88e6xxx_port_set_link,
3420 .port_set_duplex = mv88e6xxx_port_set_duplex,
3421 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3422 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003423 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003424 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003425 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003426 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003427 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003428 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003429 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003430 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003431 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003432 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003433 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003434 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003435 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003436 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003437 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3438 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003439 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003440 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3441 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003442 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003443 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003444 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003445 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003446 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003447 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3448 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003449 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003450 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3451 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003452 .avb_ops = &mv88e6390_avb_ops,
3453 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003454 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003455};
3456
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003457static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003458 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003459 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3460 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003461 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003462 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3463 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003464 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003465 .phy_read = mv88e6xxx_g2_smi_phy_read,
3466 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003467 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003468 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003469 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003470 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003471 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003472 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003473 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003474 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003475 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003476 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003477 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003478 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003479 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003480 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003481 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003482 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003483 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003484 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003485 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3486 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003487 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003488 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3489 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003490 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003491 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003492 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003493 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003494 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003495 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003496 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003497 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003498 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3499 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003500 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003501 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003502 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003503 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003504};
3505
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003506static const struct mv88e6xxx_ops mv88e6250_ops = {
3507 /* MV88E6XXX_FAMILY_6250 */
3508 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3509 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3510 .irl_init_all = mv88e6352_g2_irl_init_all,
3511 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3512 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3513 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3514 .phy_read = mv88e6xxx_g2_smi_phy_read,
3515 .phy_write = mv88e6xxx_g2_smi_phy_write,
3516 .port_set_link = mv88e6xxx_port_set_link,
3517 .port_set_duplex = mv88e6xxx_port_set_duplex,
3518 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3519 .port_set_speed = mv88e6250_port_set_speed,
3520 .port_tag_remap = mv88e6095_port_tag_remap,
3521 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3522 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3523 .port_set_ether_type = mv88e6351_port_set_ether_type,
3524 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3525 .port_pause_limit = mv88e6097_port_pause_limit,
3526 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3527 .port_link_state = mv88e6250_port_link_state,
3528 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3529 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3530 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3531 .stats_get_strings = mv88e6250_stats_get_strings,
3532 .stats_get_stats = mv88e6250_stats_get_stats,
3533 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3534 .set_egress_port = mv88e6095_g1_set_egress_port,
3535 .watchdog_ops = &mv88e6250_watchdog_ops,
3536 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3537 .pot_clear = mv88e6xxx_g2_pot_clear,
3538 .reset = mv88e6250_g1_reset,
3539 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3540 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
3541 .phylink_validate = mv88e6065_phylink_validate,
3542};
3543
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003544static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003545 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003546 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003547 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003548 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3549 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003550 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3551 .phy_read = mv88e6xxx_g2_smi_phy_read,
3552 .phy_write = mv88e6xxx_g2_smi_phy_write,
3553 .port_set_link = mv88e6xxx_port_set_link,
3554 .port_set_duplex = mv88e6xxx_port_set_duplex,
3555 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3556 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003557 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003558 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003559 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003560 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003561 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003562 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003563 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003564 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003565 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003566 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003567 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003568 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003569 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003570 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003571 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3572 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003573 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003574 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3575 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003576 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003577 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003578 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003579 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003580 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003581 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3582 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003583 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003584 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3585 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003586 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003587 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003588 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003589 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003590};
3591
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003592static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003593 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003594 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3595 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003596 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003597 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3598 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003599 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003600 .phy_read = mv88e6xxx_g2_smi_phy_read,
3601 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003602 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003603 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003604 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003605 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003606 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003607 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003608 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003609 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003610 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003611 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003612 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003613 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003614 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003615 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003616 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003617 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003618 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003619 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3620 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003621 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003622 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3623 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003624 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003625 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003626 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003627 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003628 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003629 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003630 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003631 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003632 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003633 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003634};
3635
3636static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003637 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003638 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3639 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003640 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003641 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3642 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003643 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003644 .phy_read = mv88e6xxx_g2_smi_phy_read,
3645 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003646 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003647 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003648 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003649 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003650 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003651 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003652 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003653 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003654 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003655 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003656 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003657 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003658 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003659 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003660 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003661 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003662 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003663 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3664 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003665 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003666 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3667 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003668 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003669 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003670 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003671 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003672 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003673 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003674 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003675 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003676};
3677
Vivien Didelot16e329a2017-03-28 13:50:33 -04003678static const struct mv88e6xxx_ops mv88e6341_ops = {
3679 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003680 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3681 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003682 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003683 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3684 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3685 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3686 .phy_read = mv88e6xxx_g2_smi_phy_read,
3687 .phy_write = mv88e6xxx_g2_smi_phy_write,
3688 .port_set_link = mv88e6xxx_port_set_link,
3689 .port_set_duplex = mv88e6xxx_port_set_duplex,
3690 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003691 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003692 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003693 .port_tag_remap = mv88e6095_port_tag_remap,
3694 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3695 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3696 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003697 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003698 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003699 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003700 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3701 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003702 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003703 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003704 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003705 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003706 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003707 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3708 .stats_get_strings = mv88e6320_stats_get_strings,
3709 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003710 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3711 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003712 .watchdog_ops = &mv88e6390_watchdog_ops,
3713 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003714 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003715 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003716 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003717 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003718 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003719 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003720 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003721 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003722 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003723};
3724
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003725static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003726 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003727 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3728 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003729 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003730 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003731 .phy_read = mv88e6xxx_g2_smi_phy_read,
3732 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003733 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003734 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003735 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003736 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003737 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003738 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003739 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003740 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003741 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003742 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003743 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003744 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003745 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003746 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003747 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003748 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003749 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003750 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003751 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3752 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003753 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003754 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3755 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003756 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003757 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003758 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003759 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003760 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003761 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003762 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003763};
3764
3765static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003766 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003767 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3768 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003769 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003770 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003771 .phy_read = mv88e6xxx_g2_smi_phy_read,
3772 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003773 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003774 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003775 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003776 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003777 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003778 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003779 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003780 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003781 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003782 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003783 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003784 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003785 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003786 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003787 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003788 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003789 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003790 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003791 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3792 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003793 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003794 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3795 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003796 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003797 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003798 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003799 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003800 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003801 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003802 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003803 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003804 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003805};
3806
3807static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003808 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003809 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3810 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003811 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003812 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3813 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003814 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003815 .phy_read = mv88e6xxx_g2_smi_phy_read,
3816 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003817 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003818 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003819 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003820 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003821 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003822 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003823 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003824 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003825 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003826 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003827 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003828 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003829 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003830 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003831 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003832 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003833 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003834 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003835 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3836 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003837 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003838 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3839 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003840 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003841 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003842 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003843 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003844 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003845 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003846 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003847 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003848 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3849 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003850 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003851 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003852 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003853 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3854 .serdes_get_strings = mv88e6352_serdes_get_strings,
3855 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003856 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003857};
3858
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003859static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003860 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003861 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003862 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003863 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3864 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003865 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3866 .phy_read = mv88e6xxx_g2_smi_phy_read,
3867 .phy_write = mv88e6xxx_g2_smi_phy_write,
3868 .port_set_link = mv88e6xxx_port_set_link,
3869 .port_set_duplex = mv88e6xxx_port_set_duplex,
3870 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3871 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003872 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003873 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003874 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003875 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003876 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003877 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003878 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003879 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003880 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003881 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003882 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003883 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003884 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003885 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003886 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003887 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003888 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3889 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003890 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003891 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3892 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003893 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003894 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003895 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003896 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003897 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003898 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3899 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003900 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003901 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3902 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003903 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003904 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003905 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003906 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003907};
3908
3909static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003910 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003911 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003912 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003913 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3914 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003915 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3916 .phy_read = mv88e6xxx_g2_smi_phy_read,
3917 .phy_write = mv88e6xxx_g2_smi_phy_write,
3918 .port_set_link = mv88e6xxx_port_set_link,
3919 .port_set_duplex = mv88e6xxx_port_set_duplex,
3920 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3921 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003922 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003923 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003924 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003925 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003926 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003927 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003928 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003929 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003930 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003931 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003932 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003933 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003934 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003935 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003936 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003937 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003938 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3939 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003940 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003941 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3942 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003943 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003944 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003945 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003946 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003947 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003948 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3949 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003950 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003951 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3952 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003953 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003954 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003955 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003956 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003957};
3958
Vivien Didelotf81ec902016-05-09 13:22:58 -04003959static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3960 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003961 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003962 .family = MV88E6XXX_FAMILY_6097,
3963 .name = "Marvell 88E6085",
3964 .num_databases = 4096,
3965 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003966 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003967 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003968 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003969 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003970 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003971 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003972 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003973 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003974 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003975 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003976 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003977 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003978 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003979 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003980 },
3981
3982 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003983 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 .family = MV88E6XXX_FAMILY_6095,
3985 .name = "Marvell 88E6095/88E6095F",
3986 .num_databases = 256,
3987 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003988 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003989 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003990 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003991 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003992 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003993 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003994 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003995 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003996 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003997 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003998 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003999 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004000 },
4001
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004002 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004003 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004004 .family = MV88E6XXX_FAMILY_6097,
4005 .name = "Marvell 88E6097/88E6097F",
4006 .num_databases = 4096,
4007 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004008 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004009 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004010 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004011 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004012 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004013 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004014 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004015 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004016 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004017 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004018 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004019 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004020 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004021 .ops = &mv88e6097_ops,
4022 },
4023
Vivien Didelotf81ec902016-05-09 13:22:58 -04004024 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004025 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004026 .family = MV88E6XXX_FAMILY_6165,
4027 .name = "Marvell 88E6123",
4028 .num_databases = 4096,
4029 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004030 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004031 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004032 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004033 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004034 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004035 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004036 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004037 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004038 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004039 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004040 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004041 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004042 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004043 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004044 },
4045
4046 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004047 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004048 .family = MV88E6XXX_FAMILY_6185,
4049 .name = "Marvell 88E6131",
4050 .num_databases = 256,
4051 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004052 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004053 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004054 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004055 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004056 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004057 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004058 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004059 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004060 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004061 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004062 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004063 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004064 },
4065
Vivien Didelot990e27b2017-03-28 13:50:32 -04004066 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004067 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004068 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004069 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004070 .num_databases = 4096,
4071 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004072 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004073 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004074 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004075 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004076 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004077 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004078 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004079 .age_time_coeff = 3750,
4080 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004081 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004082 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004083 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004084 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004085 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004086 .ops = &mv88e6141_ops,
4087 },
4088
Vivien Didelotf81ec902016-05-09 13:22:58 -04004089 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004090 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004091 .family = MV88E6XXX_FAMILY_6165,
4092 .name = "Marvell 88E6161",
4093 .num_databases = 4096,
4094 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004095 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004096 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004097 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004098 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004099 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004100 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004101 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004102 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004103 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004104 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004105 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004106 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004107 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004108 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004109 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004110 },
4111
4112 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004113 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004114 .family = MV88E6XXX_FAMILY_6165,
4115 .name = "Marvell 88E6165",
4116 .num_databases = 4096,
4117 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004118 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004119 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004120 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004121 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004122 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004123 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004124 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004125 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004126 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004127 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004128 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004129 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004130 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004131 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004132 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004133 },
4134
4135 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004136 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004137 .family = MV88E6XXX_FAMILY_6351,
4138 .name = "Marvell 88E6171",
4139 .num_databases = 4096,
4140 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004141 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004142 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004143 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004144 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004145 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004146 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004147 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004148 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004149 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004150 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004151 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004152 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004153 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004154 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004155 },
4156
4157 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004158 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004159 .family = MV88E6XXX_FAMILY_6352,
4160 .name = "Marvell 88E6172",
4161 .num_databases = 4096,
4162 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004163 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004164 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004165 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004166 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004167 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004168 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004169 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004170 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004171 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004172 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004173 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004174 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004175 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004176 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004177 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004178 },
4179
4180 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004181 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004182 .family = MV88E6XXX_FAMILY_6351,
4183 .name = "Marvell 88E6175",
4184 .num_databases = 4096,
4185 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004186 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004187 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004188 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004189 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004190 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004191 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004192 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004193 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004194 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004195 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004196 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004197 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004198 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004199 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004200 },
4201
4202 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004203 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004204 .family = MV88E6XXX_FAMILY_6352,
4205 .name = "Marvell 88E6176",
4206 .num_databases = 4096,
4207 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004208 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004209 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004210 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004211 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004212 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004213 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004214 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004215 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004216 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004217 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004218 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004219 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004220 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004221 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004222 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004223 },
4224
4225 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004226 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004227 .family = MV88E6XXX_FAMILY_6185,
4228 .name = "Marvell 88E6185",
4229 .num_databases = 256,
4230 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004231 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004232 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004233 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004234 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004235 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004236 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004237 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004238 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004239 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004240 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004241 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004242 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004243 },
4244
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004245 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004246 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004247 .family = MV88E6XXX_FAMILY_6390,
4248 .name = "Marvell 88E6190",
4249 .num_databases = 4096,
4250 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004251 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004252 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004253 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004254 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004255 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004256 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004257 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004258 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004259 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004260 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004261 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004262 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004263 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004264 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004265 .ops = &mv88e6190_ops,
4266 },
4267
4268 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004269 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004270 .family = MV88E6XXX_FAMILY_6390,
4271 .name = "Marvell 88E6190X",
4272 .num_databases = 4096,
4273 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004274 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004275 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004276 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004277 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004278 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004279 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004280 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004281 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004282 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004283 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004284 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004285 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004286 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004287 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004288 .ops = &mv88e6190x_ops,
4289 },
4290
4291 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004292 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004293 .family = MV88E6XXX_FAMILY_6390,
4294 .name = "Marvell 88E6191",
4295 .num_databases = 4096,
4296 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004297 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004298 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004299 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004300 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004301 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004302 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004303 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004304 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004305 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004306 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004307 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004308 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004309 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004310 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004311 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004312 },
4313
Hubert Feurstein49022642019-07-31 10:23:46 +02004314 [MV88E6220] = {
4315 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4316 .family = MV88E6XXX_FAMILY_6250,
4317 .name = "Marvell 88E6220",
4318 .num_databases = 64,
4319
4320 /* Ports 2-4 are not routed to pins
4321 * => usable ports 0, 1, 5, 6
4322 */
4323 .num_ports = 7,
4324 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004325 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004326 .max_vid = 4095,
4327 .port_base_addr = 0x08,
4328 .phy_base_addr = 0x00,
4329 .global1_addr = 0x0f,
4330 .global2_addr = 0x07,
4331 .age_time_coeff = 15000,
4332 .g1_irqs = 9,
4333 .g2_irqs = 10,
4334 .atu_move_port_mask = 0xf,
4335 .dual_chip = true,
4336 .tag_protocol = DSA_TAG_PROTO_DSA,
4337 .ops = &mv88e6250_ops,
4338 },
4339
Vivien Didelotf81ec902016-05-09 13:22:58 -04004340 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004341 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004342 .family = MV88E6XXX_FAMILY_6352,
4343 .name = "Marvell 88E6240",
4344 .num_databases = 4096,
4345 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004346 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004347 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004348 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004349 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004350 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004351 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004352 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004353 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004354 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004355 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004356 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004357 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004358 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004359 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004360 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004361 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004362 },
4363
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004364 [MV88E6250] = {
4365 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4366 .family = MV88E6XXX_FAMILY_6250,
4367 .name = "Marvell 88E6250",
4368 .num_databases = 64,
4369 .num_ports = 7,
4370 .num_internal_phys = 5,
4371 .max_vid = 4095,
4372 .port_base_addr = 0x08,
4373 .phy_base_addr = 0x00,
4374 .global1_addr = 0x0f,
4375 .global2_addr = 0x07,
4376 .age_time_coeff = 15000,
4377 .g1_irqs = 9,
4378 .g2_irqs = 10,
4379 .atu_move_port_mask = 0xf,
4380 .dual_chip = true,
4381 .tag_protocol = DSA_TAG_PROTO_DSA,
4382 .ops = &mv88e6250_ops,
4383 },
4384
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004385 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004386 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004387 .family = MV88E6XXX_FAMILY_6390,
4388 .name = "Marvell 88E6290",
4389 .num_databases = 4096,
4390 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004391 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004392 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004393 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004394 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004395 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004396 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004397 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004398 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004399 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004400 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004401 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004402 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004403 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004404 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004405 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004406 .ops = &mv88e6290_ops,
4407 },
4408
Vivien Didelotf81ec902016-05-09 13:22:58 -04004409 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004410 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004411 .family = MV88E6XXX_FAMILY_6320,
4412 .name = "Marvell 88E6320",
4413 .num_databases = 4096,
4414 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004415 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004416 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004417 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004418 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004419 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004420 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004421 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004422 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004423 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004424 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004425 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004426 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004427 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004428 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004429 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004430 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004431 },
4432
4433 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004434 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004435 .family = MV88E6XXX_FAMILY_6320,
4436 .name = "Marvell 88E6321",
4437 .num_databases = 4096,
4438 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004439 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004440 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004441 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004442 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004443 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004444 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004445 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004446 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004447 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004448 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004449 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004450 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004451 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004452 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004453 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004454 },
4455
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004456 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004457 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004458 .family = MV88E6XXX_FAMILY_6341,
4459 .name = "Marvell 88E6341",
4460 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004461 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004462 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004463 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004464 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004465 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004466 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004467 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004468 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004469 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004470 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004471 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004472 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004473 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004474 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004475 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004476 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004477 .ops = &mv88e6341_ops,
4478 },
4479
Vivien Didelotf81ec902016-05-09 13:22:58 -04004480 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004481 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004482 .family = MV88E6XXX_FAMILY_6351,
4483 .name = "Marvell 88E6350",
4484 .num_databases = 4096,
4485 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004486 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004487 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004488 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004489 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004490 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004491 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004492 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004493 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004494 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004495 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004496 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004497 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004498 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004499 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004500 },
4501
4502 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004503 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004504 .family = MV88E6XXX_FAMILY_6351,
4505 .name = "Marvell 88E6351",
4506 .num_databases = 4096,
4507 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004508 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004509 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004510 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004511 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004512 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004513 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004514 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004515 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004516 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004517 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004518 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004519 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004520 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004521 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004522 },
4523
4524 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004525 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004526 .family = MV88E6XXX_FAMILY_6352,
4527 .name = "Marvell 88E6352",
4528 .num_databases = 4096,
4529 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004530 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004531 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004532 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004533 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004534 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004535 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004536 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004537 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004538 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004539 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004540 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004541 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004542 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004543 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004544 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004545 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004546 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004547 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004548 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004549 .family = MV88E6XXX_FAMILY_6390,
4550 .name = "Marvell 88E6390",
4551 .num_databases = 4096,
4552 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004553 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004554 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004555 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004556 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004557 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004558 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004559 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004560 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004561 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004562 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004563 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004564 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004565 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004566 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004567 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004568 .ops = &mv88e6390_ops,
4569 },
4570 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004571 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004572 .family = MV88E6XXX_FAMILY_6390,
4573 .name = "Marvell 88E6390X",
4574 .num_databases = 4096,
4575 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004576 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004577 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004578 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004579 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004580 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004581 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004582 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004583 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004584 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004585 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004586 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004587 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004588 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004589 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004590 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004591 .ops = &mv88e6390x_ops,
4592 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004593};
4594
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004595static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004596{
Vivien Didelota439c062016-04-17 13:23:58 -04004597 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004598
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004599 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4600 if (mv88e6xxx_table[i].prod_num == prod_num)
4601 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004602
Vivien Didelotb9b37712015-10-30 19:39:48 -04004603 return NULL;
4604}
4605
Vivien Didelotfad09c72016-06-21 12:28:20 -04004606static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004607{
4608 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004609 unsigned int prod_num, rev;
4610 u16 id;
4611 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004612
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004613 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004614 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004615 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004616 if (err)
4617 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004618
Vivien Didelot107fcc12017-06-12 12:37:36 -04004619 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4620 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004621
4622 info = mv88e6xxx_lookup_info(prod_num);
4623 if (!info)
4624 return -ENODEV;
4625
Vivien Didelotcaac8542016-06-20 13:14:09 -04004626 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004627 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004628
Vivien Didelotca070c12016-09-02 14:45:34 -04004629 err = mv88e6xxx_g2_require(chip);
4630 if (err)
4631 return err;
4632
Vivien Didelotfad09c72016-06-21 12:28:20 -04004633 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4634 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004635
4636 return 0;
4637}
4638
Vivien Didelotfad09c72016-06-21 12:28:20 -04004639static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004640{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004641 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004642
Vivien Didelotfad09c72016-06-21 12:28:20 -04004643 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4644 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004645 return NULL;
4646
Vivien Didelotfad09c72016-06-21 12:28:20 -04004647 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004648
Vivien Didelotfad09c72016-06-21 12:28:20 -04004649 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004650 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004651
Vivien Didelotfad09c72016-06-21 12:28:20 -04004652 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004653}
4654
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004655static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4656 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004657{
Vivien Didelot04bed142016-08-31 18:06:13 -04004658 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004659
Andrew Lunn443d5a12016-12-03 04:35:18 +01004660 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004661}
4662
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004663static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004664 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004665{
4666 /* We don't need any dynamic resource from the kernel (yet),
4667 * so skip the prepare phase.
4668 */
4669
4670 return 0;
4671}
4672
4673static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004674 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004675{
Vivien Didelot04bed142016-08-31 18:06:13 -04004676 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004677
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004678 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004679 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004680 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004681 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4682 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004683 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004684}
4685
4686static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4687 const struct switchdev_obj_port_mdb *mdb)
4688{
Vivien Didelot04bed142016-08-31 18:06:13 -04004689 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004690 int err;
4691
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004692 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004693 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004694 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004695 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004696
4697 return err;
4698}
4699
Russell King4f859012019-02-20 15:35:05 -08004700static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4701 bool unicast, bool multicast)
4702{
4703 struct mv88e6xxx_chip *chip = ds->priv;
4704 int err = -EOPNOTSUPP;
4705
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004706 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08004707 if (chip->info->ops->port_set_egress_floods)
4708 err = chip->info->ops->port_set_egress_floods(chip, port,
4709 unicast,
4710 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004711 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08004712
4713 return err;
4714}
4715
Florian Fainellia82f67a2017-01-08 14:52:08 -08004716static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004717 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004718 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004719 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004720 .phylink_validate = mv88e6xxx_validate,
4721 .phylink_mac_link_state = mv88e6xxx_link_state,
4722 .phylink_mac_config = mv88e6xxx_mac_config,
4723 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4724 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004725 .get_strings = mv88e6xxx_get_strings,
4726 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4727 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004728 .port_enable = mv88e6xxx_port_enable,
4729 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004730 .get_mac_eee = mv88e6xxx_get_mac_eee,
4731 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004732 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 .get_eeprom = mv88e6xxx_get_eeprom,
4734 .set_eeprom = mv88e6xxx_set_eeprom,
4735 .get_regs_len = mv88e6xxx_get_regs_len,
4736 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004737 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 .port_bridge_join = mv88e6xxx_port_bridge_join,
4739 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004740 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004741 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004742 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004743 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4744 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4745 .port_vlan_add = mv88e6xxx_port_vlan_add,
4746 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 .port_fdb_add = mv88e6xxx_port_fdb_add,
4748 .port_fdb_del = mv88e6xxx_port_fdb_del,
4749 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004750 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4751 .port_mdb_add = mv88e6xxx_port_mdb_add,
4752 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004753 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4754 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004755 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4756 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4757 .port_txtstamp = mv88e6xxx_port_txtstamp,
4758 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4759 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004760};
4761
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004762static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004763{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004764 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004765 struct dsa_switch *ds;
4766
Vivien Didelot73b12042017-03-30 17:37:10 -04004767 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004768 if (!ds)
4769 return -ENOMEM;
4770
Vivien Didelotfad09c72016-06-21 12:28:20 -04004771 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004772 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004773 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004774 ds->ageing_time_min = chip->info->age_time_coeff;
4775 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004776
4777 dev_set_drvdata(dev, ds);
4778
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004779 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004780}
4781
Vivien Didelotfad09c72016-06-21 12:28:20 -04004782static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004783{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004784 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004785}
4786
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004787static const void *pdata_device_get_match_data(struct device *dev)
4788{
4789 const struct of_device_id *matches = dev->driver->of_match_table;
4790 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4791
4792 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4793 matches++) {
4794 if (!strcmp(pdata->compatible, matches->compatible))
4795 return matches->data;
4796 }
4797 return NULL;
4798}
4799
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004800/* There is no suspend to RAM support at DSA level yet, the switch configuration
4801 * would be lost after a power cycle so prevent it to be suspended.
4802 */
4803static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4804{
4805 return -EOPNOTSUPP;
4806}
4807
4808static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4809{
4810 return 0;
4811}
4812
4813static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4814
Vivien Didelot57d32312016-06-20 13:13:58 -04004815static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004816{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004817 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004818 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004819 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004820 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004821 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004822 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004823 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004824
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004825 if (!np && !pdata)
4826 return -EINVAL;
4827
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004828 if (np)
4829 compat_info = of_device_get_match_data(dev);
4830
4831 if (pdata) {
4832 compat_info = pdata_device_get_match_data(dev);
4833
4834 if (!pdata->netdev)
4835 return -EINVAL;
4836
4837 for (port = 0; port < DSA_MAX_PORTS; port++) {
4838 if (!(pdata->enabled_ports & (1 << port)))
4839 continue;
4840 if (strcmp(pdata->cd.port_names[port], "cpu"))
4841 continue;
4842 pdata->cd.netdev[port] = &pdata->netdev->dev;
4843 break;
4844 }
4845 }
4846
Vivien Didelotcaac8542016-06-20 13:14:09 -04004847 if (!compat_info)
4848 return -EINVAL;
4849
Vivien Didelotfad09c72016-06-21 12:28:20 -04004850 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004851 if (!chip) {
4852 err = -ENOMEM;
4853 goto out;
4854 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004855
Vivien Didelotfad09c72016-06-21 12:28:20 -04004856 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004857
Vivien Didelotfad09c72016-06-21 12:28:20 -04004858 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004859 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004860 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004861
Andrew Lunnb4308f02016-11-21 23:26:55 +01004862 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004863 if (IS_ERR(chip->reset)) {
4864 err = PTR_ERR(chip->reset);
4865 goto out;
4866 }
Baruch Siach7b75e492019-06-27 21:17:39 +03004867 if (chip->reset)
4868 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01004869
Vivien Didelotfad09c72016-06-21 12:28:20 -04004870 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004871 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004872 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004873
Vivien Didelote57e5e72016-08-15 17:19:00 -04004874 mv88e6xxx_phy_init(chip);
4875
Andrew Lunn00baabe2018-05-19 22:31:35 +02004876 if (chip->info->ops->get_eeprom) {
4877 if (np)
4878 of_property_read_u32(np, "eeprom-length",
4879 &chip->eeprom_len);
4880 else
4881 chip->eeprom_len = pdata->eeprom_len;
4882 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004883
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004884 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004885 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004886 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02004887 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004888 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004889
Andrew Lunna27415d2019-05-01 00:10:50 +02004890 if (np) {
4891 chip->irq = of_irq_get(np, 0);
4892 if (chip->irq == -EPROBE_DEFER) {
4893 err = chip->irq;
4894 goto out;
4895 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004896 }
4897
Andrew Lunna27415d2019-05-01 00:10:50 +02004898 if (pdata)
4899 chip->irq = pdata->irq;
4900
Andrew Lunn294d7112018-02-22 22:58:32 +01004901 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004902 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004903 * controllers
4904 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004905 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004906 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004907 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004908 else
4909 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004910 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004911
Andrew Lunn294d7112018-02-22 22:58:32 +01004912 if (err)
4913 goto out;
4914
4915 if (chip->info->g2_irqs > 0) {
4916 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004917 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004918 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004919 }
4920
Andrew Lunn294d7112018-02-22 22:58:32 +01004921 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4922 if (err)
4923 goto out_g2_irq;
4924
4925 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4926 if (err)
4927 goto out_g1_atu_prob_irq;
4928
Andrew Lunna3c53be52017-01-24 14:53:50 +01004929 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004930 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004931 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004932
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004933 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004934 if (err)
4935 goto out_mdio;
4936
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004937 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004938
4939out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004940 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004941out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004942 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004943out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004944 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004945out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004946 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004947 mv88e6xxx_g2_irq_free(chip);
4948out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004949 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004950 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004951 else
4952 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004953out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004954 if (pdata)
4955 dev_put(pdata->netdev);
4956
Andrew Lunndc30c352016-10-16 19:56:49 +02004957 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004958}
4959
4960static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4961{
4962 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004963 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004964
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004965 if (chip->info->ptp_support) {
4966 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004967 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004968 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004969
Andrew Lunn930188c2016-08-22 16:01:03 +02004970 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004971 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004972 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004973
Andrew Lunn76f38f12018-03-17 20:21:09 +01004974 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4975 mv88e6xxx_g1_atu_prob_irq_free(chip);
4976
4977 if (chip->info->g2_irqs > 0)
4978 mv88e6xxx_g2_irq_free(chip);
4979
Andrew Lunn76f38f12018-03-17 20:21:09 +01004980 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004981 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004982 else
4983 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004984}
4985
4986static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004987 {
4988 .compatible = "marvell,mv88e6085",
4989 .data = &mv88e6xxx_table[MV88E6085],
4990 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004991 {
4992 .compatible = "marvell,mv88e6190",
4993 .data = &mv88e6xxx_table[MV88E6190],
4994 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004995 {
4996 .compatible = "marvell,mv88e6250",
4997 .data = &mv88e6xxx_table[MV88E6250],
4998 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004999 { /* sentinel */ },
5000};
5001
5002MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5003
5004static struct mdio_driver mv88e6xxx_driver = {
5005 .probe = mv88e6xxx_probe,
5006 .remove = mv88e6xxx_remove,
5007 .mdiodrv.driver = {
5008 .name = "mv88e6085",
5009 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005010 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005011 },
5012};
5013
Andrew Lunn7324d502019-04-27 19:19:10 +02005014mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005015
5016MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5017MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5018MODULE_LICENSE("GPL");