blob: 04ef4d00f1349ac098738181e8a489f36ed8a4bc [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"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100400int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
401 int speed, int duplex, int pause,
402 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100403{
Andrew Lunna26deec2019-04-18 03:11:39 +0200404 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100405 int err;
406
407 if (!chip->info->ops->port_set_link)
408 return 0;
409
Andrew Lunna26deec2019-04-18 03:11:39 +0200410 if (!chip->info->ops->port_link_state)
411 return 0;
412
413 err = chip->info->ops->port_link_state(chip, port, &state);
414 if (err)
415 return err;
416
417 /* Has anything actually changed? We don't expect the
418 * interface mode to change without one of the other
419 * parameters also changing
420 */
421 if (state.link == link &&
422 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200423 state.duplex == duplex &&
424 (state.interface == mode ||
425 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 return 0;
427
Vivien Didelotd78343d2016-11-04 03:23:36 +0100428 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200429 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100430 if (err)
431 return err;
432
433 if (chip->info->ops->port_set_speed) {
434 err = chip->info->ops->port_set_speed(chip, port, speed);
435 if (err && err != -EOPNOTSUPP)
436 goto restore_link;
437 }
438
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100439 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
440 mode = chip->info->ops->port_max_speed_mode(port);
441
Andrew Lunn54186b92018-08-09 15:38:37 +0200442 if (chip->info->ops->port_set_pause) {
443 err = chip->info->ops->port_set_pause(chip, port, pause);
444 if (err)
445 goto restore_link;
446 }
447
Vivien Didelotd78343d2016-11-04 03:23:36 +0100448 if (chip->info->ops->port_set_duplex) {
449 err = chip->info->ops->port_set_duplex(chip, port, duplex);
450 if (err && err != -EOPNOTSUPP)
451 goto restore_link;
452 }
453
454 if (chip->info->ops->port_set_rgmii_delay) {
455 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
456 if (err && err != -EOPNOTSUPP)
457 goto restore_link;
458 }
459
Andrew Lunnf39908d2017-02-04 20:02:50 +0100460 if (chip->info->ops->port_set_cmode) {
461 err = chip->info->ops->port_set_cmode(chip, port, mode);
462 if (err && err != -EOPNOTSUPP)
463 goto restore_link;
464 }
465
Vivien Didelotd78343d2016-11-04 03:23:36 +0100466 err = 0;
467restore_link:
468 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400469 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470
471 return err;
472}
473
Marek Vasutd700ec42018-09-12 00:15:24 +0200474static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
475{
476 struct mv88e6xxx_chip *chip = ds->priv;
477
478 return port < chip->info->num_internal_phys;
479}
480
Russell King6c422e32018-08-09 15:38:39 +0200481static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
482 unsigned long *mask,
483 struct phylink_link_state *state)
484{
485 if (!phy_interface_mode_is_8023z(state->interface)) {
486 /* 10M and 100M are only supported in non-802.3z mode */
487 phylink_set(mask, 10baseT_Half);
488 phylink_set(mask, 10baseT_Full);
489 phylink_set(mask, 100baseT_Half);
490 phylink_set(mask, 100baseT_Full);
491 }
492}
493
494static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
495 unsigned long *mask,
496 struct phylink_link_state *state)
497{
498 /* FIXME: if the port is in 1000Base-X mode, then it only supports
499 * 1000M FD speeds. In this case, CMODE will indicate 5.
500 */
501 phylink_set(mask, 1000baseT_Full);
502 phylink_set(mask, 1000baseX_Full);
503
504 mv88e6065_phylink_validate(chip, port, mask, state);
505}
506
Marek Behúne3af71a2019-02-25 12:39:55 +0100507static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
508 unsigned long *mask,
509 struct phylink_link_state *state)
510{
511 if (port >= 5)
512 phylink_set(mask, 2500baseX_Full);
513
514 /* No ethtool bits for 200Mbps */
515 phylink_set(mask, 1000baseT_Full);
516 phylink_set(mask, 1000baseX_Full);
517
518 mv88e6065_phylink_validate(chip, port, mask, state);
519}
520
Russell King6c422e32018-08-09 15:38:39 +0200521static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
522 unsigned long *mask,
523 struct phylink_link_state *state)
524{
525 /* No ethtool bits for 200Mbps */
526 phylink_set(mask, 1000baseT_Full);
527 phylink_set(mask, 1000baseX_Full);
528
529 mv88e6065_phylink_validate(chip, port, mask, state);
530}
531
532static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
533 unsigned long *mask,
534 struct phylink_link_state *state)
535{
Andrew Lunnec260162019-02-08 22:25:44 +0100536 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200537 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100538 phylink_set(mask, 2500baseT_Full);
539 }
Russell King6c422e32018-08-09 15:38:39 +0200540
541 /* No ethtool bits for 200Mbps */
542 phylink_set(mask, 1000baseT_Full);
543 phylink_set(mask, 1000baseX_Full);
544
545 mv88e6065_phylink_validate(chip, port, mask, state);
546}
547
548static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
549 unsigned long *mask,
550 struct phylink_link_state *state)
551{
552 if (port >= 9) {
553 phylink_set(mask, 10000baseT_Full);
554 phylink_set(mask, 10000baseKR_Full);
555 }
556
557 mv88e6390_phylink_validate(chip, port, mask, state);
558}
559
Russell Kingc9a23562018-05-10 13:17:35 -0700560static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
561 unsigned long *supported,
562 struct phylink_link_state *state)
563{
Russell King6c422e32018-08-09 15:38:39 +0200564 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
565 struct mv88e6xxx_chip *chip = ds->priv;
566
567 /* Allow all the expected bits */
568 phylink_set(mask, Autoneg);
569 phylink_set(mask, Pause);
570 phylink_set_port_modes(mask);
571
572 if (chip->info->ops->phylink_validate)
573 chip->info->ops->phylink_validate(chip, port, mask, state);
574
575 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
576 bitmap_and(state->advertising, state->advertising, mask,
577 __ETHTOOL_LINK_MODE_MASK_NBITS);
578
579 /* We can only operate at 2500BaseX or 1000BaseX. If requested
580 * to advertise both, only report advertising at 2500BaseX.
581 */
582 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700583}
584
585static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
586 struct phylink_link_state *state)
587{
588 struct mv88e6xxx_chip *chip = ds->priv;
589 int err;
590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000591 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200592 if (chip->info->ops->port_link_state)
593 err = chip->info->ops->port_link_state(chip, port, state);
594 else
595 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000596 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700597
598 return err;
599}
600
601static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
602 unsigned int mode,
603 const struct phylink_link_state *state)
604{
605 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200606 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700607
Marek Vasutd700ec42018-09-12 00:15:24 +0200608 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700609 return;
610
611 if (mode == MLO_AN_FIXED) {
612 link = LINK_FORCED_UP;
613 speed = state->speed;
614 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200615 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
616 link = state->link;
617 speed = state->speed;
618 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700619 } else {
620 speed = SPEED_UNFORCED;
621 duplex = DUPLEX_UNFORCED;
622 link = LINK_UNFORCED;
623 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700625
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700628 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000629 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700630
631 if (err && err != -EOPNOTSUPP)
632 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
633}
634
635static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
636{
637 struct mv88e6xxx_chip *chip = ds->priv;
638 int err;
639
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000640 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700641 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000642 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700643
644 if (err)
645 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
646}
647
648static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
649 unsigned int mode,
650 phy_interface_t interface)
651{
652 if (mode == MLO_AN_FIXED)
653 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
654}
655
656static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
657 unsigned int mode, phy_interface_t interface,
658 struct phy_device *phydev)
659{
660 if (mode == MLO_AN_FIXED)
661 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
662}
663
Andrew Lunna605a0f2016-11-21 23:26:58 +0100664static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 if (!chip->info->ops->stats_snapshot)
667 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000668
Andrew Lunna605a0f2016-11-21 23:26:58 +0100669 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000670}
671
Andrew Lunne413e7e2015-04-02 04:06:38 +0200672static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100673 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
674 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
675 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
676 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
677 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
678 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
679 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
680 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
681 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
682 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
683 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
684 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
685 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
686 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
687 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
688 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
689 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
690 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
691 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
692 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
693 { "single", 4, 0x14, STATS_TYPE_BANK0, },
694 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
695 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
696 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
697 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
698 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
699 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
700 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
701 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
702 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
703 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
704 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
705 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
706 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
707 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
708 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
709 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
710 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
711 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
712 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
713 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
714 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
715 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
716 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
717 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
718 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
719 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
720 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
721 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
722 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
723 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
724 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
725 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
726 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
727 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
728 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
729 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
730 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
731 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200732};
733
Vivien Didelotfad09c72016-06-21 12:28:20 -0400734static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100735 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100736 int port, u16 bank1_select,
737 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200738{
Andrew Lunn80c46272015-06-20 18:42:30 +0200739 u32 low;
740 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100741 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200742 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200743 u64 value;
744
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100745 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100746 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200747 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
748 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800749 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200750
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200751 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100752 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200753 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
754 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800755 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000756 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200757 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100758 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100759 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100761 /* fall through */
762 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100763 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100764 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100765 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100766 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500767 break;
768 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800769 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200770 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100771 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200772 return value;
773}
774
Andrew Lunn436fe172018-03-01 02:02:29 +0100775static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
776 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100777{
778 struct mv88e6xxx_hw_stat *stat;
779 int i, j;
780
781 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
782 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100783 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100784 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
785 ETH_GSTRING_LEN);
786 j++;
787 }
788 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100789
790 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100791}
792
Andrew Lunn436fe172018-03-01 02:02:29 +0100793static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
794 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100795{
Andrew Lunn436fe172018-03-01 02:02:29 +0100796 return mv88e6xxx_stats_get_strings(chip, data,
797 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100798}
799
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000800static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
801 uint8_t *data)
802{
803 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
804}
805
Andrew Lunn436fe172018-03-01 02:02:29 +0100806static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
807 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100808{
Andrew Lunn436fe172018-03-01 02:02:29 +0100809 return mv88e6xxx_stats_get_strings(chip, data,
810 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100811}
812
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
814 "atu_member_violation",
815 "atu_miss_violation",
816 "atu_full_violation",
817 "vtu_member_violation",
818 "vtu_miss_violation",
819};
820
821static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
822{
823 unsigned int i;
824
825 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
826 strlcpy(data + i * ETH_GSTRING_LEN,
827 mv88e6xxx_atu_vtu_stats_strings[i],
828 ETH_GSTRING_LEN);
829}
830
Andrew Lunndfafe442016-11-21 23:27:02 +0100831static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700832 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100833{
Vivien Didelot04bed142016-08-31 18:06:13 -0400834 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100835 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100836
Florian Fainelli89f09042018-04-25 12:12:50 -0700837 if (stringset != ETH_SS_STATS)
838 return;
839
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000840 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100841
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100843 count = chip->info->ops->stats_get_strings(chip, data);
844
845 if (chip->info->ops->serdes_get_strings) {
846 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100848 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100849
Andrew Lunn65f60e42018-03-28 23:50:28 +0200850 data += count * ETH_GSTRING_LEN;
851 mv88e6xxx_atu_vtu_get_strings(data);
852
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000853 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100854}
855
856static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
857 int types)
858{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 struct mv88e6xxx_hw_stat *stat;
860 int i, j;
861
862 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
863 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865 j++;
866 }
867 return j;
868}
869
Andrew Lunndfafe442016-11-21 23:27:02 +0100870static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
871{
872 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
873 STATS_TYPE_PORT);
874}
875
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000876static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
877{
878 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
879}
880
Andrew Lunndfafe442016-11-21 23:27:02 +0100881static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
882{
883 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
884 STATS_TYPE_BANK1);
885}
886
Florian Fainelli89f09042018-04-25 12:12:50 -0700887static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100888{
889 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 int serdes_count = 0;
891 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100892
Florian Fainelli89f09042018-04-25 12:12:50 -0700893 if (sset != ETH_SS_STATS)
894 return 0;
895
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000896 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100898 count = chip->info->ops->stats_get_sset_count(chip);
899 if (count < 0)
900 goto out;
901
902 if (chip->info->ops->serdes_get_sset_count)
903 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
904 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200905 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100906 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907 goto out;
908 }
909 count += serdes_count;
910 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000913 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Andrew Lunn436fe172018-03-01 02:02:29 +0100918static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
919 uint64_t *data, int types,
920 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100921{
922 struct mv88e6xxx_hw_stat *stat;
923 int i, j;
924
925 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
926 stat = &mv88e6xxx_hw_stats[i];
927 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000928 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100929 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
930 bank1_select,
931 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000932 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100933
Andrew Lunn052f9472016-11-21 23:27:03 +0100934 j++;
935 }
936 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100938}
939
Andrew Lunn436fe172018-03-01 02:02:29 +0100940static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
941 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100942{
943 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100944 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400945 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100946}
947
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000948static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
949 uint64_t *data)
950{
951 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
952 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
953}
954
Andrew Lunn436fe172018-03-01 02:02:29 +0100955static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
956 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100957{
958 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400960 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
961 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100962}
963
Andrew Lunn436fe172018-03-01 02:02:29 +0100964static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
965 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100966{
967 return mv88e6xxx_stats_get_stats(chip, port, data,
968 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400969 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
970 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100971}
972
Andrew Lunn65f60e42018-03-28 23:50:28 +0200973static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
974 uint64_t *data)
975{
976 *data++ = chip->ports[port].atu_member_violation;
977 *data++ = chip->ports[port].atu_miss_violation;
978 *data++ = chip->ports[port].atu_full_violation;
979 *data++ = chip->ports[port].vtu_member_violation;
980 *data++ = chip->ports[port].vtu_miss_violation;
981}
982
Andrew Lunn052f9472016-11-21 23:27:03 +0100983static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
985{
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 int count = 0;
987
Andrew Lunn052f9472016-11-21 23:27:03 +0100988 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 count = chip->info->ops->stats_get_stats(chip, port, data);
990
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000991 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 if (chip->info->ops->serdes_get_stats) {
993 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 data += count;
997 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000998 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100999}
1000
Vivien Didelotf81ec902016-05-09 13:22:58 -04001001static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1002 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003{
Vivien Didelot04bed142016-08-31 18:06:13 -04001004 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001006
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001008
Andrew Lunna605a0f2016-11-21 23:26:58 +01001009 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001011
1012 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001014
1015 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017}
Ben Hutchings98e67302011-11-25 14:36:19 +00001018
Vivien Didelotf81ec902016-05-09 13:22:58 -04001019static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001020{
1021 return 32 * sizeof(u16);
1022}
1023
Vivien Didelotf81ec902016-05-09 13:22:58 -04001024static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1025 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001026{
Vivien Didelot04bed142016-08-31 18:06:13 -04001027 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001028 int err;
1029 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001030 u16 *p = _p;
1031 int i;
1032
Vivien Didelota5f39322018-12-17 16:05:21 -05001033 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001034
1035 memset(p, 0xff, 32 * sizeof(u16));
1036
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001037 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001038
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001039 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001040
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001041 err = mv88e6xxx_port_read(chip, port, i, &reg);
1042 if (!err)
1043 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044 }
Vivien Didelot23062512016-05-09 13:22:45 -04001045
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047}
1048
Vivien Didelot08f50062017-08-01 16:32:41 -04001049static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1050 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001051{
Vivien Didelot5480db62017-08-01 16:32:40 -04001052 /* Nothing to do on the port's MAC */
1053 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001054}
1055
Vivien Didelot08f50062017-08-01 16:32:41 -04001056static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1057 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001058{
Vivien Didelot5480db62017-08-01 16:32:40 -04001059 /* Nothing to do on the port's MAC */
1060 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061}
1062
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001063/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001064static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001065{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001066 struct dsa_switch *ds = chip->ds;
1067 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001068 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001069 struct dsa_port *dp;
1070 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001071 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001072
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001073 list_for_each_entry(dp, &dst->ports, list) {
1074 if (dp->ds->index == dev && dp->index == port) {
1075 found = true;
1076 break;
1077 }
1078 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001079
Vivien Didelote5887a22017-03-30 17:37:11 -04001080 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001081 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001082 return 0;
1083
1084 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001085 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001086 return mv88e6xxx_port_mask(chip);
1087
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001088 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001089 pvlan = 0;
1090
1091 /* Frames from user ports can egress any local DSA links and CPU ports,
1092 * as well as any local member of their bridge group.
1093 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001094 list_for_each_entry(dp, &dst->ports, list)
1095 if (dp->ds == ds &&
1096 (dp->type == DSA_PORT_TYPE_CPU ||
1097 dp->type == DSA_PORT_TYPE_DSA ||
1098 (br && dp->bridge_dev == br)))
1099 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001100
1101 return pvlan;
1102}
1103
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001104static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001105{
1106 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001107
1108 /* prevent frames from going back out of the port they came in on */
1109 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001110
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001111 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001112}
1113
Vivien Didelotf81ec902016-05-09 13:22:58 -04001114static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1115 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001116{
Vivien Didelot04bed142016-08-31 18:06:13 -04001117 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001118 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001119
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001120 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001121 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001122 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001123
1124 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001125 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001126}
1127
Vivien Didelot93e18d62018-05-11 17:16:35 -04001128static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1129{
1130 int err;
1131
1132 if (chip->info->ops->ieee_pri_map) {
1133 err = chip->info->ops->ieee_pri_map(chip);
1134 if (err)
1135 return err;
1136 }
1137
1138 if (chip->info->ops->ip_pri_map) {
1139 err = chip->info->ops->ip_pri_map(chip);
1140 if (err)
1141 return err;
1142 }
1143
1144 return 0;
1145}
1146
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001147static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1148{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001149 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001150 int target, port;
1151 int err;
1152
1153 if (!chip->info->global2_addr)
1154 return 0;
1155
1156 /* Initialize the routing port to the 32 possible target devices */
1157 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001158 port = dsa_routing_port(ds, target);
1159 if (port == ds->num_ports)
1160 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001161
1162 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1163 if (err)
1164 return err;
1165 }
1166
Vivien Didelot02317e62018-05-09 11:38:49 -04001167 if (chip->info->ops->set_cascade_port) {
1168 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1169 err = chip->info->ops->set_cascade_port(chip, port);
1170 if (err)
1171 return err;
1172 }
1173
Vivien Didelot23c98912018-05-09 11:38:50 -04001174 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1175 if (err)
1176 return err;
1177
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001178 return 0;
1179}
1180
Vivien Didelotb28f8722018-04-26 21:56:44 -04001181static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1182{
1183 /* Clear all trunk masks and mapping */
1184 if (chip->info->global2_addr)
1185 return mv88e6xxx_g2_trunk_clear(chip);
1186
1187 return 0;
1188}
1189
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001190static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1191{
1192 if (chip->info->ops->rmu_disable)
1193 return chip->info->ops->rmu_disable(chip);
1194
1195 return 0;
1196}
1197
Vivien Didelot9e907d72017-07-17 13:03:43 -04001198static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1199{
1200 if (chip->info->ops->pot_clear)
1201 return chip->info->ops->pot_clear(chip);
1202
1203 return 0;
1204}
1205
Vivien Didelot51c901a2017-07-17 13:03:41 -04001206static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1207{
1208 if (chip->info->ops->mgmt_rsvd2cpu)
1209 return chip->info->ops->mgmt_rsvd2cpu(chip);
1210
1211 return 0;
1212}
1213
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001214static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1215{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001216 int err;
1217
Vivien Didelotdaefc942017-03-11 16:12:54 -05001218 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1219 if (err)
1220 return err;
1221
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001222 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1223 if (err)
1224 return err;
1225
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001226 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1227}
1228
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001229static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1230{
1231 int port;
1232 int err;
1233
1234 if (!chip->info->ops->irl_init_all)
1235 return 0;
1236
1237 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1238 /* Disable ingress rate limiting by resetting all per port
1239 * ingress rate limit resources to their initial state.
1240 */
1241 err = chip->info->ops->irl_init_all(chip, port);
1242 if (err)
1243 return err;
1244 }
1245
1246 return 0;
1247}
1248
Vivien Didelot04a69a12017-10-13 14:18:05 -04001249static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1250{
1251 if (chip->info->ops->set_switch_mac) {
1252 u8 addr[ETH_ALEN];
1253
1254 eth_random_addr(addr);
1255
1256 return chip->info->ops->set_switch_mac(chip, addr);
1257 }
1258
1259 return 0;
1260}
1261
Vivien Didelot17a15942017-03-30 17:37:09 -04001262static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1263{
1264 u16 pvlan = 0;
1265
1266 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001267 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001268
1269 /* Skip the local source device, which uses in-chip port VLAN */
1270 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001271 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001272
1273 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1274}
1275
Vivien Didelot81228992017-03-30 17:37:08 -04001276static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1277{
Vivien Didelot17a15942017-03-30 17:37:09 -04001278 int dev, port;
1279 int err;
1280
Vivien Didelot81228992017-03-30 17:37:08 -04001281 if (!mv88e6xxx_has_pvt(chip))
1282 return 0;
1283
1284 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1285 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1286 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001287 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1288 if (err)
1289 return err;
1290
1291 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1292 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1293 err = mv88e6xxx_pvt_map(chip, dev, port);
1294 if (err)
1295 return err;
1296 }
1297 }
1298
1299 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001300}
1301
Vivien Didelot749efcb2016-09-22 16:49:24 -04001302static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1303{
1304 struct mv88e6xxx_chip *chip = ds->priv;
1305 int err;
1306
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001307 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001308 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001309 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001310
1311 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001312 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001313}
1314
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001315static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1316{
1317 if (!chip->info->max_vid)
1318 return 0;
1319
1320 return mv88e6xxx_g1_vtu_flush(chip);
1321}
1322
Vivien Didelotf1394b782017-05-01 14:05:22 -04001323static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1324 struct mv88e6xxx_vtu_entry *entry)
1325{
1326 if (!chip->info->ops->vtu_getnext)
1327 return -EOPNOTSUPP;
1328
1329 return chip->info->ops->vtu_getnext(chip, entry);
1330}
1331
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001332static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1333 struct mv88e6xxx_vtu_entry *entry)
1334{
1335 if (!chip->info->ops->vtu_loadpurge)
1336 return -EOPNOTSUPP;
1337
1338 return chip->info->ops->vtu_loadpurge(chip, entry);
1339}
1340
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001341static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001342{
1343 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001344 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001345 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001346
1347 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1348
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001349 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001350 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001351 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001352 if (err)
1353 return err;
1354
1355 set_bit(*fid, fid_bitmap);
1356 }
1357
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001358 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001359 vlan.vid = chip->info->max_vid;
1360 vlan.valid = false;
1361
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001362 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001363 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001364 if (err)
1365 return err;
1366
1367 if (!vlan.valid)
1368 break;
1369
1370 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001371 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001372
1373 /* The reset value 0x000 is used to indicate that multiple address
1374 * databases are not needed. Return the next positive available.
1375 */
1376 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001377 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001378 return -ENOSPC;
1379
1380 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001381 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001382}
1383
Andrew Lunn23e8b472019-10-25 01:03:52 +02001384static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1385{
1386 if (chip->info->ops->atu_get_hash)
1387 return chip->info->ops->atu_get_hash(chip, hash);
1388
1389 return -EOPNOTSUPP;
1390}
1391
1392static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1393{
1394 if (chip->info->ops->atu_set_hash)
1395 return chip->info->ops->atu_set_hash(chip, hash);
1396
1397 return -EOPNOTSUPP;
1398}
1399
Vivien Didelotda9c3592016-02-12 12:09:40 -05001400static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1401 u16 vid_begin, u16 vid_end)
1402{
Vivien Didelot04bed142016-08-31 18:06:13 -04001403 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001404 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001405 int i, err;
1406
Andrew Lunndb06ae412017-09-25 23:32:20 +02001407 /* DSA and CPU ports have to be members of multiple vlans */
1408 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1409 return 0;
1410
Vivien Didelotda9c3592016-02-12 12:09:40 -05001411 if (!vid_begin)
1412 return -EOPNOTSUPP;
1413
Vivien Didelot425d2d32019-08-01 14:36:34 -04001414 vlan.vid = vid_begin - 1;
1415 vlan.valid = false;
1416
Vivien Didelotda9c3592016-02-12 12:09:40 -05001417 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001418 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001419 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001420 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001421
1422 if (!vlan.valid)
1423 break;
1424
1425 if (vlan.vid > vid_end)
1426 break;
1427
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001428 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001429 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1430 continue;
1431
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001432 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001433 continue;
1434
Vivien Didelotbd00e052017-05-01 14:05:11 -04001435 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001436 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001437 continue;
1438
Vivien Didelotc8652c82017-10-16 11:12:19 -04001439 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001440 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001441 break; /* same bridge, check next VLAN */
1442
Vivien Didelotc8652c82017-10-16 11:12:19 -04001443 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001444 continue;
1445
Andrew Lunn743fcc22017-11-09 22:29:54 +01001446 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1447 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001448 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001449 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001450 }
1451 } while (vlan.vid < vid_end);
1452
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001453 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001454}
1455
Vivien Didelotf81ec902016-05-09 13:22:58 -04001456static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1457 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001458{
Vivien Didelot04bed142016-08-31 18:06:13 -04001459 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001460 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1461 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001462 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001463
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001464 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001465 return -EOPNOTSUPP;
1466
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001467 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001468 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001469 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001470
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001471 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001472}
1473
Vivien Didelot57d32312016-06-20 13:13:58 -04001474static int
1475mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001476 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001477{
Vivien Didelot04bed142016-08-31 18:06:13 -04001478 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001479 int err;
1480
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001481 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001482 return -EOPNOTSUPP;
1483
Vivien Didelotda9c3592016-02-12 12:09:40 -05001484 /* If the requested port doesn't belong to the same bridge as the VLAN
1485 * members, do not support it (yet) and fallback to software VLAN.
1486 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001487 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001488 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1489 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001490 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001491
Vivien Didelot76e398a2015-11-01 12:33:55 -05001492 /* We don't need any dynamic resource from the kernel (yet),
1493 * so skip the prepare phase.
1494 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001495 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001496}
1497
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001498static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1499 const unsigned char *addr, u16 vid,
1500 u8 state)
1501{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001502 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001503 struct mv88e6xxx_vtu_entry vlan;
1504 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001505 int err;
1506
1507 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001508 if (vid == 0) {
1509 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1510 if (err)
1511 return err;
1512 } else {
1513 vlan.vid = vid - 1;
1514 vlan.valid = false;
1515
1516 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1517 if (err)
1518 return err;
1519
1520 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1521 if (vlan.vid != vid || !vlan.valid)
1522 return -EOPNOTSUPP;
1523
1524 fid = vlan.fid;
1525 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001526
Vivien Didelotd8291a92019-09-07 16:00:47 -04001527 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001528 ether_addr_copy(entry.mac, addr);
1529 eth_addr_dec(entry.mac);
1530
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001531 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001532 if (err)
1533 return err;
1534
1535 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001536 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001537 memset(&entry, 0, sizeof(entry));
1538 ether_addr_copy(entry.mac, addr);
1539 }
1540
1541 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001542 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001543 entry.portvec &= ~BIT(port);
1544 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001545 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001546 } else {
1547 entry.portvec |= BIT(port);
1548 entry.state = state;
1549 }
1550
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001551 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001552}
1553
Vivien Didelotda7dc872019-09-07 16:00:49 -04001554static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1555 const struct mv88e6xxx_policy *policy)
1556{
1557 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1558 enum mv88e6xxx_policy_action action = policy->action;
1559 const u8 *addr = policy->addr;
1560 u16 vid = policy->vid;
1561 u8 state;
1562 int err;
1563 int id;
1564
1565 if (!chip->info->ops->port_set_policy)
1566 return -EOPNOTSUPP;
1567
1568 switch (mapping) {
1569 case MV88E6XXX_POLICY_MAPPING_DA:
1570 case MV88E6XXX_POLICY_MAPPING_SA:
1571 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1572 state = 0; /* Dissociate the port and address */
1573 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1574 is_multicast_ether_addr(addr))
1575 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1576 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1577 is_unicast_ether_addr(addr))
1578 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1579 else
1580 return -EOPNOTSUPP;
1581
1582 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1583 state);
1584 if (err)
1585 return err;
1586 break;
1587 default:
1588 return -EOPNOTSUPP;
1589 }
1590
1591 /* Skip the port's policy clearing if the mapping is still in use */
1592 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1593 idr_for_each_entry(&chip->policies, policy, id)
1594 if (policy->port == port &&
1595 policy->mapping == mapping &&
1596 policy->action != action)
1597 return 0;
1598
1599 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1600}
1601
1602static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1603 struct ethtool_rx_flow_spec *fs)
1604{
1605 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1606 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1607 enum mv88e6xxx_policy_mapping mapping;
1608 enum mv88e6xxx_policy_action action;
1609 struct mv88e6xxx_policy *policy;
1610 u16 vid = 0;
1611 u8 *addr;
1612 int err;
1613 int id;
1614
1615 if (fs->location != RX_CLS_LOC_ANY)
1616 return -EINVAL;
1617
1618 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1619 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1620 else
1621 return -EOPNOTSUPP;
1622
1623 switch (fs->flow_type & ~FLOW_EXT) {
1624 case ETHER_FLOW:
1625 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1626 is_zero_ether_addr(mac_mask->h_source)) {
1627 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1628 addr = mac_entry->h_dest;
1629 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1630 !is_zero_ether_addr(mac_mask->h_source)) {
1631 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1632 addr = mac_entry->h_source;
1633 } else {
1634 /* Cannot support DA and SA mapping in the same rule */
1635 return -EOPNOTSUPP;
1636 }
1637 break;
1638 default:
1639 return -EOPNOTSUPP;
1640 }
1641
1642 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1643 if (fs->m_ext.vlan_tci != 0xffff)
1644 return -EOPNOTSUPP;
1645 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1646 }
1647
1648 idr_for_each_entry(&chip->policies, policy, id) {
1649 if (policy->port == port && policy->mapping == mapping &&
1650 policy->action == action && policy->vid == vid &&
1651 ether_addr_equal(policy->addr, addr))
1652 return -EEXIST;
1653 }
1654
1655 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1656 if (!policy)
1657 return -ENOMEM;
1658
1659 fs->location = 0;
1660 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1661 GFP_KERNEL);
1662 if (err) {
1663 devm_kfree(chip->dev, policy);
1664 return err;
1665 }
1666
1667 memcpy(&policy->fs, fs, sizeof(*fs));
1668 ether_addr_copy(policy->addr, addr);
1669 policy->mapping = mapping;
1670 policy->action = action;
1671 policy->port = port;
1672 policy->vid = vid;
1673
1674 err = mv88e6xxx_policy_apply(chip, port, policy);
1675 if (err) {
1676 idr_remove(&chip->policies, fs->location);
1677 devm_kfree(chip->dev, policy);
1678 return err;
1679 }
1680
1681 return 0;
1682}
1683
1684static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1685 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1686{
1687 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1688 struct mv88e6xxx_chip *chip = ds->priv;
1689 struct mv88e6xxx_policy *policy;
1690 int err;
1691 int id;
1692
1693 mv88e6xxx_reg_lock(chip);
1694
1695 switch (rxnfc->cmd) {
1696 case ETHTOOL_GRXCLSRLCNT:
1697 rxnfc->data = 0;
1698 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1699 rxnfc->rule_cnt = 0;
1700 idr_for_each_entry(&chip->policies, policy, id)
1701 if (policy->port == port)
1702 rxnfc->rule_cnt++;
1703 err = 0;
1704 break;
1705 case ETHTOOL_GRXCLSRULE:
1706 err = -ENOENT;
1707 policy = idr_find(&chip->policies, fs->location);
1708 if (policy) {
1709 memcpy(fs, &policy->fs, sizeof(*fs));
1710 err = 0;
1711 }
1712 break;
1713 case ETHTOOL_GRXCLSRLALL:
1714 rxnfc->data = 0;
1715 rxnfc->rule_cnt = 0;
1716 idr_for_each_entry(&chip->policies, policy, id)
1717 if (policy->port == port)
1718 rule_locs[rxnfc->rule_cnt++] = id;
1719 err = 0;
1720 break;
1721 default:
1722 err = -EOPNOTSUPP;
1723 break;
1724 }
1725
1726 mv88e6xxx_reg_unlock(chip);
1727
1728 return err;
1729}
1730
1731static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1732 struct ethtool_rxnfc *rxnfc)
1733{
1734 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1735 struct mv88e6xxx_chip *chip = ds->priv;
1736 struct mv88e6xxx_policy *policy;
1737 int err;
1738
1739 mv88e6xxx_reg_lock(chip);
1740
1741 switch (rxnfc->cmd) {
1742 case ETHTOOL_SRXCLSRLINS:
1743 err = mv88e6xxx_policy_insert(chip, port, fs);
1744 break;
1745 case ETHTOOL_SRXCLSRLDEL:
1746 err = -ENOENT;
1747 policy = idr_remove(&chip->policies, fs->location);
1748 if (policy) {
1749 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1750 err = mv88e6xxx_policy_apply(chip, port, policy);
1751 devm_kfree(chip->dev, policy);
1752 }
1753 break;
1754 default:
1755 err = -EOPNOTSUPP;
1756 break;
1757 }
1758
1759 mv88e6xxx_reg_unlock(chip);
1760
1761 return err;
1762}
1763
Andrew Lunn87fa8862017-11-09 22:29:56 +01001764static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1765 u16 vid)
1766{
1767 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1768 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1769
1770 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1771}
1772
1773static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1774{
1775 int port;
1776 int err;
1777
1778 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1779 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1780 if (err)
1781 return err;
1782 }
1783
1784 return 0;
1785}
1786
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001787static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001788 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001789{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001790 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001791 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001792 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001793
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001794 if (!vid)
1795 return -EOPNOTSUPP;
1796
1797 vlan.vid = vid - 1;
1798 vlan.valid = false;
1799
1800 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001801 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001802 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001803
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001804 if (vlan.vid != vid || !vlan.valid) {
1805 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001806
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001807 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1808 if (err)
1809 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001810
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001811 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1812 if (i == port)
1813 vlan.member[i] = member;
1814 else
1815 vlan.member[i] = non_member;
1816
1817 vlan.vid = vid;
1818 vlan.valid = true;
1819
1820 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1821 if (err)
1822 return err;
1823
1824 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1825 if (err)
1826 return err;
1827 } else if (vlan.member[port] != member) {
1828 vlan.member[port] = member;
1829
1830 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1831 if (err)
1832 return err;
1833 } else {
1834 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1835 port, vid);
1836 }
1837
1838 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001839}
1840
Vivien Didelotf81ec902016-05-09 13:22:58 -04001841static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001842 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001843{
Vivien Didelot04bed142016-08-31 18:06:13 -04001844 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001845 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1846 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001847 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001848 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001849
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001850 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001851 return;
1852
Vivien Didelotc91498e2017-06-07 18:12:13 -04001853 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001854 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001855 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001856 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001857 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001858 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001859
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001860 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001861
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001862 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001863 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001864 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1865 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001866
Vivien Didelot77064f32016-11-04 03:23:30 +01001867 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001868 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1869 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001870
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001871 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001872}
1873
Vivien Didelot521098922019-08-01 14:36:36 -04001874static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1875 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001876{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001877 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001878 int i, err;
1879
Vivien Didelot521098922019-08-01 14:36:36 -04001880 if (!vid)
1881 return -EOPNOTSUPP;
1882
1883 vlan.vid = vid - 1;
1884 vlan.valid = false;
1885
1886 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001887 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001888 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001889
Vivien Didelot521098922019-08-01 14:36:36 -04001890 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1891 * tell switchdev that this VLAN is likely handled in software.
1892 */
1893 if (vlan.vid != vid || !vlan.valid ||
1894 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001895 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001896
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001897 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001898
1899 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001900 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001901 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001902 if (vlan.member[i] !=
1903 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001904 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001905 break;
1906 }
1907 }
1908
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001909 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001910 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001911 return err;
1912
Vivien Didelote606ca32017-03-11 16:12:55 -05001913 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001914}
1915
Vivien Didelotf81ec902016-05-09 13:22:58 -04001916static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1917 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001918{
Vivien Didelot04bed142016-08-31 18:06:13 -04001919 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001920 u16 pvid, vid;
1921 int err = 0;
1922
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001923 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001924 return -EOPNOTSUPP;
1925
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001926 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001927
Vivien Didelot77064f32016-11-04 03:23:30 +01001928 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001929 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001930 goto unlock;
1931
Vivien Didelot76e398a2015-11-01 12:33:55 -05001932 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001933 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001934 if (err)
1935 goto unlock;
1936
1937 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001938 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001939 if (err)
1940 goto unlock;
1941 }
1942 }
1943
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001944unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001945 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001946
1947 return err;
1948}
1949
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001950static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1951 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001952{
Vivien Didelot04bed142016-08-31 18:06:13 -04001953 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001954 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001955
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001956 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001957 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1958 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001959 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001960
1961 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001962}
1963
Vivien Didelotf81ec902016-05-09 13:22:58 -04001964static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001965 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001966{
Vivien Didelot04bed142016-08-31 18:06:13 -04001967 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001968 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001969
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001970 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04001971 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001972 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001973
Vivien Didelot83dabd12016-08-31 11:50:04 -04001974 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001975}
1976
Vivien Didelot83dabd12016-08-31 11:50:04 -04001977static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1978 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001979 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001980{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001981 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001982 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001983 int err;
1984
Vivien Didelotd8291a92019-09-07 16:00:47 -04001985 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001986 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001987
1988 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001989 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001990 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001991 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001992
Vivien Didelotd8291a92019-09-07 16:00:47 -04001993 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001994 break;
1995
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001996 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001997 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001998
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001999 if (!is_unicast_ether_addr(addr.mac))
2000 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002001
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002002 is_static = (addr.state ==
2003 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2004 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002005 if (err)
2006 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002007 } while (!is_broadcast_ether_addr(addr.mac));
2008
2009 return err;
2010}
2011
Vivien Didelot83dabd12016-08-31 11:50:04 -04002012static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002013 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002014{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002015 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002016 u16 fid;
2017 int err;
2018
2019 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002020 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002021 if (err)
2022 return err;
2023
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002024 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002025 if (err)
2026 return err;
2027
2028 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002029 vlan.vid = chip->info->max_vid;
2030 vlan.valid = false;
2031
Vivien Didelot83dabd12016-08-31 11:50:04 -04002032 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002033 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002034 if (err)
2035 return err;
2036
2037 if (!vlan.valid)
2038 break;
2039
2040 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002041 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002042 if (err)
2043 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002044 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002045
2046 return err;
2047}
2048
Vivien Didelotf81ec902016-05-09 13:22:58 -04002049static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002050 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002051{
Vivien Didelot04bed142016-08-31 18:06:13 -04002052 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002053 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002054
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002055 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002056 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002057 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002058
2059 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002060}
2061
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002062static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2063 struct net_device *br)
2064{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002065 struct dsa_switch *ds = chip->ds;
2066 struct dsa_switch_tree *dst = ds->dst;
2067 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002068 int err;
2069
Vivien Didelotef2025e2019-10-21 16:51:27 -04002070 list_for_each_entry(dp, &dst->ports, list) {
2071 if (dp->bridge_dev == br) {
2072 if (dp->ds == ds) {
2073 /* This is a local bridge group member,
2074 * remap its Port VLAN Map.
2075 */
2076 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2077 if (err)
2078 return err;
2079 } else {
2080 /* This is an external bridge group member,
2081 * remap its cross-chip Port VLAN Table entry.
2082 */
2083 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2084 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002085 if (err)
2086 return err;
2087 }
2088 }
2089 }
2090
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002091 return 0;
2092}
2093
Vivien Didelotf81ec902016-05-09 13:22:58 -04002094static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002095 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002096{
Vivien Didelot04bed142016-08-31 18:06:13 -04002097 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002098 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002099
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002100 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002101 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002102 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002103
Vivien Didelot466dfa02016-02-26 13:16:05 -05002104 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002105}
2106
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002107static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2108 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002109{
Vivien Didelot04bed142016-08-31 18:06:13 -04002110 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002111
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002112 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002113 if (mv88e6xxx_bridge_map(chip, br) ||
2114 mv88e6xxx_port_vlan_map(chip, port))
2115 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002116 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002117}
2118
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002119static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2120 int port, struct net_device *br)
2121{
2122 struct mv88e6xxx_chip *chip = ds->priv;
2123 int err;
2124
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002125 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002126 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002127 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002128
2129 return err;
2130}
2131
2132static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2133 int port, struct net_device *br)
2134{
2135 struct mv88e6xxx_chip *chip = ds->priv;
2136
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002137 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002138 if (mv88e6xxx_pvt_map(chip, dev, port))
2139 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002140 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002141}
2142
Vivien Didelot17e708b2016-12-05 17:30:27 -05002143static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2144{
2145 if (chip->info->ops->reset)
2146 return chip->info->ops->reset(chip);
2147
2148 return 0;
2149}
2150
Vivien Didelot309eca62016-12-05 17:30:26 -05002151static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2152{
2153 struct gpio_desc *gpiod = chip->reset;
2154
2155 /* If there is a GPIO connected to the reset pin, toggle it */
2156 if (gpiod) {
2157 gpiod_set_value_cansleep(gpiod, 1);
2158 usleep_range(10000, 20000);
2159 gpiod_set_value_cansleep(gpiod, 0);
2160 usleep_range(10000, 20000);
2161 }
2162}
2163
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002164static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2165{
2166 int i, err;
2167
2168 /* Set all ports to the Disabled state */
2169 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002170 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002171 if (err)
2172 return err;
2173 }
2174
2175 /* Wait for transmit queues to drain,
2176 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2177 */
2178 usleep_range(2000, 4000);
2179
2180 return 0;
2181}
2182
Vivien Didelotfad09c72016-06-21 12:28:20 -04002183static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002184{
Vivien Didelota935c052016-09-29 12:21:53 -04002185 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002186
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002187 err = mv88e6xxx_disable_ports(chip);
2188 if (err)
2189 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002190
Vivien Didelot309eca62016-12-05 17:30:26 -05002191 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002192
Vivien Didelot17e708b2016-12-05 17:30:27 -05002193 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002194}
2195
Vivien Didelot43145572017-03-11 16:12:59 -05002196static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002197 enum mv88e6xxx_frame_mode frame,
2198 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002199{
2200 int err;
2201
Vivien Didelot43145572017-03-11 16:12:59 -05002202 if (!chip->info->ops->port_set_frame_mode)
2203 return -EOPNOTSUPP;
2204
2205 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002206 if (err)
2207 return err;
2208
Vivien Didelot43145572017-03-11 16:12:59 -05002209 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2210 if (err)
2211 return err;
2212
2213 if (chip->info->ops->port_set_ether_type)
2214 return chip->info->ops->port_set_ether_type(chip, port, etype);
2215
2216 return 0;
2217}
2218
2219static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2220{
2221 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002222 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002223 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002224}
2225
2226static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2227{
2228 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002229 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002230 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002231}
2232
2233static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2234{
2235 return mv88e6xxx_set_port_mode(chip, port,
2236 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002237 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2238 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002239}
2240
2241static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2242{
2243 if (dsa_is_dsa_port(chip->ds, port))
2244 return mv88e6xxx_set_port_mode_dsa(chip, port);
2245
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002246 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002247 return mv88e6xxx_set_port_mode_normal(chip, port);
2248
2249 /* Setup CPU port mode depending on its supported tag format */
2250 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2251 return mv88e6xxx_set_port_mode_dsa(chip, port);
2252
2253 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2254 return mv88e6xxx_set_port_mode_edsa(chip, port);
2255
2256 return -EINVAL;
2257}
2258
Vivien Didelotea698f42017-03-11 16:12:50 -05002259static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2260{
2261 bool message = dsa_is_dsa_port(chip->ds, port);
2262
2263 return mv88e6xxx_port_set_message_port(chip, port, message);
2264}
2265
Vivien Didelot601aeed2017-03-11 16:13:00 -05002266static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2267{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002268 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002269 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002270
David S. Miller407308f2019-06-15 13:35:29 -07002271 /* Upstream ports flood frames with unknown unicast or multicast DA */
2272 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2273 if (chip->info->ops->port_set_egress_floods)
2274 return chip->info->ops->port_set_egress_floods(chip, port,
2275 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002276
David S. Miller407308f2019-06-15 13:35:29 -07002277 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002278}
2279
Vivien Didelot45de77f2019-08-31 16:18:36 -04002280static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2281{
2282 struct mv88e6xxx_port *mvp = dev_id;
2283 struct mv88e6xxx_chip *chip = mvp->chip;
2284 irqreturn_t ret = IRQ_NONE;
2285 int port = mvp->port;
2286 u8 lane;
2287
2288 mv88e6xxx_reg_lock(chip);
2289 lane = mv88e6xxx_serdes_get_lane(chip, port);
2290 if (lane)
2291 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2292 mv88e6xxx_reg_unlock(chip);
2293
2294 return ret;
2295}
2296
2297static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2298 u8 lane)
2299{
2300 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2301 unsigned int irq;
2302 int err;
2303
2304 /* Nothing to request if this SERDES port has no IRQ */
2305 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2306 if (!irq)
2307 return 0;
2308
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002309 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2310 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2311
Vivien Didelot45de77f2019-08-31 16:18:36 -04002312 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2313 mv88e6xxx_reg_unlock(chip);
2314 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002315 IRQF_ONESHOT, dev_id->serdes_irq_name,
2316 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002317 mv88e6xxx_reg_lock(chip);
2318 if (err)
2319 return err;
2320
2321 dev_id->serdes_irq = irq;
2322
2323 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2324}
2325
2326static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2327 u8 lane)
2328{
2329 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2330 unsigned int irq = dev_id->serdes_irq;
2331 int err;
2332
2333 /* Nothing to free if no IRQ has been requested */
2334 if (!irq)
2335 return 0;
2336
2337 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2338
2339 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2340 mv88e6xxx_reg_unlock(chip);
2341 free_irq(irq, dev_id);
2342 mv88e6xxx_reg_lock(chip);
2343
2344 dev_id->serdes_irq = 0;
2345
2346 return err;
2347}
2348
Andrew Lunn6d917822017-05-26 01:03:21 +02002349static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2350 bool on)
2351{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002352 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002353 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002354
Vivien Didelotdc272f62019-08-31 16:18:33 -04002355 lane = mv88e6xxx_serdes_get_lane(chip, port);
2356 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002357 return 0;
2358
2359 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002360 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002361 if (err)
2362 return err;
2363
Vivien Didelot45de77f2019-08-31 16:18:36 -04002364 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002365 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002366 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2367 if (err)
2368 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002369
Vivien Didelotdc272f62019-08-31 16:18:33 -04002370 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002371 }
2372
2373 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002374}
2375
Vivien Didelotfa371c82017-12-05 15:34:10 -05002376static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2377{
2378 struct dsa_switch *ds = chip->ds;
2379 int upstream_port;
2380 int err;
2381
Vivien Didelot07073c72017-12-05 15:34:13 -05002382 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002383 if (chip->info->ops->port_set_upstream_port) {
2384 err = chip->info->ops->port_set_upstream_port(chip, port,
2385 upstream_port);
2386 if (err)
2387 return err;
2388 }
2389
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002390 if (port == upstream_port) {
2391 if (chip->info->ops->set_cpu_port) {
2392 err = chip->info->ops->set_cpu_port(chip,
2393 upstream_port);
2394 if (err)
2395 return err;
2396 }
2397
2398 if (chip->info->ops->set_egress_port) {
2399 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002400 MV88E6XXX_EGRESS_DIR_INGRESS,
2401 upstream_port);
2402 if (err)
2403 return err;
2404
2405 err = chip->info->ops->set_egress_port(chip,
2406 MV88E6XXX_EGRESS_DIR_EGRESS,
2407 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002408 if (err)
2409 return err;
2410 }
2411 }
2412
Vivien Didelotfa371c82017-12-05 15:34:10 -05002413 return 0;
2414}
2415
Vivien Didelotfad09c72016-06-21 12:28:20 -04002416static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002417{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002418 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002419 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002420 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002421
Andrew Lunn7b898462018-08-09 15:38:47 +02002422 chip->ports[port].chip = chip;
2423 chip->ports[port].port = port;
2424
Vivien Didelotd78343d2016-11-04 03:23:36 +01002425 /* MAC Forcing register: don't force link, speed, duplex or flow control
2426 * state to any particular values on physical ports, but force the CPU
2427 * port and all DSA ports to their maximum bandwidth and full duplex.
2428 */
2429 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2430 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2431 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002432 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002433 PHY_INTERFACE_MODE_NA);
2434 else
2435 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2436 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002437 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002438 PHY_INTERFACE_MODE_NA);
2439 if (err)
2440 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002441
2442 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2443 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2444 * tunneling, determine priority by looking at 802.1p and IP
2445 * priority fields (IP prio has precedence), and set STP state
2446 * to Forwarding.
2447 *
2448 * If this is the CPU link, use DSA or EDSA tagging depending
2449 * on which tagging mode was configured.
2450 *
2451 * If this is a link to another switch, use DSA tagging mode.
2452 *
2453 * If this is the upstream port for this switch, enable
2454 * forwarding of unknown unicasts and multicasts.
2455 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002456 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2457 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2458 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2459 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002460 if (err)
2461 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002462
Vivien Didelot601aeed2017-03-11 16:13:00 -05002463 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002464 if (err)
2465 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002466
Vivien Didelot601aeed2017-03-11 16:13:00 -05002467 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002468 if (err)
2469 return err;
2470
Vivien Didelot8efdda42015-08-13 12:52:23 -04002471 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002472 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002473 * untagged frames on this port, do a destination address lookup on all
2474 * received packets as usual, disable ARP mirroring and don't send a
2475 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002476 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002477 err = mv88e6xxx_port_set_map_da(chip, port);
2478 if (err)
2479 return err;
2480
Vivien Didelotfa371c82017-12-05 15:34:10 -05002481 err = mv88e6xxx_setup_upstream_port(chip, port);
2482 if (err)
2483 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002484
Andrew Lunna23b2962017-02-04 20:15:28 +01002485 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002486 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002487 if (err)
2488 return err;
2489
Vivien Didelotcd782652017-06-08 18:34:13 -04002490 if (chip->info->ops->port_set_jumbo_size) {
2491 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002492 if (err)
2493 return err;
2494 }
2495
Andrew Lunn54d792f2015-05-06 01:09:47 +02002496 /* Port Association Vector: when learning source addresses
2497 * of packets, add the address to the address database using
2498 * a port bitmap that has only the bit for this port set and
2499 * the other bits clear.
2500 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002501 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002502 /* Disable learning for CPU port */
2503 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002504 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002505
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002506 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2507 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002508 if (err)
2509 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002510
2511 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002512 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2513 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002514 if (err)
2515 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002516
Vivien Didelot08984322017-06-08 18:34:12 -04002517 if (chip->info->ops->port_pause_limit) {
2518 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002519 if (err)
2520 return err;
2521 }
2522
Vivien Didelotc8c94892017-03-11 16:13:01 -05002523 if (chip->info->ops->port_disable_learn_limit) {
2524 err = chip->info->ops->port_disable_learn_limit(chip, port);
2525 if (err)
2526 return err;
2527 }
2528
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002529 if (chip->info->ops->port_disable_pri_override) {
2530 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002531 if (err)
2532 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002533 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002534
Andrew Lunnef0a7312016-12-03 04:35:16 +01002535 if (chip->info->ops->port_tag_remap) {
2536 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002537 if (err)
2538 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002539 }
2540
Andrew Lunnef70b112016-12-03 04:45:18 +01002541 if (chip->info->ops->port_egress_rate_limiting) {
2542 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002543 if (err)
2544 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002545 }
2546
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002547 if (chip->info->ops->port_setup_message_port) {
2548 err = chip->info->ops->port_setup_message_port(chip, port);
2549 if (err)
2550 return err;
2551 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002552
Vivien Didelot207afda2016-04-14 14:42:09 -04002553 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002554 * database, and allow bidirectional communication between the
2555 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002556 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002557 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002558 if (err)
2559 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002560
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002561 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002562 if (err)
2563 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002564
2565 /* Default VLAN ID and priority: don't set a default VLAN
2566 * ID, and set the default packet priority to zero.
2567 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002568 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002569}
2570
Andrew Lunn04aca992017-05-26 01:03:24 +02002571static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2572 struct phy_device *phydev)
2573{
2574 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002575 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002576
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002577 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002578 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002579 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002580
2581 return err;
2582}
2583
Andrew Lunn75104db2019-02-24 20:44:43 +01002584static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002585{
2586 struct mv88e6xxx_chip *chip = ds->priv;
2587
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002588 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002589 if (mv88e6xxx_serdes_power(chip, port, false))
2590 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002591 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002592}
2593
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002594static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2595 unsigned int ageing_time)
2596{
Vivien Didelot04bed142016-08-31 18:06:13 -04002597 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002598 int err;
2599
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002600 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002601 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002602 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002603
2604 return err;
2605}
2606
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002607static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002608{
2609 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002610
Andrew Lunnde2273872016-11-21 23:27:01 +01002611 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002612 if (chip->info->ops->stats_set_histogram) {
2613 err = chip->info->ops->stats_set_histogram(chip);
2614 if (err)
2615 return err;
2616 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002617
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002618 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002619}
2620
Andrew Lunnea890982019-01-09 00:24:03 +01002621/* Check if the errata has already been applied. */
2622static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2623{
2624 int port;
2625 int err;
2626 u16 val;
2627
2628 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002629 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002630 if (err) {
2631 dev_err(chip->dev,
2632 "Error reading hidden register: %d\n", err);
2633 return false;
2634 }
2635 if (val != 0x01c0)
2636 return false;
2637 }
2638
2639 return true;
2640}
2641
2642/* The 6390 copper ports have an errata which require poking magic
2643 * values into undocumented hidden registers and then performing a
2644 * software reset.
2645 */
2646static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2647{
2648 int port;
2649 int err;
2650
2651 if (mv88e6390_setup_errata_applied(chip))
2652 return 0;
2653
2654 /* Set the ports into blocking mode */
2655 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2656 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2657 if (err)
2658 return err;
2659 }
2660
2661 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002662 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002663 if (err)
2664 return err;
2665 }
2666
2667 return mv88e6xxx_software_reset(chip);
2668}
2669
Andrew Lunn23e8b472019-10-25 01:03:52 +02002670enum mv88e6xxx_devlink_param_id {
2671 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2672 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2673};
2674
2675static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2676 struct devlink_param_gset_ctx *ctx)
2677{
2678 struct mv88e6xxx_chip *chip = ds->priv;
2679 int err;
2680
2681 mv88e6xxx_reg_lock(chip);
2682
2683 switch (id) {
2684 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2685 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2686 break;
2687 default:
2688 err = -EOPNOTSUPP;
2689 break;
2690 }
2691
2692 mv88e6xxx_reg_unlock(chip);
2693
2694 return err;
2695}
2696
2697static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2698 struct devlink_param_gset_ctx *ctx)
2699{
2700 struct mv88e6xxx_chip *chip = ds->priv;
2701 int err;
2702
2703 mv88e6xxx_reg_lock(chip);
2704
2705 switch (id) {
2706 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2707 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2708 break;
2709 default:
2710 err = -EOPNOTSUPP;
2711 break;
2712 }
2713
2714 mv88e6xxx_reg_unlock(chip);
2715
2716 return err;
2717}
2718
2719static const struct devlink_param mv88e6xxx_devlink_params[] = {
2720 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2721 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2722 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2723};
2724
2725static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2726{
2727 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2728 ARRAY_SIZE(mv88e6xxx_devlink_params));
2729}
2730
2731static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2732{
2733 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2734 ARRAY_SIZE(mv88e6xxx_devlink_params));
2735}
2736
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002737enum mv88e6xxx_devlink_resource_id {
2738 MV88E6XXX_RESOURCE_ID_ATU,
2739 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2740 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2741 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2742 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2743};
2744
2745static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2746 u16 bin)
2747{
2748 u16 occupancy = 0;
2749 int err;
2750
2751 mv88e6xxx_reg_lock(chip);
2752
2753 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2754 bin);
2755 if (err) {
2756 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2757 goto unlock;
2758 }
2759
2760 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2761 if (err) {
2762 dev_err(chip->dev, "failed to perform ATU get next\n");
2763 goto unlock;
2764 }
2765
2766 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2767 if (err) {
2768 dev_err(chip->dev, "failed to get ATU stats\n");
2769 goto unlock;
2770 }
2771
2772unlock:
2773 mv88e6xxx_reg_unlock(chip);
2774
2775 return occupancy;
2776}
2777
2778static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2779{
2780 struct mv88e6xxx_chip *chip = priv;
2781
2782 return mv88e6xxx_devlink_atu_bin_get(chip,
2783 MV88E6XXX_G2_ATU_STATS_BIN_0);
2784}
2785
2786static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2787{
2788 struct mv88e6xxx_chip *chip = priv;
2789
2790 return mv88e6xxx_devlink_atu_bin_get(chip,
2791 MV88E6XXX_G2_ATU_STATS_BIN_1);
2792}
2793
2794static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2795{
2796 struct mv88e6xxx_chip *chip = priv;
2797
2798 return mv88e6xxx_devlink_atu_bin_get(chip,
2799 MV88E6XXX_G2_ATU_STATS_BIN_2);
2800}
2801
2802static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2803{
2804 struct mv88e6xxx_chip *chip = priv;
2805
2806 return mv88e6xxx_devlink_atu_bin_get(chip,
2807 MV88E6XXX_G2_ATU_STATS_BIN_3);
2808}
2809
2810static u64 mv88e6xxx_devlink_atu_get(void *priv)
2811{
2812 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2813 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2814 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2815 mv88e6xxx_devlink_atu_bin_3_get(priv);
2816}
2817
2818static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2819{
2820 struct devlink_resource_size_params size_params;
2821 struct mv88e6xxx_chip *chip = ds->priv;
2822 int err;
2823
2824 devlink_resource_size_params_init(&size_params,
2825 mv88e6xxx_num_macs(chip),
2826 mv88e6xxx_num_macs(chip),
2827 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2828
2829 err = dsa_devlink_resource_register(ds, "ATU",
2830 mv88e6xxx_num_macs(chip),
2831 MV88E6XXX_RESOURCE_ID_ATU,
2832 DEVLINK_RESOURCE_ID_PARENT_TOP,
2833 &size_params);
2834 if (err)
2835 goto out;
2836
2837 devlink_resource_size_params_init(&size_params,
2838 mv88e6xxx_num_macs(chip) / 4,
2839 mv88e6xxx_num_macs(chip) / 4,
2840 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2841
2842 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2843 mv88e6xxx_num_macs(chip) / 4,
2844 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2845 MV88E6XXX_RESOURCE_ID_ATU,
2846 &size_params);
2847 if (err)
2848 goto out;
2849
2850 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2851 mv88e6xxx_num_macs(chip) / 4,
2852 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2853 MV88E6XXX_RESOURCE_ID_ATU,
2854 &size_params);
2855 if (err)
2856 goto out;
2857
2858 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2859 mv88e6xxx_num_macs(chip) / 4,
2860 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2861 MV88E6XXX_RESOURCE_ID_ATU,
2862 &size_params);
2863 if (err)
2864 goto out;
2865
2866 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2867 mv88e6xxx_num_macs(chip) / 4,
2868 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2869 MV88E6XXX_RESOURCE_ID_ATU,
2870 &size_params);
2871 if (err)
2872 goto out;
2873
2874 dsa_devlink_resource_occ_get_register(ds,
2875 MV88E6XXX_RESOURCE_ID_ATU,
2876 mv88e6xxx_devlink_atu_get,
2877 chip);
2878
2879 dsa_devlink_resource_occ_get_register(ds,
2880 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2881 mv88e6xxx_devlink_atu_bin_0_get,
2882 chip);
2883
2884 dsa_devlink_resource_occ_get_register(ds,
2885 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2886 mv88e6xxx_devlink_atu_bin_1_get,
2887 chip);
2888
2889 dsa_devlink_resource_occ_get_register(ds,
2890 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2891 mv88e6xxx_devlink_atu_bin_2_get,
2892 chip);
2893
2894 dsa_devlink_resource_occ_get_register(ds,
2895 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2896 mv88e6xxx_devlink_atu_bin_3_get,
2897 chip);
2898
2899 return 0;
2900
2901out:
2902 dsa_devlink_resources_unregister(ds);
2903 return err;
2904}
2905
Andrew Lunn23e8b472019-10-25 01:03:52 +02002906static void mv88e6xxx_teardown(struct dsa_switch *ds)
2907{
2908 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002909 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002910}
2911
Vivien Didelotf81ec902016-05-09 13:22:58 -04002912static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002913{
Vivien Didelot04bed142016-08-31 18:06:13 -04002914 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002915 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002916 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002917 int i;
2918
Vivien Didelotfad09c72016-06-21 12:28:20 -04002919 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002920 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002921
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002922 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002923
Andrew Lunnea890982019-01-09 00:24:03 +01002924 if (chip->info->ops->setup_errata) {
2925 err = chip->info->ops->setup_errata(chip);
2926 if (err)
2927 goto unlock;
2928 }
2929
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002930 /* Cache the cmode of each port. */
2931 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2932 if (chip->info->ops->port_get_cmode) {
2933 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2934 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002935 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002936
2937 chip->ports[i].cmode = cmode;
2938 }
2939 }
2940
Vivien Didelot97299342016-07-18 20:45:30 -04002941 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002942 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002943 if (dsa_is_unused_port(ds, i))
2944 continue;
2945
Hubert Feursteinc8574862019-07-31 10:23:48 +02002946 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002947 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002948 dev_err(chip->dev, "port %d is invalid\n", i);
2949 err = -EINVAL;
2950 goto unlock;
2951 }
2952
Vivien Didelot97299342016-07-18 20:45:30 -04002953 err = mv88e6xxx_setup_port(chip, i);
2954 if (err)
2955 goto unlock;
2956 }
2957
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002958 err = mv88e6xxx_irl_setup(chip);
2959 if (err)
2960 goto unlock;
2961
Vivien Didelot04a69a12017-10-13 14:18:05 -04002962 err = mv88e6xxx_mac_setup(chip);
2963 if (err)
2964 goto unlock;
2965
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002966 err = mv88e6xxx_phy_setup(chip);
2967 if (err)
2968 goto unlock;
2969
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002970 err = mv88e6xxx_vtu_setup(chip);
2971 if (err)
2972 goto unlock;
2973
Vivien Didelot81228992017-03-30 17:37:08 -04002974 err = mv88e6xxx_pvt_setup(chip);
2975 if (err)
2976 goto unlock;
2977
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002978 err = mv88e6xxx_atu_setup(chip);
2979 if (err)
2980 goto unlock;
2981
Andrew Lunn87fa8862017-11-09 22:29:56 +01002982 err = mv88e6xxx_broadcast_setup(chip, 0);
2983 if (err)
2984 goto unlock;
2985
Vivien Didelot9e907d72017-07-17 13:03:43 -04002986 err = mv88e6xxx_pot_setup(chip);
2987 if (err)
2988 goto unlock;
2989
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002990 err = mv88e6xxx_rmu_setup(chip);
2991 if (err)
2992 goto unlock;
2993
Vivien Didelot51c901a2017-07-17 13:03:41 -04002994 err = mv88e6xxx_rsvd2cpu_setup(chip);
2995 if (err)
2996 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002997
Vivien Didelotb28f8722018-04-26 21:56:44 -04002998 err = mv88e6xxx_trunk_setup(chip);
2999 if (err)
3000 goto unlock;
3001
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003002 err = mv88e6xxx_devmap_setup(chip);
3003 if (err)
3004 goto unlock;
3005
Vivien Didelot93e18d62018-05-11 17:16:35 -04003006 err = mv88e6xxx_pri_setup(chip);
3007 if (err)
3008 goto unlock;
3009
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003010 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003011 if (chip->info->ptp_support) {
3012 err = mv88e6xxx_ptp_setup(chip);
3013 if (err)
3014 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003015
3016 err = mv88e6xxx_hwtstamp_setup(chip);
3017 if (err)
3018 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003019 }
3020
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003021 err = mv88e6xxx_stats_setup(chip);
3022 if (err)
3023 goto unlock;
3024
Vivien Didelot6b17e862015-08-13 12:52:18 -04003025unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003026 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003027
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003028 if (err)
3029 return err;
3030
3031 /* Have to be called without holding the register lock, since
3032 * they take the devlink lock, and we later take the locks in
3033 * the reverse order when getting/setting parameters or
3034 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003035 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003036 err = mv88e6xxx_setup_devlink_resources(ds);
3037 if (err)
3038 return err;
3039
3040 err = mv88e6xxx_setup_devlink_params(ds);
3041 if (err)
3042 dsa_devlink_resources_unregister(ds);
3043
3044 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003045}
3046
Vivien Didelote57e5e72016-08-15 17:19:00 -04003047static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003048{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003049 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3050 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003051 u16 val;
3052 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003053
Andrew Lunnee26a222017-01-24 14:53:48 +01003054 if (!chip->info->ops->phy_read)
3055 return -EOPNOTSUPP;
3056
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003057 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003058 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003059 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003060
Andrew Lunnda9f3302017-02-01 03:40:05 +01003061 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003062 /* Some internal PHYs don't have a model number. */
3063 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3064 /* Then there is the 6165 family. It gets is
3065 * PHYs correct. But it can also have two
3066 * SERDES interfaces in the PHY address
3067 * space. And these don't have a model
3068 * number. But they are not PHYs, so we don't
3069 * want to give them something a PHY driver
3070 * will recognise.
3071 *
3072 * Use the mv88e6390 family model number
3073 * instead, for anything which really could be
3074 * a PHY,
3075 */
3076 if (!(val & 0x3f0))
3077 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003078 }
3079
Vivien Didelote57e5e72016-08-15 17:19:00 -04003080 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003081}
3082
Vivien Didelote57e5e72016-08-15 17:19:00 -04003083static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003084{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003085 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3086 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003087 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003088
Andrew Lunnee26a222017-01-24 14:53:48 +01003089 if (!chip->info->ops->phy_write)
3090 return -EOPNOTSUPP;
3091
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003092 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003093 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003094 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003095
3096 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003097}
3098
Vivien Didelotfad09c72016-06-21 12:28:20 -04003099static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003100 struct device_node *np,
3101 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003102{
3103 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003104 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003105 struct mii_bus *bus;
3106 int err;
3107
Andrew Lunn2510bab2018-02-22 01:51:49 +01003108 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003109 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003110 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003111 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003112
3113 if (err)
3114 return err;
3115 }
3116
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003117 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003118 if (!bus)
3119 return -ENOMEM;
3120
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003121 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003122 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003123 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003124 INIT_LIST_HEAD(&mdio_bus->list);
3125 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003126
Andrew Lunnb516d452016-06-04 21:17:06 +02003127 if (np) {
3128 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003129 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003130 } else {
3131 bus->name = "mv88e6xxx SMI";
3132 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3133 }
3134
3135 bus->read = mv88e6xxx_mdio_read;
3136 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003137 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003138
Andrew Lunn6f882842018-03-17 20:32:05 +01003139 if (!external) {
3140 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3141 if (err)
3142 return err;
3143 }
3144
Florian Fainelli00e798c2018-05-15 16:56:19 -07003145 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003146 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003147 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003148 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003149 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003150 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003151
3152 if (external)
3153 list_add_tail(&mdio_bus->list, &chip->mdios);
3154 else
3155 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003156
3157 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003158}
3159
Andrew Lunna3c53be52017-01-24 14:53:50 +01003160static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3161 { .compatible = "marvell,mv88e6xxx-mdio-external",
3162 .data = (void *)true },
3163 { },
3164};
3165
Andrew Lunn3126aee2017-12-07 01:05:57 +01003166static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3167
3168{
3169 struct mv88e6xxx_mdio_bus *mdio_bus;
3170 struct mii_bus *bus;
3171
3172 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3173 bus = mdio_bus->bus;
3174
Andrew Lunn6f882842018-03-17 20:32:05 +01003175 if (!mdio_bus->external)
3176 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3177
Andrew Lunn3126aee2017-12-07 01:05:57 +01003178 mdiobus_unregister(bus);
3179 }
3180}
3181
Andrew Lunna3c53be52017-01-24 14:53:50 +01003182static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3183 struct device_node *np)
3184{
3185 const struct of_device_id *match;
3186 struct device_node *child;
3187 int err;
3188
3189 /* Always register one mdio bus for the internal/default mdio
3190 * bus. This maybe represented in the device tree, but is
3191 * optional.
3192 */
3193 child = of_get_child_by_name(np, "mdio");
3194 err = mv88e6xxx_mdio_register(chip, child, false);
3195 if (err)
3196 return err;
3197
3198 /* Walk the device tree, and see if there are any other nodes
3199 * which say they are compatible with the external mdio
3200 * bus.
3201 */
3202 for_each_available_child_of_node(np, child) {
3203 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3204 if (match) {
3205 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003206 if (err) {
3207 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303208 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003209 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003210 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003211 }
3212 }
3213
3214 return 0;
3215}
3216
Vivien Didelot855b1932016-07-20 18:18:35 -04003217static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3218{
Vivien Didelot04bed142016-08-31 18:06:13 -04003219 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003220
3221 return chip->eeprom_len;
3222}
3223
Vivien Didelot855b1932016-07-20 18:18:35 -04003224static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3225 struct ethtool_eeprom *eeprom, u8 *data)
3226{
Vivien Didelot04bed142016-08-31 18:06:13 -04003227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003228 int err;
3229
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003230 if (!chip->info->ops->get_eeprom)
3231 return -EOPNOTSUPP;
3232
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003233 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003234 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003235 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003236
3237 if (err)
3238 return err;
3239
3240 eeprom->magic = 0xc3ec4951;
3241
3242 return 0;
3243}
3244
Vivien Didelot855b1932016-07-20 18:18:35 -04003245static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3246 struct ethtool_eeprom *eeprom, u8 *data)
3247{
Vivien Didelot04bed142016-08-31 18:06:13 -04003248 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003249 int err;
3250
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003251 if (!chip->info->ops->set_eeprom)
3252 return -EOPNOTSUPP;
3253
Vivien Didelot855b1932016-07-20 18:18:35 -04003254 if (eeprom->magic != 0xc3ec4951)
3255 return -EINVAL;
3256
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003257 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003258 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003259 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003260
3261 return err;
3262}
3263
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003264static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003265 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003266 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3267 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003268 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003269 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003270 .phy_read = mv88e6185_phy_ppu_read,
3271 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003272 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003273 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003274 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003275 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003276 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003277 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003278 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003279 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003280 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003281 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003282 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003283 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003284 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003285 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003286 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003287 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003288 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3289 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003290 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003291 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3292 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003293 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003294 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003295 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003296 .ppu_enable = mv88e6185_g1_ppu_enable,
3297 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003298 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003299 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003300 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003301 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003302 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003303};
3304
3305static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003306 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003307 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3308 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003309 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003310 .phy_read = mv88e6185_phy_ppu_read,
3311 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003312 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003313 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003314 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003315 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003316 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003317 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003318 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003319 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003320 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003321 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003322 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003323 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3324 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003325 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003326 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003327 .ppu_enable = mv88e6185_g1_ppu_enable,
3328 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003329 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003330 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003331 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003332 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003333};
3334
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003335static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003336 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003337 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3338 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003339 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003340 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3341 .phy_read = mv88e6xxx_g2_smi_phy_read,
3342 .phy_write = mv88e6xxx_g2_smi_phy_write,
3343 .port_set_link = mv88e6xxx_port_set_link,
3344 .port_set_duplex = mv88e6xxx_port_set_duplex,
3345 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003346 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003347 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003348 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003349 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003350 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003351 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003352 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003353 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003354 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003355 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003356 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003357 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003358 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003359 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003360 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3361 .stats_get_strings = mv88e6095_stats_get_strings,
3362 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003363 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3364 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003365 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003366 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003367 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003368 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003369 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003370 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003371 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003372 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003373};
3374
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003375static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003376 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003377 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3378 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003379 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003380 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003381 .phy_read = mv88e6xxx_g2_smi_phy_read,
3382 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003383 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003384 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003385 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003386 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003387 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003388 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003389 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003390 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003391 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003392 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003393 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003394 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003395 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3396 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003397 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003398 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3399 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003400 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003401 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003402 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003403 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003404 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3405 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003406 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003407 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003408 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003409};
3410
3411static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003412 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003413 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3414 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003415 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003416 .phy_read = mv88e6185_phy_ppu_read,
3417 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003418 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003419 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003420 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003421 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003422 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003423 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003424 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003425 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003426 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003427 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003428 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003429 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003430 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003431 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003432 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003433 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003434 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003435 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3436 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003437 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003438 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3439 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003440 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003441 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003442 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003443 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003444 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003445 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003446 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003447 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003448 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449};
3450
Vivien Didelot990e27b2017-03-28 13:50:32 -04003451static const struct mv88e6xxx_ops mv88e6141_ops = {
3452 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003453 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3454 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003455 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003456 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3457 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3458 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3459 .phy_read = mv88e6xxx_g2_smi_phy_read,
3460 .phy_write = mv88e6xxx_g2_smi_phy_write,
3461 .port_set_link = mv88e6xxx_port_set_link,
3462 .port_set_duplex = mv88e6xxx_port_set_duplex,
3463 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003464 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003465 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003466 .port_tag_remap = mv88e6095_port_tag_remap,
3467 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3468 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3469 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003470 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003471 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003472 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003473 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3474 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003475 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003476 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003477 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003478 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003479 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003480 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003481 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3482 .stats_get_strings = mv88e6320_stats_get_strings,
3483 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003484 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3485 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003486 .watchdog_ops = &mv88e6390_watchdog_ops,
3487 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003488 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003489 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003490 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003491 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003492 .serdes_power = mv88e6390_serdes_power,
3493 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003494 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003495 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003496 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003497 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003498 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003499};
3500
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003501static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003502 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003503 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3504 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003505 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003506 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003507 .phy_read = mv88e6xxx_g2_smi_phy_read,
3508 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003509 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003510 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003511 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003512 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003513 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003514 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003515 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003516 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003517 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003518 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003519 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003520 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003521 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003522 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003523 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003524 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003525 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003526 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3527 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003528 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003529 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3530 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003531 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003532 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003533 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003534 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003535 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3536 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003537 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003538 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003539 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003540 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003541 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003542};
3543
3544static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003545 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003546 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3547 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003548 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003549 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003550 .phy_read = mv88e6165_phy_read,
3551 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003552 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003553 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003554 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003555 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003556 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003557 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003558 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003559 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003560 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003561 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003562 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3563 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003564 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003565 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3566 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003567 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003568 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003569 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003570 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003571 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3572 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003573 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003574 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003575 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003576 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003577 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003578};
3579
3580static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003581 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003582 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3583 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003584 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003585 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003586 .phy_read = mv88e6xxx_g2_smi_phy_read,
3587 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003588 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003589 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003590 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003591 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003592 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003593 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003594 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003595 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003596 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003597 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003598 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003599 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003600 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003601 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003602 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003603 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003604 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003605 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003606 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3607 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003608 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003609 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3610 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003611 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003612 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003613 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003614 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003615 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3616 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003617 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003618 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003619 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003620};
3621
3622static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003623 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003624 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3625 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003626 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003627 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3628 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003629 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003630 .phy_read = mv88e6xxx_g2_smi_phy_read,
3631 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003632 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003633 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003634 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003635 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003636 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003637 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003638 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003639 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003640 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003641 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003642 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003643 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003644 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003645 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003646 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003647 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003648 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003649 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003650 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003651 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3652 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003653 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003654 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3655 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003656 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003657 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003658 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003659 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003660 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003661 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3662 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003663 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003664 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003665 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003666 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003667 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003668 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003669};
3670
3671static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003672 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003673 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3674 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003675 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003676 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003677 .phy_read = mv88e6xxx_g2_smi_phy_read,
3678 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003679 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003680 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003681 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003682 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003683 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003684 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003685 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003686 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003687 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003688 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003689 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003690 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003691 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003692 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003693 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003694 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003695 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003696 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003697 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3698 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003699 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003700 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3701 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003702 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003703 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003704 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003705 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003706 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3707 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003708 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003709 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003710 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003711};
3712
3713static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003714 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003715 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3716 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003717 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003718 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3719 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003720 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003721 .phy_read = mv88e6xxx_g2_smi_phy_read,
3722 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003723 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003724 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003725 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003726 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003727 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003728 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003730 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003732 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003733 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003734 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003735 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003736 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003737 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003738 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003739 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003740 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003741 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003742 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3743 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003744 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003745 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3746 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003747 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003748 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003749 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003750 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003751 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003752 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3753 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003754 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003755 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003756 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003757 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003758 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003759 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003760 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003761 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003762 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003763};
3764
3765static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003766 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003767 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3768 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003769 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003770 .phy_read = mv88e6185_phy_ppu_read,
3771 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003772 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003773 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003774 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003775 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003776 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003777 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003778 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003779 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003780 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003781 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003782 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003783 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3786 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003788 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3789 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003790 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003791 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003792 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003793 .ppu_enable = mv88e6185_g1_ppu_enable,
3794 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003795 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003796 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003797 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003798 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003799};
3800
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003801static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003802 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003803 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003804 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003805 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3806 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003807 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3808 .phy_read = mv88e6xxx_g2_smi_phy_read,
3809 .phy_write = mv88e6xxx_g2_smi_phy_write,
3810 .port_set_link = mv88e6xxx_port_set_link,
3811 .port_set_duplex = mv88e6xxx_port_set_duplex,
3812 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3813 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003814 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003815 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003816 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003817 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003818 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003819 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003820 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003821 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003822 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003823 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003824 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003825 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003827 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003828 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003829 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3830 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003831 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003832 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3833 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003834 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003835 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003837 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003838 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003839 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3840 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003841 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3842 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003843 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003844 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003845 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003846 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003847 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003848 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003849 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003850};
3851
3852static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003853 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003854 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003855 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003856 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3857 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003858 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3859 .phy_read = mv88e6xxx_g2_smi_phy_read,
3860 .phy_write = mv88e6xxx_g2_smi_phy_write,
3861 .port_set_link = mv88e6xxx_port_set_link,
3862 .port_set_duplex = mv88e6xxx_port_set_duplex,
3863 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3864 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003865 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003866 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003867 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003868 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003869 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003870 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003871 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003872 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003873 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003874 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003875 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003876 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003877 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003878 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003879 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003880 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3881 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003882 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003883 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3884 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003885 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003886 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003887 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003888 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003889 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003890 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3891 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003892 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3893 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003894 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003895 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003896 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003897 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003898 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003899 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003900 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003901};
3902
3903static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003904 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003905 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003906 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003907 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3908 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003909 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3910 .phy_read = mv88e6xxx_g2_smi_phy_read,
3911 .phy_write = mv88e6xxx_g2_smi_phy_write,
3912 .port_set_link = mv88e6xxx_port_set_link,
3913 .port_set_duplex = mv88e6xxx_port_set_duplex,
3914 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3915 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003916 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003917 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003918 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003919 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003920 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003921 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003922 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003923 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003924 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003925 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003926 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003927 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003928 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003929 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003930 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3931 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003932 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003933 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3934 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003935 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003936 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003937 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003938 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003939 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003940 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3941 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003942 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3943 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003944 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003945 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003946 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003947 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003948 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003949 .avb_ops = &mv88e6390_avb_ops,
3950 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003951 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003952};
3953
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003954static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003955 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003956 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3957 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003958 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003959 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3960 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003961 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003962 .phy_read = mv88e6xxx_g2_smi_phy_read,
3963 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003964 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003965 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003966 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003967 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003968 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003969 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003970 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003971 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003972 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003973 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003974 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003975 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003976 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003977 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003978 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003979 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003980 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003981 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003982 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003983 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3984 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003985 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003986 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3987 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003988 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003989 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003990 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003991 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003992 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003993 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3994 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003995 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003996 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003997 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003998 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003999 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004000 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004001 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004002 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004003 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004004 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004005 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004006};
4007
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004008static const struct mv88e6xxx_ops mv88e6250_ops = {
4009 /* MV88E6XXX_FAMILY_6250 */
4010 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4011 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4012 .irl_init_all = mv88e6352_g2_irl_init_all,
4013 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4014 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4015 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4016 .phy_read = mv88e6xxx_g2_smi_phy_read,
4017 .phy_write = mv88e6xxx_g2_smi_phy_write,
4018 .port_set_link = mv88e6xxx_port_set_link,
4019 .port_set_duplex = mv88e6xxx_port_set_duplex,
4020 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4021 .port_set_speed = mv88e6250_port_set_speed,
4022 .port_tag_remap = mv88e6095_port_tag_remap,
4023 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4024 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4025 .port_set_ether_type = mv88e6351_port_set_ether_type,
4026 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4027 .port_pause_limit = mv88e6097_port_pause_limit,
4028 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4029 .port_link_state = mv88e6250_port_link_state,
4030 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4031 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4032 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4033 .stats_get_strings = mv88e6250_stats_get_strings,
4034 .stats_get_stats = mv88e6250_stats_get_stats,
4035 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4036 .set_egress_port = mv88e6095_g1_set_egress_port,
4037 .watchdog_ops = &mv88e6250_watchdog_ops,
4038 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4039 .pot_clear = mv88e6xxx_g2_pot_clear,
4040 .reset = mv88e6250_g1_reset,
4041 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4042 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004043 .avb_ops = &mv88e6352_avb_ops,
4044 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004045 .phylink_validate = mv88e6065_phylink_validate,
4046};
4047
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004048static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004049 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004050 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004051 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004052 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4053 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004054 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4055 .phy_read = mv88e6xxx_g2_smi_phy_read,
4056 .phy_write = mv88e6xxx_g2_smi_phy_write,
4057 .port_set_link = mv88e6xxx_port_set_link,
4058 .port_set_duplex = mv88e6xxx_port_set_duplex,
4059 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4060 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004061 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004062 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004063 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004064 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004065 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004066 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004067 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004068 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004069 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004070 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004071 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004072 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004073 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004074 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004075 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004076 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4077 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004078 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004079 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4080 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004081 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004082 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004083 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004084 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004085 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004086 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4087 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004088 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4089 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004090 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004091 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004092 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004093 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004094 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004095 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004096 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004097 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004098 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004099};
4100
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004101static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004102 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004103 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4104 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004105 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004106 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4107 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004108 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004109 .phy_read = mv88e6xxx_g2_smi_phy_read,
4110 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004111 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004112 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004113 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004114 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004115 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004116 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004117 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004118 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004119 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004120 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004121 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004122 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004123 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004124 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004125 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004126 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004127 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004128 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4129 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004130 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004131 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4132 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004133 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004134 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004135 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004136 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004137 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004138 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004139 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004140 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004141 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004142 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004143};
4144
4145static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004146 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004147 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4148 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004149 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004150 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4151 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004152 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004153 .phy_read = mv88e6xxx_g2_smi_phy_read,
4154 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004155 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004156 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004157 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004158 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004159 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004160 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004161 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004162 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004163 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004164 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004165 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004166 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004167 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004168 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004169 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004170 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004171 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004172 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4173 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004174 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004175 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4176 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004177 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004178 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004179 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004180 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004181 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004182 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004183 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004184 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004185};
4186
Vivien Didelot16e329a2017-03-28 13:50:33 -04004187static const struct mv88e6xxx_ops mv88e6341_ops = {
4188 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004189 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4190 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004191 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004192 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4193 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4194 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4195 .phy_read = mv88e6xxx_g2_smi_phy_read,
4196 .phy_write = mv88e6xxx_g2_smi_phy_write,
4197 .port_set_link = mv88e6xxx_port_set_link,
4198 .port_set_duplex = mv88e6xxx_port_set_duplex,
4199 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004200 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004201 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004202 .port_tag_remap = mv88e6095_port_tag_remap,
4203 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4204 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4205 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004206 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004207 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004208 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004209 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4210 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004211 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004212 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004213 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004214 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004215 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004216 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004217 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4218 .stats_get_strings = mv88e6320_stats_get_strings,
4219 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004220 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4221 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004222 .watchdog_ops = &mv88e6390_watchdog_ops,
4223 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004224 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004225 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004226 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004227 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004228 .serdes_power = mv88e6390_serdes_power,
4229 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004230 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004231 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004232 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004233 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004234 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004235 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004236 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004237};
4238
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004239static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004240 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004241 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4242 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004243 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004244 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004245 .phy_read = mv88e6xxx_g2_smi_phy_read,
4246 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004247 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004248 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004249 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004250 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004251 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004252 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004253 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004254 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004255 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004256 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004257 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004258 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004259 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004260 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004261 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004262 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004263 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004264 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004265 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4266 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004267 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004268 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4269 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004270 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004271 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004272 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004273 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004274 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4275 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004276 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004277 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004278 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004279};
4280
4281static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004282 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004283 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4284 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004285 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004286 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004287 .phy_read = mv88e6xxx_g2_smi_phy_read,
4288 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004289 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004290 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004291 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004292 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004293 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004294 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004295 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004296 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004297 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004298 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004299 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004300 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004301 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004302 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004303 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004304 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004305 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004306 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004307 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4308 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004309 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004310 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4311 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004312 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004313 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004314 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004315 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004316 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4317 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004318 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004319 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004320 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004321 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004322 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004323};
4324
4325static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004326 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004327 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4328 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004329 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004330 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4331 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004332 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004333 .phy_read = mv88e6xxx_g2_smi_phy_read,
4334 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004335 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004336 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004337 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004338 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004339 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004340 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004341 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004342 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004343 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004344 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004345 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004346 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004347 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004348 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004349 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004350 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004351 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004352 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004353 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004354 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4355 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004356 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004357 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4358 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004359 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004360 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004361 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004362 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004363 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004364 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4365 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004366 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004367 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004368 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004369 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004370 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004371 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004372 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004373 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004374 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004375 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004376 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4377 .serdes_get_strings = mv88e6352_serdes_get_strings,
4378 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004379 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004380};
4381
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004382static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004383 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004384 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004385 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004386 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4387 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004388 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4389 .phy_read = mv88e6xxx_g2_smi_phy_read,
4390 .phy_write = mv88e6xxx_g2_smi_phy_write,
4391 .port_set_link = mv88e6xxx_port_set_link,
4392 .port_set_duplex = mv88e6xxx_port_set_duplex,
4393 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4394 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004395 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004396 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004397 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004398 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004399 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004400 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004401 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004402 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004403 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004404 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004405 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004406 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004407 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004408 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004409 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004410 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004411 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004412 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4413 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004414 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004415 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4416 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004417 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004418 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004419 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004420 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004421 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004422 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4423 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004424 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4425 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004426 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004427 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004428 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004429 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004430 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004431 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004432 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004433 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004434 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4435 .serdes_get_strings = mv88e6390_serdes_get_strings,
4436 .serdes_get_stats = mv88e6390_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004437 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004438};
4439
4440static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004441 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004442 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004443 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004444 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4445 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004446 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4447 .phy_read = mv88e6xxx_g2_smi_phy_read,
4448 .phy_write = mv88e6xxx_g2_smi_phy_write,
4449 .port_set_link = mv88e6xxx_port_set_link,
4450 .port_set_duplex = mv88e6xxx_port_set_duplex,
4451 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4452 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004453 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004454 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004455 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004456 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004457 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004458 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004459 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004460 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004461 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004462 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004463 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004464 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004465 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004466 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004467 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004468 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004469 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004470 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4471 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004472 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004473 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4474 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004475 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004476 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004477 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004478 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004479 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004480 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4481 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004482 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4483 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004484 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004485 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004486 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004487 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004488 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004489 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004490 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004491 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004492 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004493};
4494
Vivien Didelotf81ec902016-05-09 13:22:58 -04004495static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4496 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004497 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004498 .family = MV88E6XXX_FAMILY_6097,
4499 .name = "Marvell 88E6085",
4500 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004501 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004502 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004503 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004504 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004505 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004506 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004507 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004508 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004509 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004510 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004511 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004512 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004513 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004514 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004515 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004516 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004517 },
4518
4519 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004520 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004521 .family = MV88E6XXX_FAMILY_6095,
4522 .name = "Marvell 88E6095/88E6095F",
4523 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004524 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004525 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004526 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004527 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004528 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004529 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004530 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004531 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004532 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004533 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004534 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004535 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004536 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004537 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004538 },
4539
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004540 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004541 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004542 .family = MV88E6XXX_FAMILY_6097,
4543 .name = "Marvell 88E6097/88E6097F",
4544 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004545 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004546 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004547 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004548 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004549 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004550 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004551 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004552 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004553 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004554 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004555 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004556 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004557 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004558 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004559 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004560 .ops = &mv88e6097_ops,
4561 },
4562
Vivien Didelotf81ec902016-05-09 13:22:58 -04004563 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004564 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004565 .family = MV88E6XXX_FAMILY_6165,
4566 .name = "Marvell 88E6123",
4567 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004568 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004569 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004570 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004571 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004572 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004573 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004574 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004575 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004576 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004577 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004578 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004579 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004580 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004581 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004582 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004583 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 },
4585
4586 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004587 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004588 .family = MV88E6XXX_FAMILY_6185,
4589 .name = "Marvell 88E6131",
4590 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004591 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004592 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004593 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004594 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004595 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004596 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004597 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004598 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004599 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004600 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004601 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004602 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004603 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004604 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004605 },
4606
Vivien Didelot990e27b2017-03-28 13:50:32 -04004607 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004608 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004609 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004610 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004611 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004612 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004613 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004614 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004615 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004616 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004617 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004618 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004619 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004620 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004621 .age_time_coeff = 3750,
4622 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004623 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004624 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004625 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004626 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004627 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004628 .ops = &mv88e6141_ops,
4629 },
4630
Vivien Didelotf81ec902016-05-09 13:22:58 -04004631 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004632 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004633 .family = MV88E6XXX_FAMILY_6165,
4634 .name = "Marvell 88E6161",
4635 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004636 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004637 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004638 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004639 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004640 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004641 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004642 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004643 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004644 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004645 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004646 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004647 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004648 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004649 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004650 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004651 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004652 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004653 },
4654
4655 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004656 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004657 .family = MV88E6XXX_FAMILY_6165,
4658 .name = "Marvell 88E6165",
4659 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004660 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004661 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004662 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004663 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004664 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004665 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004666 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004667 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004668 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004669 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004670 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004671 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004672 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004673 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004674 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004675 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004676 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004677 },
4678
4679 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004680 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004681 .family = MV88E6XXX_FAMILY_6351,
4682 .name = "Marvell 88E6171",
4683 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004684 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004685 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004686 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004687 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004688 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004689 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004690 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004691 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004692 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004693 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004694 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004695 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004696 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004697 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004698 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004699 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004700 },
4701
4702 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004703 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004704 .family = MV88E6XXX_FAMILY_6352,
4705 .name = "Marvell 88E6172",
4706 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004707 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004708 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004709 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004710 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004711 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004712 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004713 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004714 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004715 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004716 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004717 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004718 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004719 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004720 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004721 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004722 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004723 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004724 },
4725
4726 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004727 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 .family = MV88E6XXX_FAMILY_6351,
4729 .name = "Marvell 88E6175",
4730 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004731 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004732 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004733 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004734 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004735 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004736 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004737 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004738 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004739 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004740 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004741 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004742 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004743 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004744 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004745 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004746 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 },
4748
4749 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004750 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004751 .family = MV88E6XXX_FAMILY_6352,
4752 .name = "Marvell 88E6176",
4753 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004754 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004755 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004756 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004757 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004758 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004759 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004760 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004761 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004762 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004763 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004764 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004765 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004766 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004767 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004768 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004769 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004770 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004771 },
4772
4773 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004774 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 .family = MV88E6XXX_FAMILY_6185,
4776 .name = "Marvell 88E6185",
4777 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004778 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004779 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004780 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004781 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004782 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004783 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004784 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004785 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004786 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004787 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004788 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004789 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004790 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004791 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004792 },
4793
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004794 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004795 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004796 .family = MV88E6XXX_FAMILY_6390,
4797 .name = "Marvell 88E6190",
4798 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004799 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004800 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004801 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004802 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004803 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004804 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004805 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004806 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004807 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004808 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004809 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004810 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004811 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004812 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004813 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004814 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004815 .ops = &mv88e6190_ops,
4816 },
4817
4818 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004819 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004820 .family = MV88E6XXX_FAMILY_6390,
4821 .name = "Marvell 88E6190X",
4822 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004823 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004824 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004825 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004826 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004827 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004828 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004829 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004830 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004831 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004832 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004833 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004834 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004835 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004836 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004837 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004838 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004839 .ops = &mv88e6190x_ops,
4840 },
4841
4842 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004843 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004844 .family = MV88E6XXX_FAMILY_6390,
4845 .name = "Marvell 88E6191",
4846 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004847 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004848 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004849 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004850 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004851 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004852 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004853 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004854 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004855 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004856 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004857 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004858 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004859 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004860 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004861 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004862 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004863 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004864 },
4865
Hubert Feurstein49022642019-07-31 10:23:46 +02004866 [MV88E6220] = {
4867 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4868 .family = MV88E6XXX_FAMILY_6250,
4869 .name = "Marvell 88E6220",
4870 .num_databases = 64,
4871
4872 /* Ports 2-4 are not routed to pins
4873 * => usable ports 0, 1, 5, 6
4874 */
4875 .num_ports = 7,
4876 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004877 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004878 .max_vid = 4095,
4879 .port_base_addr = 0x08,
4880 .phy_base_addr = 0x00,
4881 .global1_addr = 0x0f,
4882 .global2_addr = 0x07,
4883 .age_time_coeff = 15000,
4884 .g1_irqs = 9,
4885 .g2_irqs = 10,
4886 .atu_move_port_mask = 0xf,
4887 .dual_chip = true,
4888 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004889 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004890 .ops = &mv88e6250_ops,
4891 },
4892
Vivien Didelotf81ec902016-05-09 13:22:58 -04004893 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004894 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004895 .family = MV88E6XXX_FAMILY_6352,
4896 .name = "Marvell 88E6240",
4897 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004898 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004899 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004900 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004901 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004902 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004903 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004904 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004905 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004906 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004907 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004908 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004909 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004910 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004911 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004912 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004913 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004914 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004915 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004916 },
4917
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004918 [MV88E6250] = {
4919 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4920 .family = MV88E6XXX_FAMILY_6250,
4921 .name = "Marvell 88E6250",
4922 .num_databases = 64,
4923 .num_ports = 7,
4924 .num_internal_phys = 5,
4925 .max_vid = 4095,
4926 .port_base_addr = 0x08,
4927 .phy_base_addr = 0x00,
4928 .global1_addr = 0x0f,
4929 .global2_addr = 0x07,
4930 .age_time_coeff = 15000,
4931 .g1_irqs = 9,
4932 .g2_irqs = 10,
4933 .atu_move_port_mask = 0xf,
4934 .dual_chip = true,
4935 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004936 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004937 .ops = &mv88e6250_ops,
4938 },
4939
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004940 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004941 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004942 .family = MV88E6XXX_FAMILY_6390,
4943 .name = "Marvell 88E6290",
4944 .num_databases = 4096,
4945 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004946 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004947 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004948 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004949 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004950 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004951 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004952 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004953 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004954 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004955 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004956 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004957 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004958 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004959 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004960 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004961 .ops = &mv88e6290_ops,
4962 },
4963
Vivien Didelotf81ec902016-05-09 13:22:58 -04004964 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004965 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004966 .family = MV88E6XXX_FAMILY_6320,
4967 .name = "Marvell 88E6320",
4968 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004969 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004970 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004971 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004972 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004973 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004974 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004975 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004976 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004977 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004978 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004979 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004980 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004981 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004982 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004983 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004984 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004985 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004986 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004987 },
4988
4989 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004990 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004991 .family = MV88E6XXX_FAMILY_6320,
4992 .name = "Marvell 88E6321",
4993 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004994 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004995 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004996 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004997 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004998 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004999 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005000 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005001 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005002 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005003 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005004 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005005 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005006 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005007 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005008 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005009 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005010 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005011 },
5012
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005013 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005014 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005015 .family = MV88E6XXX_FAMILY_6341,
5016 .name = "Marvell 88E6341",
5017 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005018 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005019 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005020 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005021 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005022 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005023 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005024 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005025 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005026 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005027 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005028 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005029 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005030 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005031 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005032 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005033 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005034 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005035 .ops = &mv88e6341_ops,
5036 },
5037
Vivien Didelotf81ec902016-05-09 13:22:58 -04005038 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005039 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005040 .family = MV88E6XXX_FAMILY_6351,
5041 .name = "Marvell 88E6350",
5042 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005043 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005044 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005045 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005046 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005047 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005048 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005049 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005050 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005051 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005052 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005053 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005054 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005055 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005056 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005057 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005058 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005059 },
5060
5061 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005062 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005063 .family = MV88E6XXX_FAMILY_6351,
5064 .name = "Marvell 88E6351",
5065 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005066 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005067 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005068 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005069 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005070 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005071 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005072 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005073 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005074 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005075 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005076 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005077 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005078 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005079 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005080 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005081 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005082 },
5083
5084 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005085 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005086 .family = MV88E6XXX_FAMILY_6352,
5087 .name = "Marvell 88E6352",
5088 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005089 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005090 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005091 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005092 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005093 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005094 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005095 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005096 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005097 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005098 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005099 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005100 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005101 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005102 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005103 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005104 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005105 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005106 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005107 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005108 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005109 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005110 .family = MV88E6XXX_FAMILY_6390,
5111 .name = "Marvell 88E6390",
5112 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005113 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005114 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005115 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005116 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005117 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005118 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005119 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005120 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005121 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005122 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005123 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005124 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005125 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005126 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005127 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005128 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005129 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005130 .ops = &mv88e6390_ops,
5131 },
5132 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005133 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005134 .family = MV88E6XXX_FAMILY_6390,
5135 .name = "Marvell 88E6390X",
5136 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005137 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005138 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005139 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005140 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005141 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005142 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005143 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005144 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005145 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005146 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005147 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005148 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005149 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005150 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005151 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005152 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005153 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005154 .ops = &mv88e6390x_ops,
5155 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005156};
5157
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005158static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005159{
Vivien Didelota439c062016-04-17 13:23:58 -04005160 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005161
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005162 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5163 if (mv88e6xxx_table[i].prod_num == prod_num)
5164 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005165
Vivien Didelotb9b37712015-10-30 19:39:48 -04005166 return NULL;
5167}
5168
Vivien Didelotfad09c72016-06-21 12:28:20 -04005169static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005170{
5171 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005172 unsigned int prod_num, rev;
5173 u16 id;
5174 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005175
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005176 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005177 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005178 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005179 if (err)
5180 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005181
Vivien Didelot107fcc12017-06-12 12:37:36 -04005182 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5183 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005184
5185 info = mv88e6xxx_lookup_info(prod_num);
5186 if (!info)
5187 return -ENODEV;
5188
Vivien Didelotcaac8542016-06-20 13:14:09 -04005189 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005190 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005191
Vivien Didelotca070c12016-09-02 14:45:34 -04005192 err = mv88e6xxx_g2_require(chip);
5193 if (err)
5194 return err;
5195
Vivien Didelotfad09c72016-06-21 12:28:20 -04005196 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5197 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005198
5199 return 0;
5200}
5201
Vivien Didelotfad09c72016-06-21 12:28:20 -04005202static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005203{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005204 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005205
Vivien Didelotfad09c72016-06-21 12:28:20 -04005206 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5207 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005208 return NULL;
5209
Vivien Didelotfad09c72016-06-21 12:28:20 -04005210 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005211
Vivien Didelotfad09c72016-06-21 12:28:20 -04005212 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005213 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005214 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005215
Vivien Didelotfad09c72016-06-21 12:28:20 -04005216 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005217}
5218
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005219static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005220 int port,
5221 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005222{
Vivien Didelot04bed142016-08-31 18:06:13 -04005223 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005224
Andrew Lunn443d5a12016-12-03 04:35:18 +01005225 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005226}
5227
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005228static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005229 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005230{
5231 /* We don't need any dynamic resource from the kernel (yet),
5232 * so skip the prepare phase.
5233 */
5234
5235 return 0;
5236}
5237
5238static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005239 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005240{
Vivien Didelot04bed142016-08-31 18:06:13 -04005241 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005242
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005243 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005244 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005245 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005246 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5247 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005248 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005249}
5250
5251static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5252 const struct switchdev_obj_port_mdb *mdb)
5253{
Vivien Didelot04bed142016-08-31 18:06:13 -04005254 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005255 int err;
5256
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005257 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005258 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005259 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005260
5261 return err;
5262}
5263
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005264static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5265 struct dsa_mall_mirror_tc_entry *mirror,
5266 bool ingress)
5267{
5268 enum mv88e6xxx_egress_direction direction = ingress ?
5269 MV88E6XXX_EGRESS_DIR_INGRESS :
5270 MV88E6XXX_EGRESS_DIR_EGRESS;
5271 struct mv88e6xxx_chip *chip = ds->priv;
5272 bool other_mirrors = false;
5273 int i;
5274 int err;
5275
5276 if (!chip->info->ops->set_egress_port)
5277 return -EOPNOTSUPP;
5278
5279 mutex_lock(&chip->reg_lock);
5280 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5281 mirror->to_local_port) {
5282 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5283 other_mirrors |= ingress ?
5284 chip->ports[i].mirror_ingress :
5285 chip->ports[i].mirror_egress;
5286
5287 /* Can't change egress port when other mirror is active */
5288 if (other_mirrors) {
5289 err = -EBUSY;
5290 goto out;
5291 }
5292
5293 err = chip->info->ops->set_egress_port(chip,
5294 direction,
5295 mirror->to_local_port);
5296 if (err)
5297 goto out;
5298 }
5299
5300 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5301out:
5302 mutex_unlock(&chip->reg_lock);
5303
5304 return err;
5305}
5306
5307static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5308 struct dsa_mall_mirror_tc_entry *mirror)
5309{
5310 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5311 MV88E6XXX_EGRESS_DIR_INGRESS :
5312 MV88E6XXX_EGRESS_DIR_EGRESS;
5313 struct mv88e6xxx_chip *chip = ds->priv;
5314 bool other_mirrors = false;
5315 int i;
5316
5317 mutex_lock(&chip->reg_lock);
5318 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5319 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5320
5321 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5322 other_mirrors |= mirror->ingress ?
5323 chip->ports[i].mirror_ingress :
5324 chip->ports[i].mirror_egress;
5325
5326 /* Reset egress port when no other mirror is active */
5327 if (!other_mirrors) {
5328 if (chip->info->ops->set_egress_port(chip,
5329 direction,
5330 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005331 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005332 dev_err(ds->dev, "failed to set egress port\n");
5333 }
5334
5335 mutex_unlock(&chip->reg_lock);
5336}
5337
Russell King4f859012019-02-20 15:35:05 -08005338static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5339 bool unicast, bool multicast)
5340{
5341 struct mv88e6xxx_chip *chip = ds->priv;
5342 int err = -EOPNOTSUPP;
5343
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005344 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005345 if (chip->info->ops->port_set_egress_floods)
5346 err = chip->info->ops->port_set_egress_floods(chip, port,
5347 unicast,
5348 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005349 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005350
5351 return err;
5352}
5353
Florian Fainellia82f67a2017-01-08 14:52:08 -08005354static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005355 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005356 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005357 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005358 .phylink_validate = mv88e6xxx_validate,
5359 .phylink_mac_link_state = mv88e6xxx_link_state,
5360 .phylink_mac_config = mv88e6xxx_mac_config,
5361 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5362 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005363 .get_strings = mv88e6xxx_get_strings,
5364 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5365 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005366 .port_enable = mv88e6xxx_port_enable,
5367 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005368 .get_mac_eee = mv88e6xxx_get_mac_eee,
5369 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005370 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005371 .get_eeprom = mv88e6xxx_get_eeprom,
5372 .set_eeprom = mv88e6xxx_set_eeprom,
5373 .get_regs_len = mv88e6xxx_get_regs_len,
5374 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005375 .get_rxnfc = mv88e6xxx_get_rxnfc,
5376 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005377 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005378 .port_bridge_join = mv88e6xxx_port_bridge_join,
5379 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005380 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005381 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005382 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005383 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5384 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5385 .port_vlan_add = mv88e6xxx_port_vlan_add,
5386 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005387 .port_fdb_add = mv88e6xxx_port_fdb_add,
5388 .port_fdb_del = mv88e6xxx_port_fdb_del,
5389 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005390 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5391 .port_mdb_add = mv88e6xxx_port_mdb_add,
5392 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005393 .port_mirror_add = mv88e6xxx_port_mirror_add,
5394 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005395 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5396 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005397 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5398 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5399 .port_txtstamp = mv88e6xxx_port_txtstamp,
5400 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5401 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005402 .devlink_param_get = mv88e6xxx_devlink_param_get,
5403 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005404};
5405
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005406static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005407{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005408 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005409 struct dsa_switch *ds;
5410
Vivien Didelot7e99e342019-10-21 16:51:30 -04005411 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005412 if (!ds)
5413 return -ENOMEM;
5414
Vivien Didelot7e99e342019-10-21 16:51:30 -04005415 ds->dev = dev;
5416 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005417 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005418 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005419 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005420 ds->ageing_time_min = chip->info->age_time_coeff;
5421 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005422
5423 dev_set_drvdata(dev, ds);
5424
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005425 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005426}
5427
Vivien Didelotfad09c72016-06-21 12:28:20 -04005428static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005429{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005430 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005431}
5432
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005433static const void *pdata_device_get_match_data(struct device *dev)
5434{
5435 const struct of_device_id *matches = dev->driver->of_match_table;
5436 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5437
5438 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5439 matches++) {
5440 if (!strcmp(pdata->compatible, matches->compatible))
5441 return matches->data;
5442 }
5443 return NULL;
5444}
5445
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005446/* There is no suspend to RAM support at DSA level yet, the switch configuration
5447 * would be lost after a power cycle so prevent it to be suspended.
5448 */
5449static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5450{
5451 return -EOPNOTSUPP;
5452}
5453
5454static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5455{
5456 return 0;
5457}
5458
5459static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5460
Vivien Didelot57d32312016-06-20 13:13:58 -04005461static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005462{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005463 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005464 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005465 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005466 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005467 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005468 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005469 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005470
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005471 if (!np && !pdata)
5472 return -EINVAL;
5473
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005474 if (np)
5475 compat_info = of_device_get_match_data(dev);
5476
5477 if (pdata) {
5478 compat_info = pdata_device_get_match_data(dev);
5479
5480 if (!pdata->netdev)
5481 return -EINVAL;
5482
5483 for (port = 0; port < DSA_MAX_PORTS; port++) {
5484 if (!(pdata->enabled_ports & (1 << port)))
5485 continue;
5486 if (strcmp(pdata->cd.port_names[port], "cpu"))
5487 continue;
5488 pdata->cd.netdev[port] = &pdata->netdev->dev;
5489 break;
5490 }
5491 }
5492
Vivien Didelotcaac8542016-06-20 13:14:09 -04005493 if (!compat_info)
5494 return -EINVAL;
5495
Vivien Didelotfad09c72016-06-21 12:28:20 -04005496 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005497 if (!chip) {
5498 err = -ENOMEM;
5499 goto out;
5500 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005501
Vivien Didelotfad09c72016-06-21 12:28:20 -04005502 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005503
Vivien Didelotfad09c72016-06-21 12:28:20 -04005504 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005505 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005506 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005507
Andrew Lunnb4308f02016-11-21 23:26:55 +01005508 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005509 if (IS_ERR(chip->reset)) {
5510 err = PTR_ERR(chip->reset);
5511 goto out;
5512 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005513 if (chip->reset)
5514 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005515
Vivien Didelotfad09c72016-06-21 12:28:20 -04005516 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005517 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005518 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005519
Vivien Didelote57e5e72016-08-15 17:19:00 -04005520 mv88e6xxx_phy_init(chip);
5521
Andrew Lunn00baabe2018-05-19 22:31:35 +02005522 if (chip->info->ops->get_eeprom) {
5523 if (np)
5524 of_property_read_u32(np, "eeprom-length",
5525 &chip->eeprom_len);
5526 else
5527 chip->eeprom_len = pdata->eeprom_len;
5528 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005529
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005530 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005531 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005532 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005533 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005534 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005535
Andrew Lunna27415d2019-05-01 00:10:50 +02005536 if (np) {
5537 chip->irq = of_irq_get(np, 0);
5538 if (chip->irq == -EPROBE_DEFER) {
5539 err = chip->irq;
5540 goto out;
5541 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005542 }
5543
Andrew Lunna27415d2019-05-01 00:10:50 +02005544 if (pdata)
5545 chip->irq = pdata->irq;
5546
Andrew Lunn294d7112018-02-22 22:58:32 +01005547 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005548 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005549 * controllers
5550 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005551 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005552 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005553 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005554 else
5555 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005556 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005557
Andrew Lunn294d7112018-02-22 22:58:32 +01005558 if (err)
5559 goto out;
5560
5561 if (chip->info->g2_irqs > 0) {
5562 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005563 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005564 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005565 }
5566
Andrew Lunn294d7112018-02-22 22:58:32 +01005567 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5568 if (err)
5569 goto out_g2_irq;
5570
5571 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5572 if (err)
5573 goto out_g1_atu_prob_irq;
5574
Andrew Lunna3c53be52017-01-24 14:53:50 +01005575 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005576 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005577 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005578
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005579 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005580 if (err)
5581 goto out_mdio;
5582
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005583 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005584
5585out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005586 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005587out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005588 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005589out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005590 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005591out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005592 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005593 mv88e6xxx_g2_irq_free(chip);
5594out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005595 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005596 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005597 else
5598 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005599out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005600 if (pdata)
5601 dev_put(pdata->netdev);
5602
Andrew Lunndc30c352016-10-16 19:56:49 +02005603 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005604}
5605
5606static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5607{
5608 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005609 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005610
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005611 if (chip->info->ptp_support) {
5612 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005613 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005614 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005615
Andrew Lunn930188c2016-08-22 16:01:03 +02005616 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005617 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005618 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005619
Andrew Lunn76f38f12018-03-17 20:21:09 +01005620 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5621 mv88e6xxx_g1_atu_prob_irq_free(chip);
5622
5623 if (chip->info->g2_irqs > 0)
5624 mv88e6xxx_g2_irq_free(chip);
5625
Andrew Lunn76f38f12018-03-17 20:21:09 +01005626 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005627 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005628 else
5629 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005630}
5631
5632static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005633 {
5634 .compatible = "marvell,mv88e6085",
5635 .data = &mv88e6xxx_table[MV88E6085],
5636 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005637 {
5638 .compatible = "marvell,mv88e6190",
5639 .data = &mv88e6xxx_table[MV88E6190],
5640 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005641 {
5642 .compatible = "marvell,mv88e6250",
5643 .data = &mv88e6xxx_table[MV88E6250],
5644 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005645 { /* sentinel */ },
5646};
5647
5648MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5649
5650static struct mdio_driver mv88e6xxx_driver = {
5651 .probe = mv88e6xxx_probe,
5652 .remove = mv88e6xxx_remove,
5653 .mdiodrv.driver = {
5654 .name = "mv88e6085",
5655 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005656 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005657 },
5658};
5659
Andrew Lunn7324d502019-04-27 19:19:10 +02005660mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005661
5662MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5663MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5664MODULE_LICENSE("GPL");