blob: e21e460c11f774463b8eee91951b7dfd85727d90 [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
2309 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2310 mv88e6xxx_reg_unlock(chip);
2311 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
2312 IRQF_ONESHOT, "mv88e6xxx-serdes", dev_id);
2313 mv88e6xxx_reg_lock(chip);
2314 if (err)
2315 return err;
2316
2317 dev_id->serdes_irq = irq;
2318
2319 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2320}
2321
2322static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2323 u8 lane)
2324{
2325 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2326 unsigned int irq = dev_id->serdes_irq;
2327 int err;
2328
2329 /* Nothing to free if no IRQ has been requested */
2330 if (!irq)
2331 return 0;
2332
2333 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2334
2335 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2336 mv88e6xxx_reg_unlock(chip);
2337 free_irq(irq, dev_id);
2338 mv88e6xxx_reg_lock(chip);
2339
2340 dev_id->serdes_irq = 0;
2341
2342 return err;
2343}
2344
Andrew Lunn6d917822017-05-26 01:03:21 +02002345static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2346 bool on)
2347{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002348 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002349 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002350
Vivien Didelotdc272f62019-08-31 16:18:33 -04002351 lane = mv88e6xxx_serdes_get_lane(chip, port);
2352 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002353 return 0;
2354
2355 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002356 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002357 if (err)
2358 return err;
2359
Vivien Didelot45de77f2019-08-31 16:18:36 -04002360 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002361 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002362 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2363 if (err)
2364 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002365
Vivien Didelotdc272f62019-08-31 16:18:33 -04002366 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002367 }
2368
2369 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002370}
2371
Vivien Didelotfa371c82017-12-05 15:34:10 -05002372static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2373{
2374 struct dsa_switch *ds = chip->ds;
2375 int upstream_port;
2376 int err;
2377
Vivien Didelot07073c72017-12-05 15:34:13 -05002378 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002379 if (chip->info->ops->port_set_upstream_port) {
2380 err = chip->info->ops->port_set_upstream_port(chip, port,
2381 upstream_port);
2382 if (err)
2383 return err;
2384 }
2385
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002386 if (port == upstream_port) {
2387 if (chip->info->ops->set_cpu_port) {
2388 err = chip->info->ops->set_cpu_port(chip,
2389 upstream_port);
2390 if (err)
2391 return err;
2392 }
2393
2394 if (chip->info->ops->set_egress_port) {
2395 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002396 MV88E6XXX_EGRESS_DIR_INGRESS,
2397 upstream_port);
2398 if (err)
2399 return err;
2400
2401 err = chip->info->ops->set_egress_port(chip,
2402 MV88E6XXX_EGRESS_DIR_EGRESS,
2403 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002404 if (err)
2405 return err;
2406 }
2407 }
2408
Vivien Didelotfa371c82017-12-05 15:34:10 -05002409 return 0;
2410}
2411
Vivien Didelotfad09c72016-06-21 12:28:20 -04002412static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002413{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002414 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002415 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002416 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002417
Andrew Lunn7b898462018-08-09 15:38:47 +02002418 chip->ports[port].chip = chip;
2419 chip->ports[port].port = port;
2420
Vivien Didelotd78343d2016-11-04 03:23:36 +01002421 /* MAC Forcing register: don't force link, speed, duplex or flow control
2422 * state to any particular values on physical ports, but force the CPU
2423 * port and all DSA ports to their maximum bandwidth and full duplex.
2424 */
2425 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2426 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2427 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002428 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002429 PHY_INTERFACE_MODE_NA);
2430 else
2431 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2432 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002433 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002434 PHY_INTERFACE_MODE_NA);
2435 if (err)
2436 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002437
2438 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2439 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2440 * tunneling, determine priority by looking at 802.1p and IP
2441 * priority fields (IP prio has precedence), and set STP state
2442 * to Forwarding.
2443 *
2444 * If this is the CPU link, use DSA or EDSA tagging depending
2445 * on which tagging mode was configured.
2446 *
2447 * If this is a link to another switch, use DSA tagging mode.
2448 *
2449 * If this is the upstream port for this switch, enable
2450 * forwarding of unknown unicasts and multicasts.
2451 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002452 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2453 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2454 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2455 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002456 if (err)
2457 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002458
Vivien Didelot601aeed2017-03-11 16:13:00 -05002459 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002460 if (err)
2461 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002462
Vivien Didelot601aeed2017-03-11 16:13:00 -05002463 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002464 if (err)
2465 return err;
2466
Vivien Didelot8efdda42015-08-13 12:52:23 -04002467 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002468 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002469 * untagged frames on this port, do a destination address lookup on all
2470 * received packets as usual, disable ARP mirroring and don't send a
2471 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002472 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002473 err = mv88e6xxx_port_set_map_da(chip, port);
2474 if (err)
2475 return err;
2476
Vivien Didelotfa371c82017-12-05 15:34:10 -05002477 err = mv88e6xxx_setup_upstream_port(chip, port);
2478 if (err)
2479 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002480
Andrew Lunna23b2962017-02-04 20:15:28 +01002481 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002482 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002483 if (err)
2484 return err;
2485
Vivien Didelotcd782652017-06-08 18:34:13 -04002486 if (chip->info->ops->port_set_jumbo_size) {
2487 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002488 if (err)
2489 return err;
2490 }
2491
Andrew Lunn54d792f2015-05-06 01:09:47 +02002492 /* Port Association Vector: when learning source addresses
2493 * of packets, add the address to the address database using
2494 * a port bitmap that has only the bit for this port set and
2495 * the other bits clear.
2496 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002497 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002498 /* Disable learning for CPU port */
2499 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002500 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002501
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002502 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2503 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002504 if (err)
2505 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002506
2507 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002508 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2509 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002510 if (err)
2511 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002512
Vivien Didelot08984322017-06-08 18:34:12 -04002513 if (chip->info->ops->port_pause_limit) {
2514 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002515 if (err)
2516 return err;
2517 }
2518
Vivien Didelotc8c94892017-03-11 16:13:01 -05002519 if (chip->info->ops->port_disable_learn_limit) {
2520 err = chip->info->ops->port_disable_learn_limit(chip, port);
2521 if (err)
2522 return err;
2523 }
2524
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002525 if (chip->info->ops->port_disable_pri_override) {
2526 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002527 if (err)
2528 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002529 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002530
Andrew Lunnef0a7312016-12-03 04:35:16 +01002531 if (chip->info->ops->port_tag_remap) {
2532 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002533 if (err)
2534 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002535 }
2536
Andrew Lunnef70b112016-12-03 04:45:18 +01002537 if (chip->info->ops->port_egress_rate_limiting) {
2538 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002539 if (err)
2540 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002541 }
2542
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002543 if (chip->info->ops->port_setup_message_port) {
2544 err = chip->info->ops->port_setup_message_port(chip, port);
2545 if (err)
2546 return err;
2547 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002548
Vivien Didelot207afda2016-04-14 14:42:09 -04002549 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002550 * database, and allow bidirectional communication between the
2551 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002552 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002553 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002554 if (err)
2555 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002556
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002557 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002558 if (err)
2559 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002560
2561 /* Default VLAN ID and priority: don't set a default VLAN
2562 * ID, and set the default packet priority to zero.
2563 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002564 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002565}
2566
Andrew Lunn04aca992017-05-26 01:03:24 +02002567static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2568 struct phy_device *phydev)
2569{
2570 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002571 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002572
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002573 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002574 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002575 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002576
2577 return err;
2578}
2579
Andrew Lunn75104db2019-02-24 20:44:43 +01002580static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002581{
2582 struct mv88e6xxx_chip *chip = ds->priv;
2583
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002584 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002585 if (mv88e6xxx_serdes_power(chip, port, false))
2586 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002587 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002588}
2589
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002590static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2591 unsigned int ageing_time)
2592{
Vivien Didelot04bed142016-08-31 18:06:13 -04002593 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002594 int err;
2595
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002596 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002597 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002598 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002599
2600 return err;
2601}
2602
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002603static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002604{
2605 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002606
Andrew Lunnde2273872016-11-21 23:27:01 +01002607 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002608 if (chip->info->ops->stats_set_histogram) {
2609 err = chip->info->ops->stats_set_histogram(chip);
2610 if (err)
2611 return err;
2612 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002613
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002614 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002615}
2616
Andrew Lunnea890982019-01-09 00:24:03 +01002617/* Check if the errata has already been applied. */
2618static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2619{
2620 int port;
2621 int err;
2622 u16 val;
2623
2624 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002625 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002626 if (err) {
2627 dev_err(chip->dev,
2628 "Error reading hidden register: %d\n", err);
2629 return false;
2630 }
2631 if (val != 0x01c0)
2632 return false;
2633 }
2634
2635 return true;
2636}
2637
2638/* The 6390 copper ports have an errata which require poking magic
2639 * values into undocumented hidden registers and then performing a
2640 * software reset.
2641 */
2642static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2643{
2644 int port;
2645 int err;
2646
2647 if (mv88e6390_setup_errata_applied(chip))
2648 return 0;
2649
2650 /* Set the ports into blocking mode */
2651 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2652 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2653 if (err)
2654 return err;
2655 }
2656
2657 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002658 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002659 if (err)
2660 return err;
2661 }
2662
2663 return mv88e6xxx_software_reset(chip);
2664}
2665
Andrew Lunn23e8b472019-10-25 01:03:52 +02002666enum mv88e6xxx_devlink_param_id {
2667 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2668 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2669};
2670
2671static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2672 struct devlink_param_gset_ctx *ctx)
2673{
2674 struct mv88e6xxx_chip *chip = ds->priv;
2675 int err;
2676
2677 mv88e6xxx_reg_lock(chip);
2678
2679 switch (id) {
2680 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2681 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2682 break;
2683 default:
2684 err = -EOPNOTSUPP;
2685 break;
2686 }
2687
2688 mv88e6xxx_reg_unlock(chip);
2689
2690 return err;
2691}
2692
2693static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2694 struct devlink_param_gset_ctx *ctx)
2695{
2696 struct mv88e6xxx_chip *chip = ds->priv;
2697 int err;
2698
2699 mv88e6xxx_reg_lock(chip);
2700
2701 switch (id) {
2702 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2703 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2704 break;
2705 default:
2706 err = -EOPNOTSUPP;
2707 break;
2708 }
2709
2710 mv88e6xxx_reg_unlock(chip);
2711
2712 return err;
2713}
2714
2715static const struct devlink_param mv88e6xxx_devlink_params[] = {
2716 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2717 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2718 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2719};
2720
2721static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2722{
2723 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2724 ARRAY_SIZE(mv88e6xxx_devlink_params));
2725}
2726
2727static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2728{
2729 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2730 ARRAY_SIZE(mv88e6xxx_devlink_params));
2731}
2732
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002733enum mv88e6xxx_devlink_resource_id {
2734 MV88E6XXX_RESOURCE_ID_ATU,
2735 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2736 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2737 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2738 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2739};
2740
2741static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2742 u16 bin)
2743{
2744 u16 occupancy = 0;
2745 int err;
2746
2747 mv88e6xxx_reg_lock(chip);
2748
2749 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2750 bin);
2751 if (err) {
2752 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2753 goto unlock;
2754 }
2755
2756 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2757 if (err) {
2758 dev_err(chip->dev, "failed to perform ATU get next\n");
2759 goto unlock;
2760 }
2761
2762 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2763 if (err) {
2764 dev_err(chip->dev, "failed to get ATU stats\n");
2765 goto unlock;
2766 }
2767
2768unlock:
2769 mv88e6xxx_reg_unlock(chip);
2770
2771 return occupancy;
2772}
2773
2774static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2775{
2776 struct mv88e6xxx_chip *chip = priv;
2777
2778 return mv88e6xxx_devlink_atu_bin_get(chip,
2779 MV88E6XXX_G2_ATU_STATS_BIN_0);
2780}
2781
2782static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2783{
2784 struct mv88e6xxx_chip *chip = priv;
2785
2786 return mv88e6xxx_devlink_atu_bin_get(chip,
2787 MV88E6XXX_G2_ATU_STATS_BIN_1);
2788}
2789
2790static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2791{
2792 struct mv88e6xxx_chip *chip = priv;
2793
2794 return mv88e6xxx_devlink_atu_bin_get(chip,
2795 MV88E6XXX_G2_ATU_STATS_BIN_2);
2796}
2797
2798static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2799{
2800 struct mv88e6xxx_chip *chip = priv;
2801
2802 return mv88e6xxx_devlink_atu_bin_get(chip,
2803 MV88E6XXX_G2_ATU_STATS_BIN_3);
2804}
2805
2806static u64 mv88e6xxx_devlink_atu_get(void *priv)
2807{
2808 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2809 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2810 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2811 mv88e6xxx_devlink_atu_bin_3_get(priv);
2812}
2813
2814static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2815{
2816 struct devlink_resource_size_params size_params;
2817 struct mv88e6xxx_chip *chip = ds->priv;
2818 int err;
2819
2820 devlink_resource_size_params_init(&size_params,
2821 mv88e6xxx_num_macs(chip),
2822 mv88e6xxx_num_macs(chip),
2823 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2824
2825 err = dsa_devlink_resource_register(ds, "ATU",
2826 mv88e6xxx_num_macs(chip),
2827 MV88E6XXX_RESOURCE_ID_ATU,
2828 DEVLINK_RESOURCE_ID_PARENT_TOP,
2829 &size_params);
2830 if (err)
2831 goto out;
2832
2833 devlink_resource_size_params_init(&size_params,
2834 mv88e6xxx_num_macs(chip) / 4,
2835 mv88e6xxx_num_macs(chip) / 4,
2836 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2837
2838 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2839 mv88e6xxx_num_macs(chip) / 4,
2840 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2841 MV88E6XXX_RESOURCE_ID_ATU,
2842 &size_params);
2843 if (err)
2844 goto out;
2845
2846 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2847 mv88e6xxx_num_macs(chip) / 4,
2848 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2849 MV88E6XXX_RESOURCE_ID_ATU,
2850 &size_params);
2851 if (err)
2852 goto out;
2853
2854 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2855 mv88e6xxx_num_macs(chip) / 4,
2856 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2857 MV88E6XXX_RESOURCE_ID_ATU,
2858 &size_params);
2859 if (err)
2860 goto out;
2861
2862 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2863 mv88e6xxx_num_macs(chip) / 4,
2864 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2865 MV88E6XXX_RESOURCE_ID_ATU,
2866 &size_params);
2867 if (err)
2868 goto out;
2869
2870 dsa_devlink_resource_occ_get_register(ds,
2871 MV88E6XXX_RESOURCE_ID_ATU,
2872 mv88e6xxx_devlink_atu_get,
2873 chip);
2874
2875 dsa_devlink_resource_occ_get_register(ds,
2876 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2877 mv88e6xxx_devlink_atu_bin_0_get,
2878 chip);
2879
2880 dsa_devlink_resource_occ_get_register(ds,
2881 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2882 mv88e6xxx_devlink_atu_bin_1_get,
2883 chip);
2884
2885 dsa_devlink_resource_occ_get_register(ds,
2886 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2887 mv88e6xxx_devlink_atu_bin_2_get,
2888 chip);
2889
2890 dsa_devlink_resource_occ_get_register(ds,
2891 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2892 mv88e6xxx_devlink_atu_bin_3_get,
2893 chip);
2894
2895 return 0;
2896
2897out:
2898 dsa_devlink_resources_unregister(ds);
2899 return err;
2900}
2901
Andrew Lunn23e8b472019-10-25 01:03:52 +02002902static void mv88e6xxx_teardown(struct dsa_switch *ds)
2903{
2904 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002905 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002906}
2907
Vivien Didelotf81ec902016-05-09 13:22:58 -04002908static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002909{
Vivien Didelot04bed142016-08-31 18:06:13 -04002910 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002911 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002912 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002913 int i;
2914
Vivien Didelotfad09c72016-06-21 12:28:20 -04002915 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002916 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002917
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002918 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002919
Andrew Lunnea890982019-01-09 00:24:03 +01002920 if (chip->info->ops->setup_errata) {
2921 err = chip->info->ops->setup_errata(chip);
2922 if (err)
2923 goto unlock;
2924 }
2925
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002926 /* Cache the cmode of each port. */
2927 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2928 if (chip->info->ops->port_get_cmode) {
2929 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2930 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002931 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002932
2933 chip->ports[i].cmode = cmode;
2934 }
2935 }
2936
Vivien Didelot97299342016-07-18 20:45:30 -04002937 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002938 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002939 if (dsa_is_unused_port(ds, i))
2940 continue;
2941
Hubert Feursteinc8574862019-07-31 10:23:48 +02002942 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002943 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002944 dev_err(chip->dev, "port %d is invalid\n", i);
2945 err = -EINVAL;
2946 goto unlock;
2947 }
2948
Vivien Didelot97299342016-07-18 20:45:30 -04002949 err = mv88e6xxx_setup_port(chip, i);
2950 if (err)
2951 goto unlock;
2952 }
2953
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002954 err = mv88e6xxx_irl_setup(chip);
2955 if (err)
2956 goto unlock;
2957
Vivien Didelot04a69a12017-10-13 14:18:05 -04002958 err = mv88e6xxx_mac_setup(chip);
2959 if (err)
2960 goto unlock;
2961
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002962 err = mv88e6xxx_phy_setup(chip);
2963 if (err)
2964 goto unlock;
2965
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002966 err = mv88e6xxx_vtu_setup(chip);
2967 if (err)
2968 goto unlock;
2969
Vivien Didelot81228992017-03-30 17:37:08 -04002970 err = mv88e6xxx_pvt_setup(chip);
2971 if (err)
2972 goto unlock;
2973
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002974 err = mv88e6xxx_atu_setup(chip);
2975 if (err)
2976 goto unlock;
2977
Andrew Lunn87fa8862017-11-09 22:29:56 +01002978 err = mv88e6xxx_broadcast_setup(chip, 0);
2979 if (err)
2980 goto unlock;
2981
Vivien Didelot9e907d72017-07-17 13:03:43 -04002982 err = mv88e6xxx_pot_setup(chip);
2983 if (err)
2984 goto unlock;
2985
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002986 err = mv88e6xxx_rmu_setup(chip);
2987 if (err)
2988 goto unlock;
2989
Vivien Didelot51c901a2017-07-17 13:03:41 -04002990 err = mv88e6xxx_rsvd2cpu_setup(chip);
2991 if (err)
2992 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002993
Vivien Didelotb28f8722018-04-26 21:56:44 -04002994 err = mv88e6xxx_trunk_setup(chip);
2995 if (err)
2996 goto unlock;
2997
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002998 err = mv88e6xxx_devmap_setup(chip);
2999 if (err)
3000 goto unlock;
3001
Vivien Didelot93e18d62018-05-11 17:16:35 -04003002 err = mv88e6xxx_pri_setup(chip);
3003 if (err)
3004 goto unlock;
3005
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003006 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003007 if (chip->info->ptp_support) {
3008 err = mv88e6xxx_ptp_setup(chip);
3009 if (err)
3010 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003011
3012 err = mv88e6xxx_hwtstamp_setup(chip);
3013 if (err)
3014 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003015 }
3016
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003017 err = mv88e6xxx_stats_setup(chip);
3018 if (err)
3019 goto unlock;
3020
Vivien Didelot6b17e862015-08-13 12:52:18 -04003021unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003022 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003023
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003024 if (err)
3025 return err;
3026
3027 /* Have to be called without holding the register lock, since
3028 * they take the devlink lock, and we later take the locks in
3029 * the reverse order when getting/setting parameters or
3030 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003031 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003032 err = mv88e6xxx_setup_devlink_resources(ds);
3033 if (err)
3034 return err;
3035
3036 err = mv88e6xxx_setup_devlink_params(ds);
3037 if (err)
3038 dsa_devlink_resources_unregister(ds);
3039
3040 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003041}
3042
Vivien Didelote57e5e72016-08-15 17:19:00 -04003043static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003044{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003045 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3046 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003047 u16 val;
3048 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003049
Andrew Lunnee26a222017-01-24 14:53:48 +01003050 if (!chip->info->ops->phy_read)
3051 return -EOPNOTSUPP;
3052
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003053 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003054 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003055 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003056
Andrew Lunnda9f3302017-02-01 03:40:05 +01003057 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003058 /* Some internal PHYs don't have a model number. */
3059 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3060 /* Then there is the 6165 family. It gets is
3061 * PHYs correct. But it can also have two
3062 * SERDES interfaces in the PHY address
3063 * space. And these don't have a model
3064 * number. But they are not PHYs, so we don't
3065 * want to give them something a PHY driver
3066 * will recognise.
3067 *
3068 * Use the mv88e6390 family model number
3069 * instead, for anything which really could be
3070 * a PHY,
3071 */
3072 if (!(val & 0x3f0))
3073 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003074 }
3075
Vivien Didelote57e5e72016-08-15 17:19:00 -04003076 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003077}
3078
Vivien Didelote57e5e72016-08-15 17:19:00 -04003079static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003080{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003081 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3082 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003083 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003084
Andrew Lunnee26a222017-01-24 14:53:48 +01003085 if (!chip->info->ops->phy_write)
3086 return -EOPNOTSUPP;
3087
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003088 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003089 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003090 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003091
3092 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003093}
3094
Vivien Didelotfad09c72016-06-21 12:28:20 -04003095static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003096 struct device_node *np,
3097 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003098{
3099 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003100 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003101 struct mii_bus *bus;
3102 int err;
3103
Andrew Lunn2510bab2018-02-22 01:51:49 +01003104 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003105 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003106 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003107 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003108
3109 if (err)
3110 return err;
3111 }
3112
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003113 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003114 if (!bus)
3115 return -ENOMEM;
3116
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003117 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003118 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003119 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003120 INIT_LIST_HEAD(&mdio_bus->list);
3121 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003122
Andrew Lunnb516d452016-06-04 21:17:06 +02003123 if (np) {
3124 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003125 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003126 } else {
3127 bus->name = "mv88e6xxx SMI";
3128 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3129 }
3130
3131 bus->read = mv88e6xxx_mdio_read;
3132 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003133 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003134
Andrew Lunn6f882842018-03-17 20:32:05 +01003135 if (!external) {
3136 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3137 if (err)
3138 return err;
3139 }
3140
Florian Fainelli00e798c2018-05-15 16:56:19 -07003141 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003142 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003143 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003144 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003145 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003146 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003147
3148 if (external)
3149 list_add_tail(&mdio_bus->list, &chip->mdios);
3150 else
3151 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003152
3153 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003154}
3155
Andrew Lunna3c53be52017-01-24 14:53:50 +01003156static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3157 { .compatible = "marvell,mv88e6xxx-mdio-external",
3158 .data = (void *)true },
3159 { },
3160};
3161
Andrew Lunn3126aee2017-12-07 01:05:57 +01003162static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3163
3164{
3165 struct mv88e6xxx_mdio_bus *mdio_bus;
3166 struct mii_bus *bus;
3167
3168 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3169 bus = mdio_bus->bus;
3170
Andrew Lunn6f882842018-03-17 20:32:05 +01003171 if (!mdio_bus->external)
3172 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3173
Andrew Lunn3126aee2017-12-07 01:05:57 +01003174 mdiobus_unregister(bus);
3175 }
3176}
3177
Andrew Lunna3c53be52017-01-24 14:53:50 +01003178static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3179 struct device_node *np)
3180{
3181 const struct of_device_id *match;
3182 struct device_node *child;
3183 int err;
3184
3185 /* Always register one mdio bus for the internal/default mdio
3186 * bus. This maybe represented in the device tree, but is
3187 * optional.
3188 */
3189 child = of_get_child_by_name(np, "mdio");
3190 err = mv88e6xxx_mdio_register(chip, child, false);
3191 if (err)
3192 return err;
3193
3194 /* Walk the device tree, and see if there are any other nodes
3195 * which say they are compatible with the external mdio
3196 * bus.
3197 */
3198 for_each_available_child_of_node(np, child) {
3199 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3200 if (match) {
3201 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003202 if (err) {
3203 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303204 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003205 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003206 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003207 }
3208 }
3209
3210 return 0;
3211}
3212
Vivien Didelot855b1932016-07-20 18:18:35 -04003213static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3214{
Vivien Didelot04bed142016-08-31 18:06:13 -04003215 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003216
3217 return chip->eeprom_len;
3218}
3219
Vivien Didelot855b1932016-07-20 18:18:35 -04003220static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3221 struct ethtool_eeprom *eeprom, u8 *data)
3222{
Vivien Didelot04bed142016-08-31 18:06:13 -04003223 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003224 int err;
3225
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003226 if (!chip->info->ops->get_eeprom)
3227 return -EOPNOTSUPP;
3228
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003229 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003230 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003231 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003232
3233 if (err)
3234 return err;
3235
3236 eeprom->magic = 0xc3ec4951;
3237
3238 return 0;
3239}
3240
Vivien Didelot855b1932016-07-20 18:18:35 -04003241static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3242 struct ethtool_eeprom *eeprom, u8 *data)
3243{
Vivien Didelot04bed142016-08-31 18:06:13 -04003244 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003245 int err;
3246
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003247 if (!chip->info->ops->set_eeprom)
3248 return -EOPNOTSUPP;
3249
Vivien Didelot855b1932016-07-20 18:18:35 -04003250 if (eeprom->magic != 0xc3ec4951)
3251 return -EINVAL;
3252
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003253 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003254 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003255 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003256
3257 return err;
3258}
3259
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003260static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003261 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003262 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3263 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003264 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003265 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003266 .phy_read = mv88e6185_phy_ppu_read,
3267 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003268 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003269 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003270 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003271 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003272 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003273 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003274 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003275 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003276 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003277 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003278 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003279 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003280 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003281 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003282 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003283 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003284 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3285 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003286 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003287 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3288 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003289 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003290 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003291 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003292 .ppu_enable = mv88e6185_g1_ppu_enable,
3293 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003294 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003295 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003296 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003297 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003298 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003299};
3300
3301static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003302 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003303 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3304 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003305 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003306 .phy_read = mv88e6185_phy_ppu_read,
3307 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003308 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003309 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003310 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003311 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003312 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003313 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003314 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003315 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003316 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003317 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003318 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003319 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3320 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003321 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003322 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003323 .ppu_enable = mv88e6185_g1_ppu_enable,
3324 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003325 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003326 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003327 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003328 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003329};
3330
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003331static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003332 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003333 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3334 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003335 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003336 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3337 .phy_read = mv88e6xxx_g2_smi_phy_read,
3338 .phy_write = mv88e6xxx_g2_smi_phy_write,
3339 .port_set_link = mv88e6xxx_port_set_link,
3340 .port_set_duplex = mv88e6xxx_port_set_duplex,
3341 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003342 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003343 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003344 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003345 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003346 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003347 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003348 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003349 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003350 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003351 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003352 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003353 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003354 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003355 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003356 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3357 .stats_get_strings = mv88e6095_stats_get_strings,
3358 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003359 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3360 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003361 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003362 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003363 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003364 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003365 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003366 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003367 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003368 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003369};
3370
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003371static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003372 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003373 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3374 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003375 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003376 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003377 .phy_read = mv88e6xxx_g2_smi_phy_read,
3378 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003379 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003380 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003381 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003382 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003383 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003384 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003385 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003386 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003387 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003388 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003389 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003390 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003391 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3392 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003393 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003394 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3395 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003396 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003397 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003398 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003399 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003400 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3401 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003402 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003403 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003404 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003405};
3406
3407static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003408 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003409 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3410 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003411 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003412 .phy_read = mv88e6185_phy_ppu_read,
3413 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003414 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003415 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003416 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003417 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003418 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003419 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003421 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003422 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003423 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003424 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003425 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003426 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003427 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003428 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003429 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003430 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003431 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3432 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003433 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003434 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3435 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003436 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003437 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003438 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003439 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003440 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003441 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003442 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003443 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003444 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003445};
3446
Vivien Didelot990e27b2017-03-28 13:50:32 -04003447static const struct mv88e6xxx_ops mv88e6141_ops = {
3448 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003449 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3450 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003451 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003452 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3453 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3455 .phy_read = mv88e6xxx_g2_smi_phy_read,
3456 .phy_write = mv88e6xxx_g2_smi_phy_write,
3457 .port_set_link = mv88e6xxx_port_set_link,
3458 .port_set_duplex = mv88e6xxx_port_set_duplex,
3459 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003460 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003461 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003462 .port_tag_remap = mv88e6095_port_tag_remap,
3463 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3464 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3465 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003466 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003467 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003468 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003469 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3470 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003471 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003472 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003473 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003474 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003475 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003476 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003477 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3478 .stats_get_strings = mv88e6320_stats_get_strings,
3479 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003480 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3481 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003482 .watchdog_ops = &mv88e6390_watchdog_ops,
3483 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003484 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003485 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003486 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003487 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003488 .serdes_power = mv88e6390_serdes_power,
3489 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003490 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003491 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003492 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003493 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003494 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003495};
3496
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003497static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003498 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003499 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3500 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003501 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003502 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003503 .phy_read = mv88e6xxx_g2_smi_phy_read,
3504 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003505 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003506 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003507 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003508 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003509 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003510 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003511 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003512 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003513 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003514 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003515 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003516 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003517 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003518 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003519 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003520 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003521 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003522 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3523 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003524 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003525 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3526 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003527 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003528 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003529 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003530 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003531 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3532 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003533 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003534 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003535 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003536 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003537 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003538};
3539
3540static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003541 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003542 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3543 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003544 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003545 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003546 .phy_read = mv88e6165_phy_read,
3547 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003548 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003549 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003550 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003551 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003552 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003553 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003554 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003555 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003556 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003557 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003558 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3559 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003560 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003561 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3562 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003563 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003564 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003565 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003566 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003567 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3568 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003569 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003570 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003571 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003572 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003573 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003574};
3575
3576static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003577 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003578 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3579 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003580 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003581 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003582 .phy_read = mv88e6xxx_g2_smi_phy_read,
3583 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003584 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003585 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003586 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003587 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003588 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003589 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003590 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003591 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003592 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003593 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003594 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003595 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003596 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003597 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003598 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003599 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003600 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003601 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003602 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3603 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003604 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003605 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3606 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003607 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003608 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003609 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003610 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003611 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3612 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003613 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003614 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003615 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003616};
3617
3618static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003619 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003620 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3621 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003622 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003623 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3624 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003625 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003626 .phy_read = mv88e6xxx_g2_smi_phy_read,
3627 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003628 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003629 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003630 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003631 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003632 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003633 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003635 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003636 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003637 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003638 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003639 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003640 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003641 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003642 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003643 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003644 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003645 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003646 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003647 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3648 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003649 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003650 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3651 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003652 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003653 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003654 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003655 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003656 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003657 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3658 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003659 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003660 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003661 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003662 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003663 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003664 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003665};
3666
3667static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003668 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003669 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3670 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003671 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003672 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003673 .phy_read = mv88e6xxx_g2_smi_phy_read,
3674 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003675 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003676 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003677 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003678 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003679 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003680 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003681 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003682 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003683 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003684 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003685 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003686 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003687 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003688 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003689 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003690 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003691 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003692 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003693 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3694 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003695 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003696 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3697 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003698 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003699 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003700 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003701 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003702 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3703 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003704 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003705 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003706 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003707};
3708
3709static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003710 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003711 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3712 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003713 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003714 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3715 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003716 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003717 .phy_read = mv88e6xxx_g2_smi_phy_read,
3718 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003719 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003720 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003721 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003722 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003723 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003724 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003725 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003726 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003727 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003728 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003729 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003730 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003731 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003732 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003733 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003734 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003735 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003736 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003737 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003738 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3739 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003740 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003741 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3742 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003743 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003744 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003745 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003746 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003747 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003748 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3749 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003750 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003751 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003752 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003753 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003754 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003755 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003756 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003757 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003758 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003759};
3760
3761static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003762 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003763 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3764 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003765 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003766 .phy_read = mv88e6185_phy_ppu_read,
3767 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003768 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003769 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003770 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003771 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003772 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003773 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003774 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003775 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003776 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003777 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003778 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003779 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003780 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003781 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3782 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003783 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003784 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3785 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003786 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003787 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003788 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003789 .ppu_enable = mv88e6185_g1_ppu_enable,
3790 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003791 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003792 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003793 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003794 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003795};
3796
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003797static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003798 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003799 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003800 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003801 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3802 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003803 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3804 .phy_read = mv88e6xxx_g2_smi_phy_read,
3805 .phy_write = mv88e6xxx_g2_smi_phy_write,
3806 .port_set_link = mv88e6xxx_port_set_link,
3807 .port_set_duplex = mv88e6xxx_port_set_duplex,
3808 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3809 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003810 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003811 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003812 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003813 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003814 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003815 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003816 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003817 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003818 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003819 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003820 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003821 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003822 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003823 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003824 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003825 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3826 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003827 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003828 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3829 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003830 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003831 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003832 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003833 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003834 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003835 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3836 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003837 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3838 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003839 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003840 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003841 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003842 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003843 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003844 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003845 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003846};
3847
3848static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003849 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003850 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003851 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003852 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3853 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003854 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3855 .phy_read = mv88e6xxx_g2_smi_phy_read,
3856 .phy_write = mv88e6xxx_g2_smi_phy_write,
3857 .port_set_link = mv88e6xxx_port_set_link,
3858 .port_set_duplex = mv88e6xxx_port_set_duplex,
3859 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3860 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003861 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003862 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003863 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003864 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003865 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003866 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003867 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003868 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003869 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003870 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003871 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003872 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003873 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003874 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003875 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003876 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3877 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003878 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003879 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3880 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003881 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003882 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003883 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003884 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003885 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003886 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3887 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003888 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3889 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003890 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003891 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003892 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003893 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003894 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003895 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003896 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003897};
3898
3899static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003900 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003901 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003902 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003903 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3904 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003905 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3906 .phy_read = mv88e6xxx_g2_smi_phy_read,
3907 .phy_write = mv88e6xxx_g2_smi_phy_write,
3908 .port_set_link = mv88e6xxx_port_set_link,
3909 .port_set_duplex = mv88e6xxx_port_set_duplex,
3910 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3911 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003912 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003913 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003914 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003915 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003916 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003917 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003918 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003919 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003920 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003921 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003922 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003923 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003924 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003925 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003926 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3927 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003928 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003929 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3930 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003931 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003932 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003933 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003934 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003935 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003936 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3937 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003938 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3939 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003940 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003941 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003942 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003943 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003944 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003945 .avb_ops = &mv88e6390_avb_ops,
3946 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003947 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003948};
3949
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003950static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003951 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003952 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3953 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003954 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003955 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3956 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003957 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003958 .phy_read = mv88e6xxx_g2_smi_phy_read,
3959 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003960 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003961 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003962 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003963 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003964 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003965 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003966 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003967 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003968 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003969 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003970 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003971 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003972 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003973 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003974 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003975 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003976 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003977 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003978 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003979 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3980 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003981 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003982 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3983 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003984 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003985 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003986 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003987 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003988 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003989 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3990 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003991 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003992 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003993 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003994 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003995 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003996 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003997 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003998 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003999 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004000 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004001 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004002};
4003
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004004static const struct mv88e6xxx_ops mv88e6250_ops = {
4005 /* MV88E6XXX_FAMILY_6250 */
4006 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4007 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4008 .irl_init_all = mv88e6352_g2_irl_init_all,
4009 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4010 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4011 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4012 .phy_read = mv88e6xxx_g2_smi_phy_read,
4013 .phy_write = mv88e6xxx_g2_smi_phy_write,
4014 .port_set_link = mv88e6xxx_port_set_link,
4015 .port_set_duplex = mv88e6xxx_port_set_duplex,
4016 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4017 .port_set_speed = mv88e6250_port_set_speed,
4018 .port_tag_remap = mv88e6095_port_tag_remap,
4019 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4020 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4021 .port_set_ether_type = mv88e6351_port_set_ether_type,
4022 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4023 .port_pause_limit = mv88e6097_port_pause_limit,
4024 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4025 .port_link_state = mv88e6250_port_link_state,
4026 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4027 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4028 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4029 .stats_get_strings = mv88e6250_stats_get_strings,
4030 .stats_get_stats = mv88e6250_stats_get_stats,
4031 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4032 .set_egress_port = mv88e6095_g1_set_egress_port,
4033 .watchdog_ops = &mv88e6250_watchdog_ops,
4034 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4035 .pot_clear = mv88e6xxx_g2_pot_clear,
4036 .reset = mv88e6250_g1_reset,
4037 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4038 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004039 .avb_ops = &mv88e6352_avb_ops,
4040 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004041 .phylink_validate = mv88e6065_phylink_validate,
4042};
4043
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004044static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004045 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004046 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004047 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004048 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4049 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004050 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4051 .phy_read = mv88e6xxx_g2_smi_phy_read,
4052 .phy_write = mv88e6xxx_g2_smi_phy_write,
4053 .port_set_link = mv88e6xxx_port_set_link,
4054 .port_set_duplex = mv88e6xxx_port_set_duplex,
4055 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4056 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004057 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004058 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004059 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004060 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004061 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004062 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004063 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004064 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004065 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004066 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004067 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004068 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004069 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004070 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004071 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004072 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4073 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004074 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004075 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4076 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004077 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004078 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004079 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004080 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004081 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004082 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4083 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004084 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4085 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004086 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004087 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004088 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004089 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004090 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004091 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004092 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004093 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004094 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004095};
4096
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004097static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004098 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004099 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4100 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004101 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004102 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4103 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004104 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004105 .phy_read = mv88e6xxx_g2_smi_phy_read,
4106 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004107 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004108 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004109 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004110 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004111 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004112 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004113 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004114 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004115 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004116 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004117 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004118 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004119 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004120 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004121 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004122 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004123 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004124 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4125 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004126 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004127 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4128 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004129 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004130 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004131 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004132 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004133 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004134 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004135 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004136 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004137 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004138 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004139};
4140
4141static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004142 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004143 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4144 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004145 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004146 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4147 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004148 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004149 .phy_read = mv88e6xxx_g2_smi_phy_read,
4150 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004151 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004152 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004153 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004154 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004155 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004156 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004157 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004158 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004159 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004160 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004161 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004162 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004163 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004164 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004165 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004166 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004167 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004168 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4169 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004170 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004171 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4172 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004173 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004174 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004175 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004176 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004177 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004178 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004179 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004180 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004181};
4182
Vivien Didelot16e329a2017-03-28 13:50:33 -04004183static const struct mv88e6xxx_ops mv88e6341_ops = {
4184 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004185 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4186 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004187 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004188 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4189 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4190 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4191 .phy_read = mv88e6xxx_g2_smi_phy_read,
4192 .phy_write = mv88e6xxx_g2_smi_phy_write,
4193 .port_set_link = mv88e6xxx_port_set_link,
4194 .port_set_duplex = mv88e6xxx_port_set_duplex,
4195 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004196 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004197 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004198 .port_tag_remap = mv88e6095_port_tag_remap,
4199 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4200 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4201 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004202 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004203 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004204 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004205 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4206 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004207 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004208 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004209 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004210 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004211 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004212 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004213 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4214 .stats_get_strings = mv88e6320_stats_get_strings,
4215 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004216 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4217 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004218 .watchdog_ops = &mv88e6390_watchdog_ops,
4219 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004220 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004221 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004222 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004223 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004224 .serdes_power = mv88e6390_serdes_power,
4225 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004226 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004227 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004228 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004229 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004230 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004231 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004232 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004233};
4234
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004235static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004236 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004237 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4238 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004239 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004240 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004241 .phy_read = mv88e6xxx_g2_smi_phy_read,
4242 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004243 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004244 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004245 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004246 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004247 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004248 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004249 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004250 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004251 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004252 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004253 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004254 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004255 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004256 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004257 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004258 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004259 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004260 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004261 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4262 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004263 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004264 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4265 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004266 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004267 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004268 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004269 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004270 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4271 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004272 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004273 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004274 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004275};
4276
4277static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004278 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004279 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4280 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004281 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004282 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004283 .phy_read = mv88e6xxx_g2_smi_phy_read,
4284 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004285 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004286 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004287 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004288 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004289 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004290 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004291 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004292 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004293 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004294 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004295 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004296 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004297 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004298 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004299 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004300 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004301 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004302 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004303 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4304 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004305 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004306 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4307 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004308 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004309 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004310 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004311 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004312 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4313 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004314 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004315 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004316 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004317 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004318 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004319};
4320
4321static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004322 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004323 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4324 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004325 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004326 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4327 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004328 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004329 .phy_read = mv88e6xxx_g2_smi_phy_read,
4330 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004331 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004332 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004333 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004334 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004335 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004336 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004337 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004338 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004339 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004340 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004341 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004342 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004343 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004344 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004345 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004346 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004347 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004348 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004349 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004350 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4351 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004352 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004353 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4354 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004355 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004356 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004357 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004358 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004359 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004360 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4361 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004362 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004363 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004364 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004365 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004366 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004367 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004368 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004369 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004370 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004371 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004372 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4373 .serdes_get_strings = mv88e6352_serdes_get_strings,
4374 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004375 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004376};
4377
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004378static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004379 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004380 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004381 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004382 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4383 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004384 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4385 .phy_read = mv88e6xxx_g2_smi_phy_read,
4386 .phy_write = mv88e6xxx_g2_smi_phy_write,
4387 .port_set_link = mv88e6xxx_port_set_link,
4388 .port_set_duplex = mv88e6xxx_port_set_duplex,
4389 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4390 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004391 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004392 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004393 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004394 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004395 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004396 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004397 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004398 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004399 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004400 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004401 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004402 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004403 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004404 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004405 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004406 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004407 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004408 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4409 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004410 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004411 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4412 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004413 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004414 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004415 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004416 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004417 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004418 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4419 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004420 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4421 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004422 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004423 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004424 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004425 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004426 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004427 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004428 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004429 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004430 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4431 .serdes_get_strings = mv88e6390_serdes_get_strings,
4432 .serdes_get_stats = mv88e6390_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004433 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004434};
4435
4436static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004437 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004438 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004439 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004440 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4441 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004442 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4443 .phy_read = mv88e6xxx_g2_smi_phy_read,
4444 .phy_write = mv88e6xxx_g2_smi_phy_write,
4445 .port_set_link = mv88e6xxx_port_set_link,
4446 .port_set_duplex = mv88e6xxx_port_set_duplex,
4447 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4448 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004449 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004450 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004451 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004452 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004453 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004454 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004455 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004456 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004457 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004458 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004459 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004460 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004461 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004462 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004463 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004464 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004465 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004466 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4467 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004468 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004469 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4470 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004471 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004472 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004473 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004474 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004475 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004476 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4477 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004478 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4479 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004480 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004481 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004482 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004483 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004484 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004485 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004486 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004487 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004488 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004489};
4490
Vivien Didelotf81ec902016-05-09 13:22:58 -04004491static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4492 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004493 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004494 .family = MV88E6XXX_FAMILY_6097,
4495 .name = "Marvell 88E6085",
4496 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004497 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004498 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004499 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004500 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004501 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004502 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004503 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004504 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004505 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004506 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004507 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004508 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004509 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004510 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004511 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004512 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004513 },
4514
4515 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004516 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004517 .family = MV88E6XXX_FAMILY_6095,
4518 .name = "Marvell 88E6095/88E6095F",
4519 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004520 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004521 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004522 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004523 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004524 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004525 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004526 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004527 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004528 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004529 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004530 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004531 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004532 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004533 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004534 },
4535
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004536 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004537 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004538 .family = MV88E6XXX_FAMILY_6097,
4539 .name = "Marvell 88E6097/88E6097F",
4540 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004541 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004542 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004543 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004544 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004545 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004546 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004547 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004548 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004549 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004550 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004551 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004552 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004553 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004554 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004555 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004556 .ops = &mv88e6097_ops,
4557 },
4558
Vivien Didelotf81ec902016-05-09 13:22:58 -04004559 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004560 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004561 .family = MV88E6XXX_FAMILY_6165,
4562 .name = "Marvell 88E6123",
4563 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004564 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004565 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004566 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004567 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004568 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004569 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004570 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004571 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004572 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004573 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004574 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004575 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004576 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004577 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004578 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004579 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004580 },
4581
4582 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004583 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 .family = MV88E6XXX_FAMILY_6185,
4585 .name = "Marvell 88E6131",
4586 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004587 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004588 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004589 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004590 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004591 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004592 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004593 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004594 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004595 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004596 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004597 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004598 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004599 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004600 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004601 },
4602
Vivien Didelot990e27b2017-03-28 13:50:32 -04004603 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004604 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004605 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004606 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004607 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004608 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004609 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004610 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004611 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004612 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004613 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004614 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004615 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004616 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004617 .age_time_coeff = 3750,
4618 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004619 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004620 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004621 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004622 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004623 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004624 .ops = &mv88e6141_ops,
4625 },
4626
Vivien Didelotf81ec902016-05-09 13:22:58 -04004627 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004628 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004629 .family = MV88E6XXX_FAMILY_6165,
4630 .name = "Marvell 88E6161",
4631 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004632 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004633 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004634 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004635 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004636 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004637 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004638 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004639 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004640 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004641 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004642 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004643 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004644 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004645 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004646 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004647 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004648 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004649 },
4650
4651 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004652 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004653 .family = MV88E6XXX_FAMILY_6165,
4654 .name = "Marvell 88E6165",
4655 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004656 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004657 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004658 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004659 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004660 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004661 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004662 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004663 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004664 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004665 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004666 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004667 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004668 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004669 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004670 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004671 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004672 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004673 },
4674
4675 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004676 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004677 .family = MV88E6XXX_FAMILY_6351,
4678 .name = "Marvell 88E6171",
4679 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004680 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004681 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004682 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004683 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004684 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004685 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004686 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004687 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004688 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004689 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004690 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004691 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004692 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004693 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004694 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004695 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004696 },
4697
4698 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004699 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004700 .family = MV88E6XXX_FAMILY_6352,
4701 .name = "Marvell 88E6172",
4702 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004703 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004704 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004705 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004706 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004707 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004708 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004709 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004710 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004711 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004712 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004713 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004714 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004715 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004716 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004717 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004718 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004719 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004720 },
4721
4722 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004723 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004724 .family = MV88E6XXX_FAMILY_6351,
4725 .name = "Marvell 88E6175",
4726 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004727 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004729 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004730 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004731 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004732 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004733 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004734 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004735 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004736 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004737 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004738 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004739 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004740 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004741 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004742 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004743 },
4744
4745 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004746 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 .family = MV88E6XXX_FAMILY_6352,
4748 .name = "Marvell 88E6176",
4749 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004750 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004751 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004752 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004753 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004754 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004755 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004756 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004757 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004758 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004759 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004760 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004761 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004762 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004763 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004764 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004765 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004766 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004767 },
4768
4769 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004770 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004771 .family = MV88E6XXX_FAMILY_6185,
4772 .name = "Marvell 88E6185",
4773 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004774 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004776 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004777 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004778 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004779 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004780 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004781 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004782 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004783 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004784 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004785 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004786 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004787 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004788 },
4789
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004790 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004791 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004792 .family = MV88E6XXX_FAMILY_6390,
4793 .name = "Marvell 88E6190",
4794 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004795 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004796 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004797 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004798 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004799 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004800 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004801 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004802 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004803 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004804 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004805 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004806 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004807 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004808 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004809 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004810 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004811 .ops = &mv88e6190_ops,
4812 },
4813
4814 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004815 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004816 .family = MV88E6XXX_FAMILY_6390,
4817 .name = "Marvell 88E6190X",
4818 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004819 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004820 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004821 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004822 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004823 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004824 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004825 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004826 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004827 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004828 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004829 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004830 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004831 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004832 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004833 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004834 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004835 .ops = &mv88e6190x_ops,
4836 },
4837
4838 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004839 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004840 .family = MV88E6XXX_FAMILY_6390,
4841 .name = "Marvell 88E6191",
4842 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004843 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004844 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004845 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004846 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004847 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004848 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004849 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004850 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004851 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004852 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004853 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004854 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004855 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004856 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004857 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004858 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004859 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004860 },
4861
Hubert Feurstein49022642019-07-31 10:23:46 +02004862 [MV88E6220] = {
4863 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4864 .family = MV88E6XXX_FAMILY_6250,
4865 .name = "Marvell 88E6220",
4866 .num_databases = 64,
4867
4868 /* Ports 2-4 are not routed to pins
4869 * => usable ports 0, 1, 5, 6
4870 */
4871 .num_ports = 7,
4872 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004873 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004874 .max_vid = 4095,
4875 .port_base_addr = 0x08,
4876 .phy_base_addr = 0x00,
4877 .global1_addr = 0x0f,
4878 .global2_addr = 0x07,
4879 .age_time_coeff = 15000,
4880 .g1_irqs = 9,
4881 .g2_irqs = 10,
4882 .atu_move_port_mask = 0xf,
4883 .dual_chip = true,
4884 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004885 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004886 .ops = &mv88e6250_ops,
4887 },
4888
Vivien Didelotf81ec902016-05-09 13:22:58 -04004889 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004890 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004891 .family = MV88E6XXX_FAMILY_6352,
4892 .name = "Marvell 88E6240",
4893 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004894 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004895 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004896 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004897 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004898 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004899 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004900 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004901 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004902 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004903 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004904 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004905 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004906 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004907 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004908 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004909 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004910 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004911 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004912 },
4913
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004914 [MV88E6250] = {
4915 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4916 .family = MV88E6XXX_FAMILY_6250,
4917 .name = "Marvell 88E6250",
4918 .num_databases = 64,
4919 .num_ports = 7,
4920 .num_internal_phys = 5,
4921 .max_vid = 4095,
4922 .port_base_addr = 0x08,
4923 .phy_base_addr = 0x00,
4924 .global1_addr = 0x0f,
4925 .global2_addr = 0x07,
4926 .age_time_coeff = 15000,
4927 .g1_irqs = 9,
4928 .g2_irqs = 10,
4929 .atu_move_port_mask = 0xf,
4930 .dual_chip = true,
4931 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004932 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004933 .ops = &mv88e6250_ops,
4934 },
4935
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004936 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004937 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004938 .family = MV88E6XXX_FAMILY_6390,
4939 .name = "Marvell 88E6290",
4940 .num_databases = 4096,
4941 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004942 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004943 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004944 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004945 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004946 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004947 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004948 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004949 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004950 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004951 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004952 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004953 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004954 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004955 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004956 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004957 .ops = &mv88e6290_ops,
4958 },
4959
Vivien Didelotf81ec902016-05-09 13:22:58 -04004960 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004961 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004962 .family = MV88E6XXX_FAMILY_6320,
4963 .name = "Marvell 88E6320",
4964 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004965 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004966 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004967 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004968 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004969 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004970 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004971 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004972 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004973 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004974 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004975 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004976 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004977 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004978 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004979 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004980 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004981 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004982 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004983 },
4984
4985 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004986 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004987 .family = MV88E6XXX_FAMILY_6320,
4988 .name = "Marvell 88E6321",
4989 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004990 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004991 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004992 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004993 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004994 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004995 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004996 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004997 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004998 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004999 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005000 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005001 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005002 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005003 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005004 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005005 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005006 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005007 },
5008
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005009 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005010 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005011 .family = MV88E6XXX_FAMILY_6341,
5012 .name = "Marvell 88E6341",
5013 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005014 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005015 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005016 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005017 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005018 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005019 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005020 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005021 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005022 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005023 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005024 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005025 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005026 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005027 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005028 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005029 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005030 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005031 .ops = &mv88e6341_ops,
5032 },
5033
Vivien Didelotf81ec902016-05-09 13:22:58 -04005034 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005035 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005036 .family = MV88E6XXX_FAMILY_6351,
5037 .name = "Marvell 88E6350",
5038 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005039 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005040 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005041 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005042 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005043 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005044 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005045 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005046 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005047 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005048 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005049 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005050 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005051 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005052 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005053 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005054 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005055 },
5056
5057 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005058 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005059 .family = MV88E6XXX_FAMILY_6351,
5060 .name = "Marvell 88E6351",
5061 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005062 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005063 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005064 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005065 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005066 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005067 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005068 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005069 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005070 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005071 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005072 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005073 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005074 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005075 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005076 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005077 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005078 },
5079
5080 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005081 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005082 .family = MV88E6XXX_FAMILY_6352,
5083 .name = "Marvell 88E6352",
5084 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005085 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005086 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005087 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005088 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005089 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005090 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005091 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005092 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005093 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005094 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005095 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005096 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005097 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005098 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005099 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005100 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005101 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005102 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005103 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005104 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005105 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005106 .family = MV88E6XXX_FAMILY_6390,
5107 .name = "Marvell 88E6390",
5108 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005109 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005110 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005111 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005112 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005113 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005114 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005115 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005116 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005117 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005118 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005119 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005120 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005121 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005122 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005123 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005124 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005125 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005126 .ops = &mv88e6390_ops,
5127 },
5128 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005129 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005130 .family = MV88E6XXX_FAMILY_6390,
5131 .name = "Marvell 88E6390X",
5132 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005133 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005134 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005135 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005136 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005137 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005138 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005139 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005140 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005141 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005142 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005143 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005144 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005145 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005146 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005147 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005148 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005149 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005150 .ops = &mv88e6390x_ops,
5151 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005152};
5153
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005154static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005155{
Vivien Didelota439c062016-04-17 13:23:58 -04005156 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005157
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005158 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5159 if (mv88e6xxx_table[i].prod_num == prod_num)
5160 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005161
Vivien Didelotb9b37712015-10-30 19:39:48 -04005162 return NULL;
5163}
5164
Vivien Didelotfad09c72016-06-21 12:28:20 -04005165static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005166{
5167 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005168 unsigned int prod_num, rev;
5169 u16 id;
5170 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005171
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005172 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005173 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005174 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005175 if (err)
5176 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005177
Vivien Didelot107fcc12017-06-12 12:37:36 -04005178 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5179 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005180
5181 info = mv88e6xxx_lookup_info(prod_num);
5182 if (!info)
5183 return -ENODEV;
5184
Vivien Didelotcaac8542016-06-20 13:14:09 -04005185 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005186 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005187
Vivien Didelotca070c12016-09-02 14:45:34 -04005188 err = mv88e6xxx_g2_require(chip);
5189 if (err)
5190 return err;
5191
Vivien Didelotfad09c72016-06-21 12:28:20 -04005192 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5193 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005194
5195 return 0;
5196}
5197
Vivien Didelotfad09c72016-06-21 12:28:20 -04005198static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005199{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005200 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005201
Vivien Didelotfad09c72016-06-21 12:28:20 -04005202 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5203 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005204 return NULL;
5205
Vivien Didelotfad09c72016-06-21 12:28:20 -04005206 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005207
Vivien Didelotfad09c72016-06-21 12:28:20 -04005208 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005209 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005210 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005211
Vivien Didelotfad09c72016-06-21 12:28:20 -04005212 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005213}
5214
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005215static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
5216 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02005217{
Vivien Didelot04bed142016-08-31 18:06:13 -04005218 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005219
Andrew Lunn443d5a12016-12-03 04:35:18 +01005220 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005221}
5222
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005223static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005224 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005225{
5226 /* We don't need any dynamic resource from the kernel (yet),
5227 * so skip the prepare phase.
5228 */
5229
5230 return 0;
5231}
5232
5233static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005234 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005235{
Vivien Didelot04bed142016-08-31 18:06:13 -04005236 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005237
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005238 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005239 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005240 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005241 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5242 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005243 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005244}
5245
5246static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5247 const struct switchdev_obj_port_mdb *mdb)
5248{
Vivien Didelot04bed142016-08-31 18:06:13 -04005249 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005250 int err;
5251
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005252 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005253 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005254 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005255
5256 return err;
5257}
5258
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005259static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5260 struct dsa_mall_mirror_tc_entry *mirror,
5261 bool ingress)
5262{
5263 enum mv88e6xxx_egress_direction direction = ingress ?
5264 MV88E6XXX_EGRESS_DIR_INGRESS :
5265 MV88E6XXX_EGRESS_DIR_EGRESS;
5266 struct mv88e6xxx_chip *chip = ds->priv;
5267 bool other_mirrors = false;
5268 int i;
5269 int err;
5270
5271 if (!chip->info->ops->set_egress_port)
5272 return -EOPNOTSUPP;
5273
5274 mutex_lock(&chip->reg_lock);
5275 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5276 mirror->to_local_port) {
5277 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5278 other_mirrors |= ingress ?
5279 chip->ports[i].mirror_ingress :
5280 chip->ports[i].mirror_egress;
5281
5282 /* Can't change egress port when other mirror is active */
5283 if (other_mirrors) {
5284 err = -EBUSY;
5285 goto out;
5286 }
5287
5288 err = chip->info->ops->set_egress_port(chip,
5289 direction,
5290 mirror->to_local_port);
5291 if (err)
5292 goto out;
5293 }
5294
5295 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5296out:
5297 mutex_unlock(&chip->reg_lock);
5298
5299 return err;
5300}
5301
5302static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5303 struct dsa_mall_mirror_tc_entry *mirror)
5304{
5305 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5306 MV88E6XXX_EGRESS_DIR_INGRESS :
5307 MV88E6XXX_EGRESS_DIR_EGRESS;
5308 struct mv88e6xxx_chip *chip = ds->priv;
5309 bool other_mirrors = false;
5310 int i;
5311
5312 mutex_lock(&chip->reg_lock);
5313 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5314 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5315
5316 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5317 other_mirrors |= mirror->ingress ?
5318 chip->ports[i].mirror_ingress :
5319 chip->ports[i].mirror_egress;
5320
5321 /* Reset egress port when no other mirror is active */
5322 if (!other_mirrors) {
5323 if (chip->info->ops->set_egress_port(chip,
5324 direction,
5325 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005326 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005327 dev_err(ds->dev, "failed to set egress port\n");
5328 }
5329
5330 mutex_unlock(&chip->reg_lock);
5331}
5332
Russell King4f859012019-02-20 15:35:05 -08005333static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5334 bool unicast, bool multicast)
5335{
5336 struct mv88e6xxx_chip *chip = ds->priv;
5337 int err = -EOPNOTSUPP;
5338
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005339 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005340 if (chip->info->ops->port_set_egress_floods)
5341 err = chip->info->ops->port_set_egress_floods(chip, port,
5342 unicast,
5343 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005344 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005345
5346 return err;
5347}
5348
Florian Fainellia82f67a2017-01-08 14:52:08 -08005349static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005350 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005351 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005352 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005353 .phylink_validate = mv88e6xxx_validate,
5354 .phylink_mac_link_state = mv88e6xxx_link_state,
5355 .phylink_mac_config = mv88e6xxx_mac_config,
5356 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5357 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005358 .get_strings = mv88e6xxx_get_strings,
5359 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5360 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005361 .port_enable = mv88e6xxx_port_enable,
5362 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005363 .get_mac_eee = mv88e6xxx_get_mac_eee,
5364 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005365 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005366 .get_eeprom = mv88e6xxx_get_eeprom,
5367 .set_eeprom = mv88e6xxx_set_eeprom,
5368 .get_regs_len = mv88e6xxx_get_regs_len,
5369 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005370 .get_rxnfc = mv88e6xxx_get_rxnfc,
5371 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005372 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005373 .port_bridge_join = mv88e6xxx_port_bridge_join,
5374 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005375 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005376 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005377 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005378 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5379 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5380 .port_vlan_add = mv88e6xxx_port_vlan_add,
5381 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005382 .port_fdb_add = mv88e6xxx_port_fdb_add,
5383 .port_fdb_del = mv88e6xxx_port_fdb_del,
5384 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005385 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5386 .port_mdb_add = mv88e6xxx_port_mdb_add,
5387 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005388 .port_mirror_add = mv88e6xxx_port_mirror_add,
5389 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005390 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5391 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005392 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5393 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5394 .port_txtstamp = mv88e6xxx_port_txtstamp,
5395 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5396 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005397 .devlink_param_get = mv88e6xxx_devlink_param_get,
5398 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005399};
5400
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005401static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005402{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005403 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005404 struct dsa_switch *ds;
5405
Vivien Didelot7e99e342019-10-21 16:51:30 -04005406 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005407 if (!ds)
5408 return -ENOMEM;
5409
Vivien Didelot7e99e342019-10-21 16:51:30 -04005410 ds->dev = dev;
5411 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005412 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005413 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005414 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005415 ds->ageing_time_min = chip->info->age_time_coeff;
5416 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005417
5418 dev_set_drvdata(dev, ds);
5419
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005420 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005421}
5422
Vivien Didelotfad09c72016-06-21 12:28:20 -04005423static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005424{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005425 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005426}
5427
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005428static const void *pdata_device_get_match_data(struct device *dev)
5429{
5430 const struct of_device_id *matches = dev->driver->of_match_table;
5431 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5432
5433 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5434 matches++) {
5435 if (!strcmp(pdata->compatible, matches->compatible))
5436 return matches->data;
5437 }
5438 return NULL;
5439}
5440
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005441/* There is no suspend to RAM support at DSA level yet, the switch configuration
5442 * would be lost after a power cycle so prevent it to be suspended.
5443 */
5444static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5445{
5446 return -EOPNOTSUPP;
5447}
5448
5449static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5450{
5451 return 0;
5452}
5453
5454static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5455
Vivien Didelot57d32312016-06-20 13:13:58 -04005456static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005457{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005458 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005459 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005460 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005461 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005462 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005463 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005464 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005465
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005466 if (!np && !pdata)
5467 return -EINVAL;
5468
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005469 if (np)
5470 compat_info = of_device_get_match_data(dev);
5471
5472 if (pdata) {
5473 compat_info = pdata_device_get_match_data(dev);
5474
5475 if (!pdata->netdev)
5476 return -EINVAL;
5477
5478 for (port = 0; port < DSA_MAX_PORTS; port++) {
5479 if (!(pdata->enabled_ports & (1 << port)))
5480 continue;
5481 if (strcmp(pdata->cd.port_names[port], "cpu"))
5482 continue;
5483 pdata->cd.netdev[port] = &pdata->netdev->dev;
5484 break;
5485 }
5486 }
5487
Vivien Didelotcaac8542016-06-20 13:14:09 -04005488 if (!compat_info)
5489 return -EINVAL;
5490
Vivien Didelotfad09c72016-06-21 12:28:20 -04005491 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005492 if (!chip) {
5493 err = -ENOMEM;
5494 goto out;
5495 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005496
Vivien Didelotfad09c72016-06-21 12:28:20 -04005497 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005498
Vivien Didelotfad09c72016-06-21 12:28:20 -04005499 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005500 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005501 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005502
Andrew Lunnb4308f02016-11-21 23:26:55 +01005503 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005504 if (IS_ERR(chip->reset)) {
5505 err = PTR_ERR(chip->reset);
5506 goto out;
5507 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005508 if (chip->reset)
5509 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005510
Vivien Didelotfad09c72016-06-21 12:28:20 -04005511 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005512 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005513 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005514
Vivien Didelote57e5e72016-08-15 17:19:00 -04005515 mv88e6xxx_phy_init(chip);
5516
Andrew Lunn00baabe2018-05-19 22:31:35 +02005517 if (chip->info->ops->get_eeprom) {
5518 if (np)
5519 of_property_read_u32(np, "eeprom-length",
5520 &chip->eeprom_len);
5521 else
5522 chip->eeprom_len = pdata->eeprom_len;
5523 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005524
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005525 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005526 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005527 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005528 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005529 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005530
Andrew Lunna27415d2019-05-01 00:10:50 +02005531 if (np) {
5532 chip->irq = of_irq_get(np, 0);
5533 if (chip->irq == -EPROBE_DEFER) {
5534 err = chip->irq;
5535 goto out;
5536 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005537 }
5538
Andrew Lunna27415d2019-05-01 00:10:50 +02005539 if (pdata)
5540 chip->irq = pdata->irq;
5541
Andrew Lunn294d7112018-02-22 22:58:32 +01005542 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005543 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005544 * controllers
5545 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005546 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005547 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005548 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005549 else
5550 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005551 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005552
Andrew Lunn294d7112018-02-22 22:58:32 +01005553 if (err)
5554 goto out;
5555
5556 if (chip->info->g2_irqs > 0) {
5557 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005558 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005559 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005560 }
5561
Andrew Lunn294d7112018-02-22 22:58:32 +01005562 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5563 if (err)
5564 goto out_g2_irq;
5565
5566 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5567 if (err)
5568 goto out_g1_atu_prob_irq;
5569
Andrew Lunna3c53be52017-01-24 14:53:50 +01005570 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005571 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005572 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005573
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005574 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005575 if (err)
5576 goto out_mdio;
5577
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005578 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005579
5580out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005581 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005582out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005583 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005584out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005585 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005586out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005587 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005588 mv88e6xxx_g2_irq_free(chip);
5589out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005590 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005591 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005592 else
5593 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005594out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005595 if (pdata)
5596 dev_put(pdata->netdev);
5597
Andrew Lunndc30c352016-10-16 19:56:49 +02005598 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005599}
5600
5601static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5602{
5603 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005604 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005605
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005606 if (chip->info->ptp_support) {
5607 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005608 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005609 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005610
Andrew Lunn930188c2016-08-22 16:01:03 +02005611 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005612 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005613 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005614
Andrew Lunn76f38f12018-03-17 20:21:09 +01005615 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5616 mv88e6xxx_g1_atu_prob_irq_free(chip);
5617
5618 if (chip->info->g2_irqs > 0)
5619 mv88e6xxx_g2_irq_free(chip);
5620
Andrew Lunn76f38f12018-03-17 20:21:09 +01005621 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005622 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005623 else
5624 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005625}
5626
5627static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005628 {
5629 .compatible = "marvell,mv88e6085",
5630 .data = &mv88e6xxx_table[MV88E6085],
5631 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005632 {
5633 .compatible = "marvell,mv88e6190",
5634 .data = &mv88e6xxx_table[MV88E6190],
5635 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005636 {
5637 .compatible = "marvell,mv88e6250",
5638 .data = &mv88e6xxx_table[MV88E6250],
5639 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005640 { /* sentinel */ },
5641};
5642
5643MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5644
5645static struct mdio_driver mv88e6xxx_driver = {
5646 .probe = mv88e6xxx_probe,
5647 .remove = mv88e6xxx_remove,
5648 .mdiodrv.driver = {
5649 .name = "mv88e6085",
5650 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005651 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005652 },
5653};
5654
Andrew Lunn7324d502019-04-27 19:19:10 +02005655mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005656
5657MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5658MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5659MODULE_LICENSE("GPL");