blob: 28414db979b0594aa266783e08e7db4036174e1a [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;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200788 high = reg;
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
Andrew Lunn436fe172018-03-01 02:02:29 +0100832static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
833 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100834{
Andrew Lunn436fe172018-03-01 02:02:29 +0100835 return mv88e6xxx_stats_get_strings(chip, data,
836 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100837}
838
Andrew Lunn65f60e42018-03-28 23:50:28 +0200839static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
840 "atu_member_violation",
841 "atu_miss_violation",
842 "atu_full_violation",
843 "vtu_member_violation",
844 "vtu_miss_violation",
845};
846
847static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
848{
849 unsigned int i;
850
851 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
852 strlcpy(data + i * ETH_GSTRING_LEN,
853 mv88e6xxx_atu_vtu_stats_strings[i],
854 ETH_GSTRING_LEN);
855}
856
Andrew Lunndfafe442016-11-21 23:27:02 +0100857static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700858 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859{
Vivien Didelot04bed142016-08-31 18:06:13 -0400860 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100861 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100862
Florian Fainelli89f09042018-04-25 12:12:50 -0700863 if (stringset != ETH_SS_STATS)
864 return;
865
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100866 mutex_lock(&chip->reg_lock);
867
Andrew Lunndfafe442016-11-21 23:27:02 +0100868 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100869 count = chip->info->ops->stats_get_strings(chip, data);
870
871 if (chip->info->ops->serdes_get_strings) {
872 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200873 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100874 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100875
Andrew Lunn65f60e42018-03-28 23:50:28 +0200876 data += count * ETH_GSTRING_LEN;
877 mv88e6xxx_atu_vtu_get_strings(data);
878
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100879 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100880}
881
882static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
883 int types)
884{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100885 struct mv88e6xxx_hw_stat *stat;
886 int i, j;
887
888 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
889 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100890 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891 j++;
892 }
893 return j;
894}
895
Andrew Lunndfafe442016-11-21 23:27:02 +0100896static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
897{
898 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
899 STATS_TYPE_PORT);
900}
901
902static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
903{
904 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
905 STATS_TYPE_BANK1);
906}
907
Florian Fainelli89f09042018-04-25 12:12:50 -0700908static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100909{
910 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100911 int serdes_count = 0;
912 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100913
Florian Fainelli89f09042018-04-25 12:12:50 -0700914 if (sset != ETH_SS_STATS)
915 return 0;
916
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100917 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100918 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100919 count = chip->info->ops->stats_get_sset_count(chip);
920 if (count < 0)
921 goto out;
922
923 if (chip->info->ops->serdes_get_sset_count)
924 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
925 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200926 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100927 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200928 goto out;
929 }
930 count += serdes_count;
931 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
932
Andrew Lunn436fe172018-03-01 02:02:29 +0100933out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100934 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100935
Andrew Lunn436fe172018-03-01 02:02:29 +0100936 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100937}
938
Andrew Lunn436fe172018-03-01 02:02:29 +0100939static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
940 uint64_t *data, int types,
941 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100942{
943 struct mv88e6xxx_hw_stat *stat;
944 int i, j;
945
946 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
947 stat = &mv88e6xxx_hw_stats[i];
948 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100949 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100950 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
951 bank1_select,
952 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100953 mutex_unlock(&chip->reg_lock);
954
Andrew Lunn052f9472016-11-21 23:27:03 +0100955 j++;
956 }
957 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100958 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100959}
960
Andrew Lunn436fe172018-03-01 02:02:29 +0100961static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
962 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100963{
964 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100965 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400966 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100967}
968
Andrew Lunn436fe172018-03-01 02:02:29 +0100969static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
970 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100971{
972 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100973 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400974 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
975 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100976}
977
Andrew Lunn436fe172018-03-01 02:02:29 +0100978static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
979 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100980{
981 return mv88e6xxx_stats_get_stats(chip, port, data,
982 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400983 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
984 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100985}
986
Andrew Lunn65f60e42018-03-28 23:50:28 +0200987static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
988 uint64_t *data)
989{
990 *data++ = chip->ports[port].atu_member_violation;
991 *data++ = chip->ports[port].atu_miss_violation;
992 *data++ = chip->ports[port].atu_full_violation;
993 *data++ = chip->ports[port].vtu_member_violation;
994 *data++ = chip->ports[port].vtu_miss_violation;
995}
996
Andrew Lunn052f9472016-11-21 23:27:03 +0100997static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
998 uint64_t *data)
999{
Andrew Lunn436fe172018-03-01 02:02:29 +01001000 int count = 0;
1001
Andrew Lunn052f9472016-11-21 23:27:03 +01001002 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001003 count = chip->info->ops->stats_get_stats(chip, port, data);
1004
Andrew Lunn65f60e42018-03-28 23:50:28 +02001005 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001006 if (chip->info->ops->serdes_get_stats) {
1007 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001009 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001010 data += count;
1011 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1012 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001013}
1014
Vivien Didelotf81ec902016-05-09 13:22:58 -04001015static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1016 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017{
Vivien Didelot04bed142016-08-31 18:06:13 -04001018 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001019 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001020
Vivien Didelotfad09c72016-06-21 12:28:20 -04001021 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001022
Andrew Lunna605a0f2016-11-21 23:26:58 +01001023 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001024 mutex_unlock(&chip->reg_lock);
1025
1026 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001027 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001028
1029 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001030
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001031}
Ben Hutchings98e67302011-11-25 14:36:19 +00001032
Vivien Didelotf81ec902016-05-09 13:22:58 -04001033static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001034{
1035 return 32 * sizeof(u16);
1036}
1037
Vivien Didelotf81ec902016-05-09 13:22:58 -04001038static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1039 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001040{
Vivien Didelot04bed142016-08-31 18:06:13 -04001041 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001042 int err;
1043 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044 u16 *p = _p;
1045 int i;
1046
Vivien Didelota5f39322018-12-17 16:05:21 -05001047 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001048
1049 memset(p, 0xff, 32 * sizeof(u16));
1050
Vivien Didelotfad09c72016-06-21 12:28:20 -04001051 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001052
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001053 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001054
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001055 err = mv88e6xxx_port_read(chip, port, i, &reg);
1056 if (!err)
1057 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001058 }
Vivien Didelot23062512016-05-09 13:22:45 -04001059
Vivien Didelotfad09c72016-06-21 12:28:20 -04001060 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001061}
1062
Vivien Didelot08f50062017-08-01 16:32:41 -04001063static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1064 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001065{
Vivien Didelot5480db62017-08-01 16:32:40 -04001066 /* Nothing to do on the port's MAC */
1067 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001068}
1069
Vivien Didelot08f50062017-08-01 16:32:41 -04001070static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1071 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001072{
Vivien Didelot5480db62017-08-01 16:32:40 -04001073 /* Nothing to do on the port's MAC */
1074 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001075}
1076
Vivien Didelote5887a22017-03-30 17:37:11 -04001077static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001078{
Vivien Didelote5887a22017-03-30 17:37:11 -04001079 struct dsa_switch *ds = NULL;
1080 struct net_device *br;
1081 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001082 int i;
1083
Vivien Didelote5887a22017-03-30 17:37:11 -04001084 if (dev < DSA_MAX_SWITCHES)
1085 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001086
Vivien Didelote5887a22017-03-30 17:37:11 -04001087 /* Prevent frames from unknown switch or port */
1088 if (!ds || port >= ds->num_ports)
1089 return 0;
1090
1091 /* Frames from DSA links and CPU ports can egress any local port */
1092 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1093 return mv88e6xxx_port_mask(chip);
1094
1095 br = ds->ports[port].bridge_dev;
1096 pvlan = 0;
1097
1098 /* Frames from user ports can egress any local DSA links and CPU ports,
1099 * as well as any local member of their bridge group.
1100 */
1101 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1102 if (dsa_is_cpu_port(chip->ds, i) ||
1103 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001104 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001105 pvlan |= BIT(i);
1106
1107 return pvlan;
1108}
1109
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001110static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001111{
1112 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001113
1114 /* prevent frames from going back out of the port they came in on */
1115 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001116
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001117 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001118}
1119
Vivien Didelotf81ec902016-05-09 13:22:58 -04001120static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1121 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001122{
Vivien Didelot04bed142016-08-31 18:06:13 -04001123 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001124 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001125
Vivien Didelotfad09c72016-06-21 12:28:20 -04001126 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001127 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001128 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001129
1130 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001131 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001132}
1133
Vivien Didelot93e18d62018-05-11 17:16:35 -04001134static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1135{
1136 int err;
1137
1138 if (chip->info->ops->ieee_pri_map) {
1139 err = chip->info->ops->ieee_pri_map(chip);
1140 if (err)
1141 return err;
1142 }
1143
1144 if (chip->info->ops->ip_pri_map) {
1145 err = chip->info->ops->ip_pri_map(chip);
1146 if (err)
1147 return err;
1148 }
1149
1150 return 0;
1151}
1152
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001153static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1154{
1155 int target, port;
1156 int err;
1157
1158 if (!chip->info->global2_addr)
1159 return 0;
1160
1161 /* Initialize the routing port to the 32 possible target devices */
1162 for (target = 0; target < 32; target++) {
1163 port = 0x1f;
1164 if (target < DSA_MAX_SWITCHES)
1165 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1166 port = chip->ds->rtable[target];
1167
1168 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1169 if (err)
1170 return err;
1171 }
1172
Vivien Didelot02317e62018-05-09 11:38:49 -04001173 if (chip->info->ops->set_cascade_port) {
1174 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1175 err = chip->info->ops->set_cascade_port(chip, port);
1176 if (err)
1177 return err;
1178 }
1179
Vivien Didelot23c98912018-05-09 11:38:50 -04001180 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1181 if (err)
1182 return err;
1183
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001184 return 0;
1185}
1186
Vivien Didelotb28f8722018-04-26 21:56:44 -04001187static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1188{
1189 /* Clear all trunk masks and mapping */
1190 if (chip->info->global2_addr)
1191 return mv88e6xxx_g2_trunk_clear(chip);
1192
1193 return 0;
1194}
1195
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001196static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1197{
1198 if (chip->info->ops->rmu_disable)
1199 return chip->info->ops->rmu_disable(chip);
1200
1201 return 0;
1202}
1203
Vivien Didelot9e907d72017-07-17 13:03:43 -04001204static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1205{
1206 if (chip->info->ops->pot_clear)
1207 return chip->info->ops->pot_clear(chip);
1208
1209 return 0;
1210}
1211
Vivien Didelot51c901a2017-07-17 13:03:41 -04001212static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1213{
1214 if (chip->info->ops->mgmt_rsvd2cpu)
1215 return chip->info->ops->mgmt_rsvd2cpu(chip);
1216
1217 return 0;
1218}
1219
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001220static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1221{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001222 int err;
1223
Vivien Didelotdaefc942017-03-11 16:12:54 -05001224 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1225 if (err)
1226 return err;
1227
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001228 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1229 if (err)
1230 return err;
1231
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001232 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1233}
1234
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001235static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1236{
1237 int port;
1238 int err;
1239
1240 if (!chip->info->ops->irl_init_all)
1241 return 0;
1242
1243 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1244 /* Disable ingress rate limiting by resetting all per port
1245 * ingress rate limit resources to their initial state.
1246 */
1247 err = chip->info->ops->irl_init_all(chip, port);
1248 if (err)
1249 return err;
1250 }
1251
1252 return 0;
1253}
1254
Vivien Didelot04a69a12017-10-13 14:18:05 -04001255static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1256{
1257 if (chip->info->ops->set_switch_mac) {
1258 u8 addr[ETH_ALEN];
1259
1260 eth_random_addr(addr);
1261
1262 return chip->info->ops->set_switch_mac(chip, addr);
1263 }
1264
1265 return 0;
1266}
1267
Vivien Didelot17a15942017-03-30 17:37:09 -04001268static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1269{
1270 u16 pvlan = 0;
1271
1272 if (!mv88e6xxx_has_pvt(chip))
1273 return -EOPNOTSUPP;
1274
1275 /* Skip the local source device, which uses in-chip port VLAN */
1276 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001277 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001278
1279 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1280}
1281
Vivien Didelot81228992017-03-30 17:37:08 -04001282static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1283{
Vivien Didelot17a15942017-03-30 17:37:09 -04001284 int dev, port;
1285 int err;
1286
Vivien Didelot81228992017-03-30 17:37:08 -04001287 if (!mv88e6xxx_has_pvt(chip))
1288 return 0;
1289
1290 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1291 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1292 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001293 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1294 if (err)
1295 return err;
1296
1297 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1298 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1299 err = mv88e6xxx_pvt_map(chip, dev, port);
1300 if (err)
1301 return err;
1302 }
1303 }
1304
1305 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001306}
1307
Vivien Didelot749efcb2016-09-22 16:49:24 -04001308static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1309{
1310 struct mv88e6xxx_chip *chip = ds->priv;
1311 int err;
1312
1313 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001314 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001315 mutex_unlock(&chip->reg_lock);
1316
1317 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001318 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001319}
1320
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001321static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1322{
1323 if (!chip->info->max_vid)
1324 return 0;
1325
1326 return mv88e6xxx_g1_vtu_flush(chip);
1327}
1328
Vivien Didelotf1394b782017-05-01 14:05:22 -04001329static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1330 struct mv88e6xxx_vtu_entry *entry)
1331{
1332 if (!chip->info->ops->vtu_getnext)
1333 return -EOPNOTSUPP;
1334
1335 return chip->info->ops->vtu_getnext(chip, entry);
1336}
1337
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001338static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1339 struct mv88e6xxx_vtu_entry *entry)
1340{
1341 if (!chip->info->ops->vtu_loadpurge)
1342 return -EOPNOTSUPP;
1343
1344 return chip->info->ops->vtu_loadpurge(chip, entry);
1345}
1346
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001347static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001348{
1349 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001350 struct mv88e6xxx_vtu_entry vlan = {
1351 .vid = chip->info->max_vid,
1352 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001353 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001354
1355 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1356
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001357 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001358 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001359 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001360 if (err)
1361 return err;
1362
1363 set_bit(*fid, fid_bitmap);
1364 }
1365
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001366 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001367 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001368 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001369 if (err)
1370 return err;
1371
1372 if (!vlan.valid)
1373 break;
1374
1375 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001376 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001377
1378 /* The reset value 0x000 is used to indicate that multiple address
1379 * databases are not needed. Return the next positive available.
1380 */
1381 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001382 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001383 return -ENOSPC;
1384
1385 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001386 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001387}
1388
Vivien Didelot567aa592017-05-01 14:05:25 -04001389static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1390 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001391{
1392 int err;
1393
1394 if (!vid)
1395 return -EINVAL;
1396
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001397 entry->vid = vid - 1;
1398 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001399
Vivien Didelotf1394b782017-05-01 14:05:22 -04001400 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001401 if (err)
1402 return err;
1403
Vivien Didelot567aa592017-05-01 14:05:25 -04001404 if (entry->vid == vid && entry->valid)
1405 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001406
Vivien Didelot567aa592017-05-01 14:05:25 -04001407 if (new) {
1408 int i;
1409
1410 /* Initialize a fresh VLAN entry */
1411 memset(entry, 0, sizeof(*entry));
1412 entry->valid = true;
1413 entry->vid = vid;
1414
Vivien Didelot553a7682017-06-07 18:12:16 -04001415 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001416 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001417 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001418 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001419
1420 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001421 }
1422
Vivien Didelot567aa592017-05-01 14:05:25 -04001423 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1424 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001425}
1426
Vivien Didelotda9c3592016-02-12 12:09:40 -05001427static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1428 u16 vid_begin, u16 vid_end)
1429{
Vivien Didelot04bed142016-08-31 18:06:13 -04001430 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001431 struct mv88e6xxx_vtu_entry vlan = {
1432 .vid = vid_begin - 1,
1433 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001434 int i, err;
1435
Andrew Lunndb06ae412017-09-25 23:32:20 +02001436 /* DSA and CPU ports have to be members of multiple vlans */
1437 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1438 return 0;
1439
Vivien Didelotda9c3592016-02-12 12:09:40 -05001440 if (!vid_begin)
1441 return -EOPNOTSUPP;
1442
Vivien Didelotfad09c72016-06-21 12:28:20 -04001443 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001444
Vivien Didelotda9c3592016-02-12 12:09:40 -05001445 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001446 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001447 if (err)
1448 goto unlock;
1449
1450 if (!vlan.valid)
1451 break;
1452
1453 if (vlan.vid > vid_end)
1454 break;
1455
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001456 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001457 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1458 continue;
1459
Andrew Lunncd886462017-11-09 22:29:53 +01001460 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001461 continue;
1462
Vivien Didelotbd00e052017-05-01 14:05:11 -04001463 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001464 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001465 continue;
1466
Vivien Didelotc8652c82017-10-16 11:12:19 -04001467 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001468 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001469 break; /* same bridge, check next VLAN */
1470
Vivien Didelotc8652c82017-10-16 11:12:19 -04001471 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001472 continue;
1473
Andrew Lunn743fcc22017-11-09 22:29:54 +01001474 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1475 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001476 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001477 err = -EOPNOTSUPP;
1478 goto unlock;
1479 }
1480 } while (vlan.vid < vid_end);
1481
1482unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001483 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001484
1485 return err;
1486}
1487
Vivien Didelotf81ec902016-05-09 13:22:58 -04001488static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1489 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001490{
Vivien Didelot04bed142016-08-31 18:06:13 -04001491 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001492 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1493 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001494 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001495
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001496 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001497 return -EOPNOTSUPP;
1498
Vivien Didelotfad09c72016-06-21 12:28:20 -04001499 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001500 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001501 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001502
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001503 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001504}
1505
Vivien Didelot57d32312016-06-20 13:13:58 -04001506static int
1507mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001508 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001509{
Vivien Didelot04bed142016-08-31 18:06:13 -04001510 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001511 int err;
1512
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001513 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001514 return -EOPNOTSUPP;
1515
Vivien Didelotda9c3592016-02-12 12:09:40 -05001516 /* If the requested port doesn't belong to the same bridge as the VLAN
1517 * members, do not support it (yet) and fallback to software VLAN.
1518 */
1519 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1520 vlan->vid_end);
1521 if (err)
1522 return err;
1523
Vivien Didelot76e398a2015-11-01 12:33:55 -05001524 /* We don't need any dynamic resource from the kernel (yet),
1525 * so skip the prepare phase.
1526 */
1527 return 0;
1528}
1529
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001530static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1531 const unsigned char *addr, u16 vid,
1532 u8 state)
1533{
1534 struct mv88e6xxx_vtu_entry vlan;
1535 struct mv88e6xxx_atu_entry entry;
1536 int err;
1537
1538 /* Null VLAN ID corresponds to the port private database */
1539 if (vid == 0)
1540 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1541 else
1542 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1543 if (err)
1544 return err;
1545
1546 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1547 ether_addr_copy(entry.mac, addr);
1548 eth_addr_dec(entry.mac);
1549
1550 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1551 if (err)
1552 return err;
1553
1554 /* Initialize a fresh ATU entry if it isn't found */
1555 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1556 !ether_addr_equal(entry.mac, addr)) {
1557 memset(&entry, 0, sizeof(entry));
1558 ether_addr_copy(entry.mac, addr);
1559 }
1560
1561 /* Purge the ATU entry only if no port is using it anymore */
1562 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1563 entry.portvec &= ~BIT(port);
1564 if (!entry.portvec)
1565 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1566 } else {
1567 entry.portvec |= BIT(port);
1568 entry.state = state;
1569 }
1570
1571 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1572}
1573
Andrew Lunn87fa8862017-11-09 22:29:56 +01001574static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1575 u16 vid)
1576{
1577 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1578 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1579
1580 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1581}
1582
1583static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1584{
1585 int port;
1586 int err;
1587
1588 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1589 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1590 if (err)
1591 return err;
1592 }
1593
1594 return 0;
1595}
1596
Vivien Didelotfad09c72016-06-21 12:28:20 -04001597static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001598 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001599{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001600 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001601 int err;
1602
Vivien Didelot567aa592017-05-01 14:05:25 -04001603 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001604 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001605 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001606
Vivien Didelotc91498e2017-06-07 18:12:13 -04001607 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001608
Andrew Lunn87fa8862017-11-09 22:29:56 +01001609 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1610 if (err)
1611 return err;
1612
1613 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001614}
1615
Vivien Didelotf81ec902016-05-09 13:22:58 -04001616static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001617 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001618{
Vivien Didelot04bed142016-08-31 18:06:13 -04001619 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1621 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001622 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001623 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001624
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001625 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001626 return;
1627
Vivien Didelotc91498e2017-06-07 18:12:13 -04001628 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001629 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001630 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001631 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001632 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001633 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001634
Vivien Didelotfad09c72016-06-21 12:28:20 -04001635 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001636
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001637 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001638 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001639 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1640 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001641
Vivien Didelot77064f32016-11-04 03:23:30 +01001642 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001643 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1644 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001645
Vivien Didelotfad09c72016-06-21 12:28:20 -04001646 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001647}
1648
Vivien Didelotfad09c72016-06-21 12:28:20 -04001649static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001650 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001651{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001652 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001653 int i, err;
1654
Vivien Didelot567aa592017-05-01 14:05:25 -04001655 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001656 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001657 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001658
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001659 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001660 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001661 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001662
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001663 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001664
1665 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001666 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001667 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001668 if (vlan.member[i] !=
1669 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001670 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001671 break;
1672 }
1673 }
1674
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001675 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001676 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001677 return err;
1678
Vivien Didelote606ca32017-03-11 16:12:55 -05001679 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001680}
1681
Vivien Didelotf81ec902016-05-09 13:22:58 -04001682static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1683 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001684{
Vivien Didelot04bed142016-08-31 18:06:13 -04001685 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001686 u16 pvid, vid;
1687 int err = 0;
1688
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001689 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001690 return -EOPNOTSUPP;
1691
Vivien Didelotfad09c72016-06-21 12:28:20 -04001692 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001693
Vivien Didelot77064f32016-11-04 03:23:30 +01001694 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001695 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001696 goto unlock;
1697
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001699 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001700 if (err)
1701 goto unlock;
1702
1703 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001704 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001705 if (err)
1706 goto unlock;
1707 }
1708 }
1709
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001710unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001711 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001712
1713 return err;
1714}
1715
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001716static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1717 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001718{
Vivien Didelot04bed142016-08-31 18:06:13 -04001719 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001720 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001721
Vivien Didelotfad09c72016-06-21 12:28:20 -04001722 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001723 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1724 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001725 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001726
1727 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001728}
1729
Vivien Didelotf81ec902016-05-09 13:22:58 -04001730static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001731 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001732{
Vivien Didelot04bed142016-08-31 18:06:13 -04001733 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001734 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001735
Vivien Didelotfad09c72016-06-21 12:28:20 -04001736 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001737 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001738 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001739 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001740
Vivien Didelot83dabd12016-08-31 11:50:04 -04001741 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001742}
1743
Vivien Didelot83dabd12016-08-31 11:50:04 -04001744static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1745 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001746 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001747{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001748 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001749 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001750 int err;
1751
Vivien Didelot27c0e602017-06-15 12:14:01 -04001752 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001753 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001754
1755 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001756 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001757 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001758 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001759 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001760 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001761
Vivien Didelot27c0e602017-06-15 12:14:01 -04001762 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001763 break;
1764
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001765 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001766 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001767
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001768 if (!is_unicast_ether_addr(addr.mac))
1769 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001770
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001771 is_static = (addr.state ==
1772 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1773 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001774 if (err)
1775 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001776 } while (!is_broadcast_ether_addr(addr.mac));
1777
1778 return err;
1779}
1780
Vivien Didelot83dabd12016-08-31 11:50:04 -04001781static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001782 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001783{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001784 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001785 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001786 };
1787 u16 fid;
1788 int err;
1789
1790 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001791 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001792 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001793 mutex_unlock(&chip->reg_lock);
1794
Vivien Didelot83dabd12016-08-31 11:50:04 -04001795 if (err)
1796 return err;
1797
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001798 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001799 if (err)
1800 return err;
1801
1802 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001803 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001804 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001805 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001806 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001807 if (err)
1808 return err;
1809
1810 if (!vlan.valid)
1811 break;
1812
1813 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001814 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001815 if (err)
1816 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001817 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001818
1819 return err;
1820}
1821
Vivien Didelotf81ec902016-05-09 13:22:58 -04001822static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001823 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001824{
Vivien Didelot04bed142016-08-31 18:06:13 -04001825 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001826
Andrew Lunna61e5402018-02-15 14:38:35 +01001827 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001828}
1829
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001830static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1831 struct net_device *br)
1832{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001833 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001834 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001835 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001836 int err;
1837
1838 /* Remap the Port VLAN of each local bridge group member */
1839 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1840 if (chip->ds->ports[port].bridge_dev == br) {
1841 err = mv88e6xxx_port_vlan_map(chip, port);
1842 if (err)
1843 return err;
1844 }
1845 }
1846
Vivien Didelote96a6e02017-03-30 17:37:13 -04001847 if (!mv88e6xxx_has_pvt(chip))
1848 return 0;
1849
1850 /* Remap the Port VLAN of each cross-chip bridge group member */
1851 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1852 ds = chip->ds->dst->ds[dev];
1853 if (!ds)
1854 break;
1855
1856 for (port = 0; port < ds->num_ports; ++port) {
1857 if (ds->ports[port].bridge_dev == br) {
1858 err = mv88e6xxx_pvt_map(chip, dev, port);
1859 if (err)
1860 return err;
1861 }
1862 }
1863 }
1864
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001865 return 0;
1866}
1867
Vivien Didelotf81ec902016-05-09 13:22:58 -04001868static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001869 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001870{
Vivien Didelot04bed142016-08-31 18:06:13 -04001871 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001872 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001873
Vivien Didelotfad09c72016-06-21 12:28:20 -04001874 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001875 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001876 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001877
Vivien Didelot466dfa02016-02-26 13:16:05 -05001878 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001879}
1880
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001881static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1882 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001883{
Vivien Didelot04bed142016-08-31 18:06:13 -04001884 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001885
Vivien Didelotfad09c72016-06-21 12:28:20 -04001886 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001887 if (mv88e6xxx_bridge_map(chip, br) ||
1888 mv88e6xxx_port_vlan_map(chip, port))
1889 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001890 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001891}
1892
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001893static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1894 int port, struct net_device *br)
1895{
1896 struct mv88e6xxx_chip *chip = ds->priv;
1897 int err;
1898
1899 if (!mv88e6xxx_has_pvt(chip))
1900 return 0;
1901
1902 mutex_lock(&chip->reg_lock);
1903 err = mv88e6xxx_pvt_map(chip, dev, port);
1904 mutex_unlock(&chip->reg_lock);
1905
1906 return err;
1907}
1908
1909static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1910 int port, struct net_device *br)
1911{
1912 struct mv88e6xxx_chip *chip = ds->priv;
1913
1914 if (!mv88e6xxx_has_pvt(chip))
1915 return;
1916
1917 mutex_lock(&chip->reg_lock);
1918 if (mv88e6xxx_pvt_map(chip, dev, port))
1919 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1920 mutex_unlock(&chip->reg_lock);
1921}
1922
Vivien Didelot17e708b2016-12-05 17:30:27 -05001923static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1924{
1925 if (chip->info->ops->reset)
1926 return chip->info->ops->reset(chip);
1927
1928 return 0;
1929}
1930
Vivien Didelot309eca62016-12-05 17:30:26 -05001931static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1932{
1933 struct gpio_desc *gpiod = chip->reset;
1934
1935 /* If there is a GPIO connected to the reset pin, toggle it */
1936 if (gpiod) {
1937 gpiod_set_value_cansleep(gpiod, 1);
1938 usleep_range(10000, 20000);
1939 gpiod_set_value_cansleep(gpiod, 0);
1940 usleep_range(10000, 20000);
1941 }
1942}
1943
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001944static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1945{
1946 int i, err;
1947
1948 /* Set all ports to the Disabled state */
1949 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001950 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001951 if (err)
1952 return err;
1953 }
1954
1955 /* Wait for transmit queues to drain,
1956 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1957 */
1958 usleep_range(2000, 4000);
1959
1960 return 0;
1961}
1962
Vivien Didelotfad09c72016-06-21 12:28:20 -04001963static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001964{
Vivien Didelota935c052016-09-29 12:21:53 -04001965 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001966
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001967 err = mv88e6xxx_disable_ports(chip);
1968 if (err)
1969 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001970
Vivien Didelot309eca62016-12-05 17:30:26 -05001971 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001972
Vivien Didelot17e708b2016-12-05 17:30:27 -05001973 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001974}
1975
Vivien Didelot43145572017-03-11 16:12:59 -05001976static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001977 enum mv88e6xxx_frame_mode frame,
1978 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001979{
1980 int err;
1981
Vivien Didelot43145572017-03-11 16:12:59 -05001982 if (!chip->info->ops->port_set_frame_mode)
1983 return -EOPNOTSUPP;
1984
1985 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001986 if (err)
1987 return err;
1988
Vivien Didelot43145572017-03-11 16:12:59 -05001989 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1990 if (err)
1991 return err;
1992
1993 if (chip->info->ops->port_set_ether_type)
1994 return chip->info->ops->port_set_ether_type(chip, port, etype);
1995
1996 return 0;
1997}
1998
1999static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2000{
2001 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002002 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002003 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002004}
2005
2006static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2007{
2008 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002009 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002010 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002011}
2012
2013static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2014{
2015 return mv88e6xxx_set_port_mode(chip, port,
2016 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002017 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2018 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002019}
2020
2021static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2022{
2023 if (dsa_is_dsa_port(chip->ds, port))
2024 return mv88e6xxx_set_port_mode_dsa(chip, port);
2025
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002026 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002027 return mv88e6xxx_set_port_mode_normal(chip, port);
2028
2029 /* Setup CPU port mode depending on its supported tag format */
2030 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2031 return mv88e6xxx_set_port_mode_dsa(chip, port);
2032
2033 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2034 return mv88e6xxx_set_port_mode_edsa(chip, port);
2035
2036 return -EINVAL;
2037}
2038
Vivien Didelotea698f42017-03-11 16:12:50 -05002039static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2040{
2041 bool message = dsa_is_dsa_port(chip->ds, port);
2042
2043 return mv88e6xxx_port_set_message_port(chip, port, message);
2044}
2045
Vivien Didelot601aeed2017-03-11 16:13:00 -05002046static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2047{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002048 struct dsa_switch *ds = chip->ds;
2049 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002050
2051 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002052 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002053 if (chip->info->ops->port_set_egress_floods)
2054 return chip->info->ops->port_set_egress_floods(chip, port,
2055 flood, flood);
2056
2057 return 0;
2058}
2059
Andrew Lunn6d917822017-05-26 01:03:21 +02002060static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2061 bool on)
2062{
Vivien Didelot523a8902017-05-26 18:02:42 -04002063 if (chip->info->ops->serdes_power)
2064 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002065
Vivien Didelot523a8902017-05-26 18:02:42 -04002066 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002067}
2068
Vivien Didelotfa371c82017-12-05 15:34:10 -05002069static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2070{
2071 struct dsa_switch *ds = chip->ds;
2072 int upstream_port;
2073 int err;
2074
Vivien Didelot07073c72017-12-05 15:34:13 -05002075 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002076 if (chip->info->ops->port_set_upstream_port) {
2077 err = chip->info->ops->port_set_upstream_port(chip, port,
2078 upstream_port);
2079 if (err)
2080 return err;
2081 }
2082
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002083 if (port == upstream_port) {
2084 if (chip->info->ops->set_cpu_port) {
2085 err = chip->info->ops->set_cpu_port(chip,
2086 upstream_port);
2087 if (err)
2088 return err;
2089 }
2090
2091 if (chip->info->ops->set_egress_port) {
2092 err = chip->info->ops->set_egress_port(chip,
2093 upstream_port);
2094 if (err)
2095 return err;
2096 }
2097 }
2098
Vivien Didelotfa371c82017-12-05 15:34:10 -05002099 return 0;
2100}
2101
Vivien Didelotfad09c72016-06-21 12:28:20 -04002102static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002103{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002104 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002105 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002106 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002107
Andrew Lunn7b898462018-08-09 15:38:47 +02002108 chip->ports[port].chip = chip;
2109 chip->ports[port].port = port;
2110
Vivien Didelotd78343d2016-11-04 03:23:36 +01002111 /* MAC Forcing register: don't force link, speed, duplex or flow control
2112 * state to any particular values on physical ports, but force the CPU
2113 * port and all DSA ports to their maximum bandwidth and full duplex.
2114 */
2115 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2116 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2117 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002118 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002119 PHY_INTERFACE_MODE_NA);
2120 else
2121 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2122 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002123 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002124 PHY_INTERFACE_MODE_NA);
2125 if (err)
2126 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002127
2128 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2129 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2130 * tunneling, determine priority by looking at 802.1p and IP
2131 * priority fields (IP prio has precedence), and set STP state
2132 * to Forwarding.
2133 *
2134 * If this is the CPU link, use DSA or EDSA tagging depending
2135 * on which tagging mode was configured.
2136 *
2137 * If this is a link to another switch, use DSA tagging mode.
2138 *
2139 * If this is the upstream port for this switch, enable
2140 * forwarding of unknown unicasts and multicasts.
2141 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002142 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2143 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2144 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2145 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002146 if (err)
2147 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002148
Vivien Didelot601aeed2017-03-11 16:13:00 -05002149 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002150 if (err)
2151 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002152
Vivien Didelot601aeed2017-03-11 16:13:00 -05002153 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002154 if (err)
2155 return err;
2156
Andrew Lunn04aca992017-05-26 01:03:24 +02002157 /* Enable the SERDES interface for DSA and CPU ports. Normal
2158 * ports SERDES are enabled when the port is enabled, thus
2159 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002160 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002161 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2162 err = mv88e6xxx_serdes_power(chip, port, true);
2163 if (err)
2164 return err;
2165 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002166
Vivien Didelot8efdda42015-08-13 12:52:23 -04002167 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002168 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002169 * untagged frames on this port, do a destination address lookup on all
2170 * received packets as usual, disable ARP mirroring and don't send a
2171 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002172 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002173 err = mv88e6xxx_port_set_map_da(chip, port);
2174 if (err)
2175 return err;
2176
Vivien Didelotfa371c82017-12-05 15:34:10 -05002177 err = mv88e6xxx_setup_upstream_port(chip, port);
2178 if (err)
2179 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002180
Andrew Lunna23b2962017-02-04 20:15:28 +01002181 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002182 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002183 if (err)
2184 return err;
2185
Vivien Didelotcd782652017-06-08 18:34:13 -04002186 if (chip->info->ops->port_set_jumbo_size) {
2187 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002188 if (err)
2189 return err;
2190 }
2191
Andrew Lunn54d792f2015-05-06 01:09:47 +02002192 /* Port Association Vector: when learning source addresses
2193 * of packets, add the address to the address database using
2194 * a port bitmap that has only the bit for this port set and
2195 * the other bits clear.
2196 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002197 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002198 /* Disable learning for CPU port */
2199 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002200 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002201
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002202 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2203 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002204 if (err)
2205 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002206
2207 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002208 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2209 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002210 if (err)
2211 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002212
Vivien Didelot08984322017-06-08 18:34:12 -04002213 if (chip->info->ops->port_pause_limit) {
2214 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002215 if (err)
2216 return err;
2217 }
2218
Vivien Didelotc8c94892017-03-11 16:13:01 -05002219 if (chip->info->ops->port_disable_learn_limit) {
2220 err = chip->info->ops->port_disable_learn_limit(chip, port);
2221 if (err)
2222 return err;
2223 }
2224
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002225 if (chip->info->ops->port_disable_pri_override) {
2226 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002227 if (err)
2228 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002229 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002230
Andrew Lunnef0a7312016-12-03 04:35:16 +01002231 if (chip->info->ops->port_tag_remap) {
2232 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002233 if (err)
2234 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002235 }
2236
Andrew Lunnef70b112016-12-03 04:45:18 +01002237 if (chip->info->ops->port_egress_rate_limiting) {
2238 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002239 if (err)
2240 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002241 }
2242
Vivien Didelotea698f42017-03-11 16:12:50 -05002243 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002244 if (err)
2245 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002246
Vivien Didelot207afda2016-04-14 14:42:09 -04002247 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002248 * database, and allow bidirectional communication between the
2249 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002250 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002251 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002252 if (err)
2253 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002254
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002255 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002256 if (err)
2257 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002258
2259 /* Default VLAN ID and priority: don't set a default VLAN
2260 * ID, and set the default packet priority to zero.
2261 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002262 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002263}
2264
Andrew Lunn04aca992017-05-26 01:03:24 +02002265static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2266 struct phy_device *phydev)
2267{
2268 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002269 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002270
2271 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002272
Vivien Didelot523a8902017-05-26 18:02:42 -04002273 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002274
2275 if (!err && chip->info->ops->serdes_irq_setup)
2276 err = chip->info->ops->serdes_irq_setup(chip, port);
2277
Andrew Lunn04aca992017-05-26 01:03:24 +02002278 mutex_unlock(&chip->reg_lock);
2279
2280 return err;
2281}
2282
Andrew Lunn75104db2019-02-24 20:44:43 +01002283static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002284{
2285 struct mv88e6xxx_chip *chip = ds->priv;
2286
2287 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002288
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002289 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2290 dev_err(chip->dev, "failed to disable port\n");
2291
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002292 if (chip->info->ops->serdes_irq_free)
2293 chip->info->ops->serdes_irq_free(chip, port);
2294
Vivien Didelot523a8902017-05-26 18:02:42 -04002295 if (mv88e6xxx_serdes_power(chip, port, false))
2296 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002297
Andrew Lunn04aca992017-05-26 01:03:24 +02002298 mutex_unlock(&chip->reg_lock);
2299}
2300
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002301static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2302 unsigned int ageing_time)
2303{
Vivien Didelot04bed142016-08-31 18:06:13 -04002304 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002305 int err;
2306
2307 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002308 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002309 mutex_unlock(&chip->reg_lock);
2310
2311 return err;
2312}
2313
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002314static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002315{
2316 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002317
Andrew Lunnde2273872016-11-21 23:27:01 +01002318 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002319 if (chip->info->ops->stats_set_histogram) {
2320 err = chip->info->ops->stats_set_histogram(chip);
2321 if (err)
2322 return err;
2323 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002324
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002325 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002326}
2327
Andrew Lunnea890982019-01-09 00:24:03 +01002328/* The mv88e6390 has some hidden registers used for debug and
2329 * development. The errata also makes use of them.
2330 */
2331static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2332 int reg, u16 val)
2333{
2334 u16 ctrl;
2335 int err;
2336
2337 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2338 PORT_RESERVED_1A, val);
2339 if (err)
2340 return err;
2341
2342 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2343 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2344 reg;
2345
2346 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2347 PORT_RESERVED_1A, ctrl);
2348}
2349
2350static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2351{
2352 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2353 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2354}
2355
2356
2357static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2358 int reg, u16 *val)
2359{
2360 u16 ctrl;
2361 int err;
2362
2363 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2364 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2365 reg;
2366
2367 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2368 PORT_RESERVED_1A, ctrl);
2369 if (err)
2370 return err;
2371
2372 err = mv88e6390_hidden_wait(chip);
2373 if (err)
2374 return err;
2375
2376 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2377 PORT_RESERVED_1A, val);
2378}
2379
2380/* Check if the errata has already been applied. */
2381static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2382{
2383 int port;
2384 int err;
2385 u16 val;
2386
2387 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2388 err = mv88e6390_hidden_read(chip, port, 0, &val);
2389 if (err) {
2390 dev_err(chip->dev,
2391 "Error reading hidden register: %d\n", err);
2392 return false;
2393 }
2394 if (val != 0x01c0)
2395 return false;
2396 }
2397
2398 return true;
2399}
2400
2401/* The 6390 copper ports have an errata which require poking magic
2402 * values into undocumented hidden registers and then performing a
2403 * software reset.
2404 */
2405static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2406{
2407 int port;
2408 int err;
2409
2410 if (mv88e6390_setup_errata_applied(chip))
2411 return 0;
2412
2413 /* Set the ports into blocking mode */
2414 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2415 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2416 if (err)
2417 return err;
2418 }
2419
2420 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2421 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2422 if (err)
2423 return err;
2424 }
2425
2426 return mv88e6xxx_software_reset(chip);
2427}
2428
Vivien Didelotf81ec902016-05-09 13:22:58 -04002429static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002430{
Vivien Didelot04bed142016-08-31 18:06:13 -04002431 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002432 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002433 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002434 int i;
2435
Vivien Didelotfad09c72016-06-21 12:28:20 -04002436 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002437 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002438
Vivien Didelotfad09c72016-06-21 12:28:20 -04002439 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002440
Andrew Lunnea890982019-01-09 00:24:03 +01002441 if (chip->info->ops->setup_errata) {
2442 err = chip->info->ops->setup_errata(chip);
2443 if (err)
2444 goto unlock;
2445 }
2446
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002447 /* Cache the cmode of each port. */
2448 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2449 if (chip->info->ops->port_get_cmode) {
2450 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2451 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002452 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002453
2454 chip->ports[i].cmode = cmode;
2455 }
2456 }
2457
Vivien Didelot97299342016-07-18 20:45:30 -04002458 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002459 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Andrew Lunn100a9b92019-05-01 00:08:31 +02002460 if (dsa_is_unused_port(ds, i)) {
2461 err = mv88e6xxx_port_set_state(chip, i,
2462 BR_STATE_DISABLED);
2463 if (err)
2464 goto unlock;
2465
2466 err = mv88e6xxx_serdes_power(chip, i, false);
2467 if (err)
2468 goto unlock;
2469
Vivien Didelot91dee142017-10-26 11:22:52 -04002470 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002471 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002472
Vivien Didelot97299342016-07-18 20:45:30 -04002473 err = mv88e6xxx_setup_port(chip, i);
2474 if (err)
2475 goto unlock;
2476 }
2477
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002478 err = mv88e6xxx_irl_setup(chip);
2479 if (err)
2480 goto unlock;
2481
Vivien Didelot04a69a12017-10-13 14:18:05 -04002482 err = mv88e6xxx_mac_setup(chip);
2483 if (err)
2484 goto unlock;
2485
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002486 err = mv88e6xxx_phy_setup(chip);
2487 if (err)
2488 goto unlock;
2489
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002490 err = mv88e6xxx_vtu_setup(chip);
2491 if (err)
2492 goto unlock;
2493
Vivien Didelot81228992017-03-30 17:37:08 -04002494 err = mv88e6xxx_pvt_setup(chip);
2495 if (err)
2496 goto unlock;
2497
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002498 err = mv88e6xxx_atu_setup(chip);
2499 if (err)
2500 goto unlock;
2501
Andrew Lunn87fa8862017-11-09 22:29:56 +01002502 err = mv88e6xxx_broadcast_setup(chip, 0);
2503 if (err)
2504 goto unlock;
2505
Vivien Didelot9e907d72017-07-17 13:03:43 -04002506 err = mv88e6xxx_pot_setup(chip);
2507 if (err)
2508 goto unlock;
2509
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002510 err = mv88e6xxx_rmu_setup(chip);
2511 if (err)
2512 goto unlock;
2513
Vivien Didelot51c901a2017-07-17 13:03:41 -04002514 err = mv88e6xxx_rsvd2cpu_setup(chip);
2515 if (err)
2516 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002517
Vivien Didelotb28f8722018-04-26 21:56:44 -04002518 err = mv88e6xxx_trunk_setup(chip);
2519 if (err)
2520 goto unlock;
2521
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002522 err = mv88e6xxx_devmap_setup(chip);
2523 if (err)
2524 goto unlock;
2525
Vivien Didelot93e18d62018-05-11 17:16:35 -04002526 err = mv88e6xxx_pri_setup(chip);
2527 if (err)
2528 goto unlock;
2529
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002530 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002531 if (chip->info->ptp_support) {
2532 err = mv88e6xxx_ptp_setup(chip);
2533 if (err)
2534 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002535
2536 err = mv88e6xxx_hwtstamp_setup(chip);
2537 if (err)
2538 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002539 }
2540
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002541 err = mv88e6xxx_stats_setup(chip);
2542 if (err)
2543 goto unlock;
2544
Vivien Didelot6b17e862015-08-13 12:52:18 -04002545unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002546 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002547
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002548 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002549}
2550
Vivien Didelote57e5e72016-08-15 17:19:00 -04002551static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002552{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002553 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2554 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002555 u16 val;
2556 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002557
Andrew Lunnee26a222017-01-24 14:53:48 +01002558 if (!chip->info->ops->phy_read)
2559 return -EOPNOTSUPP;
2560
Vivien Didelotfad09c72016-06-21 12:28:20 -04002561 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002562 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002563 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002564
Andrew Lunnda9f3302017-02-01 03:40:05 +01002565 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002566 /* Some internal PHYs don't have a model number. */
2567 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2568 /* Then there is the 6165 family. It gets is
2569 * PHYs correct. But it can also have two
2570 * SERDES interfaces in the PHY address
2571 * space. And these don't have a model
2572 * number. But they are not PHYs, so we don't
2573 * want to give them something a PHY driver
2574 * will recognise.
2575 *
2576 * Use the mv88e6390 family model number
2577 * instead, for anything which really could be
2578 * a PHY,
2579 */
2580 if (!(val & 0x3f0))
2581 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002582 }
2583
Vivien Didelote57e5e72016-08-15 17:19:00 -04002584 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002585}
2586
Vivien Didelote57e5e72016-08-15 17:19:00 -04002587static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002588{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002589 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2590 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002591 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002592
Andrew Lunnee26a222017-01-24 14:53:48 +01002593 if (!chip->info->ops->phy_write)
2594 return -EOPNOTSUPP;
2595
Vivien Didelotfad09c72016-06-21 12:28:20 -04002596 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002597 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002598 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002599
2600 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002601}
2602
Vivien Didelotfad09c72016-06-21 12:28:20 -04002603static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002604 struct device_node *np,
2605 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002606{
2607 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002608 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002609 struct mii_bus *bus;
2610 int err;
2611
Andrew Lunn2510bab2018-02-22 01:51:49 +01002612 if (external) {
2613 mutex_lock(&chip->reg_lock);
2614 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2615 mutex_unlock(&chip->reg_lock);
2616
2617 if (err)
2618 return err;
2619 }
2620
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002621 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002622 if (!bus)
2623 return -ENOMEM;
2624
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002625 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002626 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002627 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002628 INIT_LIST_HEAD(&mdio_bus->list);
2629 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002630
Andrew Lunnb516d452016-06-04 21:17:06 +02002631 if (np) {
2632 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002633 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002634 } else {
2635 bus->name = "mv88e6xxx SMI";
2636 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2637 }
2638
2639 bus->read = mv88e6xxx_mdio_read;
2640 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002641 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002642
Andrew Lunn6f882842018-03-17 20:32:05 +01002643 if (!external) {
2644 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2645 if (err)
2646 return err;
2647 }
2648
Florian Fainelli00e798c2018-05-15 16:56:19 -07002649 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002650 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002651 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002652 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002653 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002654 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002655
2656 if (external)
2657 list_add_tail(&mdio_bus->list, &chip->mdios);
2658 else
2659 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002660
2661 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002662}
2663
Andrew Lunna3c53be52017-01-24 14:53:50 +01002664static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2665 { .compatible = "marvell,mv88e6xxx-mdio-external",
2666 .data = (void *)true },
2667 { },
2668};
2669
Andrew Lunn3126aee2017-12-07 01:05:57 +01002670static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2671
2672{
2673 struct mv88e6xxx_mdio_bus *mdio_bus;
2674 struct mii_bus *bus;
2675
2676 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2677 bus = mdio_bus->bus;
2678
Andrew Lunn6f882842018-03-17 20:32:05 +01002679 if (!mdio_bus->external)
2680 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2681
Andrew Lunn3126aee2017-12-07 01:05:57 +01002682 mdiobus_unregister(bus);
2683 }
2684}
2685
Andrew Lunna3c53be52017-01-24 14:53:50 +01002686static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2687 struct device_node *np)
2688{
2689 const struct of_device_id *match;
2690 struct device_node *child;
2691 int err;
2692
2693 /* Always register one mdio bus for the internal/default mdio
2694 * bus. This maybe represented in the device tree, but is
2695 * optional.
2696 */
2697 child = of_get_child_by_name(np, "mdio");
2698 err = mv88e6xxx_mdio_register(chip, child, false);
2699 if (err)
2700 return err;
2701
2702 /* Walk the device tree, and see if there are any other nodes
2703 * which say they are compatible with the external mdio
2704 * bus.
2705 */
2706 for_each_available_child_of_node(np, child) {
2707 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2708 if (match) {
2709 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002710 if (err) {
2711 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002712 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002713 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002714 }
2715 }
2716
2717 return 0;
2718}
2719
Vivien Didelot855b1932016-07-20 18:18:35 -04002720static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2721{
Vivien Didelot04bed142016-08-31 18:06:13 -04002722 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002723
2724 return chip->eeprom_len;
2725}
2726
Vivien Didelot855b1932016-07-20 18:18:35 -04002727static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2728 struct ethtool_eeprom *eeprom, u8 *data)
2729{
Vivien Didelot04bed142016-08-31 18:06:13 -04002730 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002731 int err;
2732
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002733 if (!chip->info->ops->get_eeprom)
2734 return -EOPNOTSUPP;
2735
Vivien Didelot855b1932016-07-20 18:18:35 -04002736 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002737 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002738 mutex_unlock(&chip->reg_lock);
2739
2740 if (err)
2741 return err;
2742
2743 eeprom->magic = 0xc3ec4951;
2744
2745 return 0;
2746}
2747
Vivien Didelot855b1932016-07-20 18:18:35 -04002748static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2749 struct ethtool_eeprom *eeprom, u8 *data)
2750{
Vivien Didelot04bed142016-08-31 18:06:13 -04002751 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002752 int err;
2753
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002754 if (!chip->info->ops->set_eeprom)
2755 return -EOPNOTSUPP;
2756
Vivien Didelot855b1932016-07-20 18:18:35 -04002757 if (eeprom->magic != 0xc3ec4951)
2758 return -EINVAL;
2759
2760 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002761 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002762 mutex_unlock(&chip->reg_lock);
2763
2764 return err;
2765}
2766
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002767static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002768 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002769 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2770 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002771 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002772 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002773 .phy_read = mv88e6185_phy_ppu_read,
2774 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002775 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002776 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002777 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002778 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002779 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002780 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002781 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002782 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002783 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002784 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002785 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002786 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002787 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002788 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002789 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002790 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2791 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002792 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002793 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2794 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002795 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002796 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002797 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002798 .ppu_enable = mv88e6185_g1_ppu_enable,
2799 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002800 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002801 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002802 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002803 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002804 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002805};
2806
2807static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002808 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002809 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2810 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002811 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002812 .phy_read = mv88e6185_phy_ppu_read,
2813 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002814 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002815 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002816 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002817 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002818 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002819 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002820 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002821 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002822 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002823 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002824 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2825 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002826 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002827 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002828 .ppu_enable = mv88e6185_g1_ppu_enable,
2829 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002830 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002831 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002832 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002833 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002834};
2835
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002836static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002837 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002838 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2839 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002840 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002841 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2842 .phy_read = mv88e6xxx_g2_smi_phy_read,
2843 .phy_write = mv88e6xxx_g2_smi_phy_write,
2844 .port_set_link = mv88e6xxx_port_set_link,
2845 .port_set_duplex = mv88e6xxx_port_set_duplex,
2846 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002847 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002848 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002849 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002850 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002851 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002852 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002853 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002854 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002855 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002856 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002857 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002858 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002859 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002860 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2861 .stats_get_strings = mv88e6095_stats_get_strings,
2862 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002863 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2864 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002865 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002866 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002867 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002868 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002869 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002870 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002871 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002872 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002873};
2874
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002875static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002876 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002877 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2878 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002879 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002880 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002881 .phy_read = mv88e6xxx_g2_smi_phy_read,
2882 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002883 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002884 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002885 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002886 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002887 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002888 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002889 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002890 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002891 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002892 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002893 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002894 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2895 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002896 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002897 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2898 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002899 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002900 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002901 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002902 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002903 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002904 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002905 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002906};
2907
2908static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002909 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002910 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2911 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002912 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002913 .phy_read = mv88e6185_phy_ppu_read,
2914 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002915 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002916 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002917 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002918 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002919 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002920 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002921 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002922 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002923 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002924 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002925 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002926 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002927 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002928 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002929 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002930 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002931 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2932 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002933 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002934 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2935 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002936 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002937 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002938 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002939 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002940 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002941 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002942 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002943 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002944 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002945};
2946
Vivien Didelot990e27b2017-03-28 13:50:32 -04002947static const struct mv88e6xxx_ops mv88e6141_ops = {
2948 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002949 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2950 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002951 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002952 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2953 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2954 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2955 .phy_read = mv88e6xxx_g2_smi_phy_read,
2956 .phy_write = mv88e6xxx_g2_smi_phy_write,
2957 .port_set_link = mv88e6xxx_port_set_link,
2958 .port_set_duplex = mv88e6xxx_port_set_duplex,
2959 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002960 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002961 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002962 .port_tag_remap = mv88e6095_port_tag_remap,
2963 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2964 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2965 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002966 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002967 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002968 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002969 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2970 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002971 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002972 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002973 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002974 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002975 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2976 .stats_get_strings = mv88e6320_stats_get_strings,
2977 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002978 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2979 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002980 .watchdog_ops = &mv88e6390_watchdog_ops,
2981 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002982 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002983 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002984 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002985 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002986 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002987 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01002988 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002989};
2990
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002991static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002992 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002993 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2994 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002995 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002996 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002997 .phy_read = mv88e6xxx_g2_smi_phy_read,
2998 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002999 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003000 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003001 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003002 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003003 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003004 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003005 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003006 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003007 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003008 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003009 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003010 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003011 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003012 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003013 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003014 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003015 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3016 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003017 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003018 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3019 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003020 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003021 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003022 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003023 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003024 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003025 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003026 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003027 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003028 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003029};
3030
3031static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003032 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003033 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3034 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003035 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003036 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003037 .phy_read = mv88e6165_phy_read,
3038 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003039 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003040 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003041 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003042 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003043 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003044 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003045 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003046 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003047 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003048 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3049 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003050 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003051 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3052 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003053 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003054 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003055 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003056 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003057 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003058 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003059 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003060 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003061 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003062};
3063
3064static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003065 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003066 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3067 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003068 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003069 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003070 .phy_read = mv88e6xxx_g2_smi_phy_read,
3071 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003072 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003073 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003074 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003075 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003076 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003077 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003078 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003079 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003080 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003081 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003082 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003083 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003084 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003085 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003086 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003087 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003088 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003089 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3090 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003091 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003092 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3093 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003094 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003095 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003096 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003097 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003098 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003099 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003100 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003101};
3102
3103static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003104 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003105 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3106 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003107 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003108 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3109 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003110 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003111 .phy_read = mv88e6xxx_g2_smi_phy_read,
3112 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003113 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003114 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003115 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003116 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003117 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003118 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003119 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003120 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003121 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003122 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003123 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003124 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003125 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003126 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003127 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003128 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003129 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003130 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3131 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003132 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003133 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3134 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003135 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003136 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003137 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003138 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003139 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003140 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003141 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003142 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003143 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003144 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003145};
3146
3147static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003148 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003149 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3150 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003151 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003152 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003153 .phy_read = mv88e6xxx_g2_smi_phy_read,
3154 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003155 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003156 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003157 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003158 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003159 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003160 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003161 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003162 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003163 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003164 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003165 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003166 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003167 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003168 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003169 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003170 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003171 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003172 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3173 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003174 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003175 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3176 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003177 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003178 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003179 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003180 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003181 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003182 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003183 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003184};
3185
3186static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003187 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003188 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3189 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003190 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003191 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3192 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003193 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003194 .phy_read = mv88e6xxx_g2_smi_phy_read,
3195 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003196 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003197 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003198 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003199 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003200 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003201 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003202 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003203 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003204 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003205 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003206 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003207 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003208 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003209 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003210 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003211 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003212 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003213 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3214 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003215 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003216 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3217 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003218 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003219 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003220 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003221 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003222 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003223 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003224 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003225 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003226 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3227 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003228 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003229 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003230};
3231
3232static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003233 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003234 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3235 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003236 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003237 .phy_read = mv88e6185_phy_ppu_read,
3238 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003239 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003240 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003241 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003242 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003243 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003244 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003245 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003246 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003247 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003248 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003249 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003250 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003251 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3252 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003253 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003254 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3255 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003256 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003257 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003258 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003259 .ppu_enable = mv88e6185_g1_ppu_enable,
3260 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003261 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003262 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003263 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003264 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003265};
3266
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003267static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003268 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003269 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003270 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003271 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3272 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003273 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3274 .phy_read = mv88e6xxx_g2_smi_phy_read,
3275 .phy_write = mv88e6xxx_g2_smi_phy_write,
3276 .port_set_link = mv88e6xxx_port_set_link,
3277 .port_set_duplex = mv88e6xxx_port_set_duplex,
3278 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3279 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003280 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003281 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003282 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003283 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003284 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003285 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003286 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003287 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003288 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003289 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003290 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003291 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003292 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003293 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3294 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003295 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003296 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3297 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003298 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003299 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003300 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003301 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003302 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003303 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3304 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003305 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003306 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3307 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003308 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003309 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003310};
3311
3312static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003313 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003314 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003315 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003316 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3317 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003318 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3319 .phy_read = mv88e6xxx_g2_smi_phy_read,
3320 .phy_write = mv88e6xxx_g2_smi_phy_write,
3321 .port_set_link = mv88e6xxx_port_set_link,
3322 .port_set_duplex = mv88e6xxx_port_set_duplex,
3323 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3324 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003325 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003326 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003327 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003328 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003329 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003330 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003331 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003332 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003333 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003334 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003335 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003336 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003337 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003338 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3339 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003340 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003341 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3342 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003343 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003344 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003345 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003346 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003347 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003348 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3349 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003350 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003351 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3352 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003353 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003354 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003355};
3356
3357static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003358 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003359 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003360 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003361 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3362 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003363 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3364 .phy_read = mv88e6xxx_g2_smi_phy_read,
3365 .phy_write = mv88e6xxx_g2_smi_phy_write,
3366 .port_set_link = mv88e6xxx_port_set_link,
3367 .port_set_duplex = mv88e6xxx_port_set_duplex,
3368 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3369 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003370 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003371 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003372 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003373 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003374 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003375 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003376 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003377 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003378 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003379 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003380 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003381 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003382 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003383 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3384 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003385 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003386 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3387 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003388 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003389 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003390 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003391 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003392 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003393 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3394 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003395 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003396 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3397 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003398 .avb_ops = &mv88e6390_avb_ops,
3399 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003400 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003401};
3402
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003403static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003404 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003405 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3406 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003407 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003408 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3409 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003410 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003411 .phy_read = mv88e6xxx_g2_smi_phy_read,
3412 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003413 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003414 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003415 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003416 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003417 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003418 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003419 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003421 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003422 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003423 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003424 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003425 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003426 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003427 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003428 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003429 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003430 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3431 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003432 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003433 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3434 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003435 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003436 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003437 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003438 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003439 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003440 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003441 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003442 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003443 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3444 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003445 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003446 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003447 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003448 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449};
3450
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003451static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003452 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003453 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003454 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003455 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3456 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003457 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3458 .phy_read = mv88e6xxx_g2_smi_phy_read,
3459 .phy_write = mv88e6xxx_g2_smi_phy_write,
3460 .port_set_link = mv88e6xxx_port_set_link,
3461 .port_set_duplex = mv88e6xxx_port_set_duplex,
3462 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3463 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003464 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003465 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003466 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003467 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003468 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003469 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003470 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003471 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003472 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003473 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003474 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003475 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003476 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003477 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3478 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003479 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003480 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3481 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003482 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003483 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003484 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003485 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003486 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003487 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3488 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003489 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003490 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3491 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003492 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003493 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003494 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003495 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003496};
3497
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003498static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003499 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003500 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3501 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003502 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003503 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3504 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003505 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003506 .phy_read = mv88e6xxx_g2_smi_phy_read,
3507 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003508 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003509 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003510 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003511 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003512 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003513 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003514 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003515 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003516 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003517 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003518 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003519 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003520 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003521 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003522 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003523 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003524 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3525 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003526 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003527 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3528 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003529 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003530 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003531 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003532 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003533 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003534 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003535 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003536 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003537 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003538 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003539};
3540
3541static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003542 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003543 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3544 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003545 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003546 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3547 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003548 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003549 .phy_read = mv88e6xxx_g2_smi_phy_read,
3550 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003551 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003552 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003553 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003554 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003555 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003556 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003557 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003558 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003559 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003560 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003561 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003562 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003563 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003564 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003565 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003566 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003567 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3568 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003569 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003570 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3571 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003572 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003573 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003574 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003575 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003576 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003577 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003578 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003579 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003580};
3581
Vivien Didelot16e329a2017-03-28 13:50:33 -04003582static const struct mv88e6xxx_ops mv88e6341_ops = {
3583 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003584 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3585 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003586 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003587 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3588 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3589 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3590 .phy_read = mv88e6xxx_g2_smi_phy_read,
3591 .phy_write = mv88e6xxx_g2_smi_phy_write,
3592 .port_set_link = mv88e6xxx_port_set_link,
3593 .port_set_duplex = mv88e6xxx_port_set_duplex,
3594 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003595 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003596 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003597 .port_tag_remap = mv88e6095_port_tag_remap,
3598 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3599 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3600 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003601 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003602 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003603 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003604 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3605 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003606 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003607 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003608 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003609 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003610 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3611 .stats_get_strings = mv88e6320_stats_get_strings,
3612 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003613 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3614 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003615 .watchdog_ops = &mv88e6390_watchdog_ops,
3616 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003617 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003618 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003619 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003620 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003621 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003622 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003623 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003624 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003625 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003626};
3627
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003629 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003630 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3631 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003632 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003633 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003634 .phy_read = mv88e6xxx_g2_smi_phy_read,
3635 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003636 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003637 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003638 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003639 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003640 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003641 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003642 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003643 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003644 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003645 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003646 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003647 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003648 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003649 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003650 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003651 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003652 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003653 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3654 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003655 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003656 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3657 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003658 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003659 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003660 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003661 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003662 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003663 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003664 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003665};
3666
3667static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003668 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003669 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3670 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003671 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003672 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003673 .phy_read = mv88e6xxx_g2_smi_phy_read,
3674 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003675 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003676 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003677 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003678 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003679 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003680 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003681 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003682 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003683 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003684 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003685 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003686 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003687 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003688 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003689 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003690 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003691 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003692 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3693 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003694 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003695 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3696 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003697 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003698 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003699 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003700 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003701 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003702 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003703 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003704 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003705 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003706};
3707
3708static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003709 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003710 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3711 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003712 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003713 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3714 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003715 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003716 .phy_read = mv88e6xxx_g2_smi_phy_read,
3717 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003718 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003719 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003720 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003721 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003722 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003723 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003724 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003725 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003726 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003727 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003728 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003729 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003730 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003731 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003732 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003733 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003734 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003735 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3736 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003737 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003738 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3739 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003740 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003741 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003742 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003743 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003744 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003745 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003746 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003747 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003748 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3749 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003750 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003751 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003752 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003753 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3754 .serdes_get_strings = mv88e6352_serdes_get_strings,
3755 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003756 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003757};
3758
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003759static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003760 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003761 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003762 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003763 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3764 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003765 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3766 .phy_read = mv88e6xxx_g2_smi_phy_read,
3767 .phy_write = mv88e6xxx_g2_smi_phy_write,
3768 .port_set_link = mv88e6xxx_port_set_link,
3769 .port_set_duplex = mv88e6xxx_port_set_duplex,
3770 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3771 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003772 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003773 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003774 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003775 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003776 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003777 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003778 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003779 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003780 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003781 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003782 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003783 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003784 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003785 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003786 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003787 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3788 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003789 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003790 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3791 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003792 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003793 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003794 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003795 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003796 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003797 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3798 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003799 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003800 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3801 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003802 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003803 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003804 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003805 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003806};
3807
3808static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003809 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003810 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003811 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003812 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3813 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003814 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3815 .phy_read = mv88e6xxx_g2_smi_phy_read,
3816 .phy_write = mv88e6xxx_g2_smi_phy_write,
3817 .port_set_link = mv88e6xxx_port_set_link,
3818 .port_set_duplex = mv88e6xxx_port_set_duplex,
3819 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3820 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003821 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003822 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003823 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003824 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003825 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003826 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003827 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003828 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003829 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003830 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003831 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003832 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003833 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003834 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003835 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003836 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3837 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003838 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003839 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3840 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003841 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003842 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003843 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003844 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003845 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003846 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3847 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003848 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003849 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3850 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003851 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003852 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003853 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003854 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003855};
3856
Vivien Didelotf81ec902016-05-09 13:22:58 -04003857static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3858 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003859 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003860 .family = MV88E6XXX_FAMILY_6097,
3861 .name = "Marvell 88E6085",
3862 .num_databases = 4096,
3863 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003864 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003865 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003866 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003867 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003868 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003869 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003870 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003871 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003872 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003873 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003874 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003875 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003876 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003877 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003878 },
3879
3880 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003881 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003882 .family = MV88E6XXX_FAMILY_6095,
3883 .name = "Marvell 88E6095/88E6095F",
3884 .num_databases = 256,
3885 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003886 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003887 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003888 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003889 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003890 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003891 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003892 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003893 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003894 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003895 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003896 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003897 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003898 },
3899
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003900 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003901 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003902 .family = MV88E6XXX_FAMILY_6097,
3903 .name = "Marvell 88E6097/88E6097F",
3904 .num_databases = 4096,
3905 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003906 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003907 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003908 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003909 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003910 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003911 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003912 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003913 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003914 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003915 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003916 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003917 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003918 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003919 .ops = &mv88e6097_ops,
3920 },
3921
Vivien Didelotf81ec902016-05-09 13:22:58 -04003922 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003923 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003924 .family = MV88E6XXX_FAMILY_6165,
3925 .name = "Marvell 88E6123",
3926 .num_databases = 4096,
3927 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003928 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003929 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003930 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003931 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003932 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003933 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003934 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003935 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003936 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003937 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003938 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003939 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003940 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003941 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003942 },
3943
3944 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003946 .family = MV88E6XXX_FAMILY_6185,
3947 .name = "Marvell 88E6131",
3948 .num_databases = 256,
3949 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003950 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003951 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003952 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003953 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003954 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003955 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003956 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003957 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003958 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003959 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003960 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003961 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003962 },
3963
Vivien Didelot990e27b2017-03-28 13:50:32 -04003964 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003965 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003966 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003967 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003968 .num_databases = 4096,
3969 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003970 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003971 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003972 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003973 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003974 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003975 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003976 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003977 .age_time_coeff = 3750,
3978 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003979 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003980 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003981 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003982 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003983 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003984 .ops = &mv88e6141_ops,
3985 },
3986
Vivien Didelotf81ec902016-05-09 13:22:58 -04003987 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003988 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003989 .family = MV88E6XXX_FAMILY_6165,
3990 .name = "Marvell 88E6161",
3991 .num_databases = 4096,
3992 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003993 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003994 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003995 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003996 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003997 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003998 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003999 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004000 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004001 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004002 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004003 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004004 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004005 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004006 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004007 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 },
4009
4010 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004011 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004012 .family = MV88E6XXX_FAMILY_6165,
4013 .name = "Marvell 88E6165",
4014 .num_databases = 4096,
4015 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004016 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004017 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004018 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004019 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004020 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004021 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004022 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004023 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004024 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004025 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004026 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004027 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004028 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004029 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004030 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004031 },
4032
4033 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004034 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004035 .family = MV88E6XXX_FAMILY_6351,
4036 .name = "Marvell 88E6171",
4037 .num_databases = 4096,
4038 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004039 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004040 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004041 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004042 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004043 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004044 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004045 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004046 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004047 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004048 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004049 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004050 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004051 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004052 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004053 },
4054
4055 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004056 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004057 .family = MV88E6XXX_FAMILY_6352,
4058 .name = "Marvell 88E6172",
4059 .num_databases = 4096,
4060 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004061 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004062 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004063 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004064 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004065 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004066 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004067 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004068 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004069 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004070 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004071 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004072 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004073 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004074 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004075 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004076 },
4077
4078 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004079 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004080 .family = MV88E6XXX_FAMILY_6351,
4081 .name = "Marvell 88E6175",
4082 .num_databases = 4096,
4083 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004084 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004085 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004086 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004087 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004088 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004089 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004090 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004091 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004092 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004093 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004094 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004095 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004096 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004097 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004098 },
4099
4100 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004101 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004102 .family = MV88E6XXX_FAMILY_6352,
4103 .name = "Marvell 88E6176",
4104 .num_databases = 4096,
4105 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004106 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004107 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004108 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004109 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004110 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004111 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004112 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004113 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004114 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004115 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004116 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004117 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004118 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004119 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004120 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121 },
4122
4123 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004124 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004125 .family = MV88E6XXX_FAMILY_6185,
4126 .name = "Marvell 88E6185",
4127 .num_databases = 256,
4128 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004129 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004130 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004131 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004132 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004133 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004134 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004135 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004136 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004137 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004138 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004139 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004140 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004141 },
4142
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004143 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004144 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004145 .family = MV88E6XXX_FAMILY_6390,
4146 .name = "Marvell 88E6190",
4147 .num_databases = 4096,
4148 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004149 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004150 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004151 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004152 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004153 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004154 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004155 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004156 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004157 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004158 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004159 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004160 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004161 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004162 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004163 .ops = &mv88e6190_ops,
4164 },
4165
4166 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004167 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004168 .family = MV88E6XXX_FAMILY_6390,
4169 .name = "Marvell 88E6190X",
4170 .num_databases = 4096,
4171 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004172 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004173 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004174 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004175 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004176 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004177 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004178 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004179 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004180 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004181 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004182 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004183 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004184 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004185 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004186 .ops = &mv88e6190x_ops,
4187 },
4188
4189 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004190 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004191 .family = MV88E6XXX_FAMILY_6390,
4192 .name = "Marvell 88E6191",
4193 .num_databases = 4096,
4194 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004195 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004196 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004197 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004198 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004199 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004200 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004201 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004202 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004203 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004204 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004205 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004206 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004207 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004208 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004209 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004210 },
4211
Vivien Didelotf81ec902016-05-09 13:22:58 -04004212 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004213 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004214 .family = MV88E6XXX_FAMILY_6352,
4215 .name = "Marvell 88E6240",
4216 .num_databases = 4096,
4217 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004218 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004219 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004220 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004221 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004222 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004223 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004224 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004225 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004226 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004227 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004228 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004229 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004230 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004231 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004232 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004233 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004234 },
4235
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004236 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004237 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004238 .family = MV88E6XXX_FAMILY_6390,
4239 .name = "Marvell 88E6290",
4240 .num_databases = 4096,
4241 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004242 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004243 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004244 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004245 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004246 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004247 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004248 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004249 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004250 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004251 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004252 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004253 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004254 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004255 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004256 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004257 .ops = &mv88e6290_ops,
4258 },
4259
Vivien Didelotf81ec902016-05-09 13:22:58 -04004260 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004261 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004262 .family = MV88E6XXX_FAMILY_6320,
4263 .name = "Marvell 88E6320",
4264 .num_databases = 4096,
4265 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004266 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004267 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004268 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004269 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004270 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004271 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004272 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004273 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004274 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004275 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004276 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004277 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004278 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004279 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004280 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004281 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004282 },
4283
4284 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004285 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004286 .family = MV88E6XXX_FAMILY_6320,
4287 .name = "Marvell 88E6321",
4288 .num_databases = 4096,
4289 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004290 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004291 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004292 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004293 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004294 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004295 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004296 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004297 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004298 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004299 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004300 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004301 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004302 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004303 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004304 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004305 },
4306
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004307 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004308 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004309 .family = MV88E6XXX_FAMILY_6341,
4310 .name = "Marvell 88E6341",
4311 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004312 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004313 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004314 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004315 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004316 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004317 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004318 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004319 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004320 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004321 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004322 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004323 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004324 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004325 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004326 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004327 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004328 .ops = &mv88e6341_ops,
4329 },
4330
Vivien Didelotf81ec902016-05-09 13:22:58 -04004331 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004332 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004333 .family = MV88E6XXX_FAMILY_6351,
4334 .name = "Marvell 88E6350",
4335 .num_databases = 4096,
4336 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004337 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004338 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004339 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004340 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004341 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004342 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004343 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004344 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004345 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004346 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004347 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004348 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004349 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004350 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004351 },
4352
4353 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004354 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004355 .family = MV88E6XXX_FAMILY_6351,
4356 .name = "Marvell 88E6351",
4357 .num_databases = 4096,
4358 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004359 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004360 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004361 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004362 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004363 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004364 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004365 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004366 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004367 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004368 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004369 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004370 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004371 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004372 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004373 },
4374
4375 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004376 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004377 .family = MV88E6XXX_FAMILY_6352,
4378 .name = "Marvell 88E6352",
4379 .num_databases = 4096,
4380 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004381 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004382 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004383 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004384 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004385 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004386 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004387 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004388 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004389 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004390 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004391 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004392 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004393 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004394 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004395 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004396 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004397 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004398 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004399 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004400 .family = MV88E6XXX_FAMILY_6390,
4401 .name = "Marvell 88E6390",
4402 .num_databases = 4096,
4403 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004404 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004405 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004406 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004407 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004408 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004409 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004410 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004411 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004412 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004413 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004414 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004415 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004416 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004417 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004418 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004419 .ops = &mv88e6390_ops,
4420 },
4421 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004422 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004423 .family = MV88E6XXX_FAMILY_6390,
4424 .name = "Marvell 88E6390X",
4425 .num_databases = 4096,
4426 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004427 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004428 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004429 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004430 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004431 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004432 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004433 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004434 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004435 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004436 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004437 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004438 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004439 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004440 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004441 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004442 .ops = &mv88e6390x_ops,
4443 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004444};
4445
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004446static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004447{
Vivien Didelota439c062016-04-17 13:23:58 -04004448 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004449
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004450 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4451 if (mv88e6xxx_table[i].prod_num == prod_num)
4452 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004453
Vivien Didelotb9b37712015-10-30 19:39:48 -04004454 return NULL;
4455}
4456
Vivien Didelotfad09c72016-06-21 12:28:20 -04004457static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004458{
4459 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004460 unsigned int prod_num, rev;
4461 u16 id;
4462 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004463
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004464 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004465 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004466 mutex_unlock(&chip->reg_lock);
4467 if (err)
4468 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004469
Vivien Didelot107fcc12017-06-12 12:37:36 -04004470 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4471 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004472
4473 info = mv88e6xxx_lookup_info(prod_num);
4474 if (!info)
4475 return -ENODEV;
4476
Vivien Didelotcaac8542016-06-20 13:14:09 -04004477 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004478 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004479
Vivien Didelotca070c12016-09-02 14:45:34 -04004480 err = mv88e6xxx_g2_require(chip);
4481 if (err)
4482 return err;
4483
Vivien Didelotfad09c72016-06-21 12:28:20 -04004484 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4485 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004486
4487 return 0;
4488}
4489
Vivien Didelotfad09c72016-06-21 12:28:20 -04004490static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004491{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004492 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004493
Vivien Didelotfad09c72016-06-21 12:28:20 -04004494 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4495 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004496 return NULL;
4497
Vivien Didelotfad09c72016-06-21 12:28:20 -04004498 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004499
Vivien Didelotfad09c72016-06-21 12:28:20 -04004500 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004501 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004502
Vivien Didelotfad09c72016-06-21 12:28:20 -04004503 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004504}
4505
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004506static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4507 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004508{
Vivien Didelot04bed142016-08-31 18:06:13 -04004509 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004510
Andrew Lunn443d5a12016-12-03 04:35:18 +01004511 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004512}
4513
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004514static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004515 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004516{
4517 /* We don't need any dynamic resource from the kernel (yet),
4518 * so skip the prepare phase.
4519 */
4520
4521 return 0;
4522}
4523
4524static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004525 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004526{
Vivien Didelot04bed142016-08-31 18:06:13 -04004527 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004528
4529 mutex_lock(&chip->reg_lock);
4530 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004531 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004532 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4533 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004534 mutex_unlock(&chip->reg_lock);
4535}
4536
4537static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4538 const struct switchdev_obj_port_mdb *mdb)
4539{
Vivien Didelot04bed142016-08-31 18:06:13 -04004540 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004541 int err;
4542
4543 mutex_lock(&chip->reg_lock);
4544 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004545 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004546 mutex_unlock(&chip->reg_lock);
4547
4548 return err;
4549}
4550
Russell King4f859012019-02-20 15:35:05 -08004551static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4552 bool unicast, bool multicast)
4553{
4554 struct mv88e6xxx_chip *chip = ds->priv;
4555 int err = -EOPNOTSUPP;
4556
4557 mutex_lock(&chip->reg_lock);
4558 if (chip->info->ops->port_set_egress_floods)
4559 err = chip->info->ops->port_set_egress_floods(chip, port,
4560 unicast,
4561 multicast);
4562 mutex_unlock(&chip->reg_lock);
4563
4564 return err;
4565}
4566
Florian Fainellia82f67a2017-01-08 14:52:08 -08004567static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004568 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004569 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004570 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004571 .phylink_validate = mv88e6xxx_validate,
4572 .phylink_mac_link_state = mv88e6xxx_link_state,
4573 .phylink_mac_config = mv88e6xxx_mac_config,
4574 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4575 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576 .get_strings = mv88e6xxx_get_strings,
4577 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4578 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004579 .port_enable = mv88e6xxx_port_enable,
4580 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004581 .get_mac_eee = mv88e6xxx_get_mac_eee,
4582 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004583 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 .get_eeprom = mv88e6xxx_get_eeprom,
4585 .set_eeprom = mv88e6xxx_set_eeprom,
4586 .get_regs_len = mv88e6xxx_get_regs_len,
4587 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004588 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004589 .port_bridge_join = mv88e6xxx_port_bridge_join,
4590 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004591 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004592 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004593 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004594 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4595 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4596 .port_vlan_add = mv88e6xxx_port_vlan_add,
4597 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004598 .port_fdb_add = mv88e6xxx_port_fdb_add,
4599 .port_fdb_del = mv88e6xxx_port_fdb_del,
4600 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004601 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4602 .port_mdb_add = mv88e6xxx_port_mdb_add,
4603 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004604 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4605 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004606 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4607 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4608 .port_txtstamp = mv88e6xxx_port_txtstamp,
4609 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4610 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004611};
4612
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004613static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004614{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004615 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004616 struct dsa_switch *ds;
4617
Vivien Didelot73b12042017-03-30 17:37:10 -04004618 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004619 if (!ds)
4620 return -ENOMEM;
4621
Vivien Didelotfad09c72016-06-21 12:28:20 -04004622 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004623 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004624 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004625 ds->ageing_time_min = chip->info->age_time_coeff;
4626 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004627
4628 dev_set_drvdata(dev, ds);
4629
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004630 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004631}
4632
Vivien Didelotfad09c72016-06-21 12:28:20 -04004633static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004634{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004635 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004636}
4637
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004638static const void *pdata_device_get_match_data(struct device *dev)
4639{
4640 const struct of_device_id *matches = dev->driver->of_match_table;
4641 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4642
4643 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4644 matches++) {
4645 if (!strcmp(pdata->compatible, matches->compatible))
4646 return matches->data;
4647 }
4648 return NULL;
4649}
4650
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004651/* There is no suspend to RAM support at DSA level yet, the switch configuration
4652 * would be lost after a power cycle so prevent it to be suspended.
4653 */
4654static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4655{
4656 return -EOPNOTSUPP;
4657}
4658
4659static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4660{
4661 return 0;
4662}
4663
4664static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4665
Vivien Didelot57d32312016-06-20 13:13:58 -04004666static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004667{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004668 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004669 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004670 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004671 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004672 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004673 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004674 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004675
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004676 if (!np && !pdata)
4677 return -EINVAL;
4678
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004679 if (np)
4680 compat_info = of_device_get_match_data(dev);
4681
4682 if (pdata) {
4683 compat_info = pdata_device_get_match_data(dev);
4684
4685 if (!pdata->netdev)
4686 return -EINVAL;
4687
4688 for (port = 0; port < DSA_MAX_PORTS; port++) {
4689 if (!(pdata->enabled_ports & (1 << port)))
4690 continue;
4691 if (strcmp(pdata->cd.port_names[port], "cpu"))
4692 continue;
4693 pdata->cd.netdev[port] = &pdata->netdev->dev;
4694 break;
4695 }
4696 }
4697
Vivien Didelotcaac8542016-06-20 13:14:09 -04004698 if (!compat_info)
4699 return -EINVAL;
4700
Vivien Didelotfad09c72016-06-21 12:28:20 -04004701 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004702 if (!chip) {
4703 err = -ENOMEM;
4704 goto out;
4705 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004706
Vivien Didelotfad09c72016-06-21 12:28:20 -04004707 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004708
Vivien Didelotfad09c72016-06-21 12:28:20 -04004709 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004710 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004711 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004712
Andrew Lunnb4308f02016-11-21 23:26:55 +01004713 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004714 if (IS_ERR(chip->reset)) {
4715 err = PTR_ERR(chip->reset);
4716 goto out;
4717 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004718
Vivien Didelotfad09c72016-06-21 12:28:20 -04004719 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004720 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004721 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004722
Vivien Didelote57e5e72016-08-15 17:19:00 -04004723 mv88e6xxx_phy_init(chip);
4724
Andrew Lunn00baabe2018-05-19 22:31:35 +02004725 if (chip->info->ops->get_eeprom) {
4726 if (np)
4727 of_property_read_u32(np, "eeprom-length",
4728 &chip->eeprom_len);
4729 else
4730 chip->eeprom_len = pdata->eeprom_len;
4731 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004732
Andrew Lunndc30c352016-10-16 19:56:49 +02004733 mutex_lock(&chip->reg_lock);
4734 err = mv88e6xxx_switch_reset(chip);
4735 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004736 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004737 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004738
Andrew Lunna27415d2019-05-01 00:10:50 +02004739 if (np) {
4740 chip->irq = of_irq_get(np, 0);
4741 if (chip->irq == -EPROBE_DEFER) {
4742 err = chip->irq;
4743 goto out;
4744 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004745 }
4746
Andrew Lunna27415d2019-05-01 00:10:50 +02004747 if (pdata)
4748 chip->irq = pdata->irq;
4749
Andrew Lunn294d7112018-02-22 22:58:32 +01004750 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004751 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004752 * controllers
4753 */
4754 mutex_lock(&chip->reg_lock);
4755 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004756 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004757 else
4758 err = mv88e6xxx_irq_poll_setup(chip);
4759 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004760
Andrew Lunn294d7112018-02-22 22:58:32 +01004761 if (err)
4762 goto out;
4763
4764 if (chip->info->g2_irqs > 0) {
4765 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004766 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004767 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004768 }
4769
Andrew Lunn294d7112018-02-22 22:58:32 +01004770 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4771 if (err)
4772 goto out_g2_irq;
4773
4774 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4775 if (err)
4776 goto out_g1_atu_prob_irq;
4777
Andrew Lunna3c53be52017-01-24 14:53:50 +01004778 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004779 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004780 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004781
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004782 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004783 if (err)
4784 goto out_mdio;
4785
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004786 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004787
4788out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004789 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004790out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004791 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004792out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004793 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004794out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004795 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004796 mv88e6xxx_g2_irq_free(chip);
4797out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004798 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004799 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004800 else
4801 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004802out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004803 if (pdata)
4804 dev_put(pdata->netdev);
4805
Andrew Lunndc30c352016-10-16 19:56:49 +02004806 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004807}
4808
4809static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4810{
4811 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004812 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004813
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004814 if (chip->info->ptp_support) {
4815 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004816 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004817 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004818
Andrew Lunn930188c2016-08-22 16:01:03 +02004819 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004820 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004821 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004822
Andrew Lunn76f38f12018-03-17 20:21:09 +01004823 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4824 mv88e6xxx_g1_atu_prob_irq_free(chip);
4825
4826 if (chip->info->g2_irqs > 0)
4827 mv88e6xxx_g2_irq_free(chip);
4828
Andrew Lunn76f38f12018-03-17 20:21:09 +01004829 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004830 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004831 else
4832 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004833}
4834
4835static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004836 {
4837 .compatible = "marvell,mv88e6085",
4838 .data = &mv88e6xxx_table[MV88E6085],
4839 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004840 {
4841 .compatible = "marvell,mv88e6190",
4842 .data = &mv88e6xxx_table[MV88E6190],
4843 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004844 { /* sentinel */ },
4845};
4846
4847MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4848
4849static struct mdio_driver mv88e6xxx_driver = {
4850 .probe = mv88e6xxx_probe,
4851 .remove = mv88e6xxx_remove,
4852 .mdiodrv.driver = {
4853 .name = "mv88e6085",
4854 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004855 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004856 },
4857};
4858
Andrew Lunn7324d502019-04-27 19:19:10 +02004859mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004860
4861MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4862MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4863MODULE_LICENSE("GPL");