blob: b4bcbb6461e1c8b0de02d882161694b7ea15745e [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
121 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400122 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200123 mutex_unlock(&chip->reg_lock);
124
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
138 mutex_lock(&chip->reg_lock);
139 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:
144 mutex_unlock(&chip->reg_lock);
145 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
165 mutex_lock(&chip->reg_lock);
166}
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:
187 mutex_unlock(&chip->reg_lock);
188}
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
242 mutex_lock(&chip->reg_lock);
243 mv88e6xxx_g1_irq_free_common(chip);
244 mutex_unlock(&chip->reg_lock);
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
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100313 mutex_unlock(&chip->reg_lock);
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);
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100318 mutex_lock(&chip->reg_lock);
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
362 mutex_lock(&chip->reg_lock);
363 mv88e6xxx_g1_irq_free_common(chip);
364 mutex_unlock(&chip->reg_lock);
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
Vivien Didelotfad09c72016-06-21 12:28:20 -0400499 mutex_lock(&chip->reg_lock);
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);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400503 mutex_unlock(&chip->reg_lock);
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
619 mutex_lock(&chip->reg_lock);
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;
Russell Kingc9a23562018-05-10 13:17:35 -0700624 mutex_unlock(&chip->reg_lock);
625
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
654 mutex_lock(&chip->reg_lock);
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);
657 mutex_unlock(&chip->reg_lock);
658
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
668 mutex_lock(&chip->reg_lock);
669 err = chip->info->ops->port_set_link(chip, port, link);
670 mutex_unlock(&chip->reg_lock);
671
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;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200784 high = reg;
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
Andrew Lunn436fe172018-03-01 02:02:29 +0100828static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
829 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100830{
Andrew Lunn436fe172018-03-01 02:02:29 +0100831 return mv88e6xxx_stats_get_strings(chip, data,
832 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100833}
834
Andrew Lunn65f60e42018-03-28 23:50:28 +0200835static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
836 "atu_member_violation",
837 "atu_miss_violation",
838 "atu_full_violation",
839 "vtu_member_violation",
840 "vtu_miss_violation",
841};
842
843static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
844{
845 unsigned int i;
846
847 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
848 strlcpy(data + i * ETH_GSTRING_LEN,
849 mv88e6xxx_atu_vtu_stats_strings[i],
850 ETH_GSTRING_LEN);
851}
852
Andrew Lunndfafe442016-11-21 23:27:02 +0100853static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700854 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100855{
Vivien Didelot04bed142016-08-31 18:06:13 -0400856 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100857 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100858
Florian Fainelli89f09042018-04-25 12:12:50 -0700859 if (stringset != ETH_SS_STATS)
860 return;
861
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100862 mutex_lock(&chip->reg_lock);
863
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100865 count = chip->info->ops->stats_get_strings(chip, data);
866
867 if (chip->info->ops->serdes_get_strings) {
868 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200869 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100870 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100871
Andrew Lunn65f60e42018-03-28 23:50:28 +0200872 data += count * ETH_GSTRING_LEN;
873 mv88e6xxx_atu_vtu_get_strings(data);
874
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100875 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100876}
877
878static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
879 int types)
880{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100881 struct mv88e6xxx_hw_stat *stat;
882 int i, j;
883
884 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
885 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100886 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100887 j++;
888 }
889 return j;
890}
891
Andrew Lunndfafe442016-11-21 23:27:02 +0100892static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
893{
894 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
895 STATS_TYPE_PORT);
896}
897
898static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
899{
900 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
901 STATS_TYPE_BANK1);
902}
903
Florian Fainelli89f09042018-04-25 12:12:50 -0700904static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100905{
906 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100907 int serdes_count = 0;
908 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100909
Florian Fainelli89f09042018-04-25 12:12:50 -0700910 if (sset != ETH_SS_STATS)
911 return 0;
912
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100913 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 count = chip->info->ops->stats_get_sset_count(chip);
916 if (count < 0)
917 goto out;
918
919 if (chip->info->ops->serdes_get_sset_count)
920 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
921 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200922 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100923 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200924 goto out;
925 }
926 count += serdes_count;
927 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
928
Andrew Lunn436fe172018-03-01 02:02:29 +0100929out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100930 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100931
Andrew Lunn436fe172018-03-01 02:02:29 +0100932 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100933}
934
Andrew Lunn436fe172018-03-01 02:02:29 +0100935static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
936 uint64_t *data, int types,
937 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100938{
939 struct mv88e6xxx_hw_stat *stat;
940 int i, j;
941
942 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
943 stat = &mv88e6xxx_hw_stats[i];
944 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100945 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100946 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
947 bank1_select,
948 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100949 mutex_unlock(&chip->reg_lock);
950
Andrew Lunn052f9472016-11-21 23:27:03 +0100951 j++;
952 }
953 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100955}
956
Andrew Lunn436fe172018-03-01 02:02:29 +0100957static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
958 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100959{
960 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100961 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400962 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100963}
964
Andrew Lunn436fe172018-03-01 02:02:29 +0100965static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
966 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100967{
968 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100969 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400970 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
971 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100972}
973
Andrew Lunn436fe172018-03-01 02:02:29 +0100974static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
975 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100976{
977 return mv88e6xxx_stats_get_stats(chip, port, data,
978 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400979 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
980 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100981}
982
Andrew Lunn65f60e42018-03-28 23:50:28 +0200983static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
985{
986 *data++ = chip->ports[port].atu_member_violation;
987 *data++ = chip->ports[port].atu_miss_violation;
988 *data++ = chip->ports[port].atu_full_violation;
989 *data++ = chip->ports[port].vtu_member_violation;
990 *data++ = chip->ports[port].vtu_miss_violation;
991}
992
Andrew Lunn052f9472016-11-21 23:27:03 +0100993static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
994 uint64_t *data)
995{
Andrew Lunn436fe172018-03-01 02:02:29 +0100996 int count = 0;
997
Andrew Lunn052f9472016-11-21 23:27:03 +0100998 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_stats(chip, port, data);
1000
Andrew Lunn65f60e42018-03-28 23:50:28 +02001001 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001002 if (chip->info->ops->serdes_get_stats) {
1003 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001004 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001005 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 data += count;
1007 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1008 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001009}
1010
Vivien Didelotf81ec902016-05-09 13:22:58 -04001011static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1012 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013{
Vivien Didelot04bed142016-08-31 18:06:13 -04001014 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001015 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016
Vivien Didelotfad09c72016-06-21 12:28:20 -04001017 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001018
Andrew Lunna605a0f2016-11-21 23:26:58 +01001019 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001020 mutex_unlock(&chip->reg_lock);
1021
1022 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001023 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001024
1025 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001026
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001027}
Ben Hutchings98e67302011-11-25 14:36:19 +00001028
Vivien Didelotf81ec902016-05-09 13:22:58 -04001029static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001030{
1031 return 32 * sizeof(u16);
1032}
1033
Vivien Didelotf81ec902016-05-09 13:22:58 -04001034static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1035 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001036{
Vivien Didelot04bed142016-08-31 18:06:13 -04001037 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001038 int err;
1039 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001040 u16 *p = _p;
1041 int i;
1042
Vivien Didelota5f39322018-12-17 16:05:21 -05001043 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044
1045 memset(p, 0xff, 32 * sizeof(u16));
1046
Vivien Didelotfad09c72016-06-21 12:28:20 -04001047 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001048
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001049 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001050
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001051 err = mv88e6xxx_port_read(chip, port, i, &reg);
1052 if (!err)
1053 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001054 }
Vivien Didelot23062512016-05-09 13:22:45 -04001055
Vivien Didelotfad09c72016-06-21 12:28:20 -04001056 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001057}
1058
Vivien Didelot08f50062017-08-01 16:32:41 -04001059static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1060 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061{
Vivien Didelot5480db62017-08-01 16:32:40 -04001062 /* Nothing to do on the port's MAC */
1063 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001064}
1065
Vivien Didelot08f50062017-08-01 16:32:41 -04001066static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1067 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001068{
Vivien Didelot5480db62017-08-01 16:32:40 -04001069 /* Nothing to do on the port's MAC */
1070 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001071}
1072
Vivien Didelote5887a22017-03-30 17:37:11 -04001073static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001074{
Vivien Didelote5887a22017-03-30 17:37:11 -04001075 struct dsa_switch *ds = NULL;
1076 struct net_device *br;
1077 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001078 int i;
1079
Vivien Didelote5887a22017-03-30 17:37:11 -04001080 if (dev < DSA_MAX_SWITCHES)
1081 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001082
Vivien Didelote5887a22017-03-30 17:37:11 -04001083 /* Prevent frames from unknown switch or port */
1084 if (!ds || port >= ds->num_ports)
1085 return 0;
1086
1087 /* Frames from DSA links and CPU ports can egress any local port */
1088 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1089 return mv88e6xxx_port_mask(chip);
1090
1091 br = ds->ports[port].bridge_dev;
1092 pvlan = 0;
1093
1094 /* Frames from user ports can egress any local DSA links and CPU ports,
1095 * as well as any local member of their bridge group.
1096 */
1097 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1098 if (dsa_is_cpu_port(chip->ds, i) ||
1099 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001100 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001101 pvlan |= BIT(i);
1102
1103 return pvlan;
1104}
1105
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001106static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001107{
1108 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001109
1110 /* prevent frames from going back out of the port they came in on */
1111 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001112
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001113 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001114}
1115
Vivien Didelotf81ec902016-05-09 13:22:58 -04001116static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1117 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001118{
Vivien Didelot04bed142016-08-31 18:06:13 -04001119 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001120 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001121
Vivien Didelotfad09c72016-06-21 12:28:20 -04001122 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001123 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001124 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001125
1126 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001127 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001128}
1129
Vivien Didelot93e18d62018-05-11 17:16:35 -04001130static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1131{
1132 int err;
1133
1134 if (chip->info->ops->ieee_pri_map) {
1135 err = chip->info->ops->ieee_pri_map(chip);
1136 if (err)
1137 return err;
1138 }
1139
1140 if (chip->info->ops->ip_pri_map) {
1141 err = chip->info->ops->ip_pri_map(chip);
1142 if (err)
1143 return err;
1144 }
1145
1146 return 0;
1147}
1148
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001149static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1150{
1151 int target, port;
1152 int err;
1153
1154 if (!chip->info->global2_addr)
1155 return 0;
1156
1157 /* Initialize the routing port to the 32 possible target devices */
1158 for (target = 0; target < 32; target++) {
1159 port = 0x1f;
1160 if (target < DSA_MAX_SWITCHES)
1161 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1162 port = chip->ds->rtable[target];
1163
1164 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1165 if (err)
1166 return err;
1167 }
1168
Vivien Didelot02317e62018-05-09 11:38:49 -04001169 if (chip->info->ops->set_cascade_port) {
1170 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1171 err = chip->info->ops->set_cascade_port(chip, port);
1172 if (err)
1173 return err;
1174 }
1175
Vivien Didelot23c98912018-05-09 11:38:50 -04001176 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1177 if (err)
1178 return err;
1179
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001180 return 0;
1181}
1182
Vivien Didelotb28f8722018-04-26 21:56:44 -04001183static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1184{
1185 /* Clear all trunk masks and mapping */
1186 if (chip->info->global2_addr)
1187 return mv88e6xxx_g2_trunk_clear(chip);
1188
1189 return 0;
1190}
1191
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001192static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1193{
1194 if (chip->info->ops->rmu_disable)
1195 return chip->info->ops->rmu_disable(chip);
1196
1197 return 0;
1198}
1199
Vivien Didelot9e907d72017-07-17 13:03:43 -04001200static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1201{
1202 if (chip->info->ops->pot_clear)
1203 return chip->info->ops->pot_clear(chip);
1204
1205 return 0;
1206}
1207
Vivien Didelot51c901a2017-07-17 13:03:41 -04001208static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1209{
1210 if (chip->info->ops->mgmt_rsvd2cpu)
1211 return chip->info->ops->mgmt_rsvd2cpu(chip);
1212
1213 return 0;
1214}
1215
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001216static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1217{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001218 int err;
1219
Vivien Didelotdaefc942017-03-11 16:12:54 -05001220 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1221 if (err)
1222 return err;
1223
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001224 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1225 if (err)
1226 return err;
1227
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001228 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1229}
1230
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001231static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1232{
1233 int port;
1234 int err;
1235
1236 if (!chip->info->ops->irl_init_all)
1237 return 0;
1238
1239 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1240 /* Disable ingress rate limiting by resetting all per port
1241 * ingress rate limit resources to their initial state.
1242 */
1243 err = chip->info->ops->irl_init_all(chip, port);
1244 if (err)
1245 return err;
1246 }
1247
1248 return 0;
1249}
1250
Vivien Didelot04a69a12017-10-13 14:18:05 -04001251static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1252{
1253 if (chip->info->ops->set_switch_mac) {
1254 u8 addr[ETH_ALEN];
1255
1256 eth_random_addr(addr);
1257
1258 return chip->info->ops->set_switch_mac(chip, addr);
1259 }
1260
1261 return 0;
1262}
1263
Vivien Didelot17a15942017-03-30 17:37:09 -04001264static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1265{
1266 u16 pvlan = 0;
1267
1268 if (!mv88e6xxx_has_pvt(chip))
1269 return -EOPNOTSUPP;
1270
1271 /* Skip the local source device, which uses in-chip port VLAN */
1272 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001273 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001274
1275 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1276}
1277
Vivien Didelot81228992017-03-30 17:37:08 -04001278static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1279{
Vivien Didelot17a15942017-03-30 17:37:09 -04001280 int dev, port;
1281 int err;
1282
Vivien Didelot81228992017-03-30 17:37:08 -04001283 if (!mv88e6xxx_has_pvt(chip))
1284 return 0;
1285
1286 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1287 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1288 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001289 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1290 if (err)
1291 return err;
1292
1293 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1294 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1295 err = mv88e6xxx_pvt_map(chip, dev, port);
1296 if (err)
1297 return err;
1298 }
1299 }
1300
1301 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001302}
1303
Vivien Didelot749efcb2016-09-22 16:49:24 -04001304static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1305{
1306 struct mv88e6xxx_chip *chip = ds->priv;
1307 int err;
1308
1309 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001310 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001311 mutex_unlock(&chip->reg_lock);
1312
1313 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001314 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001315}
1316
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001317static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1318{
1319 if (!chip->info->max_vid)
1320 return 0;
1321
1322 return mv88e6xxx_g1_vtu_flush(chip);
1323}
1324
Vivien Didelotf1394b782017-05-01 14:05:22 -04001325static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1326 struct mv88e6xxx_vtu_entry *entry)
1327{
1328 if (!chip->info->ops->vtu_getnext)
1329 return -EOPNOTSUPP;
1330
1331 return chip->info->ops->vtu_getnext(chip, entry);
1332}
1333
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001334static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1335 struct mv88e6xxx_vtu_entry *entry)
1336{
1337 if (!chip->info->ops->vtu_loadpurge)
1338 return -EOPNOTSUPP;
1339
1340 return chip->info->ops->vtu_loadpurge(chip, entry);
1341}
1342
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001343static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001344{
1345 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001346 struct mv88e6xxx_vtu_entry vlan = {
1347 .vid = chip->info->max_vid,
1348 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001349 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001350
1351 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1352
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001353 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001354 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001355 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001356 if (err)
1357 return err;
1358
1359 set_bit(*fid, fid_bitmap);
1360 }
1361
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001362 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001363 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001364 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001365 if (err)
1366 return err;
1367
1368 if (!vlan.valid)
1369 break;
1370
1371 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001372 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001373
1374 /* The reset value 0x000 is used to indicate that multiple address
1375 * databases are not needed. Return the next positive available.
1376 */
1377 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001378 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001379 return -ENOSPC;
1380
1381 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001382 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001383}
1384
Vivien Didelot567aa592017-05-01 14:05:25 -04001385static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1386 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001387{
1388 int err;
1389
1390 if (!vid)
1391 return -EINVAL;
1392
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001393 entry->vid = vid - 1;
1394 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001395
Vivien Didelotf1394b782017-05-01 14:05:22 -04001396 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001397 if (err)
1398 return err;
1399
Vivien Didelot567aa592017-05-01 14:05:25 -04001400 if (entry->vid == vid && entry->valid)
1401 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001402
Vivien Didelot567aa592017-05-01 14:05:25 -04001403 if (new) {
1404 int i;
1405
1406 /* Initialize a fresh VLAN entry */
1407 memset(entry, 0, sizeof(*entry));
1408 entry->valid = true;
1409 entry->vid = vid;
1410
Vivien Didelot553a7682017-06-07 18:12:16 -04001411 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001412 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001413 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001414 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001415
1416 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001417 }
1418
Vivien Didelot567aa592017-05-01 14:05:25 -04001419 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1420 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001421}
1422
Vivien Didelotda9c3592016-02-12 12:09:40 -05001423static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1424 u16 vid_begin, u16 vid_end)
1425{
Vivien Didelot04bed142016-08-31 18:06:13 -04001426 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001427 struct mv88e6xxx_vtu_entry vlan = {
1428 .vid = vid_begin - 1,
1429 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001430 int i, err;
1431
Andrew Lunndb06ae412017-09-25 23:32:20 +02001432 /* DSA and CPU ports have to be members of multiple vlans */
1433 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1434 return 0;
1435
Vivien Didelotda9c3592016-02-12 12:09:40 -05001436 if (!vid_begin)
1437 return -EOPNOTSUPP;
1438
Vivien Didelotfad09c72016-06-21 12:28:20 -04001439 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001440
Vivien Didelotda9c3592016-02-12 12:09:40 -05001441 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001442 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001443 if (err)
1444 goto unlock;
1445
1446 if (!vlan.valid)
1447 break;
1448
1449 if (vlan.vid > vid_end)
1450 break;
1451
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001452 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001453 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1454 continue;
1455
Andrew Lunncd886462017-11-09 22:29:53 +01001456 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001457 continue;
1458
Vivien Didelotbd00e052017-05-01 14:05:11 -04001459 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001460 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001461 continue;
1462
Vivien Didelotc8652c82017-10-16 11:12:19 -04001463 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001464 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001465 break; /* same bridge, check next VLAN */
1466
Vivien Didelotc8652c82017-10-16 11:12:19 -04001467 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001468 continue;
1469
Andrew Lunn743fcc22017-11-09 22:29:54 +01001470 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1471 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001472 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001473 err = -EOPNOTSUPP;
1474 goto unlock;
1475 }
1476 } while (vlan.vid < vid_end);
1477
1478unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001479 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001480
1481 return err;
1482}
1483
Vivien Didelotf81ec902016-05-09 13:22:58 -04001484static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1485 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001486{
Vivien Didelot04bed142016-08-31 18:06:13 -04001487 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001488 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1489 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001490 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001491
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001492 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001493 return -EOPNOTSUPP;
1494
Vivien Didelotfad09c72016-06-21 12:28:20 -04001495 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001496 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001497 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001498
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001499 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001500}
1501
Vivien Didelot57d32312016-06-20 13:13:58 -04001502static int
1503mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001504 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001505{
Vivien Didelot04bed142016-08-31 18:06:13 -04001506 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001507 int err;
1508
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001509 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001510 return -EOPNOTSUPP;
1511
Vivien Didelotda9c3592016-02-12 12:09:40 -05001512 /* If the requested port doesn't belong to the same bridge as the VLAN
1513 * members, do not support it (yet) and fallback to software VLAN.
1514 */
1515 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1516 vlan->vid_end);
1517 if (err)
1518 return err;
1519
Vivien Didelot76e398a2015-11-01 12:33:55 -05001520 /* We don't need any dynamic resource from the kernel (yet),
1521 * so skip the prepare phase.
1522 */
1523 return 0;
1524}
1525
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001526static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1527 const unsigned char *addr, u16 vid,
1528 u8 state)
1529{
1530 struct mv88e6xxx_vtu_entry vlan;
1531 struct mv88e6xxx_atu_entry entry;
1532 int err;
1533
1534 /* Null VLAN ID corresponds to the port private database */
1535 if (vid == 0)
1536 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1537 else
1538 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1539 if (err)
1540 return err;
1541
1542 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1543 ether_addr_copy(entry.mac, addr);
1544 eth_addr_dec(entry.mac);
1545
1546 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1547 if (err)
1548 return err;
1549
1550 /* Initialize a fresh ATU entry if it isn't found */
1551 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1552 !ether_addr_equal(entry.mac, addr)) {
1553 memset(&entry, 0, sizeof(entry));
1554 ether_addr_copy(entry.mac, addr);
1555 }
1556
1557 /* Purge the ATU entry only if no port is using it anymore */
1558 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1559 entry.portvec &= ~BIT(port);
1560 if (!entry.portvec)
1561 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1562 } else {
1563 entry.portvec |= BIT(port);
1564 entry.state = state;
1565 }
1566
1567 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1568}
1569
Andrew Lunn87fa8862017-11-09 22:29:56 +01001570static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1571 u16 vid)
1572{
1573 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1574 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1575
1576 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1577}
1578
1579static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1580{
1581 int port;
1582 int err;
1583
1584 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1585 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1586 if (err)
1587 return err;
1588 }
1589
1590 return 0;
1591}
1592
Vivien Didelotfad09c72016-06-21 12:28:20 -04001593static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001594 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001595{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001596 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001597 int err;
1598
Vivien Didelot567aa592017-05-01 14:05:25 -04001599 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001600 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001601 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001602
Vivien Didelotc91498e2017-06-07 18:12:13 -04001603 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001604
Andrew Lunn87fa8862017-11-09 22:29:56 +01001605 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1606 if (err)
1607 return err;
1608
1609 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001610}
1611
Vivien Didelotf81ec902016-05-09 13:22:58 -04001612static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001613 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001614{
Vivien Didelot04bed142016-08-31 18:06:13 -04001615 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001616 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1617 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001618 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001619 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001621 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001622 return;
1623
Vivien Didelotc91498e2017-06-07 18:12:13 -04001624 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001625 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001626 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001627 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001628 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001629 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001630
Vivien Didelotfad09c72016-06-21 12:28:20 -04001631 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001632
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001633 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001634 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001635 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1636 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001637
Vivien Didelot77064f32016-11-04 03:23:30 +01001638 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001639 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1640 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001641
Vivien Didelotfad09c72016-06-21 12:28:20 -04001642 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001643}
1644
Vivien Didelotfad09c72016-06-21 12:28:20 -04001645static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001646 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001647{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001648 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001649 int i, err;
1650
Vivien Didelot567aa592017-05-01 14:05:25 -04001651 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001652 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001653 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001654
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001655 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001656 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001657 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001658
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001659 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001660
1661 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001662 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001663 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001664 if (vlan.member[i] !=
1665 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001666 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001667 break;
1668 }
1669 }
1670
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001671 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001672 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001673 return err;
1674
Vivien Didelote606ca32017-03-11 16:12:55 -05001675 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001676}
1677
Vivien Didelotf81ec902016-05-09 13:22:58 -04001678static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1679 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001680{
Vivien Didelot04bed142016-08-31 18:06:13 -04001681 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001682 u16 pvid, vid;
1683 int err = 0;
1684
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001685 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001686 return -EOPNOTSUPP;
1687
Vivien Didelotfad09c72016-06-21 12:28:20 -04001688 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001689
Vivien Didelot77064f32016-11-04 03:23:30 +01001690 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001691 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001692 goto unlock;
1693
Vivien Didelot76e398a2015-11-01 12:33:55 -05001694 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001695 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001696 if (err)
1697 goto unlock;
1698
1699 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001700 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001701 if (err)
1702 goto unlock;
1703 }
1704 }
1705
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001706unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001707 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001708
1709 return err;
1710}
1711
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001712static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1713 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001714{
Vivien Didelot04bed142016-08-31 18:06:13 -04001715 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001716 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001717
Vivien Didelotfad09c72016-06-21 12:28:20 -04001718 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001719 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1720 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001721 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001722
1723 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001724}
1725
Vivien Didelotf81ec902016-05-09 13:22:58 -04001726static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001727 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001728{
Vivien Didelot04bed142016-08-31 18:06:13 -04001729 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001730 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001731
Vivien Didelotfad09c72016-06-21 12:28:20 -04001732 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001733 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001734 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001735 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001736
Vivien Didelot83dabd12016-08-31 11:50:04 -04001737 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001738}
1739
Vivien Didelot83dabd12016-08-31 11:50:04 -04001740static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1741 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001742 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001743{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001744 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001745 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001746 int err;
1747
Vivien Didelot27c0e602017-06-15 12:14:01 -04001748 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001749 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001750
1751 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001752 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001753 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001754 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001755 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001756 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001757
Vivien Didelot27c0e602017-06-15 12:14:01 -04001758 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001759 break;
1760
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001761 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001762 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001763
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001764 if (!is_unicast_ether_addr(addr.mac))
1765 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001766
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001767 is_static = (addr.state ==
1768 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1769 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001770 if (err)
1771 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001772 } while (!is_broadcast_ether_addr(addr.mac));
1773
1774 return err;
1775}
1776
Vivien Didelot83dabd12016-08-31 11:50:04 -04001777static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001778 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001779{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001780 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001781 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001782 };
1783 u16 fid;
1784 int err;
1785
1786 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001787 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001788 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001789 mutex_unlock(&chip->reg_lock);
1790
Vivien Didelot83dabd12016-08-31 11:50:04 -04001791 if (err)
1792 return err;
1793
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001794 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001795 if (err)
1796 return err;
1797
1798 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001799 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001800 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001801 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001802 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001803 if (err)
1804 return err;
1805
1806 if (!vlan.valid)
1807 break;
1808
1809 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001810 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001811 if (err)
1812 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001813 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001814
1815 return err;
1816}
1817
Vivien Didelotf81ec902016-05-09 13:22:58 -04001818static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001819 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001820{
Vivien Didelot04bed142016-08-31 18:06:13 -04001821 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001822
Andrew Lunna61e5402018-02-15 14:38:35 +01001823 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001824}
1825
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001826static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1827 struct net_device *br)
1828{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001829 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001830 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001831 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001832 int err;
1833
1834 /* Remap the Port VLAN of each local bridge group member */
1835 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1836 if (chip->ds->ports[port].bridge_dev == br) {
1837 err = mv88e6xxx_port_vlan_map(chip, port);
1838 if (err)
1839 return err;
1840 }
1841 }
1842
Vivien Didelote96a6e02017-03-30 17:37:13 -04001843 if (!mv88e6xxx_has_pvt(chip))
1844 return 0;
1845
1846 /* Remap the Port VLAN of each cross-chip bridge group member */
1847 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1848 ds = chip->ds->dst->ds[dev];
1849 if (!ds)
1850 break;
1851
1852 for (port = 0; port < ds->num_ports; ++port) {
1853 if (ds->ports[port].bridge_dev == br) {
1854 err = mv88e6xxx_pvt_map(chip, dev, port);
1855 if (err)
1856 return err;
1857 }
1858 }
1859 }
1860
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001861 return 0;
1862}
1863
Vivien Didelotf81ec902016-05-09 13:22:58 -04001864static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001865 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001866{
Vivien Didelot04bed142016-08-31 18:06:13 -04001867 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001868 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001869
Vivien Didelotfad09c72016-06-21 12:28:20 -04001870 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001871 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001872 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001873
Vivien Didelot466dfa02016-02-26 13:16:05 -05001874 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001875}
1876
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001877static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1878 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001879{
Vivien Didelot04bed142016-08-31 18:06:13 -04001880 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001881
Vivien Didelotfad09c72016-06-21 12:28:20 -04001882 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001883 if (mv88e6xxx_bridge_map(chip, br) ||
1884 mv88e6xxx_port_vlan_map(chip, port))
1885 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001886 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001887}
1888
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001889static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1890 int port, struct net_device *br)
1891{
1892 struct mv88e6xxx_chip *chip = ds->priv;
1893 int err;
1894
1895 if (!mv88e6xxx_has_pvt(chip))
1896 return 0;
1897
1898 mutex_lock(&chip->reg_lock);
1899 err = mv88e6xxx_pvt_map(chip, dev, port);
1900 mutex_unlock(&chip->reg_lock);
1901
1902 return err;
1903}
1904
1905static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1906 int port, struct net_device *br)
1907{
1908 struct mv88e6xxx_chip *chip = ds->priv;
1909
1910 if (!mv88e6xxx_has_pvt(chip))
1911 return;
1912
1913 mutex_lock(&chip->reg_lock);
1914 if (mv88e6xxx_pvt_map(chip, dev, port))
1915 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1916 mutex_unlock(&chip->reg_lock);
1917}
1918
Vivien Didelot17e708b2016-12-05 17:30:27 -05001919static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1920{
1921 if (chip->info->ops->reset)
1922 return chip->info->ops->reset(chip);
1923
1924 return 0;
1925}
1926
Vivien Didelot309eca62016-12-05 17:30:26 -05001927static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1928{
1929 struct gpio_desc *gpiod = chip->reset;
1930
1931 /* If there is a GPIO connected to the reset pin, toggle it */
1932 if (gpiod) {
1933 gpiod_set_value_cansleep(gpiod, 1);
1934 usleep_range(10000, 20000);
1935 gpiod_set_value_cansleep(gpiod, 0);
1936 usleep_range(10000, 20000);
1937 }
1938}
1939
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001940static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1941{
1942 int i, err;
1943
1944 /* Set all ports to the Disabled state */
1945 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001946 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001947 if (err)
1948 return err;
1949 }
1950
1951 /* Wait for transmit queues to drain,
1952 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1953 */
1954 usleep_range(2000, 4000);
1955
1956 return 0;
1957}
1958
Vivien Didelotfad09c72016-06-21 12:28:20 -04001959static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001960{
Vivien Didelota935c052016-09-29 12:21:53 -04001961 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001962
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001963 err = mv88e6xxx_disable_ports(chip);
1964 if (err)
1965 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001966
Vivien Didelot309eca62016-12-05 17:30:26 -05001967 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001968
Vivien Didelot17e708b2016-12-05 17:30:27 -05001969 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001970}
1971
Vivien Didelot43145572017-03-11 16:12:59 -05001972static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001973 enum mv88e6xxx_frame_mode frame,
1974 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001975{
1976 int err;
1977
Vivien Didelot43145572017-03-11 16:12:59 -05001978 if (!chip->info->ops->port_set_frame_mode)
1979 return -EOPNOTSUPP;
1980
1981 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001982 if (err)
1983 return err;
1984
Vivien Didelot43145572017-03-11 16:12:59 -05001985 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1986 if (err)
1987 return err;
1988
1989 if (chip->info->ops->port_set_ether_type)
1990 return chip->info->ops->port_set_ether_type(chip, port, etype);
1991
1992 return 0;
1993}
1994
1995static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1996{
1997 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001998 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001999 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002000}
2001
2002static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2003{
2004 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002005 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002006 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002007}
2008
2009static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2010{
2011 return mv88e6xxx_set_port_mode(chip, port,
2012 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002013 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2014 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002015}
2016
2017static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2018{
2019 if (dsa_is_dsa_port(chip->ds, port))
2020 return mv88e6xxx_set_port_mode_dsa(chip, port);
2021
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002022 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002023 return mv88e6xxx_set_port_mode_normal(chip, port);
2024
2025 /* Setup CPU port mode depending on its supported tag format */
2026 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2027 return mv88e6xxx_set_port_mode_dsa(chip, port);
2028
2029 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2030 return mv88e6xxx_set_port_mode_edsa(chip, port);
2031
2032 return -EINVAL;
2033}
2034
Vivien Didelotea698f42017-03-11 16:12:50 -05002035static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2036{
2037 bool message = dsa_is_dsa_port(chip->ds, port);
2038
2039 return mv88e6xxx_port_set_message_port(chip, port, message);
2040}
2041
Vivien Didelot601aeed2017-03-11 16:13:00 -05002042static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2043{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002044 struct dsa_switch *ds = chip->ds;
2045 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002046
2047 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002048 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002049 if (chip->info->ops->port_set_egress_floods)
2050 return chip->info->ops->port_set_egress_floods(chip, port,
2051 flood, flood);
2052
2053 return 0;
2054}
2055
Andrew Lunn6d917822017-05-26 01:03:21 +02002056static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2057 bool on)
2058{
Vivien Didelot523a8902017-05-26 18:02:42 -04002059 if (chip->info->ops->serdes_power)
2060 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002061
Vivien Didelot523a8902017-05-26 18:02:42 -04002062 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002063}
2064
Vivien Didelotfa371c82017-12-05 15:34:10 -05002065static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2066{
2067 struct dsa_switch *ds = chip->ds;
2068 int upstream_port;
2069 int err;
2070
Vivien Didelot07073c72017-12-05 15:34:13 -05002071 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002072 if (chip->info->ops->port_set_upstream_port) {
2073 err = chip->info->ops->port_set_upstream_port(chip, port,
2074 upstream_port);
2075 if (err)
2076 return err;
2077 }
2078
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002079 if (port == upstream_port) {
2080 if (chip->info->ops->set_cpu_port) {
2081 err = chip->info->ops->set_cpu_port(chip,
2082 upstream_port);
2083 if (err)
2084 return err;
2085 }
2086
2087 if (chip->info->ops->set_egress_port) {
2088 err = chip->info->ops->set_egress_port(chip,
2089 upstream_port);
2090 if (err)
2091 return err;
2092 }
2093 }
2094
Vivien Didelotfa371c82017-12-05 15:34:10 -05002095 return 0;
2096}
2097
Vivien Didelotfad09c72016-06-21 12:28:20 -04002098static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002099{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002100 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002101 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002102 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002103
Andrew Lunn7b898462018-08-09 15:38:47 +02002104 chip->ports[port].chip = chip;
2105 chip->ports[port].port = port;
2106
Vivien Didelotd78343d2016-11-04 03:23:36 +01002107 /* MAC Forcing register: don't force link, speed, duplex or flow control
2108 * state to any particular values on physical ports, but force the CPU
2109 * port and all DSA ports to their maximum bandwidth and full duplex.
2110 */
2111 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2112 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2113 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002114 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002115 PHY_INTERFACE_MODE_NA);
2116 else
2117 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2118 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002119 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002120 PHY_INTERFACE_MODE_NA);
2121 if (err)
2122 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002123
2124 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2125 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2126 * tunneling, determine priority by looking at 802.1p and IP
2127 * priority fields (IP prio has precedence), and set STP state
2128 * to Forwarding.
2129 *
2130 * If this is the CPU link, use DSA or EDSA tagging depending
2131 * on which tagging mode was configured.
2132 *
2133 * If this is a link to another switch, use DSA tagging mode.
2134 *
2135 * If this is the upstream port for this switch, enable
2136 * forwarding of unknown unicasts and multicasts.
2137 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002138 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2139 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2140 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2141 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002142 if (err)
2143 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002144
Vivien Didelot601aeed2017-03-11 16:13:00 -05002145 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002146 if (err)
2147 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002148
Vivien Didelot601aeed2017-03-11 16:13:00 -05002149 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002150 if (err)
2151 return err;
2152
Andrew Lunn04aca992017-05-26 01:03:24 +02002153 /* Enable the SERDES interface for DSA and CPU ports. Normal
2154 * ports SERDES are enabled when the port is enabled, thus
2155 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002156 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002157 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2158 err = mv88e6xxx_serdes_power(chip, port, true);
2159 if (err)
2160 return err;
2161 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002162
Vivien Didelot8efdda42015-08-13 12:52:23 -04002163 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002164 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002165 * untagged frames on this port, do a destination address lookup on all
2166 * received packets as usual, disable ARP mirroring and don't send a
2167 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002168 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002169 err = mv88e6xxx_port_set_map_da(chip, port);
2170 if (err)
2171 return err;
2172
Vivien Didelotfa371c82017-12-05 15:34:10 -05002173 err = mv88e6xxx_setup_upstream_port(chip, port);
2174 if (err)
2175 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002176
Andrew Lunna23b2962017-02-04 20:15:28 +01002177 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002178 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002179 if (err)
2180 return err;
2181
Vivien Didelotcd782652017-06-08 18:34:13 -04002182 if (chip->info->ops->port_set_jumbo_size) {
2183 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002184 if (err)
2185 return err;
2186 }
2187
Andrew Lunn54d792f2015-05-06 01:09:47 +02002188 /* Port Association Vector: when learning source addresses
2189 * of packets, add the address to the address database using
2190 * a port bitmap that has only the bit for this port set and
2191 * the other bits clear.
2192 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002193 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002194 /* Disable learning for CPU port */
2195 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002196 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002197
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002198 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2199 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002200 if (err)
2201 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002202
2203 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002204 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2205 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002206 if (err)
2207 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002208
Vivien Didelot08984322017-06-08 18:34:12 -04002209 if (chip->info->ops->port_pause_limit) {
2210 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002211 if (err)
2212 return err;
2213 }
2214
Vivien Didelotc8c94892017-03-11 16:13:01 -05002215 if (chip->info->ops->port_disable_learn_limit) {
2216 err = chip->info->ops->port_disable_learn_limit(chip, port);
2217 if (err)
2218 return err;
2219 }
2220
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002221 if (chip->info->ops->port_disable_pri_override) {
2222 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002223 if (err)
2224 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002225 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002226
Andrew Lunnef0a7312016-12-03 04:35:16 +01002227 if (chip->info->ops->port_tag_remap) {
2228 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002229 if (err)
2230 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002231 }
2232
Andrew Lunnef70b112016-12-03 04:45:18 +01002233 if (chip->info->ops->port_egress_rate_limiting) {
2234 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002235 if (err)
2236 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002237 }
2238
Vivien Didelotea698f42017-03-11 16:12:50 -05002239 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002240 if (err)
2241 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002242
Vivien Didelot207afda2016-04-14 14:42:09 -04002243 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002244 * database, and allow bidirectional communication between the
2245 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002246 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002247 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002248 if (err)
2249 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002250
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002251 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002252 if (err)
2253 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002254
2255 /* Default VLAN ID and priority: don't set a default VLAN
2256 * ID, and set the default packet priority to zero.
2257 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002258 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002259}
2260
Andrew Lunn04aca992017-05-26 01:03:24 +02002261static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2262 struct phy_device *phydev)
2263{
2264 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002265 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002266
2267 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002268
Vivien Didelot523a8902017-05-26 18:02:42 -04002269 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002270
2271 if (!err && chip->info->ops->serdes_irq_setup)
2272 err = chip->info->ops->serdes_irq_setup(chip, port);
2273
Andrew Lunn04aca992017-05-26 01:03:24 +02002274 mutex_unlock(&chip->reg_lock);
2275
2276 return err;
2277}
2278
Andrew Lunn75104db2019-02-24 20:44:43 +01002279static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002280{
2281 struct mv88e6xxx_chip *chip = ds->priv;
2282
2283 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002284
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002285 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2286 dev_err(chip->dev, "failed to disable port\n");
2287
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002288 if (chip->info->ops->serdes_irq_free)
2289 chip->info->ops->serdes_irq_free(chip, port);
2290
Vivien Didelot523a8902017-05-26 18:02:42 -04002291 if (mv88e6xxx_serdes_power(chip, port, false))
2292 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002293
Andrew Lunn04aca992017-05-26 01:03:24 +02002294 mutex_unlock(&chip->reg_lock);
2295}
2296
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002297static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2298 unsigned int ageing_time)
2299{
Vivien Didelot04bed142016-08-31 18:06:13 -04002300 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002301 int err;
2302
2303 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002304 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002305 mutex_unlock(&chip->reg_lock);
2306
2307 return err;
2308}
2309
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002310static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002311{
2312 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002313
Andrew Lunnde2273872016-11-21 23:27:01 +01002314 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002315 if (chip->info->ops->stats_set_histogram) {
2316 err = chip->info->ops->stats_set_histogram(chip);
2317 if (err)
2318 return err;
2319 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002320
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002321 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002322}
2323
Andrew Lunnea890982019-01-09 00:24:03 +01002324/* The mv88e6390 has some hidden registers used for debug and
2325 * development. The errata also makes use of them.
2326 */
2327static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2328 int reg, u16 val)
2329{
2330 u16 ctrl;
2331 int err;
2332
2333 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2334 PORT_RESERVED_1A, val);
2335 if (err)
2336 return err;
2337
2338 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2339 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2340 reg;
2341
2342 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2343 PORT_RESERVED_1A, ctrl);
2344}
2345
2346static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2347{
2348 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2349 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2350}
2351
2352
2353static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2354 int reg, u16 *val)
2355{
2356 u16 ctrl;
2357 int err;
2358
2359 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2360 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2361 reg;
2362
2363 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2364 PORT_RESERVED_1A, ctrl);
2365 if (err)
2366 return err;
2367
2368 err = mv88e6390_hidden_wait(chip);
2369 if (err)
2370 return err;
2371
2372 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2373 PORT_RESERVED_1A, val);
2374}
2375
2376/* Check if the errata has already been applied. */
2377static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2378{
2379 int port;
2380 int err;
2381 u16 val;
2382
2383 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2384 err = mv88e6390_hidden_read(chip, port, 0, &val);
2385 if (err) {
2386 dev_err(chip->dev,
2387 "Error reading hidden register: %d\n", err);
2388 return false;
2389 }
2390 if (val != 0x01c0)
2391 return false;
2392 }
2393
2394 return true;
2395}
2396
2397/* The 6390 copper ports have an errata which require poking magic
2398 * values into undocumented hidden registers and then performing a
2399 * software reset.
2400 */
2401static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2402{
2403 int port;
2404 int err;
2405
2406 if (mv88e6390_setup_errata_applied(chip))
2407 return 0;
2408
2409 /* Set the ports into blocking mode */
2410 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2411 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2412 if (err)
2413 return err;
2414 }
2415
2416 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2417 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2418 if (err)
2419 return err;
2420 }
2421
2422 return mv88e6xxx_software_reset(chip);
2423}
2424
Vivien Didelotf81ec902016-05-09 13:22:58 -04002425static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002426{
Vivien Didelot04bed142016-08-31 18:06:13 -04002427 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002428 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002429 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002430 int i;
2431
Vivien Didelotfad09c72016-06-21 12:28:20 -04002432 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002433 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002434
Vivien Didelotfad09c72016-06-21 12:28:20 -04002435 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002436
Andrew Lunnea890982019-01-09 00:24:03 +01002437 if (chip->info->ops->setup_errata) {
2438 err = chip->info->ops->setup_errata(chip);
2439 if (err)
2440 goto unlock;
2441 }
2442
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002443 /* Cache the cmode of each port. */
2444 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2445 if (chip->info->ops->port_get_cmode) {
2446 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2447 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002448 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002449
2450 chip->ports[i].cmode = cmode;
2451 }
2452 }
2453
Vivien Didelot97299342016-07-18 20:45:30 -04002454 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002455 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Andrew Lunn100a9b92019-05-01 00:08:31 +02002456 if (dsa_is_unused_port(ds, i)) {
2457 err = mv88e6xxx_port_set_state(chip, i,
2458 BR_STATE_DISABLED);
2459 if (err)
2460 goto unlock;
2461
2462 err = mv88e6xxx_serdes_power(chip, i, false);
2463 if (err)
2464 goto unlock;
2465
Vivien Didelot91dee142017-10-26 11:22:52 -04002466 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002467 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002468
Vivien Didelot97299342016-07-18 20:45:30 -04002469 err = mv88e6xxx_setup_port(chip, i);
2470 if (err)
2471 goto unlock;
2472 }
2473
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002474 err = mv88e6xxx_irl_setup(chip);
2475 if (err)
2476 goto unlock;
2477
Vivien Didelot04a69a12017-10-13 14:18:05 -04002478 err = mv88e6xxx_mac_setup(chip);
2479 if (err)
2480 goto unlock;
2481
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002482 err = mv88e6xxx_phy_setup(chip);
2483 if (err)
2484 goto unlock;
2485
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002486 err = mv88e6xxx_vtu_setup(chip);
2487 if (err)
2488 goto unlock;
2489
Vivien Didelot81228992017-03-30 17:37:08 -04002490 err = mv88e6xxx_pvt_setup(chip);
2491 if (err)
2492 goto unlock;
2493
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002494 err = mv88e6xxx_atu_setup(chip);
2495 if (err)
2496 goto unlock;
2497
Andrew Lunn87fa8862017-11-09 22:29:56 +01002498 err = mv88e6xxx_broadcast_setup(chip, 0);
2499 if (err)
2500 goto unlock;
2501
Vivien Didelot9e907d72017-07-17 13:03:43 -04002502 err = mv88e6xxx_pot_setup(chip);
2503 if (err)
2504 goto unlock;
2505
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002506 err = mv88e6xxx_rmu_setup(chip);
2507 if (err)
2508 goto unlock;
2509
Vivien Didelot51c901a2017-07-17 13:03:41 -04002510 err = mv88e6xxx_rsvd2cpu_setup(chip);
2511 if (err)
2512 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002513
Vivien Didelotb28f8722018-04-26 21:56:44 -04002514 err = mv88e6xxx_trunk_setup(chip);
2515 if (err)
2516 goto unlock;
2517
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002518 err = mv88e6xxx_devmap_setup(chip);
2519 if (err)
2520 goto unlock;
2521
Vivien Didelot93e18d62018-05-11 17:16:35 -04002522 err = mv88e6xxx_pri_setup(chip);
2523 if (err)
2524 goto unlock;
2525
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002526 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002527 if (chip->info->ptp_support) {
2528 err = mv88e6xxx_ptp_setup(chip);
2529 if (err)
2530 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002531
2532 err = mv88e6xxx_hwtstamp_setup(chip);
2533 if (err)
2534 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002535 }
2536
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002537 err = mv88e6xxx_stats_setup(chip);
2538 if (err)
2539 goto unlock;
2540
Vivien Didelot6b17e862015-08-13 12:52:18 -04002541unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002542 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002543
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002544 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002545}
2546
Vivien Didelote57e5e72016-08-15 17:19:00 -04002547static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002548{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002549 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2550 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002551 u16 val;
2552 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002553
Andrew Lunnee26a222017-01-24 14:53:48 +01002554 if (!chip->info->ops->phy_read)
2555 return -EOPNOTSUPP;
2556
Vivien Didelotfad09c72016-06-21 12:28:20 -04002557 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002558 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002559 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002560
Andrew Lunnda9f3302017-02-01 03:40:05 +01002561 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002562 /* Some internal PHYs don't have a model number. */
2563 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2564 /* Then there is the 6165 family. It gets is
2565 * PHYs correct. But it can also have two
2566 * SERDES interfaces in the PHY address
2567 * space. And these don't have a model
2568 * number. But they are not PHYs, so we don't
2569 * want to give them something a PHY driver
2570 * will recognise.
2571 *
2572 * Use the mv88e6390 family model number
2573 * instead, for anything which really could be
2574 * a PHY,
2575 */
2576 if (!(val & 0x3f0))
2577 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002578 }
2579
Vivien Didelote57e5e72016-08-15 17:19:00 -04002580 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002581}
2582
Vivien Didelote57e5e72016-08-15 17:19:00 -04002583static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002584{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002585 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2586 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002587 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002588
Andrew Lunnee26a222017-01-24 14:53:48 +01002589 if (!chip->info->ops->phy_write)
2590 return -EOPNOTSUPP;
2591
Vivien Didelotfad09c72016-06-21 12:28:20 -04002592 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002593 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002594 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002595
2596 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002597}
2598
Vivien Didelotfad09c72016-06-21 12:28:20 -04002599static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002600 struct device_node *np,
2601 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002602{
2603 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002604 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002605 struct mii_bus *bus;
2606 int err;
2607
Andrew Lunn2510bab2018-02-22 01:51:49 +01002608 if (external) {
2609 mutex_lock(&chip->reg_lock);
2610 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2611 mutex_unlock(&chip->reg_lock);
2612
2613 if (err)
2614 return err;
2615 }
2616
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002617 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002618 if (!bus)
2619 return -ENOMEM;
2620
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002621 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002622 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002623 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002624 INIT_LIST_HEAD(&mdio_bus->list);
2625 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002626
Andrew Lunnb516d452016-06-04 21:17:06 +02002627 if (np) {
2628 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002629 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002630 } else {
2631 bus->name = "mv88e6xxx SMI";
2632 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2633 }
2634
2635 bus->read = mv88e6xxx_mdio_read;
2636 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002637 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002638
Andrew Lunn6f882842018-03-17 20:32:05 +01002639 if (!external) {
2640 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2641 if (err)
2642 return err;
2643 }
2644
Florian Fainelli00e798c2018-05-15 16:56:19 -07002645 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002646 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002647 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002648 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002649 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002650 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002651
2652 if (external)
2653 list_add_tail(&mdio_bus->list, &chip->mdios);
2654 else
2655 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002656
2657 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002658}
2659
Andrew Lunna3c53be52017-01-24 14:53:50 +01002660static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2661 { .compatible = "marvell,mv88e6xxx-mdio-external",
2662 .data = (void *)true },
2663 { },
2664};
2665
Andrew Lunn3126aee2017-12-07 01:05:57 +01002666static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2667
2668{
2669 struct mv88e6xxx_mdio_bus *mdio_bus;
2670 struct mii_bus *bus;
2671
2672 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2673 bus = mdio_bus->bus;
2674
Andrew Lunn6f882842018-03-17 20:32:05 +01002675 if (!mdio_bus->external)
2676 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2677
Andrew Lunn3126aee2017-12-07 01:05:57 +01002678 mdiobus_unregister(bus);
2679 }
2680}
2681
Andrew Lunna3c53be52017-01-24 14:53:50 +01002682static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2683 struct device_node *np)
2684{
2685 const struct of_device_id *match;
2686 struct device_node *child;
2687 int err;
2688
2689 /* Always register one mdio bus for the internal/default mdio
2690 * bus. This maybe represented in the device tree, but is
2691 * optional.
2692 */
2693 child = of_get_child_by_name(np, "mdio");
2694 err = mv88e6xxx_mdio_register(chip, child, false);
2695 if (err)
2696 return err;
2697
2698 /* Walk the device tree, and see if there are any other nodes
2699 * which say they are compatible with the external mdio
2700 * bus.
2701 */
2702 for_each_available_child_of_node(np, child) {
2703 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2704 if (match) {
2705 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002706 if (err) {
2707 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002708 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002709 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002710 }
2711 }
2712
2713 return 0;
2714}
2715
Vivien Didelot855b1932016-07-20 18:18:35 -04002716static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2717{
Vivien Didelot04bed142016-08-31 18:06:13 -04002718 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002719
2720 return chip->eeprom_len;
2721}
2722
Vivien Didelot855b1932016-07-20 18:18:35 -04002723static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2724 struct ethtool_eeprom *eeprom, u8 *data)
2725{
Vivien Didelot04bed142016-08-31 18:06:13 -04002726 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002727 int err;
2728
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002729 if (!chip->info->ops->get_eeprom)
2730 return -EOPNOTSUPP;
2731
Vivien Didelot855b1932016-07-20 18:18:35 -04002732 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002733 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002734 mutex_unlock(&chip->reg_lock);
2735
2736 if (err)
2737 return err;
2738
2739 eeprom->magic = 0xc3ec4951;
2740
2741 return 0;
2742}
2743
Vivien Didelot855b1932016-07-20 18:18:35 -04002744static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2745 struct ethtool_eeprom *eeprom, u8 *data)
2746{
Vivien Didelot04bed142016-08-31 18:06:13 -04002747 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002748 int err;
2749
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002750 if (!chip->info->ops->set_eeprom)
2751 return -EOPNOTSUPP;
2752
Vivien Didelot855b1932016-07-20 18:18:35 -04002753 if (eeprom->magic != 0xc3ec4951)
2754 return -EINVAL;
2755
2756 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002757 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002758 mutex_unlock(&chip->reg_lock);
2759
2760 return err;
2761}
2762
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002763static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002764 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002765 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2766 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002767 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002768 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002769 .phy_read = mv88e6185_phy_ppu_read,
2770 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002771 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002772 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002773 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002774 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002775 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002776 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002777 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002778 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002779 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002780 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002781 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002782 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002783 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002784 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002785 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002786 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2787 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002788 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002789 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2790 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002791 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002792 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002793 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002794 .ppu_enable = mv88e6185_g1_ppu_enable,
2795 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002796 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002797 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002798 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002799 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002800 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002801};
2802
2803static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002804 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002805 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2806 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002807 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002808 .phy_read = mv88e6185_phy_ppu_read,
2809 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002810 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002811 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002812 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002813 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002814 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002815 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002816 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002817 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002818 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002819 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002820 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2821 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002822 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002823 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002824 .ppu_enable = mv88e6185_g1_ppu_enable,
2825 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002826 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002827 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002828 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002829 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002830};
2831
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002832static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002833 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002834 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2835 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002836 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002837 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2838 .phy_read = mv88e6xxx_g2_smi_phy_read,
2839 .phy_write = mv88e6xxx_g2_smi_phy_write,
2840 .port_set_link = mv88e6xxx_port_set_link,
2841 .port_set_duplex = mv88e6xxx_port_set_duplex,
2842 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002843 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002844 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002845 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002847 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002848 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002849 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002850 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002851 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002852 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002853 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002854 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002855 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002856 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2857 .stats_get_strings = mv88e6095_stats_get_strings,
2858 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002859 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2860 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002861 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002862 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002863 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002864 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002865 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002866 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002867 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002868 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002869};
2870
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002871static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002872 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002873 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2874 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002875 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002876 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002877 .phy_read = mv88e6xxx_g2_smi_phy_read,
2878 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002879 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002880 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002881 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002882 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002883 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002884 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002885 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002886 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002887 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002888 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002889 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002890 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2891 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002892 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002893 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2894 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002895 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002896 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002897 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002898 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002899 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002900 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002901 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002902};
2903
2904static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002905 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002906 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2907 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002908 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002909 .phy_read = mv88e6185_phy_ppu_read,
2910 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002911 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002912 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002913 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002914 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002915 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002916 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002917 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002918 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002919 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002920 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002921 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002922 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002923 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002924 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002925 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002926 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002927 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2928 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002929 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002930 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2931 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002932 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002933 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002934 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002935 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002936 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002937 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002938 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002939 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002940 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002941};
2942
Vivien Didelot990e27b2017-03-28 13:50:32 -04002943static const struct mv88e6xxx_ops mv88e6141_ops = {
2944 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002945 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2946 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002947 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002948 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2949 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2950 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2951 .phy_read = mv88e6xxx_g2_smi_phy_read,
2952 .phy_write = mv88e6xxx_g2_smi_phy_write,
2953 .port_set_link = mv88e6xxx_port_set_link,
2954 .port_set_duplex = mv88e6xxx_port_set_duplex,
2955 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002956 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002957 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002958 .port_tag_remap = mv88e6095_port_tag_remap,
2959 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2960 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2961 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002962 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002963 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002964 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002965 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2966 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002967 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002968 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002969 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002970 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002971 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2972 .stats_get_strings = mv88e6320_stats_get_strings,
2973 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002974 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2975 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002976 .watchdog_ops = &mv88e6390_watchdog_ops,
2977 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002978 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002979 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002980 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002981 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002982 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002983 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01002984 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002985};
2986
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002987static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002988 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002989 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2990 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002991 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002992 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002993 .phy_read = mv88e6xxx_g2_smi_phy_read,
2994 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002995 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002996 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002997 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002998 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002999 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003000 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003001 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003002 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003003 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003004 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003005 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003006 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003007 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003008 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003009 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003010 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003011 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3012 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003013 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003014 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3015 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003016 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003017 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003018 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003019 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003020 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003021 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003022 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003023 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003024 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003025};
3026
3027static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003028 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003029 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3030 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003031 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003032 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003033 .phy_read = mv88e6165_phy_read,
3034 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003035 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003036 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003037 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003038 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003039 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003040 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003041 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003042 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003043 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003044 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3045 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003046 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003047 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3048 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003049 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003050 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003051 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003052 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003053 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003054 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003055 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003056 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003057 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003058};
3059
3060static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003061 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003062 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3063 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003064 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003065 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003066 .phy_read = mv88e6xxx_g2_smi_phy_read,
3067 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003068 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003069 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003070 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003071 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003072 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003073 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003074 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003075 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003076 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003077 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003078 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003079 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003080 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003081 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003082 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003083 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003084 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003085 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3086 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003087 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003088 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3089 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003090 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003091 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003092 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003093 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003094 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003095 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003096 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003097};
3098
3099static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003100 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003101 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3102 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003103 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003104 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3105 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003106 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003107 .phy_read = mv88e6xxx_g2_smi_phy_read,
3108 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003109 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003110 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003111 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003112 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003113 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003114 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003115 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003116 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003117 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003118 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003119 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003120 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003121 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003122 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003123 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003124 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003125 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003126 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3127 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003128 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003129 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3130 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003131 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003132 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003133 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003134 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003135 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003136 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003137 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003138 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003139 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003140 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003141};
3142
3143static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003144 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003145 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3146 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003147 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003148 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003149 .phy_read = mv88e6xxx_g2_smi_phy_read,
3150 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003151 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003152 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003153 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003154 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003155 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003156 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003157 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003158 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003159 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003160 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003161 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003162 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003163 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003164 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003165 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003166 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003167 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003168 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3169 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003170 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003171 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3172 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003173 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003174 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003175 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003176 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003177 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003178 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003179 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003180};
3181
3182static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003183 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003184 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3185 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003186 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003187 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3188 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003189 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003190 .phy_read = mv88e6xxx_g2_smi_phy_read,
3191 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003192 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003193 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003194 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003195 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003196 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003197 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003198 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003199 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003200 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003201 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003202 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003203 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003204 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003205 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003206 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003207 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003208 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003209 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3210 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003211 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003212 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3213 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003214 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003215 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003216 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003217 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003218 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003219 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003220 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003221 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003222 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3223 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003224 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003225 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003226};
3227
3228static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003229 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003230 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3231 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003232 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003233 .phy_read = mv88e6185_phy_ppu_read,
3234 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003235 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003236 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003237 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003238 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003239 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003240 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003241 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003242 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003243 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003244 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003245 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003246 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003247 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3248 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003249 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003250 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3251 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003252 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003253 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003254 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003255 .ppu_enable = mv88e6185_g1_ppu_enable,
3256 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003257 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003258 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003259 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003260 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003261};
3262
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003263static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003264 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003265 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003266 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003267 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3268 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003269 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3270 .phy_read = mv88e6xxx_g2_smi_phy_read,
3271 .phy_write = mv88e6xxx_g2_smi_phy_write,
3272 .port_set_link = mv88e6xxx_port_set_link,
3273 .port_set_duplex = mv88e6xxx_port_set_duplex,
3274 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3275 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003276 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003277 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003278 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003279 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003280 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003281 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003282 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003283 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003284 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003285 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003286 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003287 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003288 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003289 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3290 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003291 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003292 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3293 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003294 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003295 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003296 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003297 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003298 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003299 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3300 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003301 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003302 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3303 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003304 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003305 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003306};
3307
3308static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003309 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003310 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003311 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003312 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3313 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003314 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3315 .phy_read = mv88e6xxx_g2_smi_phy_read,
3316 .phy_write = mv88e6xxx_g2_smi_phy_write,
3317 .port_set_link = mv88e6xxx_port_set_link,
3318 .port_set_duplex = mv88e6xxx_port_set_duplex,
3319 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3320 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003321 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003322 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003323 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003324 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003325 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003326 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003327 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003328 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003329 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003330 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003331 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003332 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003333 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003334 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3335 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003336 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003337 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3338 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003339 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003340 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003341 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003342 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003343 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003344 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3345 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003346 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003347 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3348 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003349 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003350 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003351};
3352
3353static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003354 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003355 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003356 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003357 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3358 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003359 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3360 .phy_read = mv88e6xxx_g2_smi_phy_read,
3361 .phy_write = mv88e6xxx_g2_smi_phy_write,
3362 .port_set_link = mv88e6xxx_port_set_link,
3363 .port_set_duplex = mv88e6xxx_port_set_duplex,
3364 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3365 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003366 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003367 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003368 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003369 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003370 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003371 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003372 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003373 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003374 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003375 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003376 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003377 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003378 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003379 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3380 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003381 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003382 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3383 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003384 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003385 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003386 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003387 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003388 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003389 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3390 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003391 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003392 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3393 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003394 .avb_ops = &mv88e6390_avb_ops,
3395 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003396 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003397};
3398
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003399static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003400 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003401 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3402 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003403 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003404 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3405 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003406 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407 .phy_read = mv88e6xxx_g2_smi_phy_read,
3408 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003409 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003410 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003411 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003412 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003413 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003414 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003415 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003416 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003417 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003418 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003419 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003420 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003421 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003422 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003423 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003424 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003425 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003426 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3427 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003428 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003429 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3430 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003431 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003432 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003433 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003434 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003435 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003436 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003437 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003438 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003439 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3440 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003441 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003442 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003443 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003444 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003445};
3446
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003447static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003448 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003449 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003450 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003451 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3452 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003453 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3454 .phy_read = mv88e6xxx_g2_smi_phy_read,
3455 .phy_write = mv88e6xxx_g2_smi_phy_write,
3456 .port_set_link = mv88e6xxx_port_set_link,
3457 .port_set_duplex = mv88e6xxx_port_set_duplex,
3458 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3459 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003460 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003461 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003462 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003463 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003464 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003465 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003466 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003467 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003468 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003469 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003470 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003471 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003472 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003473 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3474 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003475 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003476 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3477 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003478 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003479 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003480 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003481 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003482 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003483 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3484 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003485 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003486 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3487 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003488 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003489 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003490 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003491 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003492};
3493
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003494static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003495 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003496 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3497 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003498 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003499 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3500 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003501 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003502 .phy_read = mv88e6xxx_g2_smi_phy_read,
3503 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003504 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003505 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003506 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003507 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003508 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003509 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003510 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003511 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003512 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003513 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003514 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003515 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003516 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003517 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003518 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003519 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003520 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3521 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003522 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003523 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3524 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003525 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003526 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003527 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003528 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003529 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003530 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003531 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003532 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003533 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003534 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003535};
3536
3537static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003538 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003539 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3540 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003541 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003542 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3543 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003544 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003545 .phy_read = mv88e6xxx_g2_smi_phy_read,
3546 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003547 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003548 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003549 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003550 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003551 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003552 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003553 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003554 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003555 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003556 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003557 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003558 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003559 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003560 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003561 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003562 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003563 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3564 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003565 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003566 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3567 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003568 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003569 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003570 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003571 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003572 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003573 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003574 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003575 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003576};
3577
Vivien Didelot16e329a2017-03-28 13:50:33 -04003578static const struct mv88e6xxx_ops mv88e6341_ops = {
3579 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003580 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3581 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003582 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003583 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3584 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3585 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3586 .phy_read = mv88e6xxx_g2_smi_phy_read,
3587 .phy_write = mv88e6xxx_g2_smi_phy_write,
3588 .port_set_link = mv88e6xxx_port_set_link,
3589 .port_set_duplex = mv88e6xxx_port_set_duplex,
3590 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003591 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003592 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003593 .port_tag_remap = mv88e6095_port_tag_remap,
3594 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3595 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3596 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003597 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003598 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003599 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003600 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3601 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003602 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003603 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003604 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003605 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003606 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3607 .stats_get_strings = mv88e6320_stats_get_strings,
3608 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003609 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3610 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003611 .watchdog_ops = &mv88e6390_watchdog_ops,
3612 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003613 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003614 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003615 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003616 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003617 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003618 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003619 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003620 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003621 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003622};
3623
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003624static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003625 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003626 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3627 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003628 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003629 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003630 .phy_read = mv88e6xxx_g2_smi_phy_read,
3631 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003632 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003633 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003634 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003635 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003636 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003637 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003638 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003639 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003640 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003641 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003642 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003643 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003644 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003645 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003646 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003647 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003648 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003649 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3650 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003651 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003652 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3653 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003654 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003655 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003656 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003657 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003658 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003659 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003660 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003661};
3662
3663static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003664 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003665 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3666 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003667 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003668 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003669 .phy_read = mv88e6xxx_g2_smi_phy_read,
3670 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003671 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003672 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003673 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003674 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003675 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003676 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003677 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003678 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003679 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003680 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003681 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003682 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003683 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003684 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003685 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003686 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003687 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003688 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3689 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003690 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003691 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3692 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003693 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003694 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003695 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003696 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003697 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003698 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003699 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003700 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003701 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003702};
3703
3704static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003705 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003706 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3707 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003708 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003709 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3710 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003711 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003712 .phy_read = mv88e6xxx_g2_smi_phy_read,
3713 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003714 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003715 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003716 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003717 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003718 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003719 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003720 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003721 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003722 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003723 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003724 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003725 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003726 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003727 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003728 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003729 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003730 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003731 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3732 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003733 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003734 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3735 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003736 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003737 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003738 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003739 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003740 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003741 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003742 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003743 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003744 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3745 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003746 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003747 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003748 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003749 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3750 .serdes_get_strings = mv88e6352_serdes_get_strings,
3751 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003752 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003753};
3754
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003755static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003756 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003757 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003758 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003759 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3760 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003761 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3762 .phy_read = mv88e6xxx_g2_smi_phy_read,
3763 .phy_write = mv88e6xxx_g2_smi_phy_write,
3764 .port_set_link = mv88e6xxx_port_set_link,
3765 .port_set_duplex = mv88e6xxx_port_set_duplex,
3766 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3767 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003768 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003769 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003770 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003771 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003772 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003773 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003774 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003775 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003776 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003777 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003778 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003779 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003780 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003781 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003782 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003783 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3784 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003785 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003786 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3787 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003788 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003789 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003790 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003791 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003792 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003793 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3794 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003795 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003796 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3797 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003798 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003799 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003800 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003801 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003802};
3803
3804static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003805 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003806 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003807 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003808 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3809 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003810 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3811 .phy_read = mv88e6xxx_g2_smi_phy_read,
3812 .phy_write = mv88e6xxx_g2_smi_phy_write,
3813 .port_set_link = mv88e6xxx_port_set_link,
3814 .port_set_duplex = mv88e6xxx_port_set_duplex,
3815 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3816 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003817 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003818 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003819 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003820 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003821 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003822 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003823 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003824 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003825 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003826 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003827 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003828 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003829 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003830 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003831 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003832 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3833 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003834 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003835 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3836 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003837 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003838 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003839 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003840 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003841 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003842 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3843 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003844 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003845 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3846 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003847 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003848 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003849 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003850 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003851};
3852
Vivien Didelotf81ec902016-05-09 13:22:58 -04003853static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3854 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003855 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003856 .family = MV88E6XXX_FAMILY_6097,
3857 .name = "Marvell 88E6085",
3858 .num_databases = 4096,
3859 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003860 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003861 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003862 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003863 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003864 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003865 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003866 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003867 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003868 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003869 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003870 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003871 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003872 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003873 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003874 },
3875
3876 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003877 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003878 .family = MV88E6XXX_FAMILY_6095,
3879 .name = "Marvell 88E6095/88E6095F",
3880 .num_databases = 256,
3881 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003882 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003883 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003884 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003885 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003886 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003887 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003888 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003889 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003890 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003891 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003892 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003893 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003894 },
3895
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003896 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003897 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003898 .family = MV88E6XXX_FAMILY_6097,
3899 .name = "Marvell 88E6097/88E6097F",
3900 .num_databases = 4096,
3901 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003902 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003903 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003904 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003905 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003906 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003907 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003908 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003909 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003910 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003911 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003912 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003913 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003914 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003915 .ops = &mv88e6097_ops,
3916 },
3917
Vivien Didelotf81ec902016-05-09 13:22:58 -04003918 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003919 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003920 .family = MV88E6XXX_FAMILY_6165,
3921 .name = "Marvell 88E6123",
3922 .num_databases = 4096,
3923 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003924 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003925 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003926 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003927 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003928 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003929 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003930 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003931 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003932 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003933 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003934 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003935 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003936 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003937 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003938 },
3939
3940 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003941 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003942 .family = MV88E6XXX_FAMILY_6185,
3943 .name = "Marvell 88E6131",
3944 .num_databases = 256,
3945 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003946 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003947 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003948 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003949 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003950 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003951 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003952 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003953 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003954 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003955 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003956 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003957 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003958 },
3959
Vivien Didelot990e27b2017-03-28 13:50:32 -04003960 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003961 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003962 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003963 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003964 .num_databases = 4096,
3965 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003966 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003967 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003968 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003969 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003970 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003971 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003972 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003973 .age_time_coeff = 3750,
3974 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003975 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003976 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003977 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003978 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003979 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003980 .ops = &mv88e6141_ops,
3981 },
3982
Vivien Didelotf81ec902016-05-09 13:22:58 -04003983 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003984 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003985 .family = MV88E6XXX_FAMILY_6165,
3986 .name = "Marvell 88E6161",
3987 .num_databases = 4096,
3988 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003989 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003990 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003991 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003992 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003993 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003994 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003995 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003996 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003997 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003998 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003999 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004000 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004001 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004002 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004003 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004004 },
4005
4006 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004007 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 .family = MV88E6XXX_FAMILY_6165,
4009 .name = "Marvell 88E6165",
4010 .num_databases = 4096,
4011 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004012 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004013 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004014 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004015 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004016 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004017 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004018 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004019 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004020 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004021 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004022 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004023 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004024 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004025 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004026 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004027 },
4028
4029 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004030 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004031 .family = MV88E6XXX_FAMILY_6351,
4032 .name = "Marvell 88E6171",
4033 .num_databases = 4096,
4034 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004035 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004036 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004037 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004038 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004039 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004040 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004041 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004042 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004043 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004044 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004045 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004046 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004047 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004048 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004049 },
4050
4051 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004052 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004053 .family = MV88E6XXX_FAMILY_6352,
4054 .name = "Marvell 88E6172",
4055 .num_databases = 4096,
4056 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004057 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004058 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004059 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004060 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004061 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004062 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004063 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004064 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004065 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004066 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004067 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004068 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004069 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004070 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004071 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004072 },
4073
4074 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004075 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004076 .family = MV88E6XXX_FAMILY_6351,
4077 .name = "Marvell 88E6175",
4078 .num_databases = 4096,
4079 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004080 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004081 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004082 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004083 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004084 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004085 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004086 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004087 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004088 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004089 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004090 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004091 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004092 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004093 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004094 },
4095
4096 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004097 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004098 .family = MV88E6XXX_FAMILY_6352,
4099 .name = "Marvell 88E6176",
4100 .num_databases = 4096,
4101 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004102 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004103 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004104 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004105 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004106 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004107 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004108 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004109 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004110 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004111 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004112 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004113 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004114 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004115 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004116 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004117 },
4118
4119 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004120 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121 .family = MV88E6XXX_FAMILY_6185,
4122 .name = "Marvell 88E6185",
4123 .num_databases = 256,
4124 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004125 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004126 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004127 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004128 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004129 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004130 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004131 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004132 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004133 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004134 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004135 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004136 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004137 },
4138
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004139 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004140 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004141 .family = MV88E6XXX_FAMILY_6390,
4142 .name = "Marvell 88E6190",
4143 .num_databases = 4096,
4144 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004145 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004146 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004147 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004148 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004149 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004150 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004151 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004152 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004153 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004154 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004155 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004156 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004157 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004158 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004159 .ops = &mv88e6190_ops,
4160 },
4161
4162 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004163 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004164 .family = MV88E6XXX_FAMILY_6390,
4165 .name = "Marvell 88E6190X",
4166 .num_databases = 4096,
4167 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004168 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004169 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004170 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004171 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004172 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004173 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004174 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004175 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004176 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004177 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004178 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004179 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004180 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004181 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004182 .ops = &mv88e6190x_ops,
4183 },
4184
4185 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004186 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004187 .family = MV88E6XXX_FAMILY_6390,
4188 .name = "Marvell 88E6191",
4189 .num_databases = 4096,
4190 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004191 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004192 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004193 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004194 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004195 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004196 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004197 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004198 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004199 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004200 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004201 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004202 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004203 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004204 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004205 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004206 },
4207
Vivien Didelotf81ec902016-05-09 13:22:58 -04004208 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004209 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004210 .family = MV88E6XXX_FAMILY_6352,
4211 .name = "Marvell 88E6240",
4212 .num_databases = 4096,
4213 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004214 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004215 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004216 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004217 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004218 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004219 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004220 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004221 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004222 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004223 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004224 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004225 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004226 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004227 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004228 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004229 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004230 },
4231
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004232 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004233 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004234 .family = MV88E6XXX_FAMILY_6390,
4235 .name = "Marvell 88E6290",
4236 .num_databases = 4096,
4237 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004238 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004239 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004240 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004241 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004242 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004243 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004244 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004245 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004246 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004247 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004248 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004249 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004250 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004251 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004252 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .ops = &mv88e6290_ops,
4254 },
4255
Vivien Didelotf81ec902016-05-09 13:22:58 -04004256 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004257 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004258 .family = MV88E6XXX_FAMILY_6320,
4259 .name = "Marvell 88E6320",
4260 .num_databases = 4096,
4261 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004262 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004263 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004264 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004265 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004266 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004267 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004268 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004269 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004270 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004271 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004272 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004273 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004274 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004275 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004276 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004277 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004278 },
4279
4280 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004281 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004282 .family = MV88E6XXX_FAMILY_6320,
4283 .name = "Marvell 88E6321",
4284 .num_databases = 4096,
4285 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004286 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004287 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004288 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004289 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004290 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004291 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004292 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004293 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004294 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004295 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004296 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004297 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004298 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004299 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004300 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004301 },
4302
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004303 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004304 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004305 .family = MV88E6XXX_FAMILY_6341,
4306 .name = "Marvell 88E6341",
4307 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004308 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004309 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004310 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004311 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004312 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004313 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004314 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004315 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004316 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004317 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004318 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004319 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004320 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004321 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004322 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004323 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004324 .ops = &mv88e6341_ops,
4325 },
4326
Vivien Didelotf81ec902016-05-09 13:22:58 -04004327 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004328 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004329 .family = MV88E6XXX_FAMILY_6351,
4330 .name = "Marvell 88E6350",
4331 .num_databases = 4096,
4332 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004333 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004334 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004335 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004336 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004337 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004338 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004339 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004340 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004341 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004342 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004343 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004344 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004345 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004346 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004347 },
4348
4349 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004350 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004351 .family = MV88E6XXX_FAMILY_6351,
4352 .name = "Marvell 88E6351",
4353 .num_databases = 4096,
4354 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004355 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004356 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004357 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004358 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004359 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004360 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004361 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004362 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004363 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004364 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004365 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004366 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004367 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004368 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004369 },
4370
4371 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004372 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004373 .family = MV88E6XXX_FAMILY_6352,
4374 .name = "Marvell 88E6352",
4375 .num_databases = 4096,
4376 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004377 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004378 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004379 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004380 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004381 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004382 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004383 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004384 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004385 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004386 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004387 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004388 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004389 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004390 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004391 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004392 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004393 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004394 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004395 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004396 .family = MV88E6XXX_FAMILY_6390,
4397 .name = "Marvell 88E6390",
4398 .num_databases = 4096,
4399 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004400 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004401 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004402 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004403 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004404 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004405 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004406 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004407 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004408 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004409 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004410 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004411 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004412 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004413 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004414 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004415 .ops = &mv88e6390_ops,
4416 },
4417 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004418 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004419 .family = MV88E6XXX_FAMILY_6390,
4420 .name = "Marvell 88E6390X",
4421 .num_databases = 4096,
4422 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004423 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004424 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004425 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004426 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004427 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004428 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004429 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004430 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004431 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004432 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004433 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004434 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004435 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004436 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004437 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004438 .ops = &mv88e6390x_ops,
4439 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004440};
4441
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004442static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004443{
Vivien Didelota439c062016-04-17 13:23:58 -04004444 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004445
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004446 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4447 if (mv88e6xxx_table[i].prod_num == prod_num)
4448 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004449
Vivien Didelotb9b37712015-10-30 19:39:48 -04004450 return NULL;
4451}
4452
Vivien Didelotfad09c72016-06-21 12:28:20 -04004453static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004454{
4455 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004456 unsigned int prod_num, rev;
4457 u16 id;
4458 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004459
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004460 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004461 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004462 mutex_unlock(&chip->reg_lock);
4463 if (err)
4464 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004465
Vivien Didelot107fcc12017-06-12 12:37:36 -04004466 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4467 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004468
4469 info = mv88e6xxx_lookup_info(prod_num);
4470 if (!info)
4471 return -ENODEV;
4472
Vivien Didelotcaac8542016-06-20 13:14:09 -04004473 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004474 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004475
Vivien Didelotca070c12016-09-02 14:45:34 -04004476 err = mv88e6xxx_g2_require(chip);
4477 if (err)
4478 return err;
4479
Vivien Didelotfad09c72016-06-21 12:28:20 -04004480 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4481 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004482
4483 return 0;
4484}
4485
Vivien Didelotfad09c72016-06-21 12:28:20 -04004486static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004487{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004488 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004489
Vivien Didelotfad09c72016-06-21 12:28:20 -04004490 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4491 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004492 return NULL;
4493
Vivien Didelotfad09c72016-06-21 12:28:20 -04004494 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004495
Vivien Didelotfad09c72016-06-21 12:28:20 -04004496 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004497 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004498
Vivien Didelotfad09c72016-06-21 12:28:20 -04004499 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004500}
4501
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004502static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4503 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004504{
Vivien Didelot04bed142016-08-31 18:06:13 -04004505 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004506
Andrew Lunn443d5a12016-12-03 04:35:18 +01004507 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004508}
4509
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004510static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004511 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004512{
4513 /* We don't need any dynamic resource from the kernel (yet),
4514 * so skip the prepare phase.
4515 */
4516
4517 return 0;
4518}
4519
4520static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004521 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004522{
Vivien Didelot04bed142016-08-31 18:06:13 -04004523 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004524
4525 mutex_lock(&chip->reg_lock);
4526 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004527 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004528 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4529 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004530 mutex_unlock(&chip->reg_lock);
4531}
4532
4533static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4534 const struct switchdev_obj_port_mdb *mdb)
4535{
Vivien Didelot04bed142016-08-31 18:06:13 -04004536 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004537 int err;
4538
4539 mutex_lock(&chip->reg_lock);
4540 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004541 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004542 mutex_unlock(&chip->reg_lock);
4543
4544 return err;
4545}
4546
Russell King4f859012019-02-20 15:35:05 -08004547static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4548 bool unicast, bool multicast)
4549{
4550 struct mv88e6xxx_chip *chip = ds->priv;
4551 int err = -EOPNOTSUPP;
4552
4553 mutex_lock(&chip->reg_lock);
4554 if (chip->info->ops->port_set_egress_floods)
4555 err = chip->info->ops->port_set_egress_floods(chip, port,
4556 unicast,
4557 multicast);
4558 mutex_unlock(&chip->reg_lock);
4559
4560 return err;
4561}
4562
Florian Fainellia82f67a2017-01-08 14:52:08 -08004563static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004564 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004565 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004566 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004567 .phylink_validate = mv88e6xxx_validate,
4568 .phylink_mac_link_state = mv88e6xxx_link_state,
4569 .phylink_mac_config = mv88e6xxx_mac_config,
4570 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4571 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004572 .get_strings = mv88e6xxx_get_strings,
4573 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4574 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004575 .port_enable = mv88e6xxx_port_enable,
4576 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004577 .get_mac_eee = mv88e6xxx_get_mac_eee,
4578 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004579 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004580 .get_eeprom = mv88e6xxx_get_eeprom,
4581 .set_eeprom = mv88e6xxx_set_eeprom,
4582 .get_regs_len = mv88e6xxx_get_regs_len,
4583 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004584 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004585 .port_bridge_join = mv88e6xxx_port_bridge_join,
4586 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004587 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004588 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004589 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004590 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4591 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4592 .port_vlan_add = mv88e6xxx_port_vlan_add,
4593 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004594 .port_fdb_add = mv88e6xxx_port_fdb_add,
4595 .port_fdb_del = mv88e6xxx_port_fdb_del,
4596 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004597 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4598 .port_mdb_add = mv88e6xxx_port_mdb_add,
4599 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004600 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4601 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004602 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4603 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4604 .port_txtstamp = mv88e6xxx_port_txtstamp,
4605 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4606 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004607};
4608
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004609static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004610{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004611 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004612 struct dsa_switch *ds;
4613
Vivien Didelot73b12042017-03-30 17:37:10 -04004614 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004615 if (!ds)
4616 return -ENOMEM;
4617
Vivien Didelotfad09c72016-06-21 12:28:20 -04004618 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004619 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004620 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004621 ds->ageing_time_min = chip->info->age_time_coeff;
4622 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004623
4624 dev_set_drvdata(dev, ds);
4625
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004626 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004627}
4628
Vivien Didelotfad09c72016-06-21 12:28:20 -04004629static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004630{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004631 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004632}
4633
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004634static const void *pdata_device_get_match_data(struct device *dev)
4635{
4636 const struct of_device_id *matches = dev->driver->of_match_table;
4637 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4638
4639 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4640 matches++) {
4641 if (!strcmp(pdata->compatible, matches->compatible))
4642 return matches->data;
4643 }
4644 return NULL;
4645}
4646
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004647/* There is no suspend to RAM support at DSA level yet, the switch configuration
4648 * would be lost after a power cycle so prevent it to be suspended.
4649 */
4650static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4651{
4652 return -EOPNOTSUPP;
4653}
4654
4655static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4656{
4657 return 0;
4658}
4659
4660static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4661
Vivien Didelot57d32312016-06-20 13:13:58 -04004662static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004663{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004664 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004665 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004666 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004667 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004668 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004669 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004670 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004671
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004672 if (!np && !pdata)
4673 return -EINVAL;
4674
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004675 if (np)
4676 compat_info = of_device_get_match_data(dev);
4677
4678 if (pdata) {
4679 compat_info = pdata_device_get_match_data(dev);
4680
4681 if (!pdata->netdev)
4682 return -EINVAL;
4683
4684 for (port = 0; port < DSA_MAX_PORTS; port++) {
4685 if (!(pdata->enabled_ports & (1 << port)))
4686 continue;
4687 if (strcmp(pdata->cd.port_names[port], "cpu"))
4688 continue;
4689 pdata->cd.netdev[port] = &pdata->netdev->dev;
4690 break;
4691 }
4692 }
4693
Vivien Didelotcaac8542016-06-20 13:14:09 -04004694 if (!compat_info)
4695 return -EINVAL;
4696
Vivien Didelotfad09c72016-06-21 12:28:20 -04004697 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004698 if (!chip) {
4699 err = -ENOMEM;
4700 goto out;
4701 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004702
Vivien Didelotfad09c72016-06-21 12:28:20 -04004703 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004704
Vivien Didelotfad09c72016-06-21 12:28:20 -04004705 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004706 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004707 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004708
Andrew Lunnb4308f02016-11-21 23:26:55 +01004709 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004710 if (IS_ERR(chip->reset)) {
4711 err = PTR_ERR(chip->reset);
4712 goto out;
4713 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004714
Vivien Didelotfad09c72016-06-21 12:28:20 -04004715 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004716 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004717 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004718
Vivien Didelote57e5e72016-08-15 17:19:00 -04004719 mv88e6xxx_phy_init(chip);
4720
Andrew Lunn00baabe2018-05-19 22:31:35 +02004721 if (chip->info->ops->get_eeprom) {
4722 if (np)
4723 of_property_read_u32(np, "eeprom-length",
4724 &chip->eeprom_len);
4725 else
4726 chip->eeprom_len = pdata->eeprom_len;
4727 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004728
Andrew Lunndc30c352016-10-16 19:56:49 +02004729 mutex_lock(&chip->reg_lock);
4730 err = mv88e6xxx_switch_reset(chip);
4731 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004732 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004733 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004734
Andrew Lunna27415d2019-05-01 00:10:50 +02004735 if (np) {
4736 chip->irq = of_irq_get(np, 0);
4737 if (chip->irq == -EPROBE_DEFER) {
4738 err = chip->irq;
4739 goto out;
4740 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004741 }
4742
Andrew Lunna27415d2019-05-01 00:10:50 +02004743 if (pdata)
4744 chip->irq = pdata->irq;
4745
Andrew Lunn294d7112018-02-22 22:58:32 +01004746 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004747 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004748 * controllers
4749 */
4750 mutex_lock(&chip->reg_lock);
4751 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004752 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004753 else
4754 err = mv88e6xxx_irq_poll_setup(chip);
4755 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004756
Andrew Lunn294d7112018-02-22 22:58:32 +01004757 if (err)
4758 goto out;
4759
4760 if (chip->info->g2_irqs > 0) {
4761 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004762 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004763 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004764 }
4765
Andrew Lunn294d7112018-02-22 22:58:32 +01004766 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4767 if (err)
4768 goto out_g2_irq;
4769
4770 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4771 if (err)
4772 goto out_g1_atu_prob_irq;
4773
Andrew Lunna3c53be52017-01-24 14:53:50 +01004774 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004775 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004776 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004777
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004778 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004779 if (err)
4780 goto out_mdio;
4781
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004782 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004783
4784out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004785 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004786out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004787 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004788out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004789 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004790out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004791 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004792 mv88e6xxx_g2_irq_free(chip);
4793out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004794 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004795 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004796 else
4797 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004798out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004799 if (pdata)
4800 dev_put(pdata->netdev);
4801
Andrew Lunndc30c352016-10-16 19:56:49 +02004802 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004803}
4804
4805static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4806{
4807 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004808 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004809
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004810 if (chip->info->ptp_support) {
4811 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004812 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004813 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004814
Andrew Lunn930188c2016-08-22 16:01:03 +02004815 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004816 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004817 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004818
Andrew Lunn76f38f12018-03-17 20:21:09 +01004819 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4820 mv88e6xxx_g1_atu_prob_irq_free(chip);
4821
4822 if (chip->info->g2_irqs > 0)
4823 mv88e6xxx_g2_irq_free(chip);
4824
Andrew Lunn76f38f12018-03-17 20:21:09 +01004825 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004826 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004827 else
4828 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004829}
4830
4831static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004832 {
4833 .compatible = "marvell,mv88e6085",
4834 .data = &mv88e6xxx_table[MV88E6085],
4835 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004836 {
4837 .compatible = "marvell,mv88e6190",
4838 .data = &mv88e6xxx_table[MV88E6190],
4839 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004840 { /* sentinel */ },
4841};
4842
4843MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4844
4845static struct mdio_driver mv88e6xxx_driver = {
4846 .probe = mv88e6xxx_probe,
4847 .remove = mv88e6xxx_remove,
4848 .mdiodrv.driver = {
4849 .name = "mv88e6085",
4850 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004851 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004852 },
4853};
4854
Andrew Lunn7324d502019-04-27 19:19:10 +02004855mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004856
4857MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4858MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4859MODULE_LICENSE("GPL");