blob: df9c51da77330b12c05f3bdb7ab0586cf3778c63 [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020031#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000032#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010033#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000034#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070035#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000036#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040037
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040038#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040039#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040040#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010041#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020042#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010043#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010044#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020045#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040046#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000047
Vivien Didelotfad09c72016-06-21 12:28:20 -040048static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049{
Vivien Didelotfad09c72016-06-21 12:28:20 -040050 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
51 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040052 dump_stack();
53 }
54}
55
Vivien Didelotec561272016-09-02 14:45:33 -040056int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040057{
58 int err;
59
Vivien Didelotfad09c72016-06-21 12:28:20 -040060 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040061
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 if (err)
64 return err;
65
Vivien Didelotfad09c72016-06-21 12:28:20 -040066 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040067 addr, reg, *val);
68
69 return 0;
70}
71
Vivien Didelotec561272016-09-02 14:45:33 -040072int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040073{
74 int err;
75
Vivien Didelotfad09c72016-06-21 12:28:20 -040076 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040077
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 if (err)
80 return err;
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040083 addr, reg, val);
84
85 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000086}
87
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020088struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +010089{
90 struct mv88e6xxx_mdio_bus *mdio_bus;
91
92 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
93 list);
94 if (!mdio_bus)
95 return NULL;
96
97 return mdio_bus->bus;
98}
99
Andrew Lunndc30c352016-10-16 19:56:49 +0200100static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
101{
102 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
103 unsigned int n = d->hwirq;
104
105 chip->g1_irq.masked |= (1 << n);
106}
107
108static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
109{
110 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
111 unsigned int n = d->hwirq;
112
113 chip->g1_irq.masked &= ~(1 << n);
114}
115
Andrew Lunn294d7112018-02-22 22:58:32 +0100116static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200117{
Andrew Lunndc30c352016-10-16 19:56:49 +0200118 unsigned int nhandled = 0;
119 unsigned int sub_irq;
120 unsigned int n;
121 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500122 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200123 int err;
124
125 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400126 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200127 mutex_unlock(&chip->reg_lock);
128
129 if (err)
130 goto out;
131
John David Anglin7c0db242019-02-11 13:40:21 -0500132 do {
133 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
134 if (reg & (1 << n)) {
135 sub_irq = irq_find_mapping(chip->g1_irq.domain,
136 n);
137 handle_nested_irq(sub_irq);
138 ++nhandled;
139 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200140 }
John David Anglin7c0db242019-02-11 13:40:21 -0500141
142 mutex_lock(&chip->reg_lock);
143 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
144 if (err)
145 goto unlock;
146 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
147unlock:
148 mutex_unlock(&chip->reg_lock);
149 if (err)
150 goto out;
151 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
152 } while (reg & ctl1);
153
Andrew Lunndc30c352016-10-16 19:56:49 +0200154out:
155 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
156}
157
Andrew Lunn294d7112018-02-22 22:58:32 +0100158static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
159{
160 struct mv88e6xxx_chip *chip = dev_id;
161
162 return mv88e6xxx_g1_irq_thread_work(chip);
163}
164
Andrew Lunndc30c352016-10-16 19:56:49 +0200165static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
166{
167 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
168
169 mutex_lock(&chip->reg_lock);
170}
171
172static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
173{
174 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
175 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
176 u16 reg;
177 int err;
178
Vivien Didelotd77f4322017-06-15 12:14:03 -0400179 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200180 if (err)
181 goto out;
182
183 reg &= ~mask;
184 reg |= (~chip->g1_irq.masked & mask);
185
Vivien Didelotd77f4322017-06-15 12:14:03 -0400186 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200187 if (err)
188 goto out;
189
190out:
191 mutex_unlock(&chip->reg_lock);
192}
193
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530194static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200195 .name = "mv88e6xxx-g1",
196 .irq_mask = mv88e6xxx_g1_irq_mask,
197 .irq_unmask = mv88e6xxx_g1_irq_unmask,
198 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
199 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
200};
201
202static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
203 unsigned int irq,
204 irq_hw_number_t hwirq)
205{
206 struct mv88e6xxx_chip *chip = d->host_data;
207
208 irq_set_chip_data(irq, d->host_data);
209 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
210 irq_set_noprobe(irq);
211
212 return 0;
213}
214
215static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
216 .map = mv88e6xxx_g1_irq_domain_map,
217 .xlate = irq_domain_xlate_twocell,
218};
219
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200220/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100221static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200222{
223 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100224 u16 mask;
225
Vivien Didelotd77f4322017-06-15 12:14:03 -0400226 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100227 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400228 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100229
Andreas Färber5edef2f2016-11-27 23:26:28 +0100230 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100231 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200232 irq_dispose_mapping(virq);
233 }
234
Andrew Lunna3db3d32016-11-20 20:14:14 +0100235 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200236}
237
Andrew Lunn294d7112018-02-22 22:58:32 +0100238static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
239{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200240 /*
241 * free_irq must be called without reg_lock taken because the irq
242 * handler takes this lock, too.
243 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100244 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200245
246 mutex_lock(&chip->reg_lock);
247 mv88e6xxx_g1_irq_free_common(chip);
248 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100249}
250
251static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200252{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100253 int err, irq, virq;
254 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200255
256 chip->g1_irq.nirqs = chip->info->g1_irqs;
257 chip->g1_irq.domain = irq_domain_add_simple(
258 NULL, chip->g1_irq.nirqs, 0,
259 &mv88e6xxx_g1_irq_domain_ops, chip);
260 if (!chip->g1_irq.domain)
261 return -ENOMEM;
262
263 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
264 irq_create_mapping(chip->g1_irq.domain, irq);
265
266 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
267 chip->g1_irq.masked = ~0;
268
Vivien Didelotd77f4322017-06-15 12:14:03 -0400269 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200270 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100271 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200272
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100273 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200274
Vivien Didelotd77f4322017-06-15 12:14:03 -0400275 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200276 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100277 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200278
279 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400280 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200281 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100282 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200283
Andrew Lunndc30c352016-10-16 19:56:49 +0200284 return 0;
285
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100286out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100287 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400288 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100289
290out_mapping:
291 for (irq = 0; irq < 16; irq++) {
292 virq = irq_find_mapping(chip->g1_irq.domain, irq);
293 irq_dispose_mapping(virq);
294 }
295
296 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200297
298 return err;
299}
300
Andrew Lunn294d7112018-02-22 22:58:32 +0100301static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
302{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100303 static struct lock_class_key lock_key;
304 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100305 int err;
306
307 err = mv88e6xxx_g1_irq_setup_common(chip);
308 if (err)
309 return err;
310
Andrew Lunnf6d97582019-02-23 17:43:56 +0100311 /* These lock classes tells lockdep that global 1 irqs are in
312 * a different category than their parent GPIO, so it won't
313 * report false recursion.
314 */
315 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
316
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100317 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100318 err = request_threaded_irq(chip->irq, NULL,
319 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200320 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100321 dev_name(chip->dev), chip);
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100322 mutex_lock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100323 if (err)
324 mv88e6xxx_g1_irq_free_common(chip);
325
326 return err;
327}
328
329static void mv88e6xxx_irq_poll(struct kthread_work *work)
330{
331 struct mv88e6xxx_chip *chip = container_of(work,
332 struct mv88e6xxx_chip,
333 irq_poll_work.work);
334 mv88e6xxx_g1_irq_thread_work(chip);
335
336 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
337 msecs_to_jiffies(100));
338}
339
340static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
341{
342 int err;
343
344 err = mv88e6xxx_g1_irq_setup_common(chip);
345 if (err)
346 return err;
347
348 kthread_init_delayed_work(&chip->irq_poll_work,
349 mv88e6xxx_irq_poll);
350
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800351 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (IS_ERR(chip->kworker))
353 return PTR_ERR(chip->kworker);
354
355 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
356 msecs_to_jiffies(100));
357
358 return 0;
359}
360
361static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
362{
363 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
364 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200365
366 mutex_lock(&chip->reg_lock);
367 mv88e6xxx_g1_irq_free_common(chip);
368 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100369}
370
Vivien Didelotec561272016-09-02 14:45:33 -0400371int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400372{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200373 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400374
Andrew Lunn6441e6692016-08-19 00:01:55 +0200375 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400376 u16 val;
377 int err;
378
379 err = mv88e6xxx_read(chip, addr, reg, &val);
380 if (err)
381 return err;
382
383 if (!(val & mask))
384 return 0;
385
386 usleep_range(1000, 2000);
387 }
388
Andrew Lunn30853552016-08-19 00:01:57 +0200389 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400390 return -ETIMEDOUT;
391}
392
Vivien Didelotf22ab642016-07-18 20:45:31 -0400393/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400394int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400395{
396 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200397 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400398
399 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200400 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
401 if (err)
402 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400403
404 /* Set the Update bit to trigger a write operation */
405 val = BIT(15) | update;
406
407 return mv88e6xxx_write(chip, addr, reg, val);
408}
409
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100410int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
411 int speed, int duplex, int pause,
412 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100413{
Andrew Lunna26deec2019-04-18 03:11:39 +0200414 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100415 int err;
416
417 if (!chip->info->ops->port_set_link)
418 return 0;
419
Andrew Lunna26deec2019-04-18 03:11:39 +0200420 if (!chip->info->ops->port_link_state)
421 return 0;
422
423 err = chip->info->ops->port_link_state(chip, port, &state);
424 if (err)
425 return err;
426
427 /* Has anything actually changed? We don't expect the
428 * interface mode to change without one of the other
429 * parameters also changing
430 */
431 if (state.link == link &&
432 state.speed == speed &&
433 state.duplex == duplex)
434 return 0;
435
Vivien Didelotd78343d2016-11-04 03:23:36 +0100436 /* Port's MAC control must not be changed unless the link is down */
437 err = chip->info->ops->port_set_link(chip, port, 0);
438 if (err)
439 return err;
440
441 if (chip->info->ops->port_set_speed) {
442 err = chip->info->ops->port_set_speed(chip, port, speed);
443 if (err && err != -EOPNOTSUPP)
444 goto restore_link;
445 }
446
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100447 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
448 mode = chip->info->ops->port_max_speed_mode(port);
449
Andrew Lunn54186b92018-08-09 15:38:37 +0200450 if (chip->info->ops->port_set_pause) {
451 err = chip->info->ops->port_set_pause(chip, port, pause);
452 if (err)
453 goto restore_link;
454 }
455
Vivien Didelotd78343d2016-11-04 03:23:36 +0100456 if (chip->info->ops->port_set_duplex) {
457 err = chip->info->ops->port_set_duplex(chip, port, duplex);
458 if (err && err != -EOPNOTSUPP)
459 goto restore_link;
460 }
461
462 if (chip->info->ops->port_set_rgmii_delay) {
463 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
464 if (err && err != -EOPNOTSUPP)
465 goto restore_link;
466 }
467
Andrew Lunnf39908d2017-02-04 20:02:50 +0100468 if (chip->info->ops->port_set_cmode) {
469 err = chip->info->ops->port_set_cmode(chip, port, mode);
470 if (err && err != -EOPNOTSUPP)
471 goto restore_link;
472 }
473
Vivien Didelotd78343d2016-11-04 03:23:36 +0100474 err = 0;
475restore_link:
476 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400477 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100478
479 return err;
480}
481
Marek Vasutd700ec42018-09-12 00:15:24 +0200482static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
483{
484 struct mv88e6xxx_chip *chip = ds->priv;
485
486 return port < chip->info->num_internal_phys;
487}
488
Andrew Lunndea87022015-08-31 15:56:47 +0200489/* We expect the switch to perform auto negotiation if there is a real
490 * phy. However, in the case of a fixed link phy, we force the port
491 * settings from the fixed link settings.
492 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400493static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
494 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200495{
Vivien Didelot04bed142016-08-31 18:06:13 -0400496 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200497 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200498
Marek Vasutd700ec42018-09-12 00:15:24 +0200499 if (!phy_is_pseudo_fixed_link(phydev) &&
500 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200501 return;
502
Vivien Didelotfad09c72016-06-21 12:28:20 -0400503 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100504 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200505 phydev->duplex, phydev->pause,
506 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400507 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100508
509 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400510 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200511}
512
Russell King6c422e32018-08-09 15:38:39 +0200513static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
514 unsigned long *mask,
515 struct phylink_link_state *state)
516{
517 if (!phy_interface_mode_is_8023z(state->interface)) {
518 /* 10M and 100M are only supported in non-802.3z mode */
519 phylink_set(mask, 10baseT_Half);
520 phylink_set(mask, 10baseT_Full);
521 phylink_set(mask, 100baseT_Half);
522 phylink_set(mask, 100baseT_Full);
523 }
524}
525
526static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
527 unsigned long *mask,
528 struct phylink_link_state *state)
529{
530 /* FIXME: if the port is in 1000Base-X mode, then it only supports
531 * 1000M FD speeds. In this case, CMODE will indicate 5.
532 */
533 phylink_set(mask, 1000baseT_Full);
534 phylink_set(mask, 1000baseX_Full);
535
536 mv88e6065_phylink_validate(chip, port, mask, state);
537}
538
Marek Behúne3af71a2019-02-25 12:39:55 +0100539static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
540 unsigned long *mask,
541 struct phylink_link_state *state)
542{
543 if (port >= 5)
544 phylink_set(mask, 2500baseX_Full);
545
546 /* No ethtool bits for 200Mbps */
547 phylink_set(mask, 1000baseT_Full);
548 phylink_set(mask, 1000baseX_Full);
549
550 mv88e6065_phylink_validate(chip, port, mask, state);
551}
552
Russell King6c422e32018-08-09 15:38:39 +0200553static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
554 unsigned long *mask,
555 struct phylink_link_state *state)
556{
557 /* No ethtool bits for 200Mbps */
558 phylink_set(mask, 1000baseT_Full);
559 phylink_set(mask, 1000baseX_Full);
560
561 mv88e6065_phylink_validate(chip, port, mask, state);
562}
563
564static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
565 unsigned long *mask,
566 struct phylink_link_state *state)
567{
Andrew Lunnec260162019-02-08 22:25:44 +0100568 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200569 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100570 phylink_set(mask, 2500baseT_Full);
571 }
Russell King6c422e32018-08-09 15:38:39 +0200572
573 /* No ethtool bits for 200Mbps */
574 phylink_set(mask, 1000baseT_Full);
575 phylink_set(mask, 1000baseX_Full);
576
577 mv88e6065_phylink_validate(chip, port, mask, state);
578}
579
580static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
581 unsigned long *mask,
582 struct phylink_link_state *state)
583{
584 if (port >= 9) {
585 phylink_set(mask, 10000baseT_Full);
586 phylink_set(mask, 10000baseKR_Full);
587 }
588
589 mv88e6390_phylink_validate(chip, port, mask, state);
590}
591
Russell Kingc9a23562018-05-10 13:17:35 -0700592static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
593 unsigned long *supported,
594 struct phylink_link_state *state)
595{
Russell King6c422e32018-08-09 15:38:39 +0200596 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
597 struct mv88e6xxx_chip *chip = ds->priv;
598
599 /* Allow all the expected bits */
600 phylink_set(mask, Autoneg);
601 phylink_set(mask, Pause);
602 phylink_set_port_modes(mask);
603
604 if (chip->info->ops->phylink_validate)
605 chip->info->ops->phylink_validate(chip, port, mask, state);
606
607 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
608 bitmap_and(state->advertising, state->advertising, mask,
609 __ETHTOOL_LINK_MODE_MASK_NBITS);
610
611 /* We can only operate at 2500BaseX or 1000BaseX. If requested
612 * to advertise both, only report advertising at 2500BaseX.
613 */
614 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700615}
616
617static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
618 struct phylink_link_state *state)
619{
620 struct mv88e6xxx_chip *chip = ds->priv;
621 int err;
622
623 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200624 if (chip->info->ops->port_link_state)
625 err = chip->info->ops->port_link_state(chip, port, state);
626 else
627 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700628 mutex_unlock(&chip->reg_lock);
629
630 return err;
631}
632
633static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
634 unsigned int mode,
635 const struct phylink_link_state *state)
636{
637 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200638 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700639
Marek Vasutd700ec42018-09-12 00:15:24 +0200640 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700641 return;
642
643 if (mode == MLO_AN_FIXED) {
644 link = LINK_FORCED_UP;
645 speed = state->speed;
646 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200647 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
648 link = state->link;
649 speed = state->speed;
650 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700651 } else {
652 speed = SPEED_UNFORCED;
653 duplex = DUPLEX_UNFORCED;
654 link = LINK_UNFORCED;
655 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200656 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700657
658 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200659 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700660 state->interface);
661 mutex_unlock(&chip->reg_lock);
662
663 if (err && err != -EOPNOTSUPP)
664 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
665}
666
667static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
668{
669 struct mv88e6xxx_chip *chip = ds->priv;
670 int err;
671
672 mutex_lock(&chip->reg_lock);
673 err = chip->info->ops->port_set_link(chip, port, link);
674 mutex_unlock(&chip->reg_lock);
675
676 if (err)
677 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
678}
679
680static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
681 unsigned int mode,
682 phy_interface_t interface)
683{
684 if (mode == MLO_AN_FIXED)
685 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
686}
687
688static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
689 unsigned int mode, phy_interface_t interface,
690 struct phy_device *phydev)
691{
692 if (mode == MLO_AN_FIXED)
693 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
694}
695
Andrew Lunna605a0f2016-11-21 23:26:58 +0100696static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000697{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100698 if (!chip->info->ops->stats_snapshot)
699 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000700
Andrew Lunna605a0f2016-11-21 23:26:58 +0100701 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000702}
703
Andrew Lunne413e7e2015-04-02 04:06:38 +0200704static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100705 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
706 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
707 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
708 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
709 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
710 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
711 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
712 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
713 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
714 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
715 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
716 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
717 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
718 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
719 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
720 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
721 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
722 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
723 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
724 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
725 { "single", 4, 0x14, STATS_TYPE_BANK0, },
726 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
727 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
728 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
729 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
730 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
731 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
732 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
733 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
734 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
735 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
736 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
737 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
738 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
739 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
740 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
741 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
742 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
743 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
744 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
745 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
746 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
747 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
748 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
749 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
750 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
751 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
752 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
753 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
754 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
755 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
756 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
757 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
758 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
759 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
760 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
761 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
762 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
763 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200764};
765
Vivien Didelotfad09c72016-06-21 12:28:20 -0400766static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100767 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100768 int port, u16 bank1_select,
769 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200770{
Andrew Lunn80c46272015-06-20 18:42:30 +0200771 u32 low;
772 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100773 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200774 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200775 u64 value;
776
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100777 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100778 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200779 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
780 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800781 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200782
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200783 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100784 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200785 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
786 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800787 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000788 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200789 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100790 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100791 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100792 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100793 /* fall through */
794 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100795 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100796 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100797 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100798 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500799 break;
800 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800801 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200802 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100803 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200804 return value;
805}
806
Andrew Lunn436fe172018-03-01 02:02:29 +0100807static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
808 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100809{
810 struct mv88e6xxx_hw_stat *stat;
811 int i, j;
812
813 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
814 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100815 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100816 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
817 ETH_GSTRING_LEN);
818 j++;
819 }
820 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100821
822 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100823}
824
Andrew Lunn436fe172018-03-01 02:02:29 +0100825static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
826 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100827{
Andrew Lunn436fe172018-03-01 02:02:29 +0100828 return mv88e6xxx_stats_get_strings(chip, data,
829 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100830}
831
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000832static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
833 uint8_t *data)
834{
835 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
836}
837
Andrew Lunn436fe172018-03-01 02:02:29 +0100838static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
839 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100840{
Andrew Lunn436fe172018-03-01 02:02:29 +0100841 return mv88e6xxx_stats_get_strings(chip, data,
842 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100843}
844
Andrew Lunn65f60e42018-03-28 23:50:28 +0200845static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
846 "atu_member_violation",
847 "atu_miss_violation",
848 "atu_full_violation",
849 "vtu_member_violation",
850 "vtu_miss_violation",
851};
852
853static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
854{
855 unsigned int i;
856
857 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
858 strlcpy(data + i * ETH_GSTRING_LEN,
859 mv88e6xxx_atu_vtu_stats_strings[i],
860 ETH_GSTRING_LEN);
861}
862
Andrew Lunndfafe442016-11-21 23:27:02 +0100863static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700864 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865{
Vivien Didelot04bed142016-08-31 18:06:13 -0400866 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100867 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100868
Florian Fainelli89f09042018-04-25 12:12:50 -0700869 if (stringset != ETH_SS_STATS)
870 return;
871
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100872 mutex_lock(&chip->reg_lock);
873
Andrew Lunndfafe442016-11-21 23:27:02 +0100874 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100875 count = chip->info->ops->stats_get_strings(chip, data);
876
877 if (chip->info->ops->serdes_get_strings) {
878 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200879 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100880 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100881
Andrew Lunn65f60e42018-03-28 23:50:28 +0200882 data += count * ETH_GSTRING_LEN;
883 mv88e6xxx_atu_vtu_get_strings(data);
884
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100885 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100886}
887
888static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
889 int types)
890{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891 struct mv88e6xxx_hw_stat *stat;
892 int i, j;
893
894 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
895 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100896 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100897 j++;
898 }
899 return j;
900}
901
Andrew Lunndfafe442016-11-21 23:27:02 +0100902static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
903{
904 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
905 STATS_TYPE_PORT);
906}
907
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000908static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
909{
910 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
911}
912
Andrew Lunndfafe442016-11-21 23:27:02 +0100913static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
914{
915 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
916 STATS_TYPE_BANK1);
917}
918
Florian Fainelli89f09042018-04-25 12:12:50 -0700919static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100920{
921 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100922 int serdes_count = 0;
923 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100924
Florian Fainelli89f09042018-04-25 12:12:50 -0700925 if (sset != ETH_SS_STATS)
926 return 0;
927
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100928 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100929 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100930 count = chip->info->ops->stats_get_sset_count(chip);
931 if (count < 0)
932 goto out;
933
934 if (chip->info->ops->serdes_get_sset_count)
935 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
936 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200937 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100938 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200939 goto out;
940 }
941 count += serdes_count;
942 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
943
Andrew Lunn436fe172018-03-01 02:02:29 +0100944out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100945 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100946
Andrew Lunn436fe172018-03-01 02:02:29 +0100947 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100948}
949
Andrew Lunn436fe172018-03-01 02:02:29 +0100950static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
951 uint64_t *data, int types,
952 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100953{
954 struct mv88e6xxx_hw_stat *stat;
955 int i, j;
956
957 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
958 stat = &mv88e6xxx_hw_stats[i];
959 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100960 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100961 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
962 bank1_select,
963 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100964 mutex_unlock(&chip->reg_lock);
965
Andrew Lunn052f9472016-11-21 23:27:03 +0100966 j++;
967 }
968 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100969 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100970}
971
Andrew Lunn436fe172018-03-01 02:02:29 +0100972static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
973 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100974{
975 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100976 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400977 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100978}
979
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000980static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
981 uint64_t *data)
982{
983 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
984 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
985}
986
Andrew Lunn436fe172018-03-01 02:02:29 +0100987static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
988 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100989{
990 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100991 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400992 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
993 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100994}
995
Andrew Lunn436fe172018-03-01 02:02:29 +0100996static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
997 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100998{
999 return mv88e6xxx_stats_get_stats(chip, port, data,
1000 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001001 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1002 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001003}
1004
Andrew Lunn65f60e42018-03-28 23:50:28 +02001005static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1006 uint64_t *data)
1007{
1008 *data++ = chip->ports[port].atu_member_violation;
1009 *data++ = chip->ports[port].atu_miss_violation;
1010 *data++ = chip->ports[port].atu_full_violation;
1011 *data++ = chip->ports[port].vtu_member_violation;
1012 *data++ = chip->ports[port].vtu_miss_violation;
1013}
1014
Andrew Lunn052f9472016-11-21 23:27:03 +01001015static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1016 uint64_t *data)
1017{
Andrew Lunn436fe172018-03-01 02:02:29 +01001018 int count = 0;
1019
Andrew Lunn052f9472016-11-21 23:27:03 +01001020 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001021 count = chip->info->ops->stats_get_stats(chip, port, data);
1022
Andrew Lunn65f60e42018-03-28 23:50:28 +02001023 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001024 if (chip->info->ops->serdes_get_stats) {
1025 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001026 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001027 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001028 data += count;
1029 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1030 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001031}
1032
Vivien Didelotf81ec902016-05-09 13:22:58 -04001033static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1034 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001035{
Vivien Didelot04bed142016-08-31 18:06:13 -04001036 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001037 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001038
Vivien Didelotfad09c72016-06-21 12:28:20 -04001039 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001040
Andrew Lunna605a0f2016-11-21 23:26:58 +01001041 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001042 mutex_unlock(&chip->reg_lock);
1043
1044 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001045 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001046
1047 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001048
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001049}
Ben Hutchings98e67302011-11-25 14:36:19 +00001050
Vivien Didelotf81ec902016-05-09 13:22:58 -04001051static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001052{
1053 return 32 * sizeof(u16);
1054}
1055
Vivien Didelotf81ec902016-05-09 13:22:58 -04001056static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1057 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001058{
Vivien Didelot04bed142016-08-31 18:06:13 -04001059 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001060 int err;
1061 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001062 u16 *p = _p;
1063 int i;
1064
Vivien Didelota5f39322018-12-17 16:05:21 -05001065 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001066
1067 memset(p, 0xff, 32 * sizeof(u16));
1068
Vivien Didelotfad09c72016-06-21 12:28:20 -04001069 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001070
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001071 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001072
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001073 err = mv88e6xxx_port_read(chip, port, i, &reg);
1074 if (!err)
1075 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001076 }
Vivien Didelot23062512016-05-09 13:22:45 -04001077
Vivien Didelotfad09c72016-06-21 12:28:20 -04001078 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001079}
1080
Vivien Didelot08f50062017-08-01 16:32:41 -04001081static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1082 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001083{
Vivien Didelot5480db62017-08-01 16:32:40 -04001084 /* Nothing to do on the port's MAC */
1085 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001086}
1087
Vivien Didelot08f50062017-08-01 16:32:41 -04001088static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1089 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001090{
Vivien Didelot5480db62017-08-01 16:32:40 -04001091 /* Nothing to do on the port's MAC */
1092 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001093}
1094
Vivien Didelote5887a22017-03-30 17:37:11 -04001095static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001096{
Vivien Didelote5887a22017-03-30 17:37:11 -04001097 struct dsa_switch *ds = NULL;
1098 struct net_device *br;
1099 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001100 int i;
1101
Vivien Didelote5887a22017-03-30 17:37:11 -04001102 if (dev < DSA_MAX_SWITCHES)
1103 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001104
Vivien Didelote5887a22017-03-30 17:37:11 -04001105 /* Prevent frames from unknown switch or port */
1106 if (!ds || port >= ds->num_ports)
1107 return 0;
1108
1109 /* Frames from DSA links and CPU ports can egress any local port */
1110 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1111 return mv88e6xxx_port_mask(chip);
1112
1113 br = ds->ports[port].bridge_dev;
1114 pvlan = 0;
1115
1116 /* Frames from user ports can egress any local DSA links and CPU ports,
1117 * as well as any local member of their bridge group.
1118 */
1119 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1120 if (dsa_is_cpu_port(chip->ds, i) ||
1121 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001122 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001123 pvlan |= BIT(i);
1124
1125 return pvlan;
1126}
1127
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001128static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001129{
1130 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001131
1132 /* prevent frames from going back out of the port they came in on */
1133 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001134
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001135 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001136}
1137
Vivien Didelotf81ec902016-05-09 13:22:58 -04001138static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1139 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001140{
Vivien Didelot04bed142016-08-31 18:06:13 -04001141 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001142 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001143
Vivien Didelotfad09c72016-06-21 12:28:20 -04001144 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001145 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001146 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001147
1148 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001149 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001150}
1151
Vivien Didelot93e18d62018-05-11 17:16:35 -04001152static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1153{
1154 int err;
1155
1156 if (chip->info->ops->ieee_pri_map) {
1157 err = chip->info->ops->ieee_pri_map(chip);
1158 if (err)
1159 return err;
1160 }
1161
1162 if (chip->info->ops->ip_pri_map) {
1163 err = chip->info->ops->ip_pri_map(chip);
1164 if (err)
1165 return err;
1166 }
1167
1168 return 0;
1169}
1170
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001171static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1172{
1173 int target, port;
1174 int err;
1175
1176 if (!chip->info->global2_addr)
1177 return 0;
1178
1179 /* Initialize the routing port to the 32 possible target devices */
1180 for (target = 0; target < 32; target++) {
1181 port = 0x1f;
1182 if (target < DSA_MAX_SWITCHES)
1183 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1184 port = chip->ds->rtable[target];
1185
1186 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1187 if (err)
1188 return err;
1189 }
1190
Vivien Didelot02317e62018-05-09 11:38:49 -04001191 if (chip->info->ops->set_cascade_port) {
1192 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1193 err = chip->info->ops->set_cascade_port(chip, port);
1194 if (err)
1195 return err;
1196 }
1197
Vivien Didelot23c98912018-05-09 11:38:50 -04001198 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1199 if (err)
1200 return err;
1201
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001202 return 0;
1203}
1204
Vivien Didelotb28f8722018-04-26 21:56:44 -04001205static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1206{
1207 /* Clear all trunk masks and mapping */
1208 if (chip->info->global2_addr)
1209 return mv88e6xxx_g2_trunk_clear(chip);
1210
1211 return 0;
1212}
1213
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001214static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1215{
1216 if (chip->info->ops->rmu_disable)
1217 return chip->info->ops->rmu_disable(chip);
1218
1219 return 0;
1220}
1221
Vivien Didelot9e907d72017-07-17 13:03:43 -04001222static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1223{
1224 if (chip->info->ops->pot_clear)
1225 return chip->info->ops->pot_clear(chip);
1226
1227 return 0;
1228}
1229
Vivien Didelot51c901a2017-07-17 13:03:41 -04001230static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1231{
1232 if (chip->info->ops->mgmt_rsvd2cpu)
1233 return chip->info->ops->mgmt_rsvd2cpu(chip);
1234
1235 return 0;
1236}
1237
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001238static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1239{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001240 int err;
1241
Vivien Didelotdaefc942017-03-11 16:12:54 -05001242 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1243 if (err)
1244 return err;
1245
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001246 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1247 if (err)
1248 return err;
1249
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001250 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1251}
1252
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001253static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1254{
1255 int port;
1256 int err;
1257
1258 if (!chip->info->ops->irl_init_all)
1259 return 0;
1260
1261 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1262 /* Disable ingress rate limiting by resetting all per port
1263 * ingress rate limit resources to their initial state.
1264 */
1265 err = chip->info->ops->irl_init_all(chip, port);
1266 if (err)
1267 return err;
1268 }
1269
1270 return 0;
1271}
1272
Vivien Didelot04a69a12017-10-13 14:18:05 -04001273static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1274{
1275 if (chip->info->ops->set_switch_mac) {
1276 u8 addr[ETH_ALEN];
1277
1278 eth_random_addr(addr);
1279
1280 return chip->info->ops->set_switch_mac(chip, addr);
1281 }
1282
1283 return 0;
1284}
1285
Vivien Didelot17a15942017-03-30 17:37:09 -04001286static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1287{
1288 u16 pvlan = 0;
1289
1290 if (!mv88e6xxx_has_pvt(chip))
1291 return -EOPNOTSUPP;
1292
1293 /* Skip the local source device, which uses in-chip port VLAN */
1294 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001295 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001296
1297 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1298}
1299
Vivien Didelot81228992017-03-30 17:37:08 -04001300static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1301{
Vivien Didelot17a15942017-03-30 17:37:09 -04001302 int dev, port;
1303 int err;
1304
Vivien Didelot81228992017-03-30 17:37:08 -04001305 if (!mv88e6xxx_has_pvt(chip))
1306 return 0;
1307
1308 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1309 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1310 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001311 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1312 if (err)
1313 return err;
1314
1315 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1316 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1317 err = mv88e6xxx_pvt_map(chip, dev, port);
1318 if (err)
1319 return err;
1320 }
1321 }
1322
1323 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001324}
1325
Vivien Didelot749efcb2016-09-22 16:49:24 -04001326static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1327{
1328 struct mv88e6xxx_chip *chip = ds->priv;
1329 int err;
1330
1331 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001332 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001333 mutex_unlock(&chip->reg_lock);
1334
1335 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001336 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001337}
1338
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001339static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1340{
1341 if (!chip->info->max_vid)
1342 return 0;
1343
1344 return mv88e6xxx_g1_vtu_flush(chip);
1345}
1346
Vivien Didelotf1394b782017-05-01 14:05:22 -04001347static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1348 struct mv88e6xxx_vtu_entry *entry)
1349{
1350 if (!chip->info->ops->vtu_getnext)
1351 return -EOPNOTSUPP;
1352
1353 return chip->info->ops->vtu_getnext(chip, entry);
1354}
1355
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001356static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1357 struct mv88e6xxx_vtu_entry *entry)
1358{
1359 if (!chip->info->ops->vtu_loadpurge)
1360 return -EOPNOTSUPP;
1361
1362 return chip->info->ops->vtu_loadpurge(chip, entry);
1363}
1364
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001365static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001366{
1367 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001368 struct mv88e6xxx_vtu_entry vlan = {
1369 .vid = chip->info->max_vid,
1370 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001371 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001372
1373 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1374
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001375 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001376 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001377 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001378 if (err)
1379 return err;
1380
1381 set_bit(*fid, fid_bitmap);
1382 }
1383
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001384 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001385 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001386 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001387 if (err)
1388 return err;
1389
1390 if (!vlan.valid)
1391 break;
1392
1393 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001394 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001395
1396 /* The reset value 0x000 is used to indicate that multiple address
1397 * databases are not needed. Return the next positive available.
1398 */
1399 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001400 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001401 return -ENOSPC;
1402
1403 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001404 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001405}
1406
Vivien Didelot567aa592017-05-01 14:05:25 -04001407static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1408 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001409{
1410 int err;
1411
1412 if (!vid)
1413 return -EINVAL;
1414
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001415 entry->vid = vid - 1;
1416 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001417
Vivien Didelotf1394b782017-05-01 14:05:22 -04001418 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001419 if (err)
1420 return err;
1421
Vivien Didelot567aa592017-05-01 14:05:25 -04001422 if (entry->vid == vid && entry->valid)
1423 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001424
Vivien Didelot567aa592017-05-01 14:05:25 -04001425 if (new) {
1426 int i;
1427
1428 /* Initialize a fresh VLAN entry */
1429 memset(entry, 0, sizeof(*entry));
1430 entry->valid = true;
1431 entry->vid = vid;
1432
Vivien Didelot553a7682017-06-07 18:12:16 -04001433 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001434 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001435 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001436 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001437
1438 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001439 }
1440
Vivien Didelot567aa592017-05-01 14:05:25 -04001441 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1442 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001443}
1444
Vivien Didelotda9c3592016-02-12 12:09:40 -05001445static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1446 u16 vid_begin, u16 vid_end)
1447{
Vivien Didelot04bed142016-08-31 18:06:13 -04001448 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001449 struct mv88e6xxx_vtu_entry vlan = {
1450 .vid = vid_begin - 1,
1451 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001452 int i, err;
1453
Andrew Lunndb06ae412017-09-25 23:32:20 +02001454 /* DSA and CPU ports have to be members of multiple vlans */
1455 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1456 return 0;
1457
Vivien Didelotda9c3592016-02-12 12:09:40 -05001458 if (!vid_begin)
1459 return -EOPNOTSUPP;
1460
Vivien Didelotfad09c72016-06-21 12:28:20 -04001461 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001462
Vivien Didelotda9c3592016-02-12 12:09:40 -05001463 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001464 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001465 if (err)
1466 goto unlock;
1467
1468 if (!vlan.valid)
1469 break;
1470
1471 if (vlan.vid > vid_end)
1472 break;
1473
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001474 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001475 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1476 continue;
1477
Andrew Lunncd886462017-11-09 22:29:53 +01001478 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001479 continue;
1480
Vivien Didelotbd00e052017-05-01 14:05:11 -04001481 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001482 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001483 continue;
1484
Vivien Didelotc8652c82017-10-16 11:12:19 -04001485 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001486 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001487 break; /* same bridge, check next VLAN */
1488
Vivien Didelotc8652c82017-10-16 11:12:19 -04001489 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001490 continue;
1491
Andrew Lunn743fcc22017-11-09 22:29:54 +01001492 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1493 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001494 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001495 err = -EOPNOTSUPP;
1496 goto unlock;
1497 }
1498 } while (vlan.vid < vid_end);
1499
1500unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001501 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001502
1503 return err;
1504}
1505
Vivien Didelotf81ec902016-05-09 13:22:58 -04001506static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1507 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001508{
Vivien Didelot04bed142016-08-31 18:06:13 -04001509 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001510 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1511 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001512 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001513
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001514 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001515 return -EOPNOTSUPP;
1516
Vivien Didelotfad09c72016-06-21 12:28:20 -04001517 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001518 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001519 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001520
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001521 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001522}
1523
Vivien Didelot57d32312016-06-20 13:13:58 -04001524static int
1525mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001526 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001527{
Vivien Didelot04bed142016-08-31 18:06:13 -04001528 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 int err;
1530
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001531 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001532 return -EOPNOTSUPP;
1533
Vivien Didelotda9c3592016-02-12 12:09:40 -05001534 /* If the requested port doesn't belong to the same bridge as the VLAN
1535 * members, do not support it (yet) and fallback to software VLAN.
1536 */
1537 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1538 vlan->vid_end);
1539 if (err)
1540 return err;
1541
Vivien Didelot76e398a2015-11-01 12:33:55 -05001542 /* We don't need any dynamic resource from the kernel (yet),
1543 * so skip the prepare phase.
1544 */
1545 return 0;
1546}
1547
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001548static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1549 const unsigned char *addr, u16 vid,
1550 u8 state)
1551{
1552 struct mv88e6xxx_vtu_entry vlan;
1553 struct mv88e6xxx_atu_entry entry;
1554 int err;
1555
1556 /* Null VLAN ID corresponds to the port private database */
1557 if (vid == 0)
1558 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1559 else
1560 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1561 if (err)
1562 return err;
1563
1564 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1565 ether_addr_copy(entry.mac, addr);
1566 eth_addr_dec(entry.mac);
1567
1568 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1569 if (err)
1570 return err;
1571
1572 /* Initialize a fresh ATU entry if it isn't found */
1573 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1574 !ether_addr_equal(entry.mac, addr)) {
1575 memset(&entry, 0, sizeof(entry));
1576 ether_addr_copy(entry.mac, addr);
1577 }
1578
1579 /* Purge the ATU entry only if no port is using it anymore */
1580 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1581 entry.portvec &= ~BIT(port);
1582 if (!entry.portvec)
1583 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1584 } else {
1585 entry.portvec |= BIT(port);
1586 entry.state = state;
1587 }
1588
1589 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1590}
1591
Andrew Lunn87fa8862017-11-09 22:29:56 +01001592static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1593 u16 vid)
1594{
1595 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1596 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1597
1598 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1599}
1600
1601static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1602{
1603 int port;
1604 int err;
1605
1606 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1607 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1608 if (err)
1609 return err;
1610 }
1611
1612 return 0;
1613}
1614
Vivien Didelotfad09c72016-06-21 12:28:20 -04001615static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001616 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001617{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001618 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001619 int err;
1620
Vivien Didelot567aa592017-05-01 14:05:25 -04001621 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001622 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001623 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001624
Vivien Didelotc91498e2017-06-07 18:12:13 -04001625 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001626
Andrew Lunn87fa8862017-11-09 22:29:56 +01001627 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1628 if (err)
1629 return err;
1630
1631 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001632}
1633
Vivien Didelotf81ec902016-05-09 13:22:58 -04001634static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001635 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001636{
Vivien Didelot04bed142016-08-31 18:06:13 -04001637 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001638 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1639 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001640 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001641 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001642
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001643 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001644 return;
1645
Vivien Didelotc91498e2017-06-07 18:12:13 -04001646 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001647 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001648 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001649 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001650 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001651 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001652
Vivien Didelotfad09c72016-06-21 12:28:20 -04001653 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001654
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001655 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001656 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001657 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1658 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001659
Vivien Didelot77064f32016-11-04 03:23:30 +01001660 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001661 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1662 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001663
Vivien Didelotfad09c72016-06-21 12:28:20 -04001664 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001665}
1666
Vivien Didelotfad09c72016-06-21 12:28:20 -04001667static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001668 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001669{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001670 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001671 int i, err;
1672
Vivien Didelot567aa592017-05-01 14:05:25 -04001673 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001674 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001675 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001676
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001677 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001678 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001679 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001680
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001681 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001682
1683 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001684 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001685 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001686 if (vlan.member[i] !=
1687 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001688 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001689 break;
1690 }
1691 }
1692
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001693 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001694 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001695 return err;
1696
Vivien Didelote606ca32017-03-11 16:12:55 -05001697 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698}
1699
Vivien Didelotf81ec902016-05-09 13:22:58 -04001700static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1701 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001702{
Vivien Didelot04bed142016-08-31 18:06:13 -04001703 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704 u16 pvid, vid;
1705 int err = 0;
1706
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001707 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001708 return -EOPNOTSUPP;
1709
Vivien Didelotfad09c72016-06-21 12:28:20 -04001710 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001711
Vivien Didelot77064f32016-11-04 03:23:30 +01001712 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001713 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001714 goto unlock;
1715
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001717 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001718 if (err)
1719 goto unlock;
1720
1721 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001722 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001723 if (err)
1724 goto unlock;
1725 }
1726 }
1727
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001728unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001729 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001730
1731 return err;
1732}
1733
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001734static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1735 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001736{
Vivien Didelot04bed142016-08-31 18:06:13 -04001737 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001738 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001739
Vivien Didelotfad09c72016-06-21 12:28:20 -04001740 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001741 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1742 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001743 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001744
1745 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001746}
1747
Vivien Didelotf81ec902016-05-09 13:22:58 -04001748static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001749 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001750{
Vivien Didelot04bed142016-08-31 18:06:13 -04001751 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001752 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001753
Vivien Didelotfad09c72016-06-21 12:28:20 -04001754 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001755 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001756 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001757 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001758
Vivien Didelot83dabd12016-08-31 11:50:04 -04001759 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001760}
1761
Vivien Didelot83dabd12016-08-31 11:50:04 -04001762static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1763 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001764 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001765{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001766 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001767 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001768 int err;
1769
Vivien Didelot27c0e602017-06-15 12:14:01 -04001770 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001771 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001772
1773 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001774 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001775 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001776 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001777 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001778 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001779
Vivien Didelot27c0e602017-06-15 12:14:01 -04001780 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001781 break;
1782
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001783 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001784 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001785
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001786 if (!is_unicast_ether_addr(addr.mac))
1787 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001788
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001789 is_static = (addr.state ==
1790 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1791 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001792 if (err)
1793 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001794 } while (!is_broadcast_ether_addr(addr.mac));
1795
1796 return err;
1797}
1798
Vivien Didelot83dabd12016-08-31 11:50:04 -04001799static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001800 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001801{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001802 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001803 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001804 };
1805 u16 fid;
1806 int err;
1807
1808 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001809 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001810 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001811 mutex_unlock(&chip->reg_lock);
1812
Vivien Didelot83dabd12016-08-31 11:50:04 -04001813 if (err)
1814 return err;
1815
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001816 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001817 if (err)
1818 return err;
1819
1820 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001821 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001822 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001823 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001824 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001825 if (err)
1826 return err;
1827
1828 if (!vlan.valid)
1829 break;
1830
1831 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001832 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001833 if (err)
1834 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001835 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001836
1837 return err;
1838}
1839
Vivien Didelotf81ec902016-05-09 13:22:58 -04001840static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001841 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001842{
Vivien Didelot04bed142016-08-31 18:06:13 -04001843 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001844
Andrew Lunna61e5402018-02-15 14:38:35 +01001845 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001846}
1847
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001848static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1849 struct net_device *br)
1850{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001851 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001852 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001853 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001854 int err;
1855
1856 /* Remap the Port VLAN of each local bridge group member */
1857 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1858 if (chip->ds->ports[port].bridge_dev == br) {
1859 err = mv88e6xxx_port_vlan_map(chip, port);
1860 if (err)
1861 return err;
1862 }
1863 }
1864
Vivien Didelote96a6e02017-03-30 17:37:13 -04001865 if (!mv88e6xxx_has_pvt(chip))
1866 return 0;
1867
1868 /* Remap the Port VLAN of each cross-chip bridge group member */
1869 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1870 ds = chip->ds->dst->ds[dev];
1871 if (!ds)
1872 break;
1873
1874 for (port = 0; port < ds->num_ports; ++port) {
1875 if (ds->ports[port].bridge_dev == br) {
1876 err = mv88e6xxx_pvt_map(chip, dev, port);
1877 if (err)
1878 return err;
1879 }
1880 }
1881 }
1882
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001883 return 0;
1884}
1885
Vivien Didelotf81ec902016-05-09 13:22:58 -04001886static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001887 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001888{
Vivien Didelot04bed142016-08-31 18:06:13 -04001889 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001890 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001891
Vivien Didelotfad09c72016-06-21 12:28:20 -04001892 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001893 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001894 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001895
Vivien Didelot466dfa02016-02-26 13:16:05 -05001896 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001897}
1898
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001899static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1900 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001901{
Vivien Didelot04bed142016-08-31 18:06:13 -04001902 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001903
Vivien Didelotfad09c72016-06-21 12:28:20 -04001904 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001905 if (mv88e6xxx_bridge_map(chip, br) ||
1906 mv88e6xxx_port_vlan_map(chip, port))
1907 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001908 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001909}
1910
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001911static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1912 int port, struct net_device *br)
1913{
1914 struct mv88e6xxx_chip *chip = ds->priv;
1915 int err;
1916
1917 if (!mv88e6xxx_has_pvt(chip))
1918 return 0;
1919
1920 mutex_lock(&chip->reg_lock);
1921 err = mv88e6xxx_pvt_map(chip, dev, port);
1922 mutex_unlock(&chip->reg_lock);
1923
1924 return err;
1925}
1926
1927static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1928 int port, struct net_device *br)
1929{
1930 struct mv88e6xxx_chip *chip = ds->priv;
1931
1932 if (!mv88e6xxx_has_pvt(chip))
1933 return;
1934
1935 mutex_lock(&chip->reg_lock);
1936 if (mv88e6xxx_pvt_map(chip, dev, port))
1937 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1938 mutex_unlock(&chip->reg_lock);
1939}
1940
Vivien Didelot17e708b2016-12-05 17:30:27 -05001941static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1942{
1943 if (chip->info->ops->reset)
1944 return chip->info->ops->reset(chip);
1945
1946 return 0;
1947}
1948
Vivien Didelot309eca62016-12-05 17:30:26 -05001949static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1950{
1951 struct gpio_desc *gpiod = chip->reset;
1952
1953 /* If there is a GPIO connected to the reset pin, toggle it */
1954 if (gpiod) {
1955 gpiod_set_value_cansleep(gpiod, 1);
1956 usleep_range(10000, 20000);
1957 gpiod_set_value_cansleep(gpiod, 0);
1958 usleep_range(10000, 20000);
1959 }
1960}
1961
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001962static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1963{
1964 int i, err;
1965
1966 /* Set all ports to the Disabled state */
1967 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001968 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001969 if (err)
1970 return err;
1971 }
1972
1973 /* Wait for transmit queues to drain,
1974 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1975 */
1976 usleep_range(2000, 4000);
1977
1978 return 0;
1979}
1980
Vivien Didelotfad09c72016-06-21 12:28:20 -04001981static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001982{
Vivien Didelota935c052016-09-29 12:21:53 -04001983 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001984
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001985 err = mv88e6xxx_disable_ports(chip);
1986 if (err)
1987 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001988
Vivien Didelot309eca62016-12-05 17:30:26 -05001989 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001990
Vivien Didelot17e708b2016-12-05 17:30:27 -05001991 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001992}
1993
Vivien Didelot43145572017-03-11 16:12:59 -05001994static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001995 enum mv88e6xxx_frame_mode frame,
1996 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001997{
1998 int err;
1999
Vivien Didelot43145572017-03-11 16:12:59 -05002000 if (!chip->info->ops->port_set_frame_mode)
2001 return -EOPNOTSUPP;
2002
2003 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002004 if (err)
2005 return err;
2006
Vivien Didelot43145572017-03-11 16:12:59 -05002007 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2008 if (err)
2009 return err;
2010
2011 if (chip->info->ops->port_set_ether_type)
2012 return chip->info->ops->port_set_ether_type(chip, port, etype);
2013
2014 return 0;
2015}
2016
2017static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2018{
2019 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002020 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002021 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002022}
2023
2024static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2025{
2026 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002027 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002028 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002029}
2030
2031static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2032{
2033 return mv88e6xxx_set_port_mode(chip, port,
2034 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002035 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2036 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002037}
2038
2039static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2040{
2041 if (dsa_is_dsa_port(chip->ds, port))
2042 return mv88e6xxx_set_port_mode_dsa(chip, port);
2043
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002044 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002045 return mv88e6xxx_set_port_mode_normal(chip, port);
2046
2047 /* Setup CPU port mode depending on its supported tag format */
2048 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2049 return mv88e6xxx_set_port_mode_dsa(chip, port);
2050
2051 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2052 return mv88e6xxx_set_port_mode_edsa(chip, port);
2053
2054 return -EINVAL;
2055}
2056
Vivien Didelotea698f42017-03-11 16:12:50 -05002057static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2058{
2059 bool message = dsa_is_dsa_port(chip->ds, port);
2060
2061 return mv88e6xxx_port_set_message_port(chip, port, message);
2062}
2063
Vivien Didelot601aeed2017-03-11 16:13:00 -05002064static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2065{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002066 struct dsa_switch *ds = chip->ds;
2067 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002068
2069 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002070 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002071 if (chip->info->ops->port_set_egress_floods)
2072 return chip->info->ops->port_set_egress_floods(chip, port,
2073 flood, flood);
2074
2075 return 0;
2076}
2077
Andrew Lunn6d917822017-05-26 01:03:21 +02002078static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2079 bool on)
2080{
Vivien Didelot523a8902017-05-26 18:02:42 -04002081 if (chip->info->ops->serdes_power)
2082 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002083
Vivien Didelot523a8902017-05-26 18:02:42 -04002084 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002085}
2086
Vivien Didelotfa371c82017-12-05 15:34:10 -05002087static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2088{
2089 struct dsa_switch *ds = chip->ds;
2090 int upstream_port;
2091 int err;
2092
Vivien Didelot07073c72017-12-05 15:34:13 -05002093 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002094 if (chip->info->ops->port_set_upstream_port) {
2095 err = chip->info->ops->port_set_upstream_port(chip, port,
2096 upstream_port);
2097 if (err)
2098 return err;
2099 }
2100
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002101 if (port == upstream_port) {
2102 if (chip->info->ops->set_cpu_port) {
2103 err = chip->info->ops->set_cpu_port(chip,
2104 upstream_port);
2105 if (err)
2106 return err;
2107 }
2108
2109 if (chip->info->ops->set_egress_port) {
2110 err = chip->info->ops->set_egress_port(chip,
2111 upstream_port);
2112 if (err)
2113 return err;
2114 }
2115 }
2116
Vivien Didelotfa371c82017-12-05 15:34:10 -05002117 return 0;
2118}
2119
Vivien Didelotfad09c72016-06-21 12:28:20 -04002120static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002121{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002122 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002123 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002124 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002125
Andrew Lunn7b898462018-08-09 15:38:47 +02002126 chip->ports[port].chip = chip;
2127 chip->ports[port].port = port;
2128
Vivien Didelotd78343d2016-11-04 03:23:36 +01002129 /* MAC Forcing register: don't force link, speed, duplex or flow control
2130 * state to any particular values on physical ports, but force the CPU
2131 * port and all DSA ports to their maximum bandwidth and full duplex.
2132 */
2133 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2134 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2135 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002136 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002137 PHY_INTERFACE_MODE_NA);
2138 else
2139 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2140 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002141 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002142 PHY_INTERFACE_MODE_NA);
2143 if (err)
2144 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002145
2146 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2147 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2148 * tunneling, determine priority by looking at 802.1p and IP
2149 * priority fields (IP prio has precedence), and set STP state
2150 * to Forwarding.
2151 *
2152 * If this is the CPU link, use DSA or EDSA tagging depending
2153 * on which tagging mode was configured.
2154 *
2155 * If this is a link to another switch, use DSA tagging mode.
2156 *
2157 * If this is the upstream port for this switch, enable
2158 * forwarding of unknown unicasts and multicasts.
2159 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002160 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2161 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2162 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2163 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002164 if (err)
2165 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002166
Vivien Didelot601aeed2017-03-11 16:13:00 -05002167 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002168 if (err)
2169 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002170
Vivien Didelot601aeed2017-03-11 16:13:00 -05002171 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002172 if (err)
2173 return err;
2174
Andrew Lunn04aca992017-05-26 01:03:24 +02002175 /* Enable the SERDES interface for DSA and CPU ports. Normal
2176 * ports SERDES are enabled when the port is enabled, thus
2177 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002178 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002179 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2180 err = mv88e6xxx_serdes_power(chip, port, true);
2181 if (err)
2182 return err;
2183 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002184
Vivien Didelot8efdda42015-08-13 12:52:23 -04002185 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002186 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002187 * untagged frames on this port, do a destination address lookup on all
2188 * received packets as usual, disable ARP mirroring and don't send a
2189 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002190 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002191 err = mv88e6xxx_port_set_map_da(chip, port);
2192 if (err)
2193 return err;
2194
Vivien Didelotfa371c82017-12-05 15:34:10 -05002195 err = mv88e6xxx_setup_upstream_port(chip, port);
2196 if (err)
2197 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002198
Andrew Lunna23b2962017-02-04 20:15:28 +01002199 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002200 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002201 if (err)
2202 return err;
2203
Vivien Didelotcd782652017-06-08 18:34:13 -04002204 if (chip->info->ops->port_set_jumbo_size) {
2205 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002206 if (err)
2207 return err;
2208 }
2209
Andrew Lunn54d792f2015-05-06 01:09:47 +02002210 /* Port Association Vector: when learning source addresses
2211 * of packets, add the address to the address database using
2212 * a port bitmap that has only the bit for this port set and
2213 * the other bits clear.
2214 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002215 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002216 /* Disable learning for CPU port */
2217 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002218 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002219
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002220 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2221 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002222 if (err)
2223 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002224
2225 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002226 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2227 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002228 if (err)
2229 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002230
Vivien Didelot08984322017-06-08 18:34:12 -04002231 if (chip->info->ops->port_pause_limit) {
2232 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002233 if (err)
2234 return err;
2235 }
2236
Vivien Didelotc8c94892017-03-11 16:13:01 -05002237 if (chip->info->ops->port_disable_learn_limit) {
2238 err = chip->info->ops->port_disable_learn_limit(chip, port);
2239 if (err)
2240 return err;
2241 }
2242
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002243 if (chip->info->ops->port_disable_pri_override) {
2244 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002245 if (err)
2246 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002247 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002248
Andrew Lunnef0a7312016-12-03 04:35:16 +01002249 if (chip->info->ops->port_tag_remap) {
2250 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002251 if (err)
2252 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002253 }
2254
Andrew Lunnef70b112016-12-03 04:45:18 +01002255 if (chip->info->ops->port_egress_rate_limiting) {
2256 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002257 if (err)
2258 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002259 }
2260
Vivien Didelotea698f42017-03-11 16:12:50 -05002261 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002262 if (err)
2263 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002264
Vivien Didelot207afda2016-04-14 14:42:09 -04002265 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002266 * database, and allow bidirectional communication between the
2267 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002268 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002269 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002270 if (err)
2271 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002272
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002273 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002274 if (err)
2275 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002276
2277 /* Default VLAN ID and priority: don't set a default VLAN
2278 * ID, and set the default packet priority to zero.
2279 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002280 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002281}
2282
Andrew Lunn04aca992017-05-26 01:03:24 +02002283static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2284 struct phy_device *phydev)
2285{
2286 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002287 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002288
2289 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002290
Vivien Didelot523a8902017-05-26 18:02:42 -04002291 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002292
2293 if (!err && chip->info->ops->serdes_irq_setup)
2294 err = chip->info->ops->serdes_irq_setup(chip, port);
2295
Andrew Lunn04aca992017-05-26 01:03:24 +02002296 mutex_unlock(&chip->reg_lock);
2297
2298 return err;
2299}
2300
Andrew Lunn75104db2019-02-24 20:44:43 +01002301static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002302{
2303 struct mv88e6xxx_chip *chip = ds->priv;
2304
2305 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002306
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002307 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2308 dev_err(chip->dev, "failed to disable port\n");
2309
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002310 if (chip->info->ops->serdes_irq_free)
2311 chip->info->ops->serdes_irq_free(chip, port);
2312
Vivien Didelot523a8902017-05-26 18:02:42 -04002313 if (mv88e6xxx_serdes_power(chip, port, false))
2314 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002315
Andrew Lunn04aca992017-05-26 01:03:24 +02002316 mutex_unlock(&chip->reg_lock);
2317}
2318
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002319static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2320 unsigned int ageing_time)
2321{
Vivien Didelot04bed142016-08-31 18:06:13 -04002322 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002323 int err;
2324
2325 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002326 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002327 mutex_unlock(&chip->reg_lock);
2328
2329 return err;
2330}
2331
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002332static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002333{
2334 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002335
Andrew Lunnde2273872016-11-21 23:27:01 +01002336 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002337 if (chip->info->ops->stats_set_histogram) {
2338 err = chip->info->ops->stats_set_histogram(chip);
2339 if (err)
2340 return err;
2341 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002342
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002343 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002344}
2345
Andrew Lunnea890982019-01-09 00:24:03 +01002346/* The mv88e6390 has some hidden registers used for debug and
2347 * development. The errata also makes use of them.
2348 */
2349static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2350 int reg, u16 val)
2351{
2352 u16 ctrl;
2353 int err;
2354
2355 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2356 PORT_RESERVED_1A, val);
2357 if (err)
2358 return err;
2359
2360 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2361 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2362 reg;
2363
2364 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2365 PORT_RESERVED_1A, ctrl);
2366}
2367
2368static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2369{
2370 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2371 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2372}
2373
2374
2375static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2376 int reg, u16 *val)
2377{
2378 u16 ctrl;
2379 int err;
2380
2381 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2382 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2383 reg;
2384
2385 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2386 PORT_RESERVED_1A, ctrl);
2387 if (err)
2388 return err;
2389
2390 err = mv88e6390_hidden_wait(chip);
2391 if (err)
2392 return err;
2393
2394 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2395 PORT_RESERVED_1A, val);
2396}
2397
2398/* Check if the errata has already been applied. */
2399static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2400{
2401 int port;
2402 int err;
2403 u16 val;
2404
2405 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2406 err = mv88e6390_hidden_read(chip, port, 0, &val);
2407 if (err) {
2408 dev_err(chip->dev,
2409 "Error reading hidden register: %d\n", err);
2410 return false;
2411 }
2412 if (val != 0x01c0)
2413 return false;
2414 }
2415
2416 return true;
2417}
2418
2419/* The 6390 copper ports have an errata which require poking magic
2420 * values into undocumented hidden registers and then performing a
2421 * software reset.
2422 */
2423static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2424{
2425 int port;
2426 int err;
2427
2428 if (mv88e6390_setup_errata_applied(chip))
2429 return 0;
2430
2431 /* Set the ports into blocking mode */
2432 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2433 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2434 if (err)
2435 return err;
2436 }
2437
2438 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2439 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2440 if (err)
2441 return err;
2442 }
2443
2444 return mv88e6xxx_software_reset(chip);
2445}
2446
Vivien Didelotf81ec902016-05-09 13:22:58 -04002447static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002448{
Vivien Didelot04bed142016-08-31 18:06:13 -04002449 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002450 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002451 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002452 int i;
2453
Vivien Didelotfad09c72016-06-21 12:28:20 -04002454 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002455 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002456
Vivien Didelotfad09c72016-06-21 12:28:20 -04002457 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002458
Andrew Lunnea890982019-01-09 00:24:03 +01002459 if (chip->info->ops->setup_errata) {
2460 err = chip->info->ops->setup_errata(chip);
2461 if (err)
2462 goto unlock;
2463 }
2464
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002465 /* Cache the cmode of each port. */
2466 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2467 if (chip->info->ops->port_get_cmode) {
2468 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2469 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002470 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002471
2472 chip->ports[i].cmode = cmode;
2473 }
2474 }
2475
Vivien Didelot97299342016-07-18 20:45:30 -04002476 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002477 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Andrew Lunn100a9b92019-05-01 00:08:31 +02002478 if (dsa_is_unused_port(ds, i)) {
2479 err = mv88e6xxx_port_set_state(chip, i,
2480 BR_STATE_DISABLED);
2481 if (err)
2482 goto unlock;
2483
2484 err = mv88e6xxx_serdes_power(chip, i, false);
2485 if (err)
2486 goto unlock;
2487
Vivien Didelot91dee142017-10-26 11:22:52 -04002488 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002489 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002490
Vivien Didelot97299342016-07-18 20:45:30 -04002491 err = mv88e6xxx_setup_port(chip, i);
2492 if (err)
2493 goto unlock;
2494 }
2495
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002496 err = mv88e6xxx_irl_setup(chip);
2497 if (err)
2498 goto unlock;
2499
Vivien Didelot04a69a12017-10-13 14:18:05 -04002500 err = mv88e6xxx_mac_setup(chip);
2501 if (err)
2502 goto unlock;
2503
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002504 err = mv88e6xxx_phy_setup(chip);
2505 if (err)
2506 goto unlock;
2507
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002508 err = mv88e6xxx_vtu_setup(chip);
2509 if (err)
2510 goto unlock;
2511
Vivien Didelot81228992017-03-30 17:37:08 -04002512 err = mv88e6xxx_pvt_setup(chip);
2513 if (err)
2514 goto unlock;
2515
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002516 err = mv88e6xxx_atu_setup(chip);
2517 if (err)
2518 goto unlock;
2519
Andrew Lunn87fa8862017-11-09 22:29:56 +01002520 err = mv88e6xxx_broadcast_setup(chip, 0);
2521 if (err)
2522 goto unlock;
2523
Vivien Didelot9e907d72017-07-17 13:03:43 -04002524 err = mv88e6xxx_pot_setup(chip);
2525 if (err)
2526 goto unlock;
2527
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002528 err = mv88e6xxx_rmu_setup(chip);
2529 if (err)
2530 goto unlock;
2531
Vivien Didelot51c901a2017-07-17 13:03:41 -04002532 err = mv88e6xxx_rsvd2cpu_setup(chip);
2533 if (err)
2534 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002535
Vivien Didelotb28f8722018-04-26 21:56:44 -04002536 err = mv88e6xxx_trunk_setup(chip);
2537 if (err)
2538 goto unlock;
2539
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002540 err = mv88e6xxx_devmap_setup(chip);
2541 if (err)
2542 goto unlock;
2543
Vivien Didelot93e18d62018-05-11 17:16:35 -04002544 err = mv88e6xxx_pri_setup(chip);
2545 if (err)
2546 goto unlock;
2547
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002548 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002549 if (chip->info->ptp_support) {
2550 err = mv88e6xxx_ptp_setup(chip);
2551 if (err)
2552 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002553
2554 err = mv88e6xxx_hwtstamp_setup(chip);
2555 if (err)
2556 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002557 }
2558
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002559 err = mv88e6xxx_stats_setup(chip);
2560 if (err)
2561 goto unlock;
2562
Vivien Didelot6b17e862015-08-13 12:52:18 -04002563unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002564 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002565
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002566 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002567}
2568
Vivien Didelote57e5e72016-08-15 17:19:00 -04002569static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002570{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002571 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2572 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002573 u16 val;
2574 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002575
Andrew Lunnee26a222017-01-24 14:53:48 +01002576 if (!chip->info->ops->phy_read)
2577 return -EOPNOTSUPP;
2578
Vivien Didelotfad09c72016-06-21 12:28:20 -04002579 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002580 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002581 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002582
Andrew Lunnda9f3302017-02-01 03:40:05 +01002583 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002584 /* Some internal PHYs don't have a model number. */
2585 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2586 /* Then there is the 6165 family. It gets is
2587 * PHYs correct. But it can also have two
2588 * SERDES interfaces in the PHY address
2589 * space. And these don't have a model
2590 * number. But they are not PHYs, so we don't
2591 * want to give them something a PHY driver
2592 * will recognise.
2593 *
2594 * Use the mv88e6390 family model number
2595 * instead, for anything which really could be
2596 * a PHY,
2597 */
2598 if (!(val & 0x3f0))
2599 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002600 }
2601
Vivien Didelote57e5e72016-08-15 17:19:00 -04002602 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002603}
2604
Vivien Didelote57e5e72016-08-15 17:19:00 -04002605static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002606{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002607 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2608 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002609 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002610
Andrew Lunnee26a222017-01-24 14:53:48 +01002611 if (!chip->info->ops->phy_write)
2612 return -EOPNOTSUPP;
2613
Vivien Didelotfad09c72016-06-21 12:28:20 -04002614 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002615 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002616 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002617
2618 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002619}
2620
Vivien Didelotfad09c72016-06-21 12:28:20 -04002621static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002622 struct device_node *np,
2623 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002624{
2625 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002626 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002627 struct mii_bus *bus;
2628 int err;
2629
Andrew Lunn2510bab2018-02-22 01:51:49 +01002630 if (external) {
2631 mutex_lock(&chip->reg_lock);
2632 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2633 mutex_unlock(&chip->reg_lock);
2634
2635 if (err)
2636 return err;
2637 }
2638
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002639 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002640 if (!bus)
2641 return -ENOMEM;
2642
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002643 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002644 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002645 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002646 INIT_LIST_HEAD(&mdio_bus->list);
2647 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002648
Andrew Lunnb516d452016-06-04 21:17:06 +02002649 if (np) {
2650 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002651 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002652 } else {
2653 bus->name = "mv88e6xxx SMI";
2654 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2655 }
2656
2657 bus->read = mv88e6xxx_mdio_read;
2658 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002659 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002660
Andrew Lunn6f882842018-03-17 20:32:05 +01002661 if (!external) {
2662 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2663 if (err)
2664 return err;
2665 }
2666
Florian Fainelli00e798c2018-05-15 16:56:19 -07002667 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002668 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002669 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002670 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002671 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002672 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002673
2674 if (external)
2675 list_add_tail(&mdio_bus->list, &chip->mdios);
2676 else
2677 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002678
2679 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002680}
2681
Andrew Lunna3c53be52017-01-24 14:53:50 +01002682static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2683 { .compatible = "marvell,mv88e6xxx-mdio-external",
2684 .data = (void *)true },
2685 { },
2686};
2687
Andrew Lunn3126aee2017-12-07 01:05:57 +01002688static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2689
2690{
2691 struct mv88e6xxx_mdio_bus *mdio_bus;
2692 struct mii_bus *bus;
2693
2694 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2695 bus = mdio_bus->bus;
2696
Andrew Lunn6f882842018-03-17 20:32:05 +01002697 if (!mdio_bus->external)
2698 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2699
Andrew Lunn3126aee2017-12-07 01:05:57 +01002700 mdiobus_unregister(bus);
2701 }
2702}
2703
Andrew Lunna3c53be52017-01-24 14:53:50 +01002704static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2705 struct device_node *np)
2706{
2707 const struct of_device_id *match;
2708 struct device_node *child;
2709 int err;
2710
2711 /* Always register one mdio bus for the internal/default mdio
2712 * bus. This maybe represented in the device tree, but is
2713 * optional.
2714 */
2715 child = of_get_child_by_name(np, "mdio");
2716 err = mv88e6xxx_mdio_register(chip, child, false);
2717 if (err)
2718 return err;
2719
2720 /* Walk the device tree, and see if there are any other nodes
2721 * which say they are compatible with the external mdio
2722 * bus.
2723 */
2724 for_each_available_child_of_node(np, child) {
2725 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2726 if (match) {
2727 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002728 if (err) {
2729 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002730 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002731 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002732 }
2733 }
2734
2735 return 0;
2736}
2737
Vivien Didelot855b1932016-07-20 18:18:35 -04002738static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2739{
Vivien Didelot04bed142016-08-31 18:06:13 -04002740 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002741
2742 return chip->eeprom_len;
2743}
2744
Vivien Didelot855b1932016-07-20 18:18:35 -04002745static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2746 struct ethtool_eeprom *eeprom, u8 *data)
2747{
Vivien Didelot04bed142016-08-31 18:06:13 -04002748 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002749 int err;
2750
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002751 if (!chip->info->ops->get_eeprom)
2752 return -EOPNOTSUPP;
2753
Vivien Didelot855b1932016-07-20 18:18:35 -04002754 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002755 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002756 mutex_unlock(&chip->reg_lock);
2757
2758 if (err)
2759 return err;
2760
2761 eeprom->magic = 0xc3ec4951;
2762
2763 return 0;
2764}
2765
Vivien Didelot855b1932016-07-20 18:18:35 -04002766static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2767 struct ethtool_eeprom *eeprom, u8 *data)
2768{
Vivien Didelot04bed142016-08-31 18:06:13 -04002769 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002770 int err;
2771
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002772 if (!chip->info->ops->set_eeprom)
2773 return -EOPNOTSUPP;
2774
Vivien Didelot855b1932016-07-20 18:18:35 -04002775 if (eeprom->magic != 0xc3ec4951)
2776 return -EINVAL;
2777
2778 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002779 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002780 mutex_unlock(&chip->reg_lock);
2781
2782 return err;
2783}
2784
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002785static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002786 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002787 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2788 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002789 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002790 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002791 .phy_read = mv88e6185_phy_ppu_read,
2792 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002793 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002794 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002795 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002796 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002797 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002798 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002799 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002800 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002801 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002802 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002803 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002804 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002805 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002806 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002807 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002808 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2809 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002810 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002811 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2812 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002813 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002814 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002815 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002816 .ppu_enable = mv88e6185_g1_ppu_enable,
2817 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002819 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002820 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002821 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002822 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002823};
2824
2825static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002826 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002827 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2828 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002829 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002830 .phy_read = mv88e6185_phy_ppu_read,
2831 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002832 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002833 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002834 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002835 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002836 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002837 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002838 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002839 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002840 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002841 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002842 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2843 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002844 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002845 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002846 .ppu_enable = mv88e6185_g1_ppu_enable,
2847 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002848 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002849 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002850 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002851 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002852};
2853
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002854static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002855 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002856 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2857 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002858 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002859 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2860 .phy_read = mv88e6xxx_g2_smi_phy_read,
2861 .phy_write = mv88e6xxx_g2_smi_phy_write,
2862 .port_set_link = mv88e6xxx_port_set_link,
2863 .port_set_duplex = mv88e6xxx_port_set_duplex,
2864 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002865 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002866 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002867 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002868 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002869 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002870 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002871 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002872 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002873 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002874 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002875 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002876 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002877 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002878 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2879 .stats_get_strings = mv88e6095_stats_get_strings,
2880 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002881 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2882 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002883 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002884 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002885 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002886 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002887 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002888 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002889 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002890 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002891};
2892
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002893static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002894 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002895 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2896 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002897 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002898 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002899 .phy_read = mv88e6xxx_g2_smi_phy_read,
2900 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002901 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002902 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002903 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002904 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002905 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002906 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002907 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002908 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002909 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002910 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002911 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002912 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2913 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002914 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002915 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2916 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002917 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002918 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002919 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002920 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002921 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002922 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002923 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002924};
2925
2926static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002927 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002928 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2929 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002930 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002931 .phy_read = mv88e6185_phy_ppu_read,
2932 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002933 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002934 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002935 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002936 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002937 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002938 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002939 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002940 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002941 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002942 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002943 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002944 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002945 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002946 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002947 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002948 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002949 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2950 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002951 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002952 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2953 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002954 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002955 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002956 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002957 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002958 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002959 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002960 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002961 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002962 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002963};
2964
Vivien Didelot990e27b2017-03-28 13:50:32 -04002965static const struct mv88e6xxx_ops mv88e6141_ops = {
2966 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002967 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2968 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002969 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002970 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2971 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2972 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2973 .phy_read = mv88e6xxx_g2_smi_phy_read,
2974 .phy_write = mv88e6xxx_g2_smi_phy_write,
2975 .port_set_link = mv88e6xxx_port_set_link,
2976 .port_set_duplex = mv88e6xxx_port_set_duplex,
2977 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002978 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002979 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002980 .port_tag_remap = mv88e6095_port_tag_remap,
2981 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2982 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2983 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002984 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002985 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002986 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002987 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2988 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002989 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002990 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002991 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002992 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002993 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2994 .stats_get_strings = mv88e6320_stats_get_strings,
2995 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002996 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2997 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002998 .watchdog_ops = &mv88e6390_watchdog_ops,
2999 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003000 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003001 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003002 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003003 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003004 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003005 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003006 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003007};
3008
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003009static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003010 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003011 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3012 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003013 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003014 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003015 .phy_read = mv88e6xxx_g2_smi_phy_read,
3016 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003017 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003018 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003019 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003020 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003021 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003022 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003023 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003024 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003025 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003026 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003027 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003028 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003029 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003030 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003031 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003032 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003033 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3034 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003035 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003036 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3037 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003038 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003039 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003040 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003041 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003042 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003043 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003044 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003045 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003046 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003047};
3048
3049static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003050 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003051 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3052 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003053 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003054 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003055 .phy_read = mv88e6165_phy_read,
3056 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003057 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003058 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003059 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003060 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003061 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003062 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003063 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003064 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003065 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003066 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3067 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003068 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003069 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3070 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003071 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003072 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003073 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003074 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003075 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003076 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003077 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003078 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003079 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003080};
3081
3082static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003083 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003084 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3085 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003086 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003087 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003088 .phy_read = mv88e6xxx_g2_smi_phy_read,
3089 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003090 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003091 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003092 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003093 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003094 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003095 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003096 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003097 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003098 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003099 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003100 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003101 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003102 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003103 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003104 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003105 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003106 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003107 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3108 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003109 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003110 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3111 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003112 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003113 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003114 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003115 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003116 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003117 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003118 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003119};
3120
3121static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003122 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003123 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3124 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003125 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003126 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3127 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003128 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003129 .phy_read = mv88e6xxx_g2_smi_phy_read,
3130 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003131 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003132 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003133 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003134 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003135 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003136 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003137 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003138 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003139 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003140 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003141 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003142 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003143 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003144 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003145 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003146 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003147 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003148 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3149 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003150 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003151 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3152 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003153 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003154 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003155 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003156 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003157 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003158 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003159 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003160 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003161 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003162 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003163};
3164
3165static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003166 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003167 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3168 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003169 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003170 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003171 .phy_read = mv88e6xxx_g2_smi_phy_read,
3172 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003173 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003174 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003175 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003176 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003177 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003178 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003179 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003180 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003181 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003182 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003183 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003184 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003185 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003186 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003187 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003188 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003189 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003190 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3191 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003192 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003193 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3194 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003195 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003196 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003197 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003198 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003199 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003200 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003201 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003202};
3203
3204static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003205 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003206 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3207 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003208 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003209 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3210 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003211 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003212 .phy_read = mv88e6xxx_g2_smi_phy_read,
3213 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003214 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003215 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003216 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003217 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003218 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003219 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003220 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003221 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003222 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003223 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003224 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003225 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003226 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003227 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003228 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003229 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003230 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003231 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3232 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003233 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003234 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3235 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003236 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003237 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003238 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003239 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003240 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003241 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003242 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003243 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003244 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3245 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003246 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003247 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003248};
3249
3250static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003251 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003252 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3253 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003254 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003255 .phy_read = mv88e6185_phy_ppu_read,
3256 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003257 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003258 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003259 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003260 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003261 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003262 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003263 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003264 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003265 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003266 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003267 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003268 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003269 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3270 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003271 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003272 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3273 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003274 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003275 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003276 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003277 .ppu_enable = mv88e6185_g1_ppu_enable,
3278 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003279 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003280 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003281 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003282 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003283};
3284
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003285static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003286 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003287 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003288 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003289 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3290 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003291 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3292 .phy_read = mv88e6xxx_g2_smi_phy_read,
3293 .phy_write = mv88e6xxx_g2_smi_phy_write,
3294 .port_set_link = mv88e6xxx_port_set_link,
3295 .port_set_duplex = mv88e6xxx_port_set_duplex,
3296 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3297 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003298 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003299 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003300 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003301 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003302 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003303 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003304 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003305 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003306 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003307 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003308 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003309 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003310 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003311 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3312 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003313 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003314 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3315 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003316 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003317 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003318 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003319 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003320 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003321 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3322 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003323 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003324 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3325 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003326 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003327 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003328};
3329
3330static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003331 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003332 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003333 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003334 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3335 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003336 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3337 .phy_read = mv88e6xxx_g2_smi_phy_read,
3338 .phy_write = mv88e6xxx_g2_smi_phy_write,
3339 .port_set_link = mv88e6xxx_port_set_link,
3340 .port_set_duplex = mv88e6xxx_port_set_duplex,
3341 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3342 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003343 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003344 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003345 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003346 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003347 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003348 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003349 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003350 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003351 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003352 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003353 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003354 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003355 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003356 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3357 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003358 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003359 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3360 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003361 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003362 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003363 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003364 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003365 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003366 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3367 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003368 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003369 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3370 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003371 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003372 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003373};
3374
3375static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003376 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003377 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003378 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003379 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3380 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003381 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3382 .phy_read = mv88e6xxx_g2_smi_phy_read,
3383 .phy_write = mv88e6xxx_g2_smi_phy_write,
3384 .port_set_link = mv88e6xxx_port_set_link,
3385 .port_set_duplex = mv88e6xxx_port_set_duplex,
3386 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3387 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003388 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003389 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003390 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003391 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003392 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003393 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003394 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003395 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003396 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003397 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003398 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003399 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003400 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003401 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3402 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003403 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003404 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3405 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003406 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003407 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003408 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003409 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003410 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003411 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3412 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003413 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003414 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3415 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003416 .avb_ops = &mv88e6390_avb_ops,
3417 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003418 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003419};
3420
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003421static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003422 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003423 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3424 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003425 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003426 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3427 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003428 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003429 .phy_read = mv88e6xxx_g2_smi_phy_read,
3430 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003431 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003432 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003433 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003434 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003435 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003436 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003437 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003438 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003439 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003440 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003441 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003442 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003443 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003444 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003445 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003446 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003447 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003448 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3449 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003450 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003451 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3452 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003453 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003454 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003455 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003456 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003457 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003458 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003459 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003460 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003461 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3462 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003463 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003464 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003465 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003466 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003467};
3468
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003469static const struct mv88e6xxx_ops mv88e6250_ops = {
3470 /* MV88E6XXX_FAMILY_6250 */
3471 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3472 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3473 .irl_init_all = mv88e6352_g2_irl_init_all,
3474 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3475 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3476 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3477 .phy_read = mv88e6xxx_g2_smi_phy_read,
3478 .phy_write = mv88e6xxx_g2_smi_phy_write,
3479 .port_set_link = mv88e6xxx_port_set_link,
3480 .port_set_duplex = mv88e6xxx_port_set_duplex,
3481 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3482 .port_set_speed = mv88e6250_port_set_speed,
3483 .port_tag_remap = mv88e6095_port_tag_remap,
3484 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3485 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3486 .port_set_ether_type = mv88e6351_port_set_ether_type,
3487 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3488 .port_pause_limit = mv88e6097_port_pause_limit,
3489 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3490 .port_link_state = mv88e6250_port_link_state,
3491 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3492 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3493 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3494 .stats_get_strings = mv88e6250_stats_get_strings,
3495 .stats_get_stats = mv88e6250_stats_get_stats,
3496 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3497 .set_egress_port = mv88e6095_g1_set_egress_port,
3498 .watchdog_ops = &mv88e6250_watchdog_ops,
3499 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3500 .pot_clear = mv88e6xxx_g2_pot_clear,
3501 .reset = mv88e6250_g1_reset,
3502 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3503 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
3504 .phylink_validate = mv88e6065_phylink_validate,
3505};
3506
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003507static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003508 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003509 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003510 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003511 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3512 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003513 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3514 .phy_read = mv88e6xxx_g2_smi_phy_read,
3515 .phy_write = mv88e6xxx_g2_smi_phy_write,
3516 .port_set_link = mv88e6xxx_port_set_link,
3517 .port_set_duplex = mv88e6xxx_port_set_duplex,
3518 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3519 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003520 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003521 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003522 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003523 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003524 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003525 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003526 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003527 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003528 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003529 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003530 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003531 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003532 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003533 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3534 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003535 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003536 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3537 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003538 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003539 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003540 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003541 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003542 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003543 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3544 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003545 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003546 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3547 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003548 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003549 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003550 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003551 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003552};
3553
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003554static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003555 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003556 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3557 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003558 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003559 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3560 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003561 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003562 .phy_read = mv88e6xxx_g2_smi_phy_read,
3563 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003564 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003565 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003566 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003567 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003568 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003569 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003570 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003571 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003572 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003573 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003574 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003575 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003576 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003577 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003578 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003579 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003580 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3581 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003582 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003583 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3584 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003585 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003586 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003587 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003588 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003589 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003590 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003591 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003592 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003593 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003594 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003595};
3596
3597static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003598 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003599 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3600 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003601 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003602 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3603 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003604 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003605 .phy_read = mv88e6xxx_g2_smi_phy_read,
3606 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003607 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003608 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003609 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003610 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003611 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003612 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003613 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003614 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003615 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003616 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003617 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003618 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003619 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003620 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003621 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003622 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003623 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3624 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003625 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003626 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3627 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003628 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003629 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003630 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003631 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003632 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003633 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003634 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003635 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003636};
3637
Vivien Didelot16e329a2017-03-28 13:50:33 -04003638static const struct mv88e6xxx_ops mv88e6341_ops = {
3639 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003640 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3641 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003642 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003643 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3644 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3645 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3646 .phy_read = mv88e6xxx_g2_smi_phy_read,
3647 .phy_write = mv88e6xxx_g2_smi_phy_write,
3648 .port_set_link = mv88e6xxx_port_set_link,
3649 .port_set_duplex = mv88e6xxx_port_set_duplex,
3650 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003651 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003652 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003653 .port_tag_remap = mv88e6095_port_tag_remap,
3654 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3655 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3656 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003657 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003658 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003659 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003660 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3661 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003662 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003663 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003664 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003665 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003666 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3667 .stats_get_strings = mv88e6320_stats_get_strings,
3668 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003669 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3670 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003671 .watchdog_ops = &mv88e6390_watchdog_ops,
3672 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003673 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003674 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003675 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003676 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003677 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003678 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003679 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003680 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003681 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003682};
3683
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003684static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003685 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003686 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3687 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003688 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003689 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003690 .phy_read = mv88e6xxx_g2_smi_phy_read,
3691 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003692 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003693 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003694 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003695 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003696 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003697 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003698 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003699 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003700 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003701 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003702 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003703 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003704 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003705 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003706 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003707 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003708 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003709 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3710 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003711 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003712 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3713 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003714 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003715 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003716 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003717 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003718 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003719 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003720 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003721};
3722
3723static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003724 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003725 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3726 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003727 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003728 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003729 .phy_read = mv88e6xxx_g2_smi_phy_read,
3730 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003731 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003732 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003733 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003734 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003735 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003736 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003737 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003738 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003739 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003740 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003741 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003742 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003743 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003744 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003745 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003746 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003747 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003748 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3749 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003750 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003751 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3752 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003753 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003754 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003755 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003756 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003757 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003758 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003759 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003760 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003761 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003762};
3763
3764static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003765 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003766 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3767 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003768 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003769 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3770 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003771 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003772 .phy_read = mv88e6xxx_g2_smi_phy_read,
3773 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003774 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003775 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003776 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003777 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003778 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003779 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003780 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003781 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003782 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003783 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003784 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003785 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003786 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003787 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003788 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003789 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003790 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003791 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3792 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003793 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003794 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3795 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003796 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003797 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003798 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003799 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003800 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003801 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003802 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003803 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003804 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3805 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003806 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003807 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003808 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003809 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3810 .serdes_get_strings = mv88e6352_serdes_get_strings,
3811 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003812 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003813};
3814
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003815static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003816 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003817 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003818 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003819 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3820 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003821 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3822 .phy_read = mv88e6xxx_g2_smi_phy_read,
3823 .phy_write = mv88e6xxx_g2_smi_phy_write,
3824 .port_set_link = mv88e6xxx_port_set_link,
3825 .port_set_duplex = mv88e6xxx_port_set_duplex,
3826 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3827 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003828 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003829 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003830 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003831 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003832 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003833 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003834 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003835 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003836 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003837 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003838 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003839 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003840 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003841 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003842 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003843 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3844 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003845 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003846 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3847 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003848 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003849 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003850 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003851 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003852 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003853 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3854 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003855 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003856 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3857 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003858 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003859 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003860 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003861 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003862};
3863
3864static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003865 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003866 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003867 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003868 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3869 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003870 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3871 .phy_read = mv88e6xxx_g2_smi_phy_read,
3872 .phy_write = mv88e6xxx_g2_smi_phy_write,
3873 .port_set_link = mv88e6xxx_port_set_link,
3874 .port_set_duplex = mv88e6xxx_port_set_duplex,
3875 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3876 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003877 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003878 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003879 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003880 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003881 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003882 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003883 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003884 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003885 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003886 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003887 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003888 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003889 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003890 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003891 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003892 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3893 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003894 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003895 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3896 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003897 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003898 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003899 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003900 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003901 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003902 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3903 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003904 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003905 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3906 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003907 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003908 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003909 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003910 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003911};
3912
Vivien Didelotf81ec902016-05-09 13:22:58 -04003913static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3914 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003915 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003916 .family = MV88E6XXX_FAMILY_6097,
3917 .name = "Marvell 88E6085",
3918 .num_databases = 4096,
3919 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003920 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003921 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003922 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003923 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003924 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003925 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003926 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003927 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003928 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003929 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003930 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003931 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003932 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003933 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003934 },
3935
3936 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003937 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003938 .family = MV88E6XXX_FAMILY_6095,
3939 .name = "Marvell 88E6095/88E6095F",
3940 .num_databases = 256,
3941 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003942 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003943 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003944 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003945 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003946 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003947 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003948 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003949 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003950 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003951 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003952 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003953 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003954 },
3955
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003956 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003957 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003958 .family = MV88E6XXX_FAMILY_6097,
3959 .name = "Marvell 88E6097/88E6097F",
3960 .num_databases = 4096,
3961 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003962 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003963 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003964 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003965 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003966 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003967 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003968 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003969 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003970 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003971 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003972 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003973 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003974 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003975 .ops = &mv88e6097_ops,
3976 },
3977
Vivien Didelotf81ec902016-05-09 13:22:58 -04003978 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003979 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003980 .family = MV88E6XXX_FAMILY_6165,
3981 .name = "Marvell 88E6123",
3982 .num_databases = 4096,
3983 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003984 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003985 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003986 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003987 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003988 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003989 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003990 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003991 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003992 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003993 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003994 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003995 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003996 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003997 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003998 },
3999
4000 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004001 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004002 .family = MV88E6XXX_FAMILY_6185,
4003 .name = "Marvell 88E6131",
4004 .num_databases = 256,
4005 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004006 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004007 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004008 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004009 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004010 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004011 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004012 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004013 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004014 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004015 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004016 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004017 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004018 },
4019
Vivien Didelot990e27b2017-03-28 13:50:32 -04004020 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004021 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004022 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004023 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004024 .num_databases = 4096,
4025 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004026 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004027 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004028 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004029 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004030 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004031 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004032 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004033 .age_time_coeff = 3750,
4034 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004035 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004036 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004037 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004038 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004039 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004040 .ops = &mv88e6141_ops,
4041 },
4042
Vivien Didelotf81ec902016-05-09 13:22:58 -04004043 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004044 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004045 .family = MV88E6XXX_FAMILY_6165,
4046 .name = "Marvell 88E6161",
4047 .num_databases = 4096,
4048 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004049 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004050 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004051 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004052 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004053 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004054 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004055 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004056 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004057 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004058 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004059 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004060 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004061 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004062 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004063 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004064 },
4065
4066 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004067 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004068 .family = MV88E6XXX_FAMILY_6165,
4069 .name = "Marvell 88E6165",
4070 .num_databases = 4096,
4071 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004072 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004073 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004074 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004075 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004076 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004077 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004078 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004079 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004080 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004081 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004082 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004083 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004084 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004085 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004086 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004087 },
4088
4089 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004090 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004091 .family = MV88E6XXX_FAMILY_6351,
4092 .name = "Marvell 88E6171",
4093 .num_databases = 4096,
4094 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004095 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004096 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004097 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004098 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004099 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004100 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004101 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004102 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004103 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004104 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004105 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004106 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004107 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004108 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004109 },
4110
4111 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004112 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004113 .family = MV88E6XXX_FAMILY_6352,
4114 .name = "Marvell 88E6172",
4115 .num_databases = 4096,
4116 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004117 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004118 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004119 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004120 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004121 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004122 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004123 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004124 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004125 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004126 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004127 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004128 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004129 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004130 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004131 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004132 },
4133
4134 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004135 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004136 .family = MV88E6XXX_FAMILY_6351,
4137 .name = "Marvell 88E6175",
4138 .num_databases = 4096,
4139 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004140 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004141 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004142 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004143 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004144 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004145 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004146 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004147 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004148 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004149 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004150 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004151 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004152 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004153 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004154 },
4155
4156 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004157 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004158 .family = MV88E6XXX_FAMILY_6352,
4159 .name = "Marvell 88E6176",
4160 .num_databases = 4096,
4161 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004162 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004163 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004164 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004165 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004166 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004167 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004168 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004169 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004170 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004171 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004172 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004173 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004174 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004175 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004176 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004177 },
4178
4179 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004180 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004181 .family = MV88E6XXX_FAMILY_6185,
4182 .name = "Marvell 88E6185",
4183 .num_databases = 256,
4184 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004185 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004186 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004187 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004188 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004189 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004190 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004191 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004192 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004193 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004194 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004195 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004196 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004197 },
4198
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004199 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004200 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004201 .family = MV88E6XXX_FAMILY_6390,
4202 .name = "Marvell 88E6190",
4203 .num_databases = 4096,
4204 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004205 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004206 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004207 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004208 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004209 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004210 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004211 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004212 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004213 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004214 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004215 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004216 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004217 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004218 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004219 .ops = &mv88e6190_ops,
4220 },
4221
4222 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004223 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004224 .family = MV88E6XXX_FAMILY_6390,
4225 .name = "Marvell 88E6190X",
4226 .num_databases = 4096,
4227 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004228 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004229 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004230 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004231 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004232 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004233 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004234 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004235 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004236 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004237 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004238 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004239 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004240 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004241 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004242 .ops = &mv88e6190x_ops,
4243 },
4244
4245 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004246 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004247 .family = MV88E6XXX_FAMILY_6390,
4248 .name = "Marvell 88E6191",
4249 .num_databases = 4096,
4250 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004251 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004252 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004254 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004255 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004256 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004257 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004258 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004259 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004260 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004261 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004262 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004263 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004264 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004265 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004266 },
4267
Vivien Didelotf81ec902016-05-09 13:22:58 -04004268 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004269 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004270 .family = MV88E6XXX_FAMILY_6352,
4271 .name = "Marvell 88E6240",
4272 .num_databases = 4096,
4273 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004274 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004275 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004276 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004277 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004278 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004279 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004280 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004281 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004282 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004283 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004284 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004285 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004286 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004287 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004288 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004289 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004290 },
4291
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004292 [MV88E6250] = {
4293 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4294 .family = MV88E6XXX_FAMILY_6250,
4295 .name = "Marvell 88E6250",
4296 .num_databases = 64,
4297 .num_ports = 7,
4298 .num_internal_phys = 5,
4299 .max_vid = 4095,
4300 .port_base_addr = 0x08,
4301 .phy_base_addr = 0x00,
4302 .global1_addr = 0x0f,
4303 .global2_addr = 0x07,
4304 .age_time_coeff = 15000,
4305 .g1_irqs = 9,
4306 .g2_irqs = 10,
4307 .atu_move_port_mask = 0xf,
4308 .dual_chip = true,
4309 .tag_protocol = DSA_TAG_PROTO_DSA,
4310 .ops = &mv88e6250_ops,
4311 },
4312
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004313 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004314 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004315 .family = MV88E6XXX_FAMILY_6390,
4316 .name = "Marvell 88E6290",
4317 .num_databases = 4096,
4318 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004319 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004320 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004321 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004322 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004323 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004324 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004325 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004326 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004327 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004328 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004329 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004330 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004331 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004332 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004333 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004334 .ops = &mv88e6290_ops,
4335 },
4336
Vivien Didelotf81ec902016-05-09 13:22:58 -04004337 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004338 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004339 .family = MV88E6XXX_FAMILY_6320,
4340 .name = "Marvell 88E6320",
4341 .num_databases = 4096,
4342 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004343 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004344 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004345 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004346 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004347 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004348 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004349 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004350 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004351 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004352 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004353 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004354 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004355 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004356 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004357 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004358 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004359 },
4360
4361 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004362 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004363 .family = MV88E6XXX_FAMILY_6320,
4364 .name = "Marvell 88E6321",
4365 .num_databases = 4096,
4366 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004367 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004368 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004369 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004370 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004371 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004372 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004373 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004374 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004375 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004376 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004377 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004378 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004379 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004380 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004381 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004382 },
4383
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004384 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004385 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004386 .family = MV88E6XXX_FAMILY_6341,
4387 .name = "Marvell 88E6341",
4388 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004389 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004390 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004391 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004392 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004393 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004394 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004395 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004396 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004397 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004398 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004399 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004400 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004401 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004402 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004403 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004404 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004405 .ops = &mv88e6341_ops,
4406 },
4407
Vivien Didelotf81ec902016-05-09 13:22:58 -04004408 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004409 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004410 .family = MV88E6XXX_FAMILY_6351,
4411 .name = "Marvell 88E6350",
4412 .num_databases = 4096,
4413 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004414 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004415 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004416 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004417 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004418 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004419 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004420 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004421 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004422 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004423 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004424 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004425 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004426 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004427 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004428 },
4429
4430 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004431 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004432 .family = MV88E6XXX_FAMILY_6351,
4433 .name = "Marvell 88E6351",
4434 .num_databases = 4096,
4435 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004436 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004437 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004438 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004439 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004440 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004441 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004442 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004443 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004444 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004445 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004446 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004447 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004448 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004449 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004450 },
4451
4452 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004453 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004454 .family = MV88E6XXX_FAMILY_6352,
4455 .name = "Marvell 88E6352",
4456 .num_databases = 4096,
4457 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004458 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004459 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004460 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004461 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004462 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004463 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004464 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004465 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004466 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004467 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004468 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004469 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004470 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004471 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004472 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004473 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004474 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004475 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004476 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004477 .family = MV88E6XXX_FAMILY_6390,
4478 .name = "Marvell 88E6390",
4479 .num_databases = 4096,
4480 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004481 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004482 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004483 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004484 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004485 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004486 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004487 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004488 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004489 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004490 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004491 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004492 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004493 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004494 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004495 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004496 .ops = &mv88e6390_ops,
4497 },
4498 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004499 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004500 .family = MV88E6XXX_FAMILY_6390,
4501 .name = "Marvell 88E6390X",
4502 .num_databases = 4096,
4503 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004504 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004505 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004506 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004507 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004508 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004509 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004510 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004511 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004512 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004513 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004514 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004515 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004516 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004517 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004518 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004519 .ops = &mv88e6390x_ops,
4520 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004521};
4522
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004523static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004524{
Vivien Didelota439c062016-04-17 13:23:58 -04004525 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004526
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004527 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4528 if (mv88e6xxx_table[i].prod_num == prod_num)
4529 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004530
Vivien Didelotb9b37712015-10-30 19:39:48 -04004531 return NULL;
4532}
4533
Vivien Didelotfad09c72016-06-21 12:28:20 -04004534static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004535{
4536 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004537 unsigned int prod_num, rev;
4538 u16 id;
4539 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004540
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004541 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004542 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004543 mutex_unlock(&chip->reg_lock);
4544 if (err)
4545 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004546
Vivien Didelot107fcc12017-06-12 12:37:36 -04004547 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4548 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004549
4550 info = mv88e6xxx_lookup_info(prod_num);
4551 if (!info)
4552 return -ENODEV;
4553
Vivien Didelotcaac8542016-06-20 13:14:09 -04004554 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004555 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004556
Vivien Didelotca070c12016-09-02 14:45:34 -04004557 err = mv88e6xxx_g2_require(chip);
4558 if (err)
4559 return err;
4560
Vivien Didelotfad09c72016-06-21 12:28:20 -04004561 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4562 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004563
4564 return 0;
4565}
4566
Vivien Didelotfad09c72016-06-21 12:28:20 -04004567static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004568{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004569 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004570
Vivien Didelotfad09c72016-06-21 12:28:20 -04004571 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4572 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004573 return NULL;
4574
Vivien Didelotfad09c72016-06-21 12:28:20 -04004575 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004576
Vivien Didelotfad09c72016-06-21 12:28:20 -04004577 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004578 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004579
Vivien Didelotfad09c72016-06-21 12:28:20 -04004580 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004581}
4582
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004583static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4584 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004585{
Vivien Didelot04bed142016-08-31 18:06:13 -04004586 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004587
Andrew Lunn443d5a12016-12-03 04:35:18 +01004588 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004589}
4590
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004591static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004592 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004593{
4594 /* We don't need any dynamic resource from the kernel (yet),
4595 * so skip the prepare phase.
4596 */
4597
4598 return 0;
4599}
4600
4601static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004602 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004603{
Vivien Didelot04bed142016-08-31 18:06:13 -04004604 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004605
4606 mutex_lock(&chip->reg_lock);
4607 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004608 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004609 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4610 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004611 mutex_unlock(&chip->reg_lock);
4612}
4613
4614static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4615 const struct switchdev_obj_port_mdb *mdb)
4616{
Vivien Didelot04bed142016-08-31 18:06:13 -04004617 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004618 int err;
4619
4620 mutex_lock(&chip->reg_lock);
4621 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004622 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004623 mutex_unlock(&chip->reg_lock);
4624
4625 return err;
4626}
4627
Russell King4f859012019-02-20 15:35:05 -08004628static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4629 bool unicast, bool multicast)
4630{
4631 struct mv88e6xxx_chip *chip = ds->priv;
4632 int err = -EOPNOTSUPP;
4633
4634 mutex_lock(&chip->reg_lock);
4635 if (chip->info->ops->port_set_egress_floods)
4636 err = chip->info->ops->port_set_egress_floods(chip, port,
4637 unicast,
4638 multicast);
4639 mutex_unlock(&chip->reg_lock);
4640
4641 return err;
4642}
4643
Florian Fainellia82f67a2017-01-08 14:52:08 -08004644static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004645 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004646 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004647 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004648 .phylink_validate = mv88e6xxx_validate,
4649 .phylink_mac_link_state = mv88e6xxx_link_state,
4650 .phylink_mac_config = mv88e6xxx_mac_config,
4651 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4652 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004653 .get_strings = mv88e6xxx_get_strings,
4654 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4655 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004656 .port_enable = mv88e6xxx_port_enable,
4657 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004658 .get_mac_eee = mv88e6xxx_get_mac_eee,
4659 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004660 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004661 .get_eeprom = mv88e6xxx_get_eeprom,
4662 .set_eeprom = mv88e6xxx_set_eeprom,
4663 .get_regs_len = mv88e6xxx_get_regs_len,
4664 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004665 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 .port_bridge_join = mv88e6xxx_port_bridge_join,
4667 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004668 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004669 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004670 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004671 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4672 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4673 .port_vlan_add = mv88e6xxx_port_vlan_add,
4674 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004675 .port_fdb_add = mv88e6xxx_port_fdb_add,
4676 .port_fdb_del = mv88e6xxx_port_fdb_del,
4677 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004678 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4679 .port_mdb_add = mv88e6xxx_port_mdb_add,
4680 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004681 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4682 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004683 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4684 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4685 .port_txtstamp = mv88e6xxx_port_txtstamp,
4686 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4687 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004688};
4689
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004690static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004691{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004692 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004693 struct dsa_switch *ds;
4694
Vivien Didelot73b12042017-03-30 17:37:10 -04004695 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004696 if (!ds)
4697 return -ENOMEM;
4698
Vivien Didelotfad09c72016-06-21 12:28:20 -04004699 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004700 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004701 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004702 ds->ageing_time_min = chip->info->age_time_coeff;
4703 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004704
4705 dev_set_drvdata(dev, ds);
4706
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004707 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004708}
4709
Vivien Didelotfad09c72016-06-21 12:28:20 -04004710static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004711{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004712 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004713}
4714
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004715static const void *pdata_device_get_match_data(struct device *dev)
4716{
4717 const struct of_device_id *matches = dev->driver->of_match_table;
4718 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4719
4720 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4721 matches++) {
4722 if (!strcmp(pdata->compatible, matches->compatible))
4723 return matches->data;
4724 }
4725 return NULL;
4726}
4727
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004728/* There is no suspend to RAM support at DSA level yet, the switch configuration
4729 * would be lost after a power cycle so prevent it to be suspended.
4730 */
4731static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4732{
4733 return -EOPNOTSUPP;
4734}
4735
4736static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4737{
4738 return 0;
4739}
4740
4741static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4742
Vivien Didelot57d32312016-06-20 13:13:58 -04004743static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004744{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004745 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004746 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004747 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004748 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004749 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004750 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004751 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004752
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004753 if (!np && !pdata)
4754 return -EINVAL;
4755
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004756 if (np)
4757 compat_info = of_device_get_match_data(dev);
4758
4759 if (pdata) {
4760 compat_info = pdata_device_get_match_data(dev);
4761
4762 if (!pdata->netdev)
4763 return -EINVAL;
4764
4765 for (port = 0; port < DSA_MAX_PORTS; port++) {
4766 if (!(pdata->enabled_ports & (1 << port)))
4767 continue;
4768 if (strcmp(pdata->cd.port_names[port], "cpu"))
4769 continue;
4770 pdata->cd.netdev[port] = &pdata->netdev->dev;
4771 break;
4772 }
4773 }
4774
Vivien Didelotcaac8542016-06-20 13:14:09 -04004775 if (!compat_info)
4776 return -EINVAL;
4777
Vivien Didelotfad09c72016-06-21 12:28:20 -04004778 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004779 if (!chip) {
4780 err = -ENOMEM;
4781 goto out;
4782 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004783
Vivien Didelotfad09c72016-06-21 12:28:20 -04004784 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004785
Vivien Didelotfad09c72016-06-21 12:28:20 -04004786 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004787 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004788 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004789
Andrew Lunnb4308f02016-11-21 23:26:55 +01004790 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004791 if (IS_ERR(chip->reset)) {
4792 err = PTR_ERR(chip->reset);
4793 goto out;
4794 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004795
Vivien Didelotfad09c72016-06-21 12:28:20 -04004796 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004797 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004798 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004799
Vivien Didelote57e5e72016-08-15 17:19:00 -04004800 mv88e6xxx_phy_init(chip);
4801
Andrew Lunn00baabe2018-05-19 22:31:35 +02004802 if (chip->info->ops->get_eeprom) {
4803 if (np)
4804 of_property_read_u32(np, "eeprom-length",
4805 &chip->eeprom_len);
4806 else
4807 chip->eeprom_len = pdata->eeprom_len;
4808 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004809
Andrew Lunndc30c352016-10-16 19:56:49 +02004810 mutex_lock(&chip->reg_lock);
4811 err = mv88e6xxx_switch_reset(chip);
4812 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004813 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004814 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004815
Andrew Lunna27415d2019-05-01 00:10:50 +02004816 if (np) {
4817 chip->irq = of_irq_get(np, 0);
4818 if (chip->irq == -EPROBE_DEFER) {
4819 err = chip->irq;
4820 goto out;
4821 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004822 }
4823
Andrew Lunna27415d2019-05-01 00:10:50 +02004824 if (pdata)
4825 chip->irq = pdata->irq;
4826
Andrew Lunn294d7112018-02-22 22:58:32 +01004827 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004828 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004829 * controllers
4830 */
4831 mutex_lock(&chip->reg_lock);
4832 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004833 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004834 else
4835 err = mv88e6xxx_irq_poll_setup(chip);
4836 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004837
Andrew Lunn294d7112018-02-22 22:58:32 +01004838 if (err)
4839 goto out;
4840
4841 if (chip->info->g2_irqs > 0) {
4842 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004843 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004844 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004845 }
4846
Andrew Lunn294d7112018-02-22 22:58:32 +01004847 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4848 if (err)
4849 goto out_g2_irq;
4850
4851 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4852 if (err)
4853 goto out_g1_atu_prob_irq;
4854
Andrew Lunna3c53be52017-01-24 14:53:50 +01004855 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004856 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004857 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004858
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004859 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004860 if (err)
4861 goto out_mdio;
4862
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004863 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004864
4865out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004866 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004867out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004868 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004869out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004870 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004871out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004872 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004873 mv88e6xxx_g2_irq_free(chip);
4874out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004875 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004876 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004877 else
4878 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004879out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004880 if (pdata)
4881 dev_put(pdata->netdev);
4882
Andrew Lunndc30c352016-10-16 19:56:49 +02004883 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004884}
4885
4886static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4887{
4888 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004889 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004890
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004891 if (chip->info->ptp_support) {
4892 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004893 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004894 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004895
Andrew Lunn930188c2016-08-22 16:01:03 +02004896 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004897 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004898 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004899
Andrew Lunn76f38f12018-03-17 20:21:09 +01004900 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4901 mv88e6xxx_g1_atu_prob_irq_free(chip);
4902
4903 if (chip->info->g2_irqs > 0)
4904 mv88e6xxx_g2_irq_free(chip);
4905
Andrew Lunn76f38f12018-03-17 20:21:09 +01004906 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004907 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004908 else
4909 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004910}
4911
4912static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004913 {
4914 .compatible = "marvell,mv88e6085",
4915 .data = &mv88e6xxx_table[MV88E6085],
4916 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004917 {
4918 .compatible = "marvell,mv88e6190",
4919 .data = &mv88e6xxx_table[MV88E6190],
4920 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004921 {
4922 .compatible = "marvell,mv88e6250",
4923 .data = &mv88e6xxx_table[MV88E6250],
4924 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004925 { /* sentinel */ },
4926};
4927
4928MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4929
4930static struct mdio_driver mv88e6xxx_driver = {
4931 .probe = mv88e6xxx_probe,
4932 .remove = mv88e6xxx_remove,
4933 .mdiodrv.driver = {
4934 .name = "mv88e6085",
4935 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004936 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004937 },
4938};
4939
Andrew Lunn7324d502019-04-27 19:19:10 +02004940mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004941
4942MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4943MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4944MODULE_LICENSE("GPL");