blob: d8bb5e5e8583101ce982efc4160226847dd64fe1 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Andrew Lunn9dd43aa2020-09-18 21:11:05 +020035#include "devlink.h"
Vivien Didelota935c052016-09-29 12:21:53 -040036#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040037#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010038#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020039#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010040#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010041#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020042#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040043#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000044
Vivien Didelotfad09c72016-06-21 12:28:20 -040045static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040046{
Vivien Didelotfad09c72016-06-21 12:28:20 -040047 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
48 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049 dump_stack();
50 }
51}
52
Vivien Didelotec561272016-09-02 14:45:33 -040053int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040054{
55 int err;
56
Vivien Didelotfad09c72016-06-21 12:28:20 -040057 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040058
Vivien Didelotfad09c72016-06-21 12:28:20 -040059 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040060 if (err)
61 return err;
62
Vivien Didelotfad09c72016-06-21 12:28:20 -040063 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040064 addr, reg, *val);
65
66 return 0;
67}
68
Vivien Didelotec561272016-09-02 14:45:33 -040069int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040070{
71 int err;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074
Vivien Didelotfad09c72016-06-21 12:28:20 -040075 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040076 if (err)
77 return err;
78
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 addr, reg, val);
81
82 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000083}
84
Vivien Didelot683f2242019-08-09 18:47:54 -040085int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
86 u16 mask, u16 val)
87{
88 u16 data;
89 int err;
90 int i;
91
92 /* There's no bus specific operation to wait for a mask */
93 for (i = 0; i < 16; i++) {
94 err = mv88e6xxx_read(chip, addr, reg, &data);
95 if (err)
96 return err;
97
98 if ((data & mask) == val)
99 return 0;
100
101 usleep_range(1000, 2000);
102 }
103
104 dev_err(chip->dev, "Timeout while waiting for switch\n");
105 return -ETIMEDOUT;
106}
107
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400108int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
109 int bit, int val)
110{
111 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
112 val ? BIT(bit) : 0x0000);
113}
114
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200115struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100116{
117 struct mv88e6xxx_mdio_bus *mdio_bus;
118
119 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
120 list);
121 if (!mdio_bus)
122 return NULL;
123
124 return mdio_bus->bus;
125}
126
Andrew Lunndc30c352016-10-16 19:56:49 +0200127static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
128{
129 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
130 unsigned int n = d->hwirq;
131
132 chip->g1_irq.masked |= (1 << n);
133}
134
135static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
136{
137 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
138 unsigned int n = d->hwirq;
139
140 chip->g1_irq.masked &= ~(1 << n);
141}
142
Andrew Lunn294d7112018-02-22 22:58:32 +0100143static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200144{
Andrew Lunndc30c352016-10-16 19:56:49 +0200145 unsigned int nhandled = 0;
146 unsigned int sub_irq;
147 unsigned int n;
148 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500149 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200150 int err;
151
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000152 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400153 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000154 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200155
156 if (err)
157 goto out;
158
John David Anglin7c0db242019-02-11 13:40:21 -0500159 do {
160 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
161 if (reg & (1 << n)) {
162 sub_irq = irq_find_mapping(chip->g1_irq.domain,
163 n);
164 handle_nested_irq(sub_irq);
165 ++nhandled;
166 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200167 }
John David Anglin7c0db242019-02-11 13:40:21 -0500168
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000169 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500170 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
171 if (err)
172 goto unlock;
173 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
174unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000175 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500176 if (err)
177 goto out;
178 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
179 } while (reg & ctl1);
180
Andrew Lunndc30c352016-10-16 19:56:49 +0200181out:
182 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
183}
184
Andrew Lunn294d7112018-02-22 22:58:32 +0100185static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
186{
187 struct mv88e6xxx_chip *chip = dev_id;
188
189 return mv88e6xxx_g1_irq_thread_work(chip);
190}
191
Andrew Lunndc30c352016-10-16 19:56:49 +0200192static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
193{
194 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
195
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000196 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200197}
198
199static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
200{
201 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
202 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
203 u16 reg;
204 int err;
205
Vivien Didelotd77f4322017-06-15 12:14:03 -0400206 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200207 if (err)
208 goto out;
209
210 reg &= ~mask;
211 reg |= (~chip->g1_irq.masked & mask);
212
Vivien Didelotd77f4322017-06-15 12:14:03 -0400213 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200214 if (err)
215 goto out;
216
217out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000218 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200219}
220
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530221static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200222 .name = "mv88e6xxx-g1",
223 .irq_mask = mv88e6xxx_g1_irq_mask,
224 .irq_unmask = mv88e6xxx_g1_irq_unmask,
225 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
226 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
227};
228
229static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
230 unsigned int irq,
231 irq_hw_number_t hwirq)
232{
233 struct mv88e6xxx_chip *chip = d->host_data;
234
235 irq_set_chip_data(irq, d->host_data);
236 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
237 irq_set_noprobe(irq);
238
239 return 0;
240}
241
242static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
243 .map = mv88e6xxx_g1_irq_domain_map,
244 .xlate = irq_domain_xlate_twocell,
245};
246
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200247/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100248static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200249{
250 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100251 u16 mask;
252
Vivien Didelotd77f4322017-06-15 12:14:03 -0400253 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100254 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400255 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100256
Andreas Färber5edef2f2016-11-27 23:26:28 +0100257 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100258 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200259 irq_dispose_mapping(virq);
260 }
261
Andrew Lunna3db3d32016-11-20 20:14:14 +0100262 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200263}
264
Andrew Lunn294d7112018-02-22 22:58:32 +0100265static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
266{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200267 /*
268 * free_irq must be called without reg_lock taken because the irq
269 * handler takes this lock, too.
270 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100271 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200272
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000273 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200274 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000275 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100276}
277
278static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200279{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100280 int err, irq, virq;
281 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200282
283 chip->g1_irq.nirqs = chip->info->g1_irqs;
284 chip->g1_irq.domain = irq_domain_add_simple(
285 NULL, chip->g1_irq.nirqs, 0,
286 &mv88e6xxx_g1_irq_domain_ops, chip);
287 if (!chip->g1_irq.domain)
288 return -ENOMEM;
289
290 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
291 irq_create_mapping(chip->g1_irq.domain, irq);
292
293 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
294 chip->g1_irq.masked = ~0;
295
Vivien Didelotd77f4322017-06-15 12:14:03 -0400296 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200297 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100298 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200299
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100300 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200301
Vivien Didelotd77f4322017-06-15 12:14:03 -0400302 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200303 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100304 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200305
306 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400307 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200308 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100309 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200310
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 return 0;
312
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100313out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100314 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400315 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100316
317out_mapping:
318 for (irq = 0; irq < 16; irq++) {
319 virq = irq_find_mapping(chip->g1_irq.domain, irq);
320 irq_dispose_mapping(virq);
321 }
322
323 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200324
325 return err;
326}
327
Andrew Lunn294d7112018-02-22 22:58:32 +0100328static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
329{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100330 static struct lock_class_key lock_key;
331 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100332 int err;
333
334 err = mv88e6xxx_g1_irq_setup_common(chip);
335 if (err)
336 return err;
337
Andrew Lunnf6d97582019-02-23 17:43:56 +0100338 /* These lock classes tells lockdep that global 1 irqs are in
339 * a different category than their parent GPIO, so it won't
340 * report false recursion.
341 */
342 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
343
Andrew Lunn30953832020-01-06 17:13:48 +0100344 snprintf(chip->irq_name, sizeof(chip->irq_name),
345 "mv88e6xxx-%s", dev_name(chip->dev));
346
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000347 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100348 err = request_threaded_irq(chip->irq, NULL,
349 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200350 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100351 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000352 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100353 if (err)
354 mv88e6xxx_g1_irq_free_common(chip);
355
356 return err;
357}
358
359static void mv88e6xxx_irq_poll(struct kthread_work *work)
360{
361 struct mv88e6xxx_chip *chip = container_of(work,
362 struct mv88e6xxx_chip,
363 irq_poll_work.work);
364 mv88e6xxx_g1_irq_thread_work(chip);
365
366 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
367 msecs_to_jiffies(100));
368}
369
370static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
371{
372 int err;
373
374 err = mv88e6xxx_g1_irq_setup_common(chip);
375 if (err)
376 return err;
377
378 kthread_init_delayed_work(&chip->irq_poll_work,
379 mv88e6xxx_irq_poll);
380
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800381 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100382 if (IS_ERR(chip->kworker))
383 return PTR_ERR(chip->kworker);
384
385 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
386 msecs_to_jiffies(100));
387
388 return 0;
389}
390
391static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
392{
393 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
394 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200395
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000396 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200397 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000398 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100399}
400
Russell King64d47d52020-03-14 10:15:38 +0000401static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
402 int port, phy_interface_t interface)
403{
404 int err;
405
406 if (chip->info->ops->port_set_rgmii_delay) {
407 err = chip->info->ops->port_set_rgmii_delay(chip, port,
408 interface);
409 if (err && err != -EOPNOTSUPP)
410 return err;
411 }
412
413 if (chip->info->ops->port_set_cmode) {
414 err = chip->info->ops->port_set_cmode(chip, port,
415 interface);
416 if (err && err != -EOPNOTSUPP)
417 return err;
418 }
419
420 return 0;
421}
422
Russell Kinga5a68582020-03-14 10:15:43 +0000423static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
424 int link, int speed, int duplex, int pause,
425 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100426{
427 int err;
428
429 if (!chip->info->ops->port_set_link)
430 return 0;
431
432 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200433 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100434 if (err)
435 return err;
436
Russell Kingf365c6f2020-03-14 10:15:53 +0000437 if (chip->info->ops->port_set_speed_duplex) {
438 err = chip->info->ops->port_set_speed_duplex(chip, port,
439 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100440 if (err && err != -EOPNOTSUPP)
441 goto restore_link;
442 }
443
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100444 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
445 mode = chip->info->ops->port_max_speed_mode(port);
446
Andrew Lunn54186b92018-08-09 15:38:37 +0200447 if (chip->info->ops->port_set_pause) {
448 err = chip->info->ops->port_set_pause(chip, port, pause);
449 if (err)
450 goto restore_link;
451 }
452
Russell King64d47d52020-03-14 10:15:38 +0000453 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100454restore_link:
455 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400456 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100457
458 return err;
459}
460
Marek Vasutd700ec42018-09-12 00:15:24 +0200461static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
462{
463 struct mv88e6xxx_chip *chip = ds->priv;
464
465 return port < chip->info->num_internal_phys;
466}
467
Russell King5d5b2312020-03-14 10:16:03 +0000468static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
469{
470 u16 reg;
471 int err;
472
473 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
474 if (err) {
475 dev_err(chip->dev,
476 "p%d: %s: failed to read port status\n",
477 port, __func__);
478 return err;
479 }
480
481 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
482}
483
Russell Kinga5a68582020-03-14 10:15:43 +0000484static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
485 struct phylink_link_state *state)
486{
487 struct mv88e6xxx_chip *chip = ds->priv;
488 u8 lane;
489 int err;
490
491 mv88e6xxx_reg_lock(chip);
492 lane = mv88e6xxx_serdes_get_lane(chip, port);
493 if (lane && chip->info->ops->serdes_pcs_get_state)
494 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
495 state);
496 else
497 err = -EOPNOTSUPP;
498 mv88e6xxx_reg_unlock(chip);
499
500 return err;
501}
502
503static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
504 unsigned int mode,
505 phy_interface_t interface,
506 const unsigned long *advertise)
507{
508 const struct mv88e6xxx_ops *ops = chip->info->ops;
509 u8 lane;
510
511 if (ops->serdes_pcs_config) {
512 lane = mv88e6xxx_serdes_get_lane(chip, port);
513 if (lane)
514 return ops->serdes_pcs_config(chip, port, lane, mode,
515 interface, advertise);
516 }
517
518 return 0;
519}
520
521static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
522{
523 struct mv88e6xxx_chip *chip = ds->priv;
524 const struct mv88e6xxx_ops *ops;
525 int err = 0;
526 u8 lane;
527
528 ops = chip->info->ops;
529
530 if (ops->serdes_pcs_an_restart) {
531 mv88e6xxx_reg_lock(chip);
532 lane = mv88e6xxx_serdes_get_lane(chip, port);
533 if (lane)
534 err = ops->serdes_pcs_an_restart(chip, port, lane);
535 mv88e6xxx_reg_unlock(chip);
536
537 if (err)
538 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
539 }
540}
541
542static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
543 unsigned int mode,
544 int speed, int duplex)
545{
546 const struct mv88e6xxx_ops *ops = chip->info->ops;
547 u8 lane;
548
549 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
550 lane = mv88e6xxx_serdes_get_lane(chip, port);
551 if (lane)
552 return ops->serdes_pcs_link_up(chip, port, lane,
553 speed, duplex);
554 }
555
556 return 0;
557}
558
Russell King6c422e32018-08-09 15:38:39 +0200559static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
560 unsigned long *mask,
561 struct phylink_link_state *state)
562{
563 if (!phy_interface_mode_is_8023z(state->interface)) {
564 /* 10M and 100M are only supported in non-802.3z mode */
565 phylink_set(mask, 10baseT_Half);
566 phylink_set(mask, 10baseT_Full);
567 phylink_set(mask, 100baseT_Half);
568 phylink_set(mask, 100baseT_Full);
569 }
570}
571
572static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
573 unsigned long *mask,
574 struct phylink_link_state *state)
575{
576 /* FIXME: if the port is in 1000Base-X mode, then it only supports
577 * 1000M FD speeds. In this case, CMODE will indicate 5.
578 */
579 phylink_set(mask, 1000baseT_Full);
580 phylink_set(mask, 1000baseX_Full);
581
582 mv88e6065_phylink_validate(chip, port, mask, state);
583}
584
Marek Behúne3af71a2019-02-25 12:39:55 +0100585static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
586 unsigned long *mask,
587 struct phylink_link_state *state)
588{
589 if (port >= 5)
590 phylink_set(mask, 2500baseX_Full);
591
592 /* No ethtool bits for 200Mbps */
593 phylink_set(mask, 1000baseT_Full);
594 phylink_set(mask, 1000baseX_Full);
595
596 mv88e6065_phylink_validate(chip, port, mask, state);
597}
598
Russell King6c422e32018-08-09 15:38:39 +0200599static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
600 unsigned long *mask,
601 struct phylink_link_state *state)
602{
603 /* No ethtool bits for 200Mbps */
604 phylink_set(mask, 1000baseT_Full);
605 phylink_set(mask, 1000baseX_Full);
606
607 mv88e6065_phylink_validate(chip, port, mask, state);
608}
609
610static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
611 unsigned long *mask,
612 struct phylink_link_state *state)
613{
Andrew Lunnec260162019-02-08 22:25:44 +0100614 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200615 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100616 phylink_set(mask, 2500baseT_Full);
617 }
Russell King6c422e32018-08-09 15:38:39 +0200618
619 /* No ethtool bits for 200Mbps */
620 phylink_set(mask, 1000baseT_Full);
621 phylink_set(mask, 1000baseX_Full);
622
623 mv88e6065_phylink_validate(chip, port, mask, state);
624}
625
626static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
627 unsigned long *mask,
628 struct phylink_link_state *state)
629{
630 if (port >= 9) {
631 phylink_set(mask, 10000baseT_Full);
632 phylink_set(mask, 10000baseKR_Full);
633 }
634
635 mv88e6390_phylink_validate(chip, port, mask, state);
636}
637
Russell Kingc9a23562018-05-10 13:17:35 -0700638static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
639 unsigned long *supported,
640 struct phylink_link_state *state)
641{
Russell King6c422e32018-08-09 15:38:39 +0200642 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
643 struct mv88e6xxx_chip *chip = ds->priv;
644
645 /* Allow all the expected bits */
646 phylink_set(mask, Autoneg);
647 phylink_set(mask, Pause);
648 phylink_set_port_modes(mask);
649
650 if (chip->info->ops->phylink_validate)
651 chip->info->ops->phylink_validate(chip, port, mask, state);
652
653 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
654 bitmap_and(state->advertising, state->advertising, mask,
655 __ETHTOOL_LINK_MODE_MASK_NBITS);
656
657 /* We can only operate at 2500BaseX or 1000BaseX. If requested
658 * to advertise both, only report advertising at 2500BaseX.
659 */
660 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700661}
662
Russell Kingc9a23562018-05-10 13:17:35 -0700663static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
664 unsigned int mode,
665 const struct phylink_link_state *state)
666{
667 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100668 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000669 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700670
Russell Kingfad58192020-07-19 12:00:35 +0100671 p = &chip->ports[port];
672
Russell King64d47d52020-03-14 10:15:38 +0000673 /* FIXME: is this the correct test? If we're in fixed mode on an
674 * internal port, why should we process this any different from
675 * PHY mode? On the other hand, the port may be automedia between
676 * an internal PHY and the serdes...
677 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200678 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700679 return;
680
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000681 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100682 /* In inband mode, the link may come up at any time while the link
683 * is not forced down. Force the link down while we reconfigure the
684 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000685 */
Russell Kingfad58192020-07-19 12:00:35 +0100686 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
687 chip->info->ops->port_set_link)
688 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
689
Russell King64d47d52020-03-14 10:15:38 +0000690 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000691 if (err && err != -EOPNOTSUPP)
692 goto err_unlock;
693
694 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
695 state->advertising);
696 /* FIXME: we should restart negotiation if something changed - which
697 * is something we get if we convert to using phylinks PCS operations.
698 */
699 if (err > 0)
700 err = 0;
701
Russell Kingfad58192020-07-19 12:00:35 +0100702 /* Undo the forced down state above after completing configuration
703 * irrespective of its state on entry, which allows the link to come up.
704 */
705 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
706 chip->info->ops->port_set_link)
707 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
708
709 p->interface = state->interface;
710
Russell Kinga5a68582020-03-14 10:15:43 +0000711err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000712 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700713
714 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000715 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700716}
717
Russell Kingc9a23562018-05-10 13:17:35 -0700718static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
719 unsigned int mode,
720 phy_interface_t interface)
721{
Russell King30c4a5b2020-02-26 10:23:51 +0000722 struct mv88e6xxx_chip *chip = ds->priv;
723 const struct mv88e6xxx_ops *ops;
724 int err = 0;
725
726 ops = chip->info->ops;
727
Russell King5d5b2312020-03-14 10:16:03 +0000728 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200729 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
730 mode == MLO_AN_FIXED) && ops->port_set_link)
Russell King30c4a5b2020-02-26 10:23:51 +0000731 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Russell King5d5b2312020-03-14 10:16:03 +0000732 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000733
Russell King5d5b2312020-03-14 10:16:03 +0000734 if (err)
735 dev_err(chip->dev,
736 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700737}
738
739static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
740 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000741 struct phy_device *phydev,
742 int speed, int duplex,
743 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700744{
Russell King30c4a5b2020-02-26 10:23:51 +0000745 struct mv88e6xxx_chip *chip = ds->priv;
746 const struct mv88e6xxx_ops *ops;
747 int err = 0;
748
749 ops = chip->info->ops;
750
Russell King5d5b2312020-03-14 10:16:03 +0000751 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200752 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000753 /* FIXME: for an automedia port, should we force the link
754 * down here - what if the link comes up due to "other" media
755 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000756 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000757 * shared between internal PHY and Serdes.
758 */
Russell Kinga5a68582020-03-14 10:15:43 +0000759 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
760 duplex);
761 if (err)
762 goto error;
763
Russell Kingf365c6f2020-03-14 10:15:53 +0000764 if (ops->port_set_speed_duplex) {
765 err = ops->port_set_speed_duplex(chip, port,
766 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000767 if (err && err != -EOPNOTSUPP)
768 goto error;
769 }
770
771 if (ops->port_set_link)
772 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
Russell King30c4a5b2020-02-26 10:23:51 +0000773 }
Russell King5d5b2312020-03-14 10:16:03 +0000774error:
775 mv88e6xxx_reg_unlock(chip);
776
777 if (err && err != -EOPNOTSUPP)
778 dev_err(ds->dev,
779 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700780}
781
Andrew Lunna605a0f2016-11-21 23:26:58 +0100782static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000783{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100784 if (!chip->info->ops->stats_snapshot)
785 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000786
Andrew Lunna605a0f2016-11-21 23:26:58 +0100787 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000788}
789
Andrew Lunne413e7e2015-04-02 04:06:38 +0200790static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100791 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
792 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
793 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
794 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
795 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
796 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
797 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
798 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
799 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
800 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
801 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
802 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
803 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
804 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
805 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
806 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
807 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
808 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
809 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
810 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
811 { "single", 4, 0x14, STATS_TYPE_BANK0, },
812 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
813 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
814 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
815 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
816 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
817 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
818 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
819 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
820 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
821 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
822 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
823 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
824 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
825 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
826 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
827 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
828 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
829 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
830 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
831 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
832 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
833 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
834 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
835 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
836 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
837 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
838 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
839 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
840 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
841 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
842 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
843 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
844 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
845 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
846 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
847 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
848 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
849 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200850};
851
Vivien Didelotfad09c72016-06-21 12:28:20 -0400852static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100853 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100854 int port, u16 bank1_select,
855 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200856{
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 u32 low;
858 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200860 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200861 u64 value;
862
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100863 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200868
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200869 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100870 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200871 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
872 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800873 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000874 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200875 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100876 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100877 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100878 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500879 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100880 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100881 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100882 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100883 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100884 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500885 break;
886 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800887 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200888 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100889 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200890 return value;
891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100895{
896 struct mv88e6xxx_hw_stat *stat;
897 int i, j;
898
899 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
900 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100901 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100902 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
903 ETH_GSTRING_LEN);
904 j++;
905 }
906 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100907
908 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100909}
910
Andrew Lunn436fe172018-03-01 02:02:29 +0100911static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
912 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100913{
Andrew Lunn436fe172018-03-01 02:02:29 +0100914 return mv88e6xxx_stats_get_strings(chip, data,
915 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000918static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
919 uint8_t *data)
920{
921 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
922}
923
Andrew Lunn436fe172018-03-01 02:02:29 +0100924static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
925 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100926{
Andrew Lunn436fe172018-03-01 02:02:29 +0100927 return mv88e6xxx_stats_get_strings(chip, data,
928 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100929}
930
Andrew Lunn65f60e42018-03-28 23:50:28 +0200931static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
932 "atu_member_violation",
933 "atu_miss_violation",
934 "atu_full_violation",
935 "vtu_member_violation",
936 "vtu_miss_violation",
937};
938
939static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
940{
941 unsigned int i;
942
943 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
944 strlcpy(data + i * ETH_GSTRING_LEN,
945 mv88e6xxx_atu_vtu_stats_strings[i],
946 ETH_GSTRING_LEN);
947}
948
Andrew Lunndfafe442016-11-21 23:27:02 +0100949static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700950 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100951{
Vivien Didelot04bed142016-08-31 18:06:13 -0400952 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100953 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100954
Florian Fainelli89f09042018-04-25 12:12:50 -0700955 if (stringset != ETH_SS_STATS)
956 return;
957
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000958 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959
Andrew Lunndfafe442016-11-21 23:27:02 +0100960 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100961 count = chip->info->ops->stats_get_strings(chip, data);
962
963 if (chip->info->ops->serdes_get_strings) {
964 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200965 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100966 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100967
Andrew Lunn65f60e42018-03-28 23:50:28 +0200968 data += count * ETH_GSTRING_LEN;
969 mv88e6xxx_atu_vtu_get_strings(data);
970
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000971 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100972}
973
974static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
975 int types)
976{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100977 struct mv88e6xxx_hw_stat *stat;
978 int i, j;
979
980 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
981 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100982 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100983 j++;
984 }
985 return j;
986}
987
Andrew Lunndfafe442016-11-21 23:27:02 +0100988static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
989{
990 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
991 STATS_TYPE_PORT);
992}
993
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000994static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
995{
996 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
997}
998
Andrew Lunndfafe442016-11-21 23:27:02 +0100999static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1000{
1001 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1002 STATS_TYPE_BANK1);
1003}
1004
Florian Fainelli89f09042018-04-25 12:12:50 -07001005static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001006{
1007 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001008 int serdes_count = 0;
1009 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001010
Florian Fainelli89f09042018-04-25 12:12:50 -07001011 if (sset != ETH_SS_STATS)
1012 return 0;
1013
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001014 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 count = chip->info->ops->stats_get_sset_count(chip);
1017 if (count < 0)
1018 goto out;
1019
1020 if (chip->info->ops->serdes_get_sset_count)
1021 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1022 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001023 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001024 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001025 goto out;
1026 }
1027 count += serdes_count;
1028 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1029
Andrew Lunn436fe172018-03-01 02:02:29 +01001030out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001031 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001032
Andrew Lunn436fe172018-03-01 02:02:29 +01001033 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001034}
1035
Andrew Lunn436fe172018-03-01 02:02:29 +01001036static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1037 uint64_t *data, int types,
1038 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001039{
1040 struct mv88e6xxx_hw_stat *stat;
1041 int i, j;
1042
1043 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1044 stat = &mv88e6xxx_hw_stats[i];
1045 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001047 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1048 bank1_select,
1049 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001050 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001051
Andrew Lunn052f9472016-11-21 23:27:03 +01001052 j++;
1053 }
1054 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001055 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001062 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001064}
1065
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001066static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1067 uint64_t *data)
1068{
1069 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1070 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1071}
1072
Andrew Lunn436fe172018-03-01 02:02:29 +01001073static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1074 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001075{
1076 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001077 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001078 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1079 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001080}
1081
Andrew Lunn436fe172018-03-01 02:02:29 +01001082static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1083 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001084{
1085 return mv88e6xxx_stats_get_stats(chip, port, data,
1086 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001087 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1088 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001089}
1090
Andrew Lunn65f60e42018-03-28 23:50:28 +02001091static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1092 uint64_t *data)
1093{
1094 *data++ = chip->ports[port].atu_member_violation;
1095 *data++ = chip->ports[port].atu_miss_violation;
1096 *data++ = chip->ports[port].atu_full_violation;
1097 *data++ = chip->ports[port].vtu_member_violation;
1098 *data++ = chip->ports[port].vtu_miss_violation;
1099}
1100
Andrew Lunn052f9472016-11-21 23:27:03 +01001101static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1102 uint64_t *data)
1103{
Andrew Lunn436fe172018-03-01 02:02:29 +01001104 int count = 0;
1105
Andrew Lunn052f9472016-11-21 23:27:03 +01001106 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001107 count = chip->info->ops->stats_get_stats(chip, port, data);
1108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001109 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001110 if (chip->info->ops->serdes_get_stats) {
1111 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001112 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001113 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001114 data += count;
1115 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001116 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001117}
1118
Vivien Didelotf81ec902016-05-09 13:22:58 -04001119static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1120 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001121{
Vivien Didelot04bed142016-08-31 18:06:13 -04001122 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001124
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001125 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001126
Andrew Lunna605a0f2016-11-21 23:26:58 +01001127 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001128 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001129
1130 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001131 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001132
1133 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001134
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001135}
Ben Hutchings98e67302011-11-25 14:36:19 +00001136
Vivien Didelotf81ec902016-05-09 13:22:58 -04001137static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001139 struct mv88e6xxx_chip *chip = ds->priv;
1140 int len;
1141
1142 len = 32 * sizeof(u16);
1143 if (chip->info->ops->serdes_get_regs_len)
1144 len += chip->info->ops->serdes_get_regs_len(chip, port);
1145
1146 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147}
1148
Vivien Didelotf81ec902016-05-09 13:22:58 -04001149static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1150 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151{
Vivien Didelot04bed142016-08-31 18:06:13 -04001152 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001153 int err;
1154 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001155 u16 *p = _p;
1156 int i;
1157
Vivien Didelota5f39322018-12-17 16:05:21 -05001158 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001159
1160 memset(p, 0xff, 32 * sizeof(u16));
1161
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001162 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001163
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001164 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001165
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001166 err = mv88e6xxx_port_read(chip, port, i, &reg);
1167 if (!err)
1168 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001169 }
Vivien Didelot23062512016-05-09 13:22:45 -04001170
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001171 if (chip->info->ops->serdes_get_regs)
1172 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1173
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001174 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001175}
1176
Vivien Didelot08f50062017-08-01 16:32:41 -04001177static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1178 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001179{
Vivien Didelot5480db62017-08-01 16:32:40 -04001180 /* Nothing to do on the port's MAC */
1181 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001182}
1183
Vivien Didelot08f50062017-08-01 16:32:41 -04001184static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1185 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001186{
Vivien Didelot5480db62017-08-01 16:32:40 -04001187 /* Nothing to do on the port's MAC */
1188 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001189}
1190
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001191/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001192static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001193{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001194 struct dsa_switch *ds = chip->ds;
1195 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001196 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001197 struct dsa_port *dp;
1198 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001199 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001200
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001201 list_for_each_entry(dp, &dst->ports, list) {
1202 if (dp->ds->index == dev && dp->index == port) {
1203 found = true;
1204 break;
1205 }
1206 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001207
Vivien Didelote5887a22017-03-30 17:37:11 -04001208 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001209 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001210 return 0;
1211
1212 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001213 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001214 return mv88e6xxx_port_mask(chip);
1215
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001216 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001217 pvlan = 0;
1218
1219 /* Frames from user ports can egress any local DSA links and CPU ports,
1220 * as well as any local member of their bridge group.
1221 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001222 list_for_each_entry(dp, &dst->ports, list)
1223 if (dp->ds == ds &&
1224 (dp->type == DSA_PORT_TYPE_CPU ||
1225 dp->type == DSA_PORT_TYPE_DSA ||
1226 (br && dp->bridge_dev == br)))
1227 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001228
1229 return pvlan;
1230}
1231
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001232static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001233{
1234 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001235
1236 /* prevent frames from going back out of the port they came in on */
1237 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001238
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001239 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001240}
1241
Vivien Didelotf81ec902016-05-09 13:22:58 -04001242static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1243 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001244{
Vivien Didelot04bed142016-08-31 18:06:13 -04001245 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001246 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001247
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001248 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001249 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001250 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001251
1252 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001253 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001254}
1255
Vivien Didelot93e18d62018-05-11 17:16:35 -04001256static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1257{
1258 int err;
1259
1260 if (chip->info->ops->ieee_pri_map) {
1261 err = chip->info->ops->ieee_pri_map(chip);
1262 if (err)
1263 return err;
1264 }
1265
1266 if (chip->info->ops->ip_pri_map) {
1267 err = chip->info->ops->ip_pri_map(chip);
1268 if (err)
1269 return err;
1270 }
1271
1272 return 0;
1273}
1274
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001275static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1276{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001277 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001278 int target, port;
1279 int err;
1280
1281 if (!chip->info->global2_addr)
1282 return 0;
1283
1284 /* Initialize the routing port to the 32 possible target devices */
1285 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001286 port = dsa_routing_port(ds, target);
1287 if (port == ds->num_ports)
1288 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001289
1290 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1291 if (err)
1292 return err;
1293 }
1294
Vivien Didelot02317e62018-05-09 11:38:49 -04001295 if (chip->info->ops->set_cascade_port) {
1296 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1297 err = chip->info->ops->set_cascade_port(chip, port);
1298 if (err)
1299 return err;
1300 }
1301
Vivien Didelot23c98912018-05-09 11:38:50 -04001302 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1303 if (err)
1304 return err;
1305
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001306 return 0;
1307}
1308
Vivien Didelotb28f8722018-04-26 21:56:44 -04001309static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1310{
1311 /* Clear all trunk masks and mapping */
1312 if (chip->info->global2_addr)
1313 return mv88e6xxx_g2_trunk_clear(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001318static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1319{
1320 if (chip->info->ops->rmu_disable)
1321 return chip->info->ops->rmu_disable(chip);
1322
1323 return 0;
1324}
1325
Vivien Didelot9e907d72017-07-17 13:03:43 -04001326static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1327{
1328 if (chip->info->ops->pot_clear)
1329 return chip->info->ops->pot_clear(chip);
1330
1331 return 0;
1332}
1333
Vivien Didelot51c901a2017-07-17 13:03:41 -04001334static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1335{
1336 if (chip->info->ops->mgmt_rsvd2cpu)
1337 return chip->info->ops->mgmt_rsvd2cpu(chip);
1338
1339 return 0;
1340}
1341
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001342static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1343{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001344 int err;
1345
Vivien Didelotdaefc942017-03-11 16:12:54 -05001346 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1347 if (err)
1348 return err;
1349
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001350 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1351 if (err)
1352 return err;
1353
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001354 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1355}
1356
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001357static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1358{
1359 int port;
1360 int err;
1361
1362 if (!chip->info->ops->irl_init_all)
1363 return 0;
1364
1365 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1366 /* Disable ingress rate limiting by resetting all per port
1367 * ingress rate limit resources to their initial state.
1368 */
1369 err = chip->info->ops->irl_init_all(chip, port);
1370 if (err)
1371 return err;
1372 }
1373
1374 return 0;
1375}
1376
Vivien Didelot04a69a12017-10-13 14:18:05 -04001377static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1378{
1379 if (chip->info->ops->set_switch_mac) {
1380 u8 addr[ETH_ALEN];
1381
1382 eth_random_addr(addr);
1383
1384 return chip->info->ops->set_switch_mac(chip, addr);
1385 }
1386
1387 return 0;
1388}
1389
Vivien Didelot17a15942017-03-30 17:37:09 -04001390static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1391{
1392 u16 pvlan = 0;
1393
1394 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001395 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001396
1397 /* Skip the local source device, which uses in-chip port VLAN */
1398 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001399 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001400
1401 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1402}
1403
Vivien Didelot81228992017-03-30 17:37:08 -04001404static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1405{
Vivien Didelot17a15942017-03-30 17:37:09 -04001406 int dev, port;
1407 int err;
1408
Vivien Didelot81228992017-03-30 17:37:08 -04001409 if (!mv88e6xxx_has_pvt(chip))
1410 return 0;
1411
1412 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1413 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1414 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001415 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1416 if (err)
1417 return err;
1418
1419 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1420 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1421 err = mv88e6xxx_pvt_map(chip, dev, port);
1422 if (err)
1423 return err;
1424 }
1425 }
1426
1427 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001428}
1429
Vivien Didelot749efcb2016-09-22 16:49:24 -04001430static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1431{
1432 struct mv88e6xxx_chip *chip = ds->priv;
1433 int err;
1434
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001435 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001436 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001437 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001438
1439 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001440 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001441}
1442
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001443static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1444{
1445 if (!chip->info->max_vid)
1446 return 0;
1447
1448 return mv88e6xxx_g1_vtu_flush(chip);
1449}
1450
Vivien Didelotf1394b782017-05-01 14:05:22 -04001451static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1452 struct mv88e6xxx_vtu_entry *entry)
1453{
1454 if (!chip->info->ops->vtu_getnext)
1455 return -EOPNOTSUPP;
1456
1457 return chip->info->ops->vtu_getnext(chip, entry);
1458}
1459
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001460static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1461 struct mv88e6xxx_vtu_entry *entry)
1462{
1463 if (!chip->info->ops->vtu_loadpurge)
1464 return -EOPNOTSUPP;
1465
1466 return chip->info->ops->vtu_loadpurge(chip, entry);
1467}
1468
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001469int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001470{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001471 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001472 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001473 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001474
1475 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1476
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001477 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001478 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001479 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001480 if (err)
1481 return err;
1482
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001483 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001484 }
1485
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001486 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001487 vlan.vid = chip->info->max_vid;
1488 vlan.valid = false;
1489
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001490 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001491 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001492 if (err)
1493 return err;
1494
1495 if (!vlan.valid)
1496 break;
1497
1498 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001499 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001500
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001501 return 0;
1502}
1503
1504static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1505{
1506 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1507 int err;
1508
1509 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1510 if (err)
1511 return err;
1512
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001513 /* The reset value 0x000 is used to indicate that multiple address
1514 * databases are not needed. Return the next positive available.
1515 */
1516 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001517 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001518 return -ENOSPC;
1519
1520 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001521 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001522}
1523
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1525 u16 vid_begin, u16 vid_end)
1526{
Vivien Didelot04bed142016-08-31 18:06:13 -04001527 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001528 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 int i, err;
1530
Andrew Lunndb06ae412017-09-25 23:32:20 +02001531 /* DSA and CPU ports have to be members of multiple vlans */
1532 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1533 return 0;
1534
Vivien Didelotda9c3592016-02-12 12:09:40 -05001535 if (!vid_begin)
1536 return -EOPNOTSUPP;
1537
Vivien Didelot425d2d32019-08-01 14:36:34 -04001538 vlan.vid = vid_begin - 1;
1539 vlan.valid = false;
1540
Vivien Didelotda9c3592016-02-12 12:09:40 -05001541 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001542 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001543 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001544 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545
1546 if (!vlan.valid)
1547 break;
1548
1549 if (vlan.vid > vid_end)
1550 break;
1551
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001552 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001553 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1554 continue;
1555
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001556 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001557 continue;
1558
Vivien Didelotbd00e052017-05-01 14:05:11 -04001559 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001560 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 continue;
1562
Vivien Didelotc8652c82017-10-16 11:12:19 -04001563 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001564 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565 break; /* same bridge, check next VLAN */
1566
Vivien Didelotc8652c82017-10-16 11:12:19 -04001567 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001568 continue;
1569
Andrew Lunn743fcc22017-11-09 22:29:54 +01001570 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1571 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001572 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001573 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001574 }
1575 } while (vlan.vid < vid_end);
1576
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001577 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001578}
1579
Vivien Didelotf81ec902016-05-09 13:22:58 -04001580static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1581 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582{
Vivien Didelot04bed142016-08-31 18:06:13 -04001583 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001584 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1585 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001586 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001587
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001588 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001589 return -EOPNOTSUPP;
1590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001591 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001592 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001593 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001594
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001595 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001596}
1597
Vivien Didelot57d32312016-06-20 13:13:58 -04001598static int
1599mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001600 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001601{
Vivien Didelot04bed142016-08-31 18:06:13 -04001602 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001603 int err;
1604
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001605 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001606 return -EOPNOTSUPP;
1607
Vivien Didelotda9c3592016-02-12 12:09:40 -05001608 /* If the requested port doesn't belong to the same bridge as the VLAN
1609 * members, do not support it (yet) and fallback to software VLAN.
1610 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001611 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001612 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1613 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001614 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001615
Vivien Didelot76e398a2015-11-01 12:33:55 -05001616 /* We don't need any dynamic resource from the kernel (yet),
1617 * so skip the prepare phase.
1618 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001619 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620}
1621
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001622static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1623 const unsigned char *addr, u16 vid,
1624 u8 state)
1625{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001626 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001627 struct mv88e6xxx_vtu_entry vlan;
1628 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001629 int err;
1630
1631 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001632 if (vid == 0) {
1633 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1634 if (err)
1635 return err;
1636 } else {
1637 vlan.vid = vid - 1;
1638 vlan.valid = false;
1639
1640 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1641 if (err)
1642 return err;
1643
1644 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1645 if (vlan.vid != vid || !vlan.valid)
1646 return -EOPNOTSUPP;
1647
1648 fid = vlan.fid;
1649 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001650
Vivien Didelotd8291a92019-09-07 16:00:47 -04001651 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001652 ether_addr_copy(entry.mac, addr);
1653 eth_addr_dec(entry.mac);
1654
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001655 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001656 if (err)
1657 return err;
1658
1659 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001660 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001661 memset(&entry, 0, sizeof(entry));
1662 ether_addr_copy(entry.mac, addr);
1663 }
1664
1665 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001666 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001667 entry.portvec &= ~BIT(port);
1668 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001669 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001670 } else {
1671 entry.portvec |= BIT(port);
1672 entry.state = state;
1673 }
1674
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001675 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001676}
1677
Vivien Didelotda7dc872019-09-07 16:00:49 -04001678static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1679 const struct mv88e6xxx_policy *policy)
1680{
1681 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1682 enum mv88e6xxx_policy_action action = policy->action;
1683 const u8 *addr = policy->addr;
1684 u16 vid = policy->vid;
1685 u8 state;
1686 int err;
1687 int id;
1688
1689 if (!chip->info->ops->port_set_policy)
1690 return -EOPNOTSUPP;
1691
1692 switch (mapping) {
1693 case MV88E6XXX_POLICY_MAPPING_DA:
1694 case MV88E6XXX_POLICY_MAPPING_SA:
1695 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1696 state = 0; /* Dissociate the port and address */
1697 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1698 is_multicast_ether_addr(addr))
1699 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1700 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1701 is_unicast_ether_addr(addr))
1702 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1703 else
1704 return -EOPNOTSUPP;
1705
1706 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1707 state);
1708 if (err)
1709 return err;
1710 break;
1711 default:
1712 return -EOPNOTSUPP;
1713 }
1714
1715 /* Skip the port's policy clearing if the mapping is still in use */
1716 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1717 idr_for_each_entry(&chip->policies, policy, id)
1718 if (policy->port == port &&
1719 policy->mapping == mapping &&
1720 policy->action != action)
1721 return 0;
1722
1723 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1724}
1725
1726static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1727 struct ethtool_rx_flow_spec *fs)
1728{
1729 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1730 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1731 enum mv88e6xxx_policy_mapping mapping;
1732 enum mv88e6xxx_policy_action action;
1733 struct mv88e6xxx_policy *policy;
1734 u16 vid = 0;
1735 u8 *addr;
1736 int err;
1737 int id;
1738
1739 if (fs->location != RX_CLS_LOC_ANY)
1740 return -EINVAL;
1741
1742 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1743 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1744 else
1745 return -EOPNOTSUPP;
1746
1747 switch (fs->flow_type & ~FLOW_EXT) {
1748 case ETHER_FLOW:
1749 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1750 is_zero_ether_addr(mac_mask->h_source)) {
1751 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1752 addr = mac_entry->h_dest;
1753 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1754 !is_zero_ether_addr(mac_mask->h_source)) {
1755 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1756 addr = mac_entry->h_source;
1757 } else {
1758 /* Cannot support DA and SA mapping in the same rule */
1759 return -EOPNOTSUPP;
1760 }
1761 break;
1762 default:
1763 return -EOPNOTSUPP;
1764 }
1765
1766 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001767 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001768 return -EOPNOTSUPP;
1769 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1770 }
1771
1772 idr_for_each_entry(&chip->policies, policy, id) {
1773 if (policy->port == port && policy->mapping == mapping &&
1774 policy->action == action && policy->vid == vid &&
1775 ether_addr_equal(policy->addr, addr))
1776 return -EEXIST;
1777 }
1778
1779 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1780 if (!policy)
1781 return -ENOMEM;
1782
1783 fs->location = 0;
1784 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1785 GFP_KERNEL);
1786 if (err) {
1787 devm_kfree(chip->dev, policy);
1788 return err;
1789 }
1790
1791 memcpy(&policy->fs, fs, sizeof(*fs));
1792 ether_addr_copy(policy->addr, addr);
1793 policy->mapping = mapping;
1794 policy->action = action;
1795 policy->port = port;
1796 policy->vid = vid;
1797
1798 err = mv88e6xxx_policy_apply(chip, port, policy);
1799 if (err) {
1800 idr_remove(&chip->policies, fs->location);
1801 devm_kfree(chip->dev, policy);
1802 return err;
1803 }
1804
1805 return 0;
1806}
1807
1808static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1809 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1810{
1811 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1812 struct mv88e6xxx_chip *chip = ds->priv;
1813 struct mv88e6xxx_policy *policy;
1814 int err;
1815 int id;
1816
1817 mv88e6xxx_reg_lock(chip);
1818
1819 switch (rxnfc->cmd) {
1820 case ETHTOOL_GRXCLSRLCNT:
1821 rxnfc->data = 0;
1822 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1823 rxnfc->rule_cnt = 0;
1824 idr_for_each_entry(&chip->policies, policy, id)
1825 if (policy->port == port)
1826 rxnfc->rule_cnt++;
1827 err = 0;
1828 break;
1829 case ETHTOOL_GRXCLSRULE:
1830 err = -ENOENT;
1831 policy = idr_find(&chip->policies, fs->location);
1832 if (policy) {
1833 memcpy(fs, &policy->fs, sizeof(*fs));
1834 err = 0;
1835 }
1836 break;
1837 case ETHTOOL_GRXCLSRLALL:
1838 rxnfc->data = 0;
1839 rxnfc->rule_cnt = 0;
1840 idr_for_each_entry(&chip->policies, policy, id)
1841 if (policy->port == port)
1842 rule_locs[rxnfc->rule_cnt++] = id;
1843 err = 0;
1844 break;
1845 default:
1846 err = -EOPNOTSUPP;
1847 break;
1848 }
1849
1850 mv88e6xxx_reg_unlock(chip);
1851
1852 return err;
1853}
1854
1855static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1856 struct ethtool_rxnfc *rxnfc)
1857{
1858 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1859 struct mv88e6xxx_chip *chip = ds->priv;
1860 struct mv88e6xxx_policy *policy;
1861 int err;
1862
1863 mv88e6xxx_reg_lock(chip);
1864
1865 switch (rxnfc->cmd) {
1866 case ETHTOOL_SRXCLSRLINS:
1867 err = mv88e6xxx_policy_insert(chip, port, fs);
1868 break;
1869 case ETHTOOL_SRXCLSRLDEL:
1870 err = -ENOENT;
1871 policy = idr_remove(&chip->policies, fs->location);
1872 if (policy) {
1873 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1874 err = mv88e6xxx_policy_apply(chip, port, policy);
1875 devm_kfree(chip->dev, policy);
1876 }
1877 break;
1878 default:
1879 err = -EOPNOTSUPP;
1880 break;
1881 }
1882
1883 mv88e6xxx_reg_unlock(chip);
1884
1885 return err;
1886}
1887
Andrew Lunn87fa8862017-11-09 22:29:56 +01001888static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1889 u16 vid)
1890{
1891 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1892 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1893
1894 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1895}
1896
1897static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1898{
1899 int port;
1900 int err;
1901
1902 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1903 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1904 if (err)
1905 return err;
1906 }
1907
1908 return 0;
1909}
1910
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001911static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001912 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001913{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001914 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001915 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001916 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001917
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001918 if (!vid)
1919 return -EOPNOTSUPP;
1920
1921 vlan.vid = vid - 1;
1922 vlan.valid = false;
1923
1924 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001925 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001926 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001927
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001928 if (vlan.vid != vid || !vlan.valid) {
1929 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001930
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001931 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1932 if (err)
1933 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001934
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001935 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1936 if (i == port)
1937 vlan.member[i] = member;
1938 else
1939 vlan.member[i] = non_member;
1940
1941 vlan.vid = vid;
1942 vlan.valid = true;
1943
1944 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1945 if (err)
1946 return err;
1947
1948 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1949 if (err)
1950 return err;
1951 } else if (vlan.member[port] != member) {
1952 vlan.member[port] = member;
1953
1954 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1955 if (err)
1956 return err;
Russell King933b4422020-02-26 17:14:26 +00001957 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001958 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1959 port, vid);
1960 }
1961
1962 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001963}
1964
Vivien Didelotf81ec902016-05-09 13:22:58 -04001965static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001966 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001967{
Vivien Didelot04bed142016-08-31 18:06:13 -04001968 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001969 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1970 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001971 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001972 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001973 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001974
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001975 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001976 return;
1977
Vivien Didelotc91498e2017-06-07 18:12:13 -04001978 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001979 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001980 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001981 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001982 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001983 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001984
Russell King933b4422020-02-26 17:14:26 +00001985 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1986 * and then the CPU port. Do not warn for duplicates for the CPU port.
1987 */
1988 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1989
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001990 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001991
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001992 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001993 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001994 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1995 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001996
Vivien Didelot77064f32016-11-04 03:23:30 +01001997 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001998 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1999 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002000
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002001 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002002}
2003
Vivien Didelot521098922019-08-01 14:36:36 -04002004static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2005 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002006{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002007 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002008 int i, err;
2009
Vivien Didelot521098922019-08-01 14:36:36 -04002010 if (!vid)
2011 return -EOPNOTSUPP;
2012
2013 vlan.vid = vid - 1;
2014 vlan.valid = false;
2015
2016 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002017 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002018 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002019
Vivien Didelot521098922019-08-01 14:36:36 -04002020 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2021 * tell switchdev that this VLAN is likely handled in software.
2022 */
2023 if (vlan.vid != vid || !vlan.valid ||
2024 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002025 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002026
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002027 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002028
2029 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002030 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002031 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002032 if (vlan.member[i] !=
2033 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002034 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002035 break;
2036 }
2037 }
2038
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002039 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002040 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002041 return err;
2042
Vivien Didelote606ca32017-03-11 16:12:55 -05002043 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002044}
2045
Vivien Didelotf81ec902016-05-09 13:22:58 -04002046static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2047 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002048{
Vivien Didelot04bed142016-08-31 18:06:13 -04002049 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002050 u16 pvid, vid;
2051 int err = 0;
2052
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002053 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002054 return -EOPNOTSUPP;
2055
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002056 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002057
Vivien Didelot77064f32016-11-04 03:23:30 +01002058 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002059 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002060 goto unlock;
2061
Vivien Didelot76e398a2015-11-01 12:33:55 -05002062 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002063 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002064 if (err)
2065 goto unlock;
2066
2067 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002068 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002069 if (err)
2070 goto unlock;
2071 }
2072 }
2073
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002074unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002075 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002076
2077 return err;
2078}
2079
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002080static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2081 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002082{
Vivien Didelot04bed142016-08-31 18:06:13 -04002083 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002084 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002085
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002086 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002087 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2088 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002089 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002090
2091 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002092}
2093
Vivien Didelotf81ec902016-05-09 13:22:58 -04002094static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002095 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002096{
Vivien Didelot04bed142016-08-31 18:06:13 -04002097 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002098 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002099
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002100 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002101 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002102 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002103
Vivien Didelot83dabd12016-08-31 11:50:04 -04002104 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002105}
2106
Vivien Didelot83dabd12016-08-31 11:50:04 -04002107static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2108 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002109 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002110{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002111 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002112 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002113 int err;
2114
Vivien Didelotd8291a92019-09-07 16:00:47 -04002115 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002116 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002117
2118 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002119 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002120 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002121 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002122
Vivien Didelotd8291a92019-09-07 16:00:47 -04002123 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002124 break;
2125
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002126 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002127 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002128
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002129 if (!is_unicast_ether_addr(addr.mac))
2130 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002131
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002132 is_static = (addr.state ==
2133 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2134 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002135 if (err)
2136 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002137 } while (!is_broadcast_ether_addr(addr.mac));
2138
2139 return err;
2140}
2141
Vivien Didelot83dabd12016-08-31 11:50:04 -04002142static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002143 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002144{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002145 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002146 u16 fid;
2147 int err;
2148
2149 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002150 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002151 if (err)
2152 return err;
2153
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002154 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002155 if (err)
2156 return err;
2157
2158 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002159 vlan.vid = chip->info->max_vid;
2160 vlan.valid = false;
2161
Vivien Didelot83dabd12016-08-31 11:50:04 -04002162 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002163 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002164 if (err)
2165 return err;
2166
2167 if (!vlan.valid)
2168 break;
2169
2170 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002171 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002172 if (err)
2173 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002174 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002175
2176 return err;
2177}
2178
Vivien Didelotf81ec902016-05-09 13:22:58 -04002179static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002180 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002181{
Vivien Didelot04bed142016-08-31 18:06:13 -04002182 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002183 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002184
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002185 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002186 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002187 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002188
2189 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002190}
2191
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002192static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2193 struct net_device *br)
2194{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002195 struct dsa_switch *ds = chip->ds;
2196 struct dsa_switch_tree *dst = ds->dst;
2197 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002198 int err;
2199
Vivien Didelotef2025e2019-10-21 16:51:27 -04002200 list_for_each_entry(dp, &dst->ports, list) {
2201 if (dp->bridge_dev == br) {
2202 if (dp->ds == ds) {
2203 /* This is a local bridge group member,
2204 * remap its Port VLAN Map.
2205 */
2206 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2207 if (err)
2208 return err;
2209 } else {
2210 /* This is an external bridge group member,
2211 * remap its cross-chip Port VLAN Table entry.
2212 */
2213 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2214 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002215 if (err)
2216 return err;
2217 }
2218 }
2219 }
2220
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002221 return 0;
2222}
2223
Vivien Didelotf81ec902016-05-09 13:22:58 -04002224static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002225 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002226{
Vivien Didelot04bed142016-08-31 18:06:13 -04002227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002228 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002229
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002230 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002231 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002232 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002233
Vivien Didelot466dfa02016-02-26 13:16:05 -05002234 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002235}
2236
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002237static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2238 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002239{
Vivien Didelot04bed142016-08-31 18:06:13 -04002240 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002241
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002242 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002243 if (mv88e6xxx_bridge_map(chip, br) ||
2244 mv88e6xxx_port_vlan_map(chip, port))
2245 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002246 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002247}
2248
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002249static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2250 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002251 int port, struct net_device *br)
2252{
2253 struct mv88e6xxx_chip *chip = ds->priv;
2254 int err;
2255
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002256 if (tree_index != ds->dst->index)
2257 return 0;
2258
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002259 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002260 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002261 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002262
2263 return err;
2264}
2265
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002266static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2267 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002268 int port, struct net_device *br)
2269{
2270 struct mv88e6xxx_chip *chip = ds->priv;
2271
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002272 if (tree_index != ds->dst->index)
2273 return;
2274
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002275 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002276 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002277 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002278 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002279}
2280
Vivien Didelot17e708b2016-12-05 17:30:27 -05002281static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2282{
2283 if (chip->info->ops->reset)
2284 return chip->info->ops->reset(chip);
2285
2286 return 0;
2287}
2288
Vivien Didelot309eca62016-12-05 17:30:26 -05002289static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2290{
2291 struct gpio_desc *gpiod = chip->reset;
2292
2293 /* If there is a GPIO connected to the reset pin, toggle it */
2294 if (gpiod) {
2295 gpiod_set_value_cansleep(gpiod, 1);
2296 usleep_range(10000, 20000);
2297 gpiod_set_value_cansleep(gpiod, 0);
2298 usleep_range(10000, 20000);
2299 }
2300}
2301
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002302static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2303{
2304 int i, err;
2305
2306 /* Set all ports to the Disabled state */
2307 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002308 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002309 if (err)
2310 return err;
2311 }
2312
2313 /* Wait for transmit queues to drain,
2314 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2315 */
2316 usleep_range(2000, 4000);
2317
2318 return 0;
2319}
2320
Vivien Didelotfad09c72016-06-21 12:28:20 -04002321static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002322{
Vivien Didelota935c052016-09-29 12:21:53 -04002323 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002324
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002325 err = mv88e6xxx_disable_ports(chip);
2326 if (err)
2327 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002328
Vivien Didelot309eca62016-12-05 17:30:26 -05002329 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002330
Vivien Didelot17e708b2016-12-05 17:30:27 -05002331 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002332}
2333
Vivien Didelot43145572017-03-11 16:12:59 -05002334static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002335 enum mv88e6xxx_frame_mode frame,
2336 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002337{
2338 int err;
2339
Vivien Didelot43145572017-03-11 16:12:59 -05002340 if (!chip->info->ops->port_set_frame_mode)
2341 return -EOPNOTSUPP;
2342
2343 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002344 if (err)
2345 return err;
2346
Vivien Didelot43145572017-03-11 16:12:59 -05002347 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2348 if (err)
2349 return err;
2350
2351 if (chip->info->ops->port_set_ether_type)
2352 return chip->info->ops->port_set_ether_type(chip, port, etype);
2353
2354 return 0;
2355}
2356
2357static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2358{
2359 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002360 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002361 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002362}
2363
2364static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2365{
2366 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002367 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002368 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002369}
2370
2371static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2372{
2373 return mv88e6xxx_set_port_mode(chip, port,
2374 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002375 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2376 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002377}
2378
2379static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2380{
2381 if (dsa_is_dsa_port(chip->ds, port))
2382 return mv88e6xxx_set_port_mode_dsa(chip, port);
2383
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002384 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002385 return mv88e6xxx_set_port_mode_normal(chip, port);
2386
2387 /* Setup CPU port mode depending on its supported tag format */
2388 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2389 return mv88e6xxx_set_port_mode_dsa(chip, port);
2390
2391 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2392 return mv88e6xxx_set_port_mode_edsa(chip, port);
2393
2394 return -EINVAL;
2395}
2396
Vivien Didelotea698f42017-03-11 16:12:50 -05002397static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2398{
2399 bool message = dsa_is_dsa_port(chip->ds, port);
2400
2401 return mv88e6xxx_port_set_message_port(chip, port, message);
2402}
2403
Vivien Didelot601aeed2017-03-11 16:13:00 -05002404static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2405{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002406 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002407 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002408
David S. Miller407308f2019-06-15 13:35:29 -07002409 /* Upstream ports flood frames with unknown unicast or multicast DA */
2410 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2411 if (chip->info->ops->port_set_egress_floods)
2412 return chip->info->ops->port_set_egress_floods(chip, port,
2413 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002414
David S. Miller407308f2019-06-15 13:35:29 -07002415 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002416}
2417
Vivien Didelot45de77f2019-08-31 16:18:36 -04002418static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2419{
2420 struct mv88e6xxx_port *mvp = dev_id;
2421 struct mv88e6xxx_chip *chip = mvp->chip;
2422 irqreturn_t ret = IRQ_NONE;
2423 int port = mvp->port;
2424 u8 lane;
2425
2426 mv88e6xxx_reg_lock(chip);
2427 lane = mv88e6xxx_serdes_get_lane(chip, port);
2428 if (lane)
2429 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2430 mv88e6xxx_reg_unlock(chip);
2431
2432 return ret;
2433}
2434
2435static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2436 u8 lane)
2437{
2438 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2439 unsigned int irq;
2440 int err;
2441
2442 /* Nothing to request if this SERDES port has no IRQ */
2443 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2444 if (!irq)
2445 return 0;
2446
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002447 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2448 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2449
Vivien Didelot45de77f2019-08-31 16:18:36 -04002450 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2451 mv88e6xxx_reg_unlock(chip);
2452 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002453 IRQF_ONESHOT, dev_id->serdes_irq_name,
2454 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002455 mv88e6xxx_reg_lock(chip);
2456 if (err)
2457 return err;
2458
2459 dev_id->serdes_irq = irq;
2460
2461 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2462}
2463
2464static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2465 u8 lane)
2466{
2467 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2468 unsigned int irq = dev_id->serdes_irq;
2469 int err;
2470
2471 /* Nothing to free if no IRQ has been requested */
2472 if (!irq)
2473 return 0;
2474
2475 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2476
2477 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2478 mv88e6xxx_reg_unlock(chip);
2479 free_irq(irq, dev_id);
2480 mv88e6xxx_reg_lock(chip);
2481
2482 dev_id->serdes_irq = 0;
2483
2484 return err;
2485}
2486
Andrew Lunn6d917822017-05-26 01:03:21 +02002487static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2488 bool on)
2489{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002490 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002491 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002492
Vivien Didelotdc272f62019-08-31 16:18:33 -04002493 lane = mv88e6xxx_serdes_get_lane(chip, port);
2494 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002495 return 0;
2496
2497 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002498 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002499 if (err)
2500 return err;
2501
Vivien Didelot45de77f2019-08-31 16:18:36 -04002502 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002503 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002504 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2505 if (err)
2506 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002507
Vivien Didelotdc272f62019-08-31 16:18:33 -04002508 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002509 }
2510
2511 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002512}
2513
Vivien Didelotfa371c82017-12-05 15:34:10 -05002514static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2515{
2516 struct dsa_switch *ds = chip->ds;
2517 int upstream_port;
2518 int err;
2519
Vivien Didelot07073c72017-12-05 15:34:13 -05002520 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002521 if (chip->info->ops->port_set_upstream_port) {
2522 err = chip->info->ops->port_set_upstream_port(chip, port,
2523 upstream_port);
2524 if (err)
2525 return err;
2526 }
2527
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002528 if (port == upstream_port) {
2529 if (chip->info->ops->set_cpu_port) {
2530 err = chip->info->ops->set_cpu_port(chip,
2531 upstream_port);
2532 if (err)
2533 return err;
2534 }
2535
2536 if (chip->info->ops->set_egress_port) {
2537 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002538 MV88E6XXX_EGRESS_DIR_INGRESS,
2539 upstream_port);
2540 if (err)
2541 return err;
2542
2543 err = chip->info->ops->set_egress_port(chip,
2544 MV88E6XXX_EGRESS_DIR_EGRESS,
2545 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002546 if (err)
2547 return err;
2548 }
2549 }
2550
Vivien Didelotfa371c82017-12-05 15:34:10 -05002551 return 0;
2552}
2553
Vivien Didelotfad09c72016-06-21 12:28:20 -04002554static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002555{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002556 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002557 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002558 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002559
Andrew Lunn7b898462018-08-09 15:38:47 +02002560 chip->ports[port].chip = chip;
2561 chip->ports[port].port = port;
2562
Vivien Didelotd78343d2016-11-04 03:23:36 +01002563 /* MAC Forcing register: don't force link, speed, duplex or flow control
2564 * state to any particular values on physical ports, but force the CPU
2565 * port and all DSA ports to their maximum bandwidth and full duplex.
2566 */
2567 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2568 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2569 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002570 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002571 PHY_INTERFACE_MODE_NA);
2572 else
2573 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2574 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002575 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002576 PHY_INTERFACE_MODE_NA);
2577 if (err)
2578 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002579
2580 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2581 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2582 * tunneling, determine priority by looking at 802.1p and IP
2583 * priority fields (IP prio has precedence), and set STP state
2584 * to Forwarding.
2585 *
2586 * If this is the CPU link, use DSA or EDSA tagging depending
2587 * on which tagging mode was configured.
2588 *
2589 * If this is a link to another switch, use DSA tagging mode.
2590 *
2591 * If this is the upstream port for this switch, enable
2592 * forwarding of unknown unicasts and multicasts.
2593 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002594 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2595 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2596 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2597 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002598 if (err)
2599 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002600
Vivien Didelot601aeed2017-03-11 16:13:00 -05002601 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002602 if (err)
2603 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002604
Vivien Didelot601aeed2017-03-11 16:13:00 -05002605 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002606 if (err)
2607 return err;
2608
Vivien Didelot8efdda42015-08-13 12:52:23 -04002609 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002610 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002611 * untagged frames on this port, do a destination address lookup on all
2612 * received packets as usual, disable ARP mirroring and don't send a
2613 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002614 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002615 err = mv88e6xxx_port_set_map_da(chip, port);
2616 if (err)
2617 return err;
2618
Vivien Didelotfa371c82017-12-05 15:34:10 -05002619 err = mv88e6xxx_setup_upstream_port(chip, port);
2620 if (err)
2621 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002622
Andrew Lunna23b2962017-02-04 20:15:28 +01002623 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002624 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002625 if (err)
2626 return err;
2627
Vivien Didelotcd782652017-06-08 18:34:13 -04002628 if (chip->info->ops->port_set_jumbo_size) {
2629 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002630 if (err)
2631 return err;
2632 }
2633
Andrew Lunn54d792f2015-05-06 01:09:47 +02002634 /* Port Association Vector: when learning source addresses
2635 * of packets, add the address to the address database using
2636 * a port bitmap that has only the bit for this port set and
2637 * the other bits clear.
2638 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002639 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002640 /* Disable learning for CPU port */
2641 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002642 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002643
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002644 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2645 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002646 if (err)
2647 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002648
2649 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002650 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2651 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002652 if (err)
2653 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002654
Vivien Didelot08984322017-06-08 18:34:12 -04002655 if (chip->info->ops->port_pause_limit) {
2656 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002657 if (err)
2658 return err;
2659 }
2660
Vivien Didelotc8c94892017-03-11 16:13:01 -05002661 if (chip->info->ops->port_disable_learn_limit) {
2662 err = chip->info->ops->port_disable_learn_limit(chip, port);
2663 if (err)
2664 return err;
2665 }
2666
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002667 if (chip->info->ops->port_disable_pri_override) {
2668 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002669 if (err)
2670 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002671 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002672
Andrew Lunnef0a7312016-12-03 04:35:16 +01002673 if (chip->info->ops->port_tag_remap) {
2674 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002675 if (err)
2676 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002677 }
2678
Andrew Lunnef70b112016-12-03 04:45:18 +01002679 if (chip->info->ops->port_egress_rate_limiting) {
2680 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002681 if (err)
2682 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002683 }
2684
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002685 if (chip->info->ops->port_setup_message_port) {
2686 err = chip->info->ops->port_setup_message_port(chip, port);
2687 if (err)
2688 return err;
2689 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002690
Vivien Didelot207afda2016-04-14 14:42:09 -04002691 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002692 * database, and allow bidirectional communication between the
2693 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002694 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002695 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002696 if (err)
2697 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002698
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002699 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002700 if (err)
2701 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002702
2703 /* Default VLAN ID and priority: don't set a default VLAN
2704 * ID, and set the default packet priority to zero.
2705 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002706 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002707}
2708
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002709static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2710{
2711 struct mv88e6xxx_chip *chip = ds->priv;
2712
2713 if (chip->info->ops->port_set_jumbo_size)
2714 return 10240;
Chris Packham1baf0fa2020-07-24 11:21:22 +12002715 else if (chip->info->ops->set_max_frame_size)
2716 return 1632;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002717 return 1522;
2718}
2719
2720static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2721{
2722 struct mv88e6xxx_chip *chip = ds->priv;
2723 int ret = 0;
2724
2725 mv88e6xxx_reg_lock(chip);
2726 if (chip->info->ops->port_set_jumbo_size)
2727 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12002728 else if (chip->info->ops->set_max_frame_size)
2729 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002730 else
2731 if (new_mtu > 1522)
2732 ret = -EINVAL;
2733 mv88e6xxx_reg_unlock(chip);
2734
2735 return ret;
2736}
2737
Andrew Lunn04aca992017-05-26 01:03:24 +02002738static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2739 struct phy_device *phydev)
2740{
2741 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002742 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002743
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002744 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002745 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002746 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002747
2748 return err;
2749}
2750
Andrew Lunn75104db2019-02-24 20:44:43 +01002751static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002752{
2753 struct mv88e6xxx_chip *chip = ds->priv;
2754
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002755 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002756 if (mv88e6xxx_serdes_power(chip, port, false))
2757 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002758 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002759}
2760
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002761static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2762 unsigned int ageing_time)
2763{
Vivien Didelot04bed142016-08-31 18:06:13 -04002764 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002765 int err;
2766
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002767 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002768 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002769 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002770
2771 return err;
2772}
2773
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002774static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002775{
2776 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002777
Andrew Lunnde2273872016-11-21 23:27:01 +01002778 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002779 if (chip->info->ops->stats_set_histogram) {
2780 err = chip->info->ops->stats_set_histogram(chip);
2781 if (err)
2782 return err;
2783 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002784
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002785 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002786}
2787
Andrew Lunnea890982019-01-09 00:24:03 +01002788/* Check if the errata has already been applied. */
2789static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2790{
2791 int port;
2792 int err;
2793 u16 val;
2794
2795 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002796 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002797 if (err) {
2798 dev_err(chip->dev,
2799 "Error reading hidden register: %d\n", err);
2800 return false;
2801 }
2802 if (val != 0x01c0)
2803 return false;
2804 }
2805
2806 return true;
2807}
2808
2809/* The 6390 copper ports have an errata which require poking magic
2810 * values into undocumented hidden registers and then performing a
2811 * software reset.
2812 */
2813static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2814{
2815 int port;
2816 int err;
2817
2818 if (mv88e6390_setup_errata_applied(chip))
2819 return 0;
2820
2821 /* Set the ports into blocking mode */
2822 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2823 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2824 if (err)
2825 return err;
2826 }
2827
2828 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002829 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002830 if (err)
2831 return err;
2832 }
2833
2834 return mv88e6xxx_software_reset(chip);
2835}
2836
Andrew Lunn23e8b472019-10-25 01:03:52 +02002837static void mv88e6xxx_teardown(struct dsa_switch *ds)
2838{
2839 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002840 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002841}
2842
Vivien Didelotf81ec902016-05-09 13:22:58 -04002843static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002844{
Vivien Didelot04bed142016-08-31 18:06:13 -04002845 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002846 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002847 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002848 int i;
2849
Vivien Didelotfad09c72016-06-21 12:28:20 -04002850 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002851 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002852
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002853 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002854
Andrew Lunnea890982019-01-09 00:24:03 +01002855 if (chip->info->ops->setup_errata) {
2856 err = chip->info->ops->setup_errata(chip);
2857 if (err)
2858 goto unlock;
2859 }
2860
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002861 /* Cache the cmode of each port. */
2862 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2863 if (chip->info->ops->port_get_cmode) {
2864 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2865 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002866 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002867
2868 chip->ports[i].cmode = cmode;
2869 }
2870 }
2871
Vivien Didelot97299342016-07-18 20:45:30 -04002872 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002873 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002874 if (dsa_is_unused_port(ds, i))
2875 continue;
2876
Hubert Feursteinc8574862019-07-31 10:23:48 +02002877 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002878 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002879 dev_err(chip->dev, "port %d is invalid\n", i);
2880 err = -EINVAL;
2881 goto unlock;
2882 }
2883
Vivien Didelot97299342016-07-18 20:45:30 -04002884 err = mv88e6xxx_setup_port(chip, i);
2885 if (err)
2886 goto unlock;
2887 }
2888
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002889 err = mv88e6xxx_irl_setup(chip);
2890 if (err)
2891 goto unlock;
2892
Vivien Didelot04a69a12017-10-13 14:18:05 -04002893 err = mv88e6xxx_mac_setup(chip);
2894 if (err)
2895 goto unlock;
2896
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002897 err = mv88e6xxx_phy_setup(chip);
2898 if (err)
2899 goto unlock;
2900
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002901 err = mv88e6xxx_vtu_setup(chip);
2902 if (err)
2903 goto unlock;
2904
Vivien Didelot81228992017-03-30 17:37:08 -04002905 err = mv88e6xxx_pvt_setup(chip);
2906 if (err)
2907 goto unlock;
2908
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002909 err = mv88e6xxx_atu_setup(chip);
2910 if (err)
2911 goto unlock;
2912
Andrew Lunn87fa8862017-11-09 22:29:56 +01002913 err = mv88e6xxx_broadcast_setup(chip, 0);
2914 if (err)
2915 goto unlock;
2916
Vivien Didelot9e907d72017-07-17 13:03:43 -04002917 err = mv88e6xxx_pot_setup(chip);
2918 if (err)
2919 goto unlock;
2920
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002921 err = mv88e6xxx_rmu_setup(chip);
2922 if (err)
2923 goto unlock;
2924
Vivien Didelot51c901a2017-07-17 13:03:41 -04002925 err = mv88e6xxx_rsvd2cpu_setup(chip);
2926 if (err)
2927 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002928
Vivien Didelotb28f8722018-04-26 21:56:44 -04002929 err = mv88e6xxx_trunk_setup(chip);
2930 if (err)
2931 goto unlock;
2932
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002933 err = mv88e6xxx_devmap_setup(chip);
2934 if (err)
2935 goto unlock;
2936
Vivien Didelot93e18d62018-05-11 17:16:35 -04002937 err = mv88e6xxx_pri_setup(chip);
2938 if (err)
2939 goto unlock;
2940
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002941 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002942 if (chip->info->ptp_support) {
2943 err = mv88e6xxx_ptp_setup(chip);
2944 if (err)
2945 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002946
2947 err = mv88e6xxx_hwtstamp_setup(chip);
2948 if (err)
2949 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002950 }
2951
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002952 err = mv88e6xxx_stats_setup(chip);
2953 if (err)
2954 goto unlock;
2955
Vivien Didelot6b17e862015-08-13 12:52:18 -04002956unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002957 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002958
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002959 if (err)
2960 return err;
2961
2962 /* Have to be called without holding the register lock, since
2963 * they take the devlink lock, and we later take the locks in
2964 * the reverse order when getting/setting parameters or
2965 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02002966 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002967 err = mv88e6xxx_setup_devlink_resources(ds);
2968 if (err)
2969 return err;
2970
2971 err = mv88e6xxx_setup_devlink_params(ds);
2972 if (err)
2973 dsa_devlink_resources_unregister(ds);
2974
2975 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002976}
2977
Vivien Didelote57e5e72016-08-15 17:19:00 -04002978static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002979{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002980 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2981 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002982 u16 val;
2983 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002984
Andrew Lunnee26a222017-01-24 14:53:48 +01002985 if (!chip->info->ops->phy_read)
2986 return -EOPNOTSUPP;
2987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002988 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002989 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002990 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002991
Andrew Lunnda9f3302017-02-01 03:40:05 +01002992 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002993 /* Some internal PHYs don't have a model number. */
2994 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2995 /* Then there is the 6165 family. It gets is
2996 * PHYs correct. But it can also have two
2997 * SERDES interfaces in the PHY address
2998 * space. And these don't have a model
2999 * number. But they are not PHYs, so we don't
3000 * want to give them something a PHY driver
3001 * will recognise.
3002 *
3003 * Use the mv88e6390 family model number
3004 * instead, for anything which really could be
3005 * a PHY,
3006 */
3007 if (!(val & 0x3f0))
3008 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003009 }
3010
Vivien Didelote57e5e72016-08-15 17:19:00 -04003011 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003012}
3013
Vivien Didelote57e5e72016-08-15 17:19:00 -04003014static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003015{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003016 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3017 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003018 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003019
Andrew Lunnee26a222017-01-24 14:53:48 +01003020 if (!chip->info->ops->phy_write)
3021 return -EOPNOTSUPP;
3022
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003023 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003024 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003025 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003026
3027 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003028}
3029
Vivien Didelotfad09c72016-06-21 12:28:20 -04003030static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003031 struct device_node *np,
3032 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003033{
3034 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003035 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003036 struct mii_bus *bus;
3037 int err;
3038
Andrew Lunn2510bab2018-02-22 01:51:49 +01003039 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003040 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003041 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003042 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003043
3044 if (err)
3045 return err;
3046 }
3047
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003048 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003049 if (!bus)
3050 return -ENOMEM;
3051
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003052 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003053 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003054 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003055 INIT_LIST_HEAD(&mdio_bus->list);
3056 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003057
Andrew Lunnb516d452016-06-04 21:17:06 +02003058 if (np) {
3059 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003060 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003061 } else {
3062 bus->name = "mv88e6xxx SMI";
3063 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3064 }
3065
3066 bus->read = mv88e6xxx_mdio_read;
3067 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003068 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003069
Andrew Lunn6f882842018-03-17 20:32:05 +01003070 if (!external) {
3071 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3072 if (err)
3073 return err;
3074 }
3075
Florian Fainelli00e798c2018-05-15 16:56:19 -07003076 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003077 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003078 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003079 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003080 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003081 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003082
3083 if (external)
3084 list_add_tail(&mdio_bus->list, &chip->mdios);
3085 else
3086 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003087
3088 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003089}
3090
Andrew Lunn3126aee2017-12-07 01:05:57 +01003091static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3092
3093{
3094 struct mv88e6xxx_mdio_bus *mdio_bus;
3095 struct mii_bus *bus;
3096
3097 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3098 bus = mdio_bus->bus;
3099
Andrew Lunn6f882842018-03-17 20:32:05 +01003100 if (!mdio_bus->external)
3101 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3102
Andrew Lunn3126aee2017-12-07 01:05:57 +01003103 mdiobus_unregister(bus);
3104 }
3105}
3106
Andrew Lunna3c53be52017-01-24 14:53:50 +01003107static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3108 struct device_node *np)
3109{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003110 struct device_node *child;
3111 int err;
3112
3113 /* Always register one mdio bus for the internal/default mdio
3114 * bus. This maybe represented in the device tree, but is
3115 * optional.
3116 */
3117 child = of_get_child_by_name(np, "mdio");
3118 err = mv88e6xxx_mdio_register(chip, child, false);
3119 if (err)
3120 return err;
3121
3122 /* Walk the device tree, and see if there are any other nodes
3123 * which say they are compatible with the external mdio
3124 * bus.
3125 */
3126 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003127 if (of_device_is_compatible(
3128 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003129 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003130 if (err) {
3131 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303132 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003133 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003134 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003135 }
3136 }
3137
3138 return 0;
3139}
3140
Vivien Didelot855b1932016-07-20 18:18:35 -04003141static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3142{
Vivien Didelot04bed142016-08-31 18:06:13 -04003143 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003144
3145 return chip->eeprom_len;
3146}
3147
Vivien Didelot855b1932016-07-20 18:18:35 -04003148static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3149 struct ethtool_eeprom *eeprom, u8 *data)
3150{
Vivien Didelot04bed142016-08-31 18:06:13 -04003151 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003152 int err;
3153
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003154 if (!chip->info->ops->get_eeprom)
3155 return -EOPNOTSUPP;
3156
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003157 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003158 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003159 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003160
3161 if (err)
3162 return err;
3163
3164 eeprom->magic = 0xc3ec4951;
3165
3166 return 0;
3167}
3168
Vivien Didelot855b1932016-07-20 18:18:35 -04003169static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3170 struct ethtool_eeprom *eeprom, u8 *data)
3171{
Vivien Didelot04bed142016-08-31 18:06:13 -04003172 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003173 int err;
3174
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003175 if (!chip->info->ops->set_eeprom)
3176 return -EOPNOTSUPP;
3177
Vivien Didelot855b1932016-07-20 18:18:35 -04003178 if (eeprom->magic != 0xc3ec4951)
3179 return -EINVAL;
3180
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003181 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003182 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003183 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003184
3185 return err;
3186}
3187
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003188static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003189 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003190 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3191 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003192 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003193 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003194 .phy_read = mv88e6185_phy_ppu_read,
3195 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003196 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003197 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003198 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003199 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003200 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003201 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003202 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003203 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003204 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003205 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003206 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003207 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003208 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003209 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003210 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3211 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003212 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003213 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3214 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003215 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003216 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003217 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003218 .ppu_enable = mv88e6185_g1_ppu_enable,
3219 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003220 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003221 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003222 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003223 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003224 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003225 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003226};
3227
3228static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003229 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003230 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3231 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003232 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003233 .phy_read = mv88e6185_phy_ppu_read,
3234 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003235 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003236 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003237 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003238 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003239 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003240 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003241 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003242 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003243 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003244 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3245 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003246 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003247 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003248 .ppu_enable = mv88e6185_g1_ppu_enable,
3249 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003250 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003251 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003252 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003253 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003254 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003255};
3256
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003257static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003258 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003259 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3260 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003261 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003262 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3263 .phy_read = mv88e6xxx_g2_smi_phy_read,
3264 .phy_write = mv88e6xxx_g2_smi_phy_write,
3265 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003266 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003267 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003268 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003269 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003270 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003271 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003272 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003273 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003274 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003275 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003276 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003277 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003278 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003279 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3280 .stats_get_strings = mv88e6095_stats_get_strings,
3281 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003282 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3283 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003284 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003285 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003286 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003287 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003288 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003289 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003290 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003291 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003292 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003293};
3294
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003295static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003296 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003297 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3298 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003299 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003300 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003301 .phy_read = mv88e6xxx_g2_smi_phy_read,
3302 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003303 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003304 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003305 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003306 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003307 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003308 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003309 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003310 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003311 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003312 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003313 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3314 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003315 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003316 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3317 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003318 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003319 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003320 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003321 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003322 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3323 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003324 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003325 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003326 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003327 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003328};
3329
3330static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003331 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003332 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3333 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003334 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003335 .phy_read = mv88e6185_phy_ppu_read,
3336 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003337 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003338 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003339 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003340 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003341 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003342 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003343 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003344 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003345 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003346 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003347 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003348 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003349 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003350 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003351 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003352 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3353 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003354 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003355 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3356 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003357 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003358 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003359 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003360 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003361 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003362 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003363 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003364 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003365 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003366};
3367
Vivien Didelot990e27b2017-03-28 13:50:32 -04003368static const struct mv88e6xxx_ops mv88e6141_ops = {
3369 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003370 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3371 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003372 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003373 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3374 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3375 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3376 .phy_read = mv88e6xxx_g2_smi_phy_read,
3377 .phy_write = mv88e6xxx_g2_smi_phy_write,
3378 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003379 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003380 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003381 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003382 .port_tag_remap = mv88e6095_port_tag_remap,
3383 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3384 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3385 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003386 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003387 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003388 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003389 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3390 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003391 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003392 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003393 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003394 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003395 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003396 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3397 .stats_get_strings = mv88e6320_stats_get_strings,
3398 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003399 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3400 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003401 .watchdog_ops = &mv88e6390_watchdog_ops,
3402 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003403 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003404 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003405 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003406 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003407 .serdes_power = mv88e6390_serdes_power,
3408 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003409 /* Check status register pause & lpa register */
3410 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3411 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3412 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3413 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003414 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003415 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003416 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003417 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003418 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003419};
3420
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003421static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003422 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003423 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3424 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003425 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003426 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003427 .phy_read = mv88e6xxx_g2_smi_phy_read,
3428 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003429 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003430 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003431 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003432 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003433 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003434 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003435 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003436 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003437 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003438 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003439 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003440 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003441 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003442 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003443 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003444 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3445 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003446 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003447 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3448 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003449 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003450 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003451 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003452 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003453 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3454 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003455 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003456 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003457 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003458 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003459 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003460};
3461
3462static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003463 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003464 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3465 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003466 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003467 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003468 .phy_read = mv88e6165_phy_read,
3469 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003470 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003471 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003472 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003473 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003474 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003475 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003476 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003477 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003478 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3479 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003480 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003481 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3482 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003483 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003484 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003485 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003486 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003487 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3488 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003489 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003490 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003491 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003492 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003493 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003494};
3495
3496static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003497 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003498 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3499 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003500 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003501 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003502 .phy_read = mv88e6xxx_g2_smi_phy_read,
3503 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003504 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003505 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003506 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003507 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003508 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003509 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003510 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003511 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003512 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003513 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003514 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003515 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003516 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003517 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003518 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003519 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003520 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3521 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003522 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003523 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3524 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003525 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003526 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003527 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003528 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003529 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3530 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003531 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003532 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003533 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003534};
3535
3536static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003537 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003538 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3539 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003540 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003541 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3542 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003543 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003544 .phy_read = mv88e6xxx_g2_smi_phy_read,
3545 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003546 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003547 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003548 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003549 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003550 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003551 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003552 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003553 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003554 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003555 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003556 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003557 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003558 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003559 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003560 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003561 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003562 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003563 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3564 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003565 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003566 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3567 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003568 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003569 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003570 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003571 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003572 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003573 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3574 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003575 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003576 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003577 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003578 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3579 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3580 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3581 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003582 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003583 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3584 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003585 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003586 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003587};
3588
3589static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003590 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003591 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3592 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003593 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003594 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003595 .phy_read = mv88e6xxx_g2_smi_phy_read,
3596 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003597 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003598 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003599 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003600 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003601 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003602 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003603 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003604 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003605 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003606 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003607 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003608 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003609 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003610 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003611 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003612 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003613 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3614 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003615 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003616 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3617 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003618 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003619 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003620 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003621 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003622 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3623 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003624 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003625 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003626 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003627};
3628
3629static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003630 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003631 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3632 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003633 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003634 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3635 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003636 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003637 .phy_read = mv88e6xxx_g2_smi_phy_read,
3638 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003639 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003640 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003641 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003642 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003643 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003644 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003645 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003646 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003647 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003648 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003649 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003650 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003651 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003652 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003653 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003654 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003655 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003656 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3657 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003658 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003659 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3660 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003661 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003662 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003663 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003664 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003665 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003666 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3667 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003668 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003669 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003670 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003671 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3672 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3673 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3674 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003675 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003676 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003677 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003678 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003679 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3680 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003681 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003682 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003683};
3684
3685static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003686 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003687 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3688 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003689 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003690 .phy_read = mv88e6185_phy_ppu_read,
3691 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003692 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003693 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003694 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003695 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003696 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003697 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003698 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003699 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003700 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003701 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003702 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003703 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3704 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003705 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003706 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3707 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003708 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003709 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003710 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003711 .ppu_enable = mv88e6185_g1_ppu_enable,
3712 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003713 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003714 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003715 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003716 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003717 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003718};
3719
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003720static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003721 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003722 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003723 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003724 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3725 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003726 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3727 .phy_read = mv88e6xxx_g2_smi_phy_read,
3728 .phy_write = mv88e6xxx_g2_smi_phy_write,
3729 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003730 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003731 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003732 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003733 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003734 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003735 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003736 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003737 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003738 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003739 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003740 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003741 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003742 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003743 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003744 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003745 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003746 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003747 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3748 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003749 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003750 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3751 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003752 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003753 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003754 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003755 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003756 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003757 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3758 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003759 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3760 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003761 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003762 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003763 /* Check status register pause & lpa register */
3764 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3765 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3766 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3767 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003768 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003769 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003770 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003771 .serdes_get_strings = mv88e6390_serdes_get_strings,
3772 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003773 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3774 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003775 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003776 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003777};
3778
3779static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003780 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003781 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003782 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003783 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3784 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003785 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3786 .phy_read = mv88e6xxx_g2_smi_phy_read,
3787 .phy_write = mv88e6xxx_g2_smi_phy_write,
3788 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003789 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003790 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003791 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003792 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003793 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003794 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003795 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003796 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003797 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003798 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003799 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003800 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003801 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003802 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003803 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003804 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003805 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003806 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3807 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003808 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003809 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3810 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003811 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003812 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003813 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003814 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003815 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003816 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3817 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003818 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3819 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003820 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003821 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003822 /* Check status register pause & lpa register */
3823 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3824 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3825 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3826 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003827 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003828 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003829 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003830 .serdes_get_strings = mv88e6390_serdes_get_strings,
3831 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003832 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3833 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003834 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003835 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003836};
3837
3838static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003839 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003840 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003841 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003842 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3843 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003844 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3845 .phy_read = mv88e6xxx_g2_smi_phy_read,
3846 .phy_write = mv88e6xxx_g2_smi_phy_write,
3847 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003848 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003849 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003850 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003851 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003852 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003853 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003854 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003855 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003856 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003857 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003858 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003859 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003860 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003861 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003862 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003863 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3864 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003865 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003866 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3867 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003868 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003869 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003870 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003871 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003872 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003873 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3874 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003875 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3876 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003877 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003878 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003879 /* Check status register pause & lpa register */
3880 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3881 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3882 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3883 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003884 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003885 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003886 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003887 .serdes_get_strings = mv88e6390_serdes_get_strings,
3888 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003889 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3890 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003891 .avb_ops = &mv88e6390_avb_ops,
3892 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003893 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003894};
3895
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003896static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003897 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003898 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3899 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003900 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003901 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3902 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003903 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003904 .phy_read = mv88e6xxx_g2_smi_phy_read,
3905 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003906 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003907 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003908 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003909 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003910 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003911 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003912 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003913 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003914 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003915 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003916 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003917 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003918 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003919 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003920 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003921 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003922 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003923 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3924 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003925 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003926 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3927 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003928 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003929 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003930 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003931 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003932 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003933 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3934 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003935 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003936 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003937 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003938 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3939 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3940 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3941 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003942 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003943 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003944 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003945 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003946 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3947 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003948 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003949 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003950 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003951 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003952};
3953
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003954static const struct mv88e6xxx_ops mv88e6250_ops = {
3955 /* MV88E6XXX_FAMILY_6250 */
3956 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3957 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3958 .irl_init_all = mv88e6352_g2_irl_init_all,
3959 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3960 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3961 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3962 .phy_read = mv88e6xxx_g2_smi_phy_read,
3963 .phy_write = mv88e6xxx_g2_smi_phy_write,
3964 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003965 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003966 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003967 .port_tag_remap = mv88e6095_port_tag_remap,
3968 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3969 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3970 .port_set_ether_type = mv88e6351_port_set_ether_type,
3971 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3972 .port_pause_limit = mv88e6097_port_pause_limit,
3973 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003974 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3975 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3976 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3977 .stats_get_strings = mv88e6250_stats_get_strings,
3978 .stats_get_stats = mv88e6250_stats_get_stats,
3979 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3980 .set_egress_port = mv88e6095_g1_set_egress_port,
3981 .watchdog_ops = &mv88e6250_watchdog_ops,
3982 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3983 .pot_clear = mv88e6xxx_g2_pot_clear,
3984 .reset = mv88e6250_g1_reset,
3985 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3986 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02003987 .avb_ops = &mv88e6352_avb_ops,
3988 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003989 .phylink_validate = mv88e6065_phylink_validate,
3990};
3991
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003992static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003993 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003994 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003995 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003996 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3997 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003998 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3999 .phy_read = mv88e6xxx_g2_smi_phy_read,
4000 .phy_write = mv88e6xxx_g2_smi_phy_write,
4001 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004002 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004003 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004004 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004005 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004006 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004007 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004008 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004009 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004010 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004011 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004012 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004013 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004014 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004015 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004016 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004017 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004018 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4019 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004020 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004021 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4022 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004023 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004024 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004025 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004026 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004027 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004028 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4029 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004030 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4031 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004032 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004033 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004034 /* Check status register pause & lpa register */
4035 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4036 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4037 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4038 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004039 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004040 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004041 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004042 .serdes_get_strings = mv88e6390_serdes_get_strings,
4043 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004044 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4045 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004046 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004047 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004048 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004049 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004050};
4051
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004052static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004053 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004054 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4055 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004056 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004057 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4058 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004059 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004060 .phy_read = mv88e6xxx_g2_smi_phy_read,
4061 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004062 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004063 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004064 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004065 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004066 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004067 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004068 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004069 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004070 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004071 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004072 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004073 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004074 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004075 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004076 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004077 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4078 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004079 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004080 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4081 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004082 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004083 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004084 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004085 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004086 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004087 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004088 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004089 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004090 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004091 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004092};
4093
4094static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004095 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004096 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4097 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004098 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004099 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4100 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004101 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004102 .phy_read = mv88e6xxx_g2_smi_phy_read,
4103 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004104 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004105 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004106 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004107 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004108 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004109 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004110 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004111 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004112 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004113 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004114 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004115 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004116 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004117 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004118 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004119 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4120 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004121 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004122 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4123 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004124 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004125 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004126 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004127 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004128 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004129 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004130 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004131 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004132};
4133
Vivien Didelot16e329a2017-03-28 13:50:33 -04004134static const struct mv88e6xxx_ops mv88e6341_ops = {
4135 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004136 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4137 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004138 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004139 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4140 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4141 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4142 .phy_read = mv88e6xxx_g2_smi_phy_read,
4143 .phy_write = mv88e6xxx_g2_smi_phy_write,
4144 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004145 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004146 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004147 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004148 .port_tag_remap = mv88e6095_port_tag_remap,
4149 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4150 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4151 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004152 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004153 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004154 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004155 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4156 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004157 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004158 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004159 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004160 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004161 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004162 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4163 .stats_get_strings = mv88e6320_stats_get_strings,
4164 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004165 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4166 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004167 .watchdog_ops = &mv88e6390_watchdog_ops,
4168 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004169 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004170 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004171 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004172 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004173 .serdes_power = mv88e6390_serdes_power,
4174 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004175 /* Check status register pause & lpa register */
4176 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4177 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4178 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4179 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004180 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004181 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004182 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004183 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004184 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004185 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004186 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004187};
4188
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004189static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004190 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004191 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4192 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004193 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004194 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004195 .phy_read = mv88e6xxx_g2_smi_phy_read,
4196 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004197 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004198 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004199 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004200 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004201 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004202 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004203 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004204 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004205 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004206 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004207 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004208 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004209 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004210 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004211 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004212 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004213 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4214 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004215 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004216 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4217 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004218 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004219 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004220 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004221 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004222 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4223 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004224 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004225 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004226 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004227};
4228
4229static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004230 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004231 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4232 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004233 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004234 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004235 .phy_read = mv88e6xxx_g2_smi_phy_read,
4236 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004237 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004238 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004239 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004240 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004241 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004242 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004243 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004244 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004245 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004246 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004247 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004248 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004249 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004250 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004251 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004252 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004253 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4254 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004255 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004256 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4257 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004258 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004259 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004260 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004261 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004262 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4263 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004264 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004265 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004266 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004267 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004268 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004269};
4270
4271static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004272 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004273 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4274 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004275 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004276 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4277 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004278 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004279 .phy_read = mv88e6xxx_g2_smi_phy_read,
4280 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004281 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004282 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004283 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004284 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004285 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004286 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004287 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004288 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004289 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004290 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004291 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004292 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004293 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004294 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004295 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004296 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004297 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004298 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4299 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004300 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004301 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4302 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004303 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004304 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004305 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004306 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004307 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004308 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4309 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004310 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004311 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004312 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004313 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4314 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4315 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4316 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004317 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004318 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004319 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004320 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004321 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004322 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004323 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004324 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4325 .serdes_get_strings = mv88e6352_serdes_get_strings,
4326 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004327 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4328 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004329 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004330};
4331
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004332static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004333 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004334 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004335 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004336 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4337 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004338 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4339 .phy_read = mv88e6xxx_g2_smi_phy_read,
4340 .phy_write = mv88e6xxx_g2_smi_phy_write,
4341 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004342 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004343 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004344 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004345 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004346 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004347 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004348 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004349 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004350 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004351 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004352 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004353 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004354 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004355 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004356 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004357 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004358 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004359 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004360 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4361 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004362 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004363 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4364 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004365 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004366 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004367 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004368 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004369 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004370 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4371 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004372 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4373 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004374 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004375 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004376 /* Check status register pause & lpa register */
4377 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4378 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4379 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4380 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004381 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004382 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004383 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004384 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004385 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004386 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004387 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4388 .serdes_get_strings = mv88e6390_serdes_get_strings,
4389 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004390 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4391 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004392 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004393};
4394
4395static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004396 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004397 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004398 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004399 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4400 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004401 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4402 .phy_read = mv88e6xxx_g2_smi_phy_read,
4403 .phy_write = mv88e6xxx_g2_smi_phy_write,
4404 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004405 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004406 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004407 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004408 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004409 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004410 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004411 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004412 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004413 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004414 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004415 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004416 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004417 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004418 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004419 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004420 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004421 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004422 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004423 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4424 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004425 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004426 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4427 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004428 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004429 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004430 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004431 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004432 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004433 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4434 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004435 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4436 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004437 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004438 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004439 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4440 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4441 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4442 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004443 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004444 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004445 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004446 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4447 .serdes_get_strings = mv88e6390_serdes_get_strings,
4448 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004449 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4450 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004451 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004452 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004453 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004454 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004455};
4456
Vivien Didelotf81ec902016-05-09 13:22:58 -04004457static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4458 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004459 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004460 .family = MV88E6XXX_FAMILY_6097,
4461 .name = "Marvell 88E6085",
4462 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004463 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004464 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004465 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004466 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004467 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004468 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004469 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004470 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004471 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004472 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004473 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004474 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004475 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004476 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004477 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004478 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004479 },
4480
4481 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004482 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004483 .family = MV88E6XXX_FAMILY_6095,
4484 .name = "Marvell 88E6095/88E6095F",
4485 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004486 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004487 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004488 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004489 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004490 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004491 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004492 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004493 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004494 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004495 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004496 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004497 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004498 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004499 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004500 },
4501
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004502 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004503 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004504 .family = MV88E6XXX_FAMILY_6097,
4505 .name = "Marvell 88E6097/88E6097F",
4506 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004507 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004508 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004509 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004510 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004511 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004512 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004513 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004514 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004515 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004516 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004517 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004518 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004519 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004520 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004521 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004522 .ops = &mv88e6097_ops,
4523 },
4524
Vivien Didelotf81ec902016-05-09 13:22:58 -04004525 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004526 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004527 .family = MV88E6XXX_FAMILY_6165,
4528 .name = "Marvell 88E6123",
4529 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004530 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004531 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004532 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004533 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004534 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004535 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004536 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004537 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004538 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004539 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004540 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004541 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004542 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004543 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004544 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004545 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004546 },
4547
4548 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004549 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004550 .family = MV88E6XXX_FAMILY_6185,
4551 .name = "Marvell 88E6131",
4552 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004553 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004554 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004555 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004556 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004557 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004558 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004559 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004560 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004561 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004562 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004563 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004564 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004565 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004566 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004567 },
4568
Vivien Didelot990e27b2017-03-28 13:50:32 -04004569 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004570 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004571 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004572 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004573 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004574 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004575 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004576 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004577 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004578 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004579 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004580 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004581 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004582 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004583 .age_time_coeff = 3750,
4584 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004585 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004586 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004587 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004588 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004589 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004590 .ops = &mv88e6141_ops,
4591 },
4592
Vivien Didelotf81ec902016-05-09 13:22:58 -04004593 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004594 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004595 .family = MV88E6XXX_FAMILY_6165,
4596 .name = "Marvell 88E6161",
4597 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004598 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004599 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004600 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004601 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004602 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004603 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004604 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004605 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004606 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004607 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004608 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004609 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004610 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004611 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004612 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004613 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004614 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004615 },
4616
4617 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004618 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004619 .family = MV88E6XXX_FAMILY_6165,
4620 .name = "Marvell 88E6165",
4621 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004622 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004623 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004624 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004625 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004626 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004627 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004628 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004629 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004630 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004631 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004632 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004633 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004634 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004635 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004636 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004637 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004638 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004639 },
4640
4641 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004642 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004643 .family = MV88E6XXX_FAMILY_6351,
4644 .name = "Marvell 88E6171",
4645 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004646 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004647 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004648 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004649 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004650 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004651 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004652 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004653 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004654 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004655 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004656 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004657 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004658 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004659 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004660 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004661 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004662 },
4663
4664 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004665 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 .family = MV88E6XXX_FAMILY_6352,
4667 .name = "Marvell 88E6172",
4668 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004669 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004670 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004671 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004672 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004673 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004674 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004675 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004676 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004677 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004678 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004679 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004680 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004681 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004682 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004683 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004684 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004685 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004686 },
4687
4688 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004689 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004690 .family = MV88E6XXX_FAMILY_6351,
4691 .name = "Marvell 88E6175",
4692 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004693 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004694 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004695 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004696 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004697 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004698 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004699 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004700 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004701 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004702 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004703 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004704 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004705 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004706 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004707 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004708 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004709 },
4710
4711 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004712 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004713 .family = MV88E6XXX_FAMILY_6352,
4714 .name = "Marvell 88E6176",
4715 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004716 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004717 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004718 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004719 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004720 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004721 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004722 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004723 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004724 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004725 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004726 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004727 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004728 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004729 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004730 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004731 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004732 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 },
4734
4735 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004736 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004737 .family = MV88E6XXX_FAMILY_6185,
4738 .name = "Marvell 88E6185",
4739 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004740 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004741 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004742 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004743 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004744 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004745 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004746 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004747 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004748 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004749 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004750 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004751 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004752 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004753 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 },
4755
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004756 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004757 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004758 .family = MV88E6XXX_FAMILY_6390,
4759 .name = "Marvell 88E6190",
4760 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004761 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004762 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004763 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004764 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004765 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004766 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004767 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004768 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004769 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004770 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004771 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004772 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004773 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004774 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004775 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004776 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004777 .ops = &mv88e6190_ops,
4778 },
4779
4780 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004781 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004782 .family = MV88E6XXX_FAMILY_6390,
4783 .name = "Marvell 88E6190X",
4784 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004785 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004786 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004787 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004788 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004789 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004790 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004791 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004792 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004793 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004794 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004795 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004796 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004797 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004798 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004799 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004800 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004801 .ops = &mv88e6190x_ops,
4802 },
4803
4804 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004805 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004806 .family = MV88E6XXX_FAMILY_6390,
4807 .name = "Marvell 88E6191",
4808 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004809 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004810 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004811 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004812 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004813 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004814 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004815 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004816 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004817 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004818 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004819 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004820 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004821 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004822 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004823 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004824 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004825 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004826 },
4827
Hubert Feurstein49022642019-07-31 10:23:46 +02004828 [MV88E6220] = {
4829 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4830 .family = MV88E6XXX_FAMILY_6250,
4831 .name = "Marvell 88E6220",
4832 .num_databases = 64,
4833
4834 /* Ports 2-4 are not routed to pins
4835 * => usable ports 0, 1, 5, 6
4836 */
4837 .num_ports = 7,
4838 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004839 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004840 .max_vid = 4095,
4841 .port_base_addr = 0x08,
4842 .phy_base_addr = 0x00,
4843 .global1_addr = 0x0f,
4844 .global2_addr = 0x07,
4845 .age_time_coeff = 15000,
4846 .g1_irqs = 9,
4847 .g2_irqs = 10,
4848 .atu_move_port_mask = 0xf,
4849 .dual_chip = true,
4850 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004851 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004852 .ops = &mv88e6250_ops,
4853 },
4854
Vivien Didelotf81ec902016-05-09 13:22:58 -04004855 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004856 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004857 .family = MV88E6XXX_FAMILY_6352,
4858 .name = "Marvell 88E6240",
4859 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004860 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004861 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004862 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004863 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004864 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004865 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004866 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004867 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004868 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004869 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004870 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004871 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004872 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004873 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004874 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004875 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004876 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004877 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004878 },
4879
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004880 [MV88E6250] = {
4881 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4882 .family = MV88E6XXX_FAMILY_6250,
4883 .name = "Marvell 88E6250",
4884 .num_databases = 64,
4885 .num_ports = 7,
4886 .num_internal_phys = 5,
4887 .max_vid = 4095,
4888 .port_base_addr = 0x08,
4889 .phy_base_addr = 0x00,
4890 .global1_addr = 0x0f,
4891 .global2_addr = 0x07,
4892 .age_time_coeff = 15000,
4893 .g1_irqs = 9,
4894 .g2_irqs = 10,
4895 .atu_move_port_mask = 0xf,
4896 .dual_chip = true,
4897 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004898 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004899 .ops = &mv88e6250_ops,
4900 },
4901
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004902 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004903 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004904 .family = MV88E6XXX_FAMILY_6390,
4905 .name = "Marvell 88E6290",
4906 .num_databases = 4096,
4907 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004908 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004909 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004910 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004911 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004912 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004913 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004914 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004915 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004916 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004917 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004918 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004919 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004920 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004921 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004922 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004923 .ops = &mv88e6290_ops,
4924 },
4925
Vivien Didelotf81ec902016-05-09 13:22:58 -04004926 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004927 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004928 .family = MV88E6XXX_FAMILY_6320,
4929 .name = "Marvell 88E6320",
4930 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004931 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004932 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004933 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004934 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004935 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004936 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004937 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004938 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004939 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004940 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004941 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004942 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004943 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004944 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004945 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004946 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004947 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004948 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004949 },
4950
4951 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004952 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004953 .family = MV88E6XXX_FAMILY_6320,
4954 .name = "Marvell 88E6321",
4955 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004956 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004957 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004958 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004959 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004960 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004961 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004962 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004963 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004964 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004965 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004966 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004967 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004968 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004969 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004970 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004971 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004972 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004973 },
4974
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004975 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004976 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004977 .family = MV88E6XXX_FAMILY_6341,
4978 .name = "Marvell 88E6341",
4979 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004980 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01004981 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004982 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004983 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004984 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004985 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004986 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004987 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004988 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004989 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004990 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004991 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004992 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004993 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004994 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004995 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004996 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004997 .ops = &mv88e6341_ops,
4998 },
4999
Vivien Didelotf81ec902016-05-09 13:22:58 -04005000 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005001 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005002 .family = MV88E6XXX_FAMILY_6351,
5003 .name = "Marvell 88E6350",
5004 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005005 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005006 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005007 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005008 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005009 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005010 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005011 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005012 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005013 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005014 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005015 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005016 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005017 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005018 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005019 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005020 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005021 },
5022
5023 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005024 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005025 .family = MV88E6XXX_FAMILY_6351,
5026 .name = "Marvell 88E6351",
5027 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005028 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005029 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005030 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005031 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005032 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005033 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005034 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005035 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005036 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005037 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005038 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005039 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005040 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005041 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005042 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005043 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005044 },
5045
5046 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005047 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005048 .family = MV88E6XXX_FAMILY_6352,
5049 .name = "Marvell 88E6352",
5050 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005051 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005052 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005053 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005054 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005055 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005056 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005057 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005058 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005059 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005060 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005061 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005062 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005063 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005064 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005065 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005066 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005067 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005068 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005069 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005070 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005071 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005072 .family = MV88E6XXX_FAMILY_6390,
5073 .name = "Marvell 88E6390",
5074 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005075 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005076 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005077 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005078 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005079 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005080 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005081 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005082 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005083 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005084 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005085 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005086 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005087 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005088 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005089 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005090 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005091 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005092 .ops = &mv88e6390_ops,
5093 },
5094 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005095 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005096 .family = MV88E6XXX_FAMILY_6390,
5097 .name = "Marvell 88E6390X",
5098 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005099 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005100 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005101 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005102 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005103 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005104 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005105 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005106 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005107 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005108 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005109 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005110 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005111 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005112 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005113 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005114 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005115 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005116 .ops = &mv88e6390x_ops,
5117 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005118};
5119
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005120static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005121{
Vivien Didelota439c062016-04-17 13:23:58 -04005122 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005123
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005124 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5125 if (mv88e6xxx_table[i].prod_num == prod_num)
5126 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005127
Vivien Didelotb9b37712015-10-30 19:39:48 -04005128 return NULL;
5129}
5130
Vivien Didelotfad09c72016-06-21 12:28:20 -04005131static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005132{
5133 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005134 unsigned int prod_num, rev;
5135 u16 id;
5136 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005137
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005138 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005139 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005140 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005141 if (err)
5142 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005143
Vivien Didelot107fcc12017-06-12 12:37:36 -04005144 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5145 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005146
5147 info = mv88e6xxx_lookup_info(prod_num);
5148 if (!info)
5149 return -ENODEV;
5150
Vivien Didelotcaac8542016-06-20 13:14:09 -04005151 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005152 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005153
Vivien Didelotca070c12016-09-02 14:45:34 -04005154 err = mv88e6xxx_g2_require(chip);
5155 if (err)
5156 return err;
5157
Vivien Didelotfad09c72016-06-21 12:28:20 -04005158 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5159 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005160
5161 return 0;
5162}
5163
Vivien Didelotfad09c72016-06-21 12:28:20 -04005164static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005165{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005166 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005167
Vivien Didelotfad09c72016-06-21 12:28:20 -04005168 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5169 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005170 return NULL;
5171
Vivien Didelotfad09c72016-06-21 12:28:20 -04005172 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005173
Vivien Didelotfad09c72016-06-21 12:28:20 -04005174 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005175 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005176 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005177
Vivien Didelotfad09c72016-06-21 12:28:20 -04005178 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005179}
5180
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005181static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005182 int port,
5183 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005184{
Vivien Didelot04bed142016-08-31 18:06:13 -04005185 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005186
Andrew Lunn443d5a12016-12-03 04:35:18 +01005187 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005188}
5189
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005190static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005191 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005192{
5193 /* We don't need any dynamic resource from the kernel (yet),
5194 * so skip the prepare phase.
5195 */
5196
5197 return 0;
5198}
5199
5200static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005201 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005202{
Vivien Didelot04bed142016-08-31 18:06:13 -04005203 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005204
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005205 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005206 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005207 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005208 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5209 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005210 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005211}
5212
5213static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5214 const struct switchdev_obj_port_mdb *mdb)
5215{
Vivien Didelot04bed142016-08-31 18:06:13 -04005216 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005217 int err;
5218
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005219 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005220 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005221 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005222
5223 return err;
5224}
5225
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005226static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5227 struct dsa_mall_mirror_tc_entry *mirror,
5228 bool ingress)
5229{
5230 enum mv88e6xxx_egress_direction direction = ingress ?
5231 MV88E6XXX_EGRESS_DIR_INGRESS :
5232 MV88E6XXX_EGRESS_DIR_EGRESS;
5233 struct mv88e6xxx_chip *chip = ds->priv;
5234 bool other_mirrors = false;
5235 int i;
5236 int err;
5237
5238 if (!chip->info->ops->set_egress_port)
5239 return -EOPNOTSUPP;
5240
5241 mutex_lock(&chip->reg_lock);
5242 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5243 mirror->to_local_port) {
5244 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5245 other_mirrors |= ingress ?
5246 chip->ports[i].mirror_ingress :
5247 chip->ports[i].mirror_egress;
5248
5249 /* Can't change egress port when other mirror is active */
5250 if (other_mirrors) {
5251 err = -EBUSY;
5252 goto out;
5253 }
5254
5255 err = chip->info->ops->set_egress_port(chip,
5256 direction,
5257 mirror->to_local_port);
5258 if (err)
5259 goto out;
5260 }
5261
5262 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5263out:
5264 mutex_unlock(&chip->reg_lock);
5265
5266 return err;
5267}
5268
5269static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5270 struct dsa_mall_mirror_tc_entry *mirror)
5271{
5272 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5273 MV88E6XXX_EGRESS_DIR_INGRESS :
5274 MV88E6XXX_EGRESS_DIR_EGRESS;
5275 struct mv88e6xxx_chip *chip = ds->priv;
5276 bool other_mirrors = false;
5277 int i;
5278
5279 mutex_lock(&chip->reg_lock);
5280 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5281 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5282
5283 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5284 other_mirrors |= mirror->ingress ?
5285 chip->ports[i].mirror_ingress :
5286 chip->ports[i].mirror_egress;
5287
5288 /* Reset egress port when no other mirror is active */
5289 if (!other_mirrors) {
5290 if (chip->info->ops->set_egress_port(chip,
5291 direction,
5292 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005293 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005294 dev_err(ds->dev, "failed to set egress port\n");
5295 }
5296
5297 mutex_unlock(&chip->reg_lock);
5298}
5299
Russell King4f859012019-02-20 15:35:05 -08005300static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5301 bool unicast, bool multicast)
5302{
5303 struct mv88e6xxx_chip *chip = ds->priv;
5304 int err = -EOPNOTSUPP;
5305
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005306 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005307 if (chip->info->ops->port_set_egress_floods)
5308 err = chip->info->ops->port_set_egress_floods(chip, port,
5309 unicast,
5310 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005311 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005312
5313 return err;
5314}
5315
Florian Fainellia82f67a2017-01-08 14:52:08 -08005316static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005317 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005318 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005319 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005320 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005321 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005322 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005323 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005324 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5325 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005326 .get_strings = mv88e6xxx_get_strings,
5327 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5328 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005329 .port_enable = mv88e6xxx_port_enable,
5330 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005331 .port_max_mtu = mv88e6xxx_get_max_mtu,
5332 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005333 .get_mac_eee = mv88e6xxx_get_mac_eee,
5334 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005335 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005336 .get_eeprom = mv88e6xxx_get_eeprom,
5337 .set_eeprom = mv88e6xxx_set_eeprom,
5338 .get_regs_len = mv88e6xxx_get_regs_len,
5339 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005340 .get_rxnfc = mv88e6xxx_get_rxnfc,
5341 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005342 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005343 .port_bridge_join = mv88e6xxx_port_bridge_join,
5344 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005345 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005346 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005347 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005348 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5349 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5350 .port_vlan_add = mv88e6xxx_port_vlan_add,
5351 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005352 .port_fdb_add = mv88e6xxx_port_fdb_add,
5353 .port_fdb_del = mv88e6xxx_port_fdb_del,
5354 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005355 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5356 .port_mdb_add = mv88e6xxx_port_mdb_add,
5357 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005358 .port_mirror_add = mv88e6xxx_port_mirror_add,
5359 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005360 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5361 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005362 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5363 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5364 .port_txtstamp = mv88e6xxx_port_txtstamp,
5365 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5366 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005367 .devlink_param_get = mv88e6xxx_devlink_param_get,
5368 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005369};
5370
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005371static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005372{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005373 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005374 struct dsa_switch *ds;
5375
Vivien Didelot7e99e342019-10-21 16:51:30 -04005376 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005377 if (!ds)
5378 return -ENOMEM;
5379
Vivien Didelot7e99e342019-10-21 16:51:30 -04005380 ds->dev = dev;
5381 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005382 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005383 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005384 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005385 ds->ageing_time_min = chip->info->age_time_coeff;
5386 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005387
5388 dev_set_drvdata(dev, ds);
5389
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005390 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005391}
5392
Vivien Didelotfad09c72016-06-21 12:28:20 -04005393static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005394{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005395 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005396}
5397
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005398static const void *pdata_device_get_match_data(struct device *dev)
5399{
5400 const struct of_device_id *matches = dev->driver->of_match_table;
5401 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5402
5403 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5404 matches++) {
5405 if (!strcmp(pdata->compatible, matches->compatible))
5406 return matches->data;
5407 }
5408 return NULL;
5409}
5410
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005411/* There is no suspend to RAM support at DSA level yet, the switch configuration
5412 * would be lost after a power cycle so prevent it to be suspended.
5413 */
5414static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5415{
5416 return -EOPNOTSUPP;
5417}
5418
5419static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5420{
5421 return 0;
5422}
5423
5424static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5425
Vivien Didelot57d32312016-06-20 13:13:58 -04005426static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005427{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005428 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005429 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005430 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005431 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005432 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005433 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005434 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005435
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005436 if (!np && !pdata)
5437 return -EINVAL;
5438
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005439 if (np)
5440 compat_info = of_device_get_match_data(dev);
5441
5442 if (pdata) {
5443 compat_info = pdata_device_get_match_data(dev);
5444
5445 if (!pdata->netdev)
5446 return -EINVAL;
5447
5448 for (port = 0; port < DSA_MAX_PORTS; port++) {
5449 if (!(pdata->enabled_ports & (1 << port)))
5450 continue;
5451 if (strcmp(pdata->cd.port_names[port], "cpu"))
5452 continue;
5453 pdata->cd.netdev[port] = &pdata->netdev->dev;
5454 break;
5455 }
5456 }
5457
Vivien Didelotcaac8542016-06-20 13:14:09 -04005458 if (!compat_info)
5459 return -EINVAL;
5460
Vivien Didelotfad09c72016-06-21 12:28:20 -04005461 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005462 if (!chip) {
5463 err = -ENOMEM;
5464 goto out;
5465 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005466
Vivien Didelotfad09c72016-06-21 12:28:20 -04005467 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005468
Vivien Didelotfad09c72016-06-21 12:28:20 -04005469 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005470 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005471 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005472
Andrew Lunnb4308f02016-11-21 23:26:55 +01005473 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005474 if (IS_ERR(chip->reset)) {
5475 err = PTR_ERR(chip->reset);
5476 goto out;
5477 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005478 if (chip->reset)
5479 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005480
Vivien Didelotfad09c72016-06-21 12:28:20 -04005481 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005482 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005483 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005484
Vivien Didelote57e5e72016-08-15 17:19:00 -04005485 mv88e6xxx_phy_init(chip);
5486
Andrew Lunn00baabe2018-05-19 22:31:35 +02005487 if (chip->info->ops->get_eeprom) {
5488 if (np)
5489 of_property_read_u32(np, "eeprom-length",
5490 &chip->eeprom_len);
5491 else
5492 chip->eeprom_len = pdata->eeprom_len;
5493 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005494
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005495 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005496 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005497 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005498 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005499 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005500
Andrew Lunna27415d2019-05-01 00:10:50 +02005501 if (np) {
5502 chip->irq = of_irq_get(np, 0);
5503 if (chip->irq == -EPROBE_DEFER) {
5504 err = chip->irq;
5505 goto out;
5506 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005507 }
5508
Andrew Lunna27415d2019-05-01 00:10:50 +02005509 if (pdata)
5510 chip->irq = pdata->irq;
5511
Andrew Lunn294d7112018-02-22 22:58:32 +01005512 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005513 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005514 * controllers
5515 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005516 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005517 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005518 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005519 else
5520 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005521 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005522
Andrew Lunn294d7112018-02-22 22:58:32 +01005523 if (err)
5524 goto out;
5525
5526 if (chip->info->g2_irqs > 0) {
5527 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005528 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005529 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005530 }
5531
Andrew Lunn294d7112018-02-22 22:58:32 +01005532 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5533 if (err)
5534 goto out_g2_irq;
5535
5536 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5537 if (err)
5538 goto out_g1_atu_prob_irq;
5539
Andrew Lunna3c53be52017-01-24 14:53:50 +01005540 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005541 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005542 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005543
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005544 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005545 if (err)
5546 goto out_mdio;
5547
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005548 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005549
5550out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005551 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005552out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005553 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005554out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005555 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005556out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005557 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005558 mv88e6xxx_g2_irq_free(chip);
5559out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005560 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005561 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005562 else
5563 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005564out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005565 if (pdata)
5566 dev_put(pdata->netdev);
5567
Andrew Lunndc30c352016-10-16 19:56:49 +02005568 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005569}
5570
5571static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5572{
5573 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005574 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005575
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005576 if (chip->info->ptp_support) {
5577 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005578 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005579 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005580
Andrew Lunn930188c2016-08-22 16:01:03 +02005581 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005582 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005583 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005584
Andrew Lunn76f38f12018-03-17 20:21:09 +01005585 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5586 mv88e6xxx_g1_atu_prob_irq_free(chip);
5587
5588 if (chip->info->g2_irqs > 0)
5589 mv88e6xxx_g2_irq_free(chip);
5590
Andrew Lunn76f38f12018-03-17 20:21:09 +01005591 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005592 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005593 else
5594 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005595}
5596
5597static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005598 {
5599 .compatible = "marvell,mv88e6085",
5600 .data = &mv88e6xxx_table[MV88E6085],
5601 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005602 {
5603 .compatible = "marvell,mv88e6190",
5604 .data = &mv88e6xxx_table[MV88E6190],
5605 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005606 {
5607 .compatible = "marvell,mv88e6250",
5608 .data = &mv88e6xxx_table[MV88E6250],
5609 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005610 { /* sentinel */ },
5611};
5612
5613MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5614
5615static struct mdio_driver mv88e6xxx_driver = {
5616 .probe = mv88e6xxx_probe,
5617 .remove = mv88e6xxx_remove,
5618 .mdiodrv.driver = {
5619 .name = "mv88e6085",
5620 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005621 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005622 },
5623};
5624
Andrew Lunn7324d502019-04-27 19:19:10 +02005625mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005626
5627MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5628MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5629MODULE_LICENSE("GPL");