blob: 8c92895496881cb9d11adf4ee459bd549b247fe3 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100400int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
401 int speed, int duplex, int pause,
402 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100403{
Andrew Lunna26deec2019-04-18 03:11:39 +0200404 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100405 int err;
406
407 if (!chip->info->ops->port_set_link)
408 return 0;
409
Andrew Lunna26deec2019-04-18 03:11:39 +0200410 if (!chip->info->ops->port_link_state)
411 return 0;
412
413 err = chip->info->ops->port_link_state(chip, port, &state);
414 if (err)
415 return err;
416
417 /* Has anything actually changed? We don't expect the
418 * interface mode to change without one of the other
419 * parameters also changing
420 */
421 if (state.link == link &&
422 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200423 state.duplex == duplex &&
424 (state.interface == mode ||
425 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200426 return 0;
427
Vivien Didelotd78343d2016-11-04 03:23:36 +0100428 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200429 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100430 if (err)
431 return err;
432
433 if (chip->info->ops->port_set_speed) {
434 err = chip->info->ops->port_set_speed(chip, port, speed);
435 if (err && err != -EOPNOTSUPP)
436 goto restore_link;
437 }
438
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100439 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
440 mode = chip->info->ops->port_max_speed_mode(port);
441
Andrew Lunn54186b92018-08-09 15:38:37 +0200442 if (chip->info->ops->port_set_pause) {
443 err = chip->info->ops->port_set_pause(chip, port, pause);
444 if (err)
445 goto restore_link;
446 }
447
Vivien Didelotd78343d2016-11-04 03:23:36 +0100448 if (chip->info->ops->port_set_duplex) {
449 err = chip->info->ops->port_set_duplex(chip, port, duplex);
450 if (err && err != -EOPNOTSUPP)
451 goto restore_link;
452 }
453
454 if (chip->info->ops->port_set_rgmii_delay) {
455 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
456 if (err && err != -EOPNOTSUPP)
457 goto restore_link;
458 }
459
Andrew Lunnf39908d2017-02-04 20:02:50 +0100460 if (chip->info->ops->port_set_cmode) {
461 err = chip->info->ops->port_set_cmode(chip, port, mode);
462 if (err && err != -EOPNOTSUPP)
463 goto restore_link;
464 }
465
Vivien Didelotd78343d2016-11-04 03:23:36 +0100466 err = 0;
467restore_link:
468 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400469 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100470
471 return err;
472}
473
Marek Vasutd700ec42018-09-12 00:15:24 +0200474static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
475{
476 struct mv88e6xxx_chip *chip = ds->priv;
477
478 return port < chip->info->num_internal_phys;
479}
480
Russell King6c422e32018-08-09 15:38:39 +0200481static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
482 unsigned long *mask,
483 struct phylink_link_state *state)
484{
485 if (!phy_interface_mode_is_8023z(state->interface)) {
486 /* 10M and 100M are only supported in non-802.3z mode */
487 phylink_set(mask, 10baseT_Half);
488 phylink_set(mask, 10baseT_Full);
489 phylink_set(mask, 100baseT_Half);
490 phylink_set(mask, 100baseT_Full);
491 }
492}
493
494static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
495 unsigned long *mask,
496 struct phylink_link_state *state)
497{
498 /* FIXME: if the port is in 1000Base-X mode, then it only supports
499 * 1000M FD speeds. In this case, CMODE will indicate 5.
500 */
501 phylink_set(mask, 1000baseT_Full);
502 phylink_set(mask, 1000baseX_Full);
503
504 mv88e6065_phylink_validate(chip, port, mask, state);
505}
506
Marek Behúne3af71a2019-02-25 12:39:55 +0100507static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
508 unsigned long *mask,
509 struct phylink_link_state *state)
510{
511 if (port >= 5)
512 phylink_set(mask, 2500baseX_Full);
513
514 /* No ethtool bits for 200Mbps */
515 phylink_set(mask, 1000baseT_Full);
516 phylink_set(mask, 1000baseX_Full);
517
518 mv88e6065_phylink_validate(chip, port, mask, state);
519}
520
Russell King6c422e32018-08-09 15:38:39 +0200521static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
522 unsigned long *mask,
523 struct phylink_link_state *state)
524{
525 /* No ethtool bits for 200Mbps */
526 phylink_set(mask, 1000baseT_Full);
527 phylink_set(mask, 1000baseX_Full);
528
529 mv88e6065_phylink_validate(chip, port, mask, state);
530}
531
532static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
533 unsigned long *mask,
534 struct phylink_link_state *state)
535{
Andrew Lunnec260162019-02-08 22:25:44 +0100536 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200537 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100538 phylink_set(mask, 2500baseT_Full);
539 }
Russell King6c422e32018-08-09 15:38:39 +0200540
541 /* No ethtool bits for 200Mbps */
542 phylink_set(mask, 1000baseT_Full);
543 phylink_set(mask, 1000baseX_Full);
544
545 mv88e6065_phylink_validate(chip, port, mask, state);
546}
547
548static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
549 unsigned long *mask,
550 struct phylink_link_state *state)
551{
552 if (port >= 9) {
553 phylink_set(mask, 10000baseT_Full);
554 phylink_set(mask, 10000baseKR_Full);
555 }
556
557 mv88e6390_phylink_validate(chip, port, mask, state);
558}
559
Russell Kingc9a23562018-05-10 13:17:35 -0700560static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
561 unsigned long *supported,
562 struct phylink_link_state *state)
563{
Russell King6c422e32018-08-09 15:38:39 +0200564 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
565 struct mv88e6xxx_chip *chip = ds->priv;
566
567 /* Allow all the expected bits */
568 phylink_set(mask, Autoneg);
569 phylink_set(mask, Pause);
570 phylink_set_port_modes(mask);
571
572 if (chip->info->ops->phylink_validate)
573 chip->info->ops->phylink_validate(chip, port, mask, state);
574
575 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
576 bitmap_and(state->advertising, state->advertising, mask,
577 __ETHTOOL_LINK_MODE_MASK_NBITS);
578
579 /* We can only operate at 2500BaseX or 1000BaseX. If requested
580 * to advertise both, only report advertising at 2500BaseX.
581 */
582 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700583}
584
585static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
586 struct phylink_link_state *state)
587{
588 struct mv88e6xxx_chip *chip = ds->priv;
589 int err;
590
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000591 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200592 if (chip->info->ops->port_link_state)
593 err = chip->info->ops->port_link_state(chip, port, state);
594 else
595 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000596 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700597
598 return err;
599}
600
601static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
602 unsigned int mode,
603 const struct phylink_link_state *state)
604{
605 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200606 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700607
Marek Vasutd700ec42018-09-12 00:15:24 +0200608 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700609 return;
610
611 if (mode == MLO_AN_FIXED) {
612 link = LINK_FORCED_UP;
613 speed = state->speed;
614 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200615 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
616 link = state->link;
617 speed = state->speed;
618 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700619 } else {
620 speed = SPEED_UNFORCED;
621 duplex = DUPLEX_UNFORCED;
622 link = LINK_UNFORCED;
623 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700625
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700628 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000629 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700630
631 if (err && err != -EOPNOTSUPP)
632 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
633}
634
635static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
636{
637 struct mv88e6xxx_chip *chip = ds->priv;
638 int err;
639
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000640 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700641 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000642 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700643
644 if (err)
645 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
646}
647
648static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
649 unsigned int mode,
650 phy_interface_t interface)
651{
652 if (mode == MLO_AN_FIXED)
653 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
654}
655
656static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
657 unsigned int mode, phy_interface_t interface,
658 struct phy_device *phydev)
659{
660 if (mode == MLO_AN_FIXED)
661 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
662}
663
Andrew Lunna605a0f2016-11-21 23:26:58 +0100664static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 if (!chip->info->ops->stats_snapshot)
667 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000668
Andrew Lunna605a0f2016-11-21 23:26:58 +0100669 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000670}
671
Andrew Lunne413e7e2015-04-02 04:06:38 +0200672static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100673 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
674 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
675 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
676 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
677 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
678 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
679 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
680 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
681 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
682 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
683 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
684 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
685 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
686 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
687 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
688 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
689 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
690 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
691 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
692 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
693 { "single", 4, 0x14, STATS_TYPE_BANK0, },
694 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
695 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
696 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
697 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
698 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
699 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
700 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
701 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
702 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
703 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
704 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
705 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
706 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
707 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
708 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
709 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
710 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
711 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
712 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
713 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
714 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
715 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
716 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
717 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
718 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
719 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
720 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
721 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
722 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
723 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
724 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
725 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
726 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
727 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
728 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
729 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
730 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
731 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200732};
733
Vivien Didelotfad09c72016-06-21 12:28:20 -0400734static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100735 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100736 int port, u16 bank1_select,
737 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200738{
Andrew Lunn80c46272015-06-20 18:42:30 +0200739 u32 low;
740 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100741 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200742 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200743 u64 value;
744
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100745 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100746 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200747 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
748 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800749 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200750
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200751 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100752 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200753 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
754 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800755 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000756 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200757 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100758 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100759 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100761 /* fall through */
762 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100763 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100764 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100765 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100766 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500767 break;
768 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800769 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200770 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100771 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200772 return value;
773}
774
Andrew Lunn436fe172018-03-01 02:02:29 +0100775static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
776 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100777{
778 struct mv88e6xxx_hw_stat *stat;
779 int i, j;
780
781 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
782 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100783 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100784 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
785 ETH_GSTRING_LEN);
786 j++;
787 }
788 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100789
790 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100791}
792
Andrew Lunn436fe172018-03-01 02:02:29 +0100793static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
794 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100795{
Andrew Lunn436fe172018-03-01 02:02:29 +0100796 return mv88e6xxx_stats_get_strings(chip, data,
797 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100798}
799
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000800static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
801 uint8_t *data)
802{
803 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
804}
805
Andrew Lunn436fe172018-03-01 02:02:29 +0100806static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
807 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100808{
Andrew Lunn436fe172018-03-01 02:02:29 +0100809 return mv88e6xxx_stats_get_strings(chip, data,
810 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100811}
812
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
814 "atu_member_violation",
815 "atu_miss_violation",
816 "atu_full_violation",
817 "vtu_member_violation",
818 "vtu_miss_violation",
819};
820
821static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
822{
823 unsigned int i;
824
825 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
826 strlcpy(data + i * ETH_GSTRING_LEN,
827 mv88e6xxx_atu_vtu_stats_strings[i],
828 ETH_GSTRING_LEN);
829}
830
Andrew Lunndfafe442016-11-21 23:27:02 +0100831static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700832 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100833{
Vivien Didelot04bed142016-08-31 18:06:13 -0400834 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100835 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100836
Florian Fainelli89f09042018-04-25 12:12:50 -0700837 if (stringset != ETH_SS_STATS)
838 return;
839
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000840 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100841
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100843 count = chip->info->ops->stats_get_strings(chip, data);
844
845 if (chip->info->ops->serdes_get_strings) {
846 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100848 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100849
Andrew Lunn65f60e42018-03-28 23:50:28 +0200850 data += count * ETH_GSTRING_LEN;
851 mv88e6xxx_atu_vtu_get_strings(data);
852
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000853 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100854}
855
856static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
857 int types)
858{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 struct mv88e6xxx_hw_stat *stat;
860 int i, j;
861
862 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
863 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865 j++;
866 }
867 return j;
868}
869
Andrew Lunndfafe442016-11-21 23:27:02 +0100870static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
871{
872 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
873 STATS_TYPE_PORT);
874}
875
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000876static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
877{
878 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
879}
880
Andrew Lunndfafe442016-11-21 23:27:02 +0100881static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
882{
883 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
884 STATS_TYPE_BANK1);
885}
886
Florian Fainelli89f09042018-04-25 12:12:50 -0700887static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100888{
889 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 int serdes_count = 0;
891 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100892
Florian Fainelli89f09042018-04-25 12:12:50 -0700893 if (sset != ETH_SS_STATS)
894 return 0;
895
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000896 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100898 count = chip->info->ops->stats_get_sset_count(chip);
899 if (count < 0)
900 goto out;
901
902 if (chip->info->ops->serdes_get_sset_count)
903 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
904 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200905 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100906 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907 goto out;
908 }
909 count += serdes_count;
910 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000913 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Andrew Lunn436fe172018-03-01 02:02:29 +0100918static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
919 uint64_t *data, int types,
920 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100921{
922 struct mv88e6xxx_hw_stat *stat;
923 int i, j;
924
925 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
926 stat = &mv88e6xxx_hw_stats[i];
927 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000928 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100929 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
930 bank1_select,
931 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000932 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100933
Andrew Lunn052f9472016-11-21 23:27:03 +0100934 j++;
935 }
936 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100938}
939
Andrew Lunn436fe172018-03-01 02:02:29 +0100940static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
941 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100942{
943 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100944 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400945 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100946}
947
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000948static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
949 uint64_t *data)
950{
951 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
952 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
953}
954
Andrew Lunn436fe172018-03-01 02:02:29 +0100955static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
956 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100957{
958 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400960 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
961 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100962}
963
Andrew Lunn436fe172018-03-01 02:02:29 +0100964static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
965 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100966{
967 return mv88e6xxx_stats_get_stats(chip, port, data,
968 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400969 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
970 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100971}
972
Andrew Lunn65f60e42018-03-28 23:50:28 +0200973static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
974 uint64_t *data)
975{
976 *data++ = chip->ports[port].atu_member_violation;
977 *data++ = chip->ports[port].atu_miss_violation;
978 *data++ = chip->ports[port].atu_full_violation;
979 *data++ = chip->ports[port].vtu_member_violation;
980 *data++ = chip->ports[port].vtu_miss_violation;
981}
982
Andrew Lunn052f9472016-11-21 23:27:03 +0100983static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
984 uint64_t *data)
985{
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 int count = 0;
987
Andrew Lunn052f9472016-11-21 23:27:03 +0100988 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 count = chip->info->ops->stats_get_stats(chip, port, data);
990
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000991 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 if (chip->info->ops->serdes_get_stats) {
993 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 data += count;
997 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000998 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100999}
1000
Vivien Didelotf81ec902016-05-09 13:22:58 -04001001static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1002 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003{
Vivien Didelot04bed142016-08-31 18:06:13 -04001004 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001006
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001008
Andrew Lunna605a0f2016-11-21 23:26:58 +01001009 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001011
1012 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001014
1015 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001017}
Ben Hutchings98e67302011-11-25 14:36:19 +00001018
Vivien Didelotf81ec902016-05-09 13:22:58 -04001019static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001020{
1021 return 32 * sizeof(u16);
1022}
1023
Vivien Didelotf81ec902016-05-09 13:22:58 -04001024static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1025 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001026{
Vivien Didelot04bed142016-08-31 18:06:13 -04001027 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001028 int err;
1029 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001030 u16 *p = _p;
1031 int i;
1032
Vivien Didelota5f39322018-12-17 16:05:21 -05001033 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001034
1035 memset(p, 0xff, 32 * sizeof(u16));
1036
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001037 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001038
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001039 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001040
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001041 err = mv88e6xxx_port_read(chip, port, i, &reg);
1042 if (!err)
1043 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044 }
Vivien Didelot23062512016-05-09 13:22:45 -04001045
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047}
1048
Vivien Didelot08f50062017-08-01 16:32:41 -04001049static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1050 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001051{
Vivien Didelot5480db62017-08-01 16:32:40 -04001052 /* Nothing to do on the port's MAC */
1053 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001054}
1055
Vivien Didelot08f50062017-08-01 16:32:41 -04001056static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1057 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001058{
Vivien Didelot5480db62017-08-01 16:32:40 -04001059 /* Nothing to do on the port's MAC */
1060 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061}
1062
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001063/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001064static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001065{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001066 struct dsa_switch *ds = chip->ds;
1067 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001068 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001069 struct dsa_port *dp;
1070 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001071 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001072
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001073 list_for_each_entry(dp, &dst->ports, list) {
1074 if (dp->ds->index == dev && dp->index == port) {
1075 found = true;
1076 break;
1077 }
1078 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001079
Vivien Didelote5887a22017-03-30 17:37:11 -04001080 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001081 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001082 return 0;
1083
1084 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001085 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001086 return mv88e6xxx_port_mask(chip);
1087
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001088 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001089 pvlan = 0;
1090
1091 /* Frames from user ports can egress any local DSA links and CPU ports,
1092 * as well as any local member of their bridge group.
1093 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001094 list_for_each_entry(dp, &dst->ports, list)
1095 if (dp->ds == ds &&
1096 (dp->type == DSA_PORT_TYPE_CPU ||
1097 dp->type == DSA_PORT_TYPE_DSA ||
1098 (br && dp->bridge_dev == br)))
1099 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001100
1101 return pvlan;
1102}
1103
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001104static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001105{
1106 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001107
1108 /* prevent frames from going back out of the port they came in on */
1109 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001110
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001111 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001112}
1113
Vivien Didelotf81ec902016-05-09 13:22:58 -04001114static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1115 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001116{
Vivien Didelot04bed142016-08-31 18:06:13 -04001117 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001118 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001119
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001120 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001121 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001122 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001123
1124 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001125 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001126}
1127
Vivien Didelot93e18d62018-05-11 17:16:35 -04001128static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1129{
1130 int err;
1131
1132 if (chip->info->ops->ieee_pri_map) {
1133 err = chip->info->ops->ieee_pri_map(chip);
1134 if (err)
1135 return err;
1136 }
1137
1138 if (chip->info->ops->ip_pri_map) {
1139 err = chip->info->ops->ip_pri_map(chip);
1140 if (err)
1141 return err;
1142 }
1143
1144 return 0;
1145}
1146
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001147static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1148{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001149 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001150 int target, port;
1151 int err;
1152
1153 if (!chip->info->global2_addr)
1154 return 0;
1155
1156 /* Initialize the routing port to the 32 possible target devices */
1157 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001158 port = dsa_routing_port(ds, target);
1159 if (port == ds->num_ports)
1160 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001161
1162 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1163 if (err)
1164 return err;
1165 }
1166
Vivien Didelot02317e62018-05-09 11:38:49 -04001167 if (chip->info->ops->set_cascade_port) {
1168 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1169 err = chip->info->ops->set_cascade_port(chip, port);
1170 if (err)
1171 return err;
1172 }
1173
Vivien Didelot23c98912018-05-09 11:38:50 -04001174 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1175 if (err)
1176 return err;
1177
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001178 return 0;
1179}
1180
Vivien Didelotb28f8722018-04-26 21:56:44 -04001181static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1182{
1183 /* Clear all trunk masks and mapping */
1184 if (chip->info->global2_addr)
1185 return mv88e6xxx_g2_trunk_clear(chip);
1186
1187 return 0;
1188}
1189
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001190static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1191{
1192 if (chip->info->ops->rmu_disable)
1193 return chip->info->ops->rmu_disable(chip);
1194
1195 return 0;
1196}
1197
Vivien Didelot9e907d72017-07-17 13:03:43 -04001198static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1199{
1200 if (chip->info->ops->pot_clear)
1201 return chip->info->ops->pot_clear(chip);
1202
1203 return 0;
1204}
1205
Vivien Didelot51c901a2017-07-17 13:03:41 -04001206static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1207{
1208 if (chip->info->ops->mgmt_rsvd2cpu)
1209 return chip->info->ops->mgmt_rsvd2cpu(chip);
1210
1211 return 0;
1212}
1213
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001214static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1215{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001216 int err;
1217
Vivien Didelotdaefc942017-03-11 16:12:54 -05001218 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1219 if (err)
1220 return err;
1221
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001222 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1223 if (err)
1224 return err;
1225
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001226 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1227}
1228
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001229static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1230{
1231 int port;
1232 int err;
1233
1234 if (!chip->info->ops->irl_init_all)
1235 return 0;
1236
1237 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1238 /* Disable ingress rate limiting by resetting all per port
1239 * ingress rate limit resources to their initial state.
1240 */
1241 err = chip->info->ops->irl_init_all(chip, port);
1242 if (err)
1243 return err;
1244 }
1245
1246 return 0;
1247}
1248
Vivien Didelot04a69a12017-10-13 14:18:05 -04001249static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1250{
1251 if (chip->info->ops->set_switch_mac) {
1252 u8 addr[ETH_ALEN];
1253
1254 eth_random_addr(addr);
1255
1256 return chip->info->ops->set_switch_mac(chip, addr);
1257 }
1258
1259 return 0;
1260}
1261
Vivien Didelot17a15942017-03-30 17:37:09 -04001262static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1263{
1264 u16 pvlan = 0;
1265
1266 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001267 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001268
1269 /* Skip the local source device, which uses in-chip port VLAN */
1270 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001271 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001272
1273 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1274}
1275
Vivien Didelot81228992017-03-30 17:37:08 -04001276static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1277{
Vivien Didelot17a15942017-03-30 17:37:09 -04001278 int dev, port;
1279 int err;
1280
Vivien Didelot81228992017-03-30 17:37:08 -04001281 if (!mv88e6xxx_has_pvt(chip))
1282 return 0;
1283
1284 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1285 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1286 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001287 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1288 if (err)
1289 return err;
1290
1291 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1292 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1293 err = mv88e6xxx_pvt_map(chip, dev, port);
1294 if (err)
1295 return err;
1296 }
1297 }
1298
1299 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001300}
1301
Vivien Didelot749efcb2016-09-22 16:49:24 -04001302static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1303{
1304 struct mv88e6xxx_chip *chip = ds->priv;
1305 int err;
1306
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001307 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001308 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001309 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001310
1311 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001312 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001313}
1314
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001315static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1316{
1317 if (!chip->info->max_vid)
1318 return 0;
1319
1320 return mv88e6xxx_g1_vtu_flush(chip);
1321}
1322
Vivien Didelotf1394b782017-05-01 14:05:22 -04001323static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1324 struct mv88e6xxx_vtu_entry *entry)
1325{
1326 if (!chip->info->ops->vtu_getnext)
1327 return -EOPNOTSUPP;
1328
1329 return chip->info->ops->vtu_getnext(chip, entry);
1330}
1331
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001332static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1333 struct mv88e6xxx_vtu_entry *entry)
1334{
1335 if (!chip->info->ops->vtu_loadpurge)
1336 return -EOPNOTSUPP;
1337
1338 return chip->info->ops->vtu_loadpurge(chip, entry);
1339}
1340
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001341static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001342{
1343 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001344 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001345 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001346
1347 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1348
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001349 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001350 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001351 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001352 if (err)
1353 return err;
1354
1355 set_bit(*fid, fid_bitmap);
1356 }
1357
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001358 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001359 vlan.vid = chip->info->max_vid;
1360 vlan.valid = false;
1361
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001362 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001363 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001364 if (err)
1365 return err;
1366
1367 if (!vlan.valid)
1368 break;
1369
1370 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001371 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001372
1373 /* The reset value 0x000 is used to indicate that multiple address
1374 * databases are not needed. Return the next positive available.
1375 */
1376 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001377 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001378 return -ENOSPC;
1379
1380 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001381 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001382}
1383
Andrew Lunn23e8b472019-10-25 01:03:52 +02001384static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1385{
1386 if (chip->info->ops->atu_get_hash)
1387 return chip->info->ops->atu_get_hash(chip, hash);
1388
1389 return -EOPNOTSUPP;
1390}
1391
1392static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1393{
1394 if (chip->info->ops->atu_set_hash)
1395 return chip->info->ops->atu_set_hash(chip, hash);
1396
1397 return -EOPNOTSUPP;
1398}
1399
Vivien Didelotda9c3592016-02-12 12:09:40 -05001400static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1401 u16 vid_begin, u16 vid_end)
1402{
Vivien Didelot04bed142016-08-31 18:06:13 -04001403 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001404 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001405 int i, err;
1406
Andrew Lunndb06ae412017-09-25 23:32:20 +02001407 /* DSA and CPU ports have to be members of multiple vlans */
1408 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1409 return 0;
1410
Vivien Didelotda9c3592016-02-12 12:09:40 -05001411 if (!vid_begin)
1412 return -EOPNOTSUPP;
1413
Vivien Didelot425d2d32019-08-01 14:36:34 -04001414 vlan.vid = vid_begin - 1;
1415 vlan.valid = false;
1416
Vivien Didelotda9c3592016-02-12 12:09:40 -05001417 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001418 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001419 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001420 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001421
1422 if (!vlan.valid)
1423 break;
1424
1425 if (vlan.vid > vid_end)
1426 break;
1427
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001428 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001429 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1430 continue;
1431
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001432 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001433 continue;
1434
Vivien Didelotbd00e052017-05-01 14:05:11 -04001435 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001436 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001437 continue;
1438
Vivien Didelotc8652c82017-10-16 11:12:19 -04001439 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001440 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001441 break; /* same bridge, check next VLAN */
1442
Vivien Didelotc8652c82017-10-16 11:12:19 -04001443 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001444 continue;
1445
Andrew Lunn743fcc22017-11-09 22:29:54 +01001446 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1447 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001448 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001449 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001450 }
1451 } while (vlan.vid < vid_end);
1452
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001453 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001454}
1455
Vivien Didelotf81ec902016-05-09 13:22:58 -04001456static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1457 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001458{
Vivien Didelot04bed142016-08-31 18:06:13 -04001459 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001460 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1461 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001462 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001463
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001464 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001465 return -EOPNOTSUPP;
1466
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001467 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001468 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001469 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001470
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001471 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001472}
1473
Vivien Didelot57d32312016-06-20 13:13:58 -04001474static int
1475mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001476 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001477{
Vivien Didelot04bed142016-08-31 18:06:13 -04001478 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001479 int err;
1480
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001481 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001482 return -EOPNOTSUPP;
1483
Vivien Didelotda9c3592016-02-12 12:09:40 -05001484 /* If the requested port doesn't belong to the same bridge as the VLAN
1485 * members, do not support it (yet) and fallback to software VLAN.
1486 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001487 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001488 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1489 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001490 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001491
Vivien Didelot76e398a2015-11-01 12:33:55 -05001492 /* We don't need any dynamic resource from the kernel (yet),
1493 * so skip the prepare phase.
1494 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001495 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001496}
1497
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001498static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1499 const unsigned char *addr, u16 vid,
1500 u8 state)
1501{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001502 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001503 struct mv88e6xxx_vtu_entry vlan;
1504 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001505 int err;
1506
1507 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001508 if (vid == 0) {
1509 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1510 if (err)
1511 return err;
1512 } else {
1513 vlan.vid = vid - 1;
1514 vlan.valid = false;
1515
1516 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1517 if (err)
1518 return err;
1519
1520 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1521 if (vlan.vid != vid || !vlan.valid)
1522 return -EOPNOTSUPP;
1523
1524 fid = vlan.fid;
1525 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001526
Vivien Didelotd8291a92019-09-07 16:00:47 -04001527 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001528 ether_addr_copy(entry.mac, addr);
1529 eth_addr_dec(entry.mac);
1530
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001531 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001532 if (err)
1533 return err;
1534
1535 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001536 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001537 memset(&entry, 0, sizeof(entry));
1538 ether_addr_copy(entry.mac, addr);
1539 }
1540
1541 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001542 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001543 entry.portvec &= ~BIT(port);
1544 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001545 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001546 } else {
1547 entry.portvec |= BIT(port);
1548 entry.state = state;
1549 }
1550
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001551 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001552}
1553
Vivien Didelotda7dc872019-09-07 16:00:49 -04001554static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1555 const struct mv88e6xxx_policy *policy)
1556{
1557 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1558 enum mv88e6xxx_policy_action action = policy->action;
1559 const u8 *addr = policy->addr;
1560 u16 vid = policy->vid;
1561 u8 state;
1562 int err;
1563 int id;
1564
1565 if (!chip->info->ops->port_set_policy)
1566 return -EOPNOTSUPP;
1567
1568 switch (mapping) {
1569 case MV88E6XXX_POLICY_MAPPING_DA:
1570 case MV88E6XXX_POLICY_MAPPING_SA:
1571 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1572 state = 0; /* Dissociate the port and address */
1573 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1574 is_multicast_ether_addr(addr))
1575 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1576 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1577 is_unicast_ether_addr(addr))
1578 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1579 else
1580 return -EOPNOTSUPP;
1581
1582 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1583 state);
1584 if (err)
1585 return err;
1586 break;
1587 default:
1588 return -EOPNOTSUPP;
1589 }
1590
1591 /* Skip the port's policy clearing if the mapping is still in use */
1592 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1593 idr_for_each_entry(&chip->policies, policy, id)
1594 if (policy->port == port &&
1595 policy->mapping == mapping &&
1596 policy->action != action)
1597 return 0;
1598
1599 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1600}
1601
1602static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1603 struct ethtool_rx_flow_spec *fs)
1604{
1605 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1606 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1607 enum mv88e6xxx_policy_mapping mapping;
1608 enum mv88e6xxx_policy_action action;
1609 struct mv88e6xxx_policy *policy;
1610 u16 vid = 0;
1611 u8 *addr;
1612 int err;
1613 int id;
1614
1615 if (fs->location != RX_CLS_LOC_ANY)
1616 return -EINVAL;
1617
1618 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1619 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1620 else
1621 return -EOPNOTSUPP;
1622
1623 switch (fs->flow_type & ~FLOW_EXT) {
1624 case ETHER_FLOW:
1625 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1626 is_zero_ether_addr(mac_mask->h_source)) {
1627 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1628 addr = mac_entry->h_dest;
1629 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1630 !is_zero_ether_addr(mac_mask->h_source)) {
1631 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1632 addr = mac_entry->h_source;
1633 } else {
1634 /* Cannot support DA and SA mapping in the same rule */
1635 return -EOPNOTSUPP;
1636 }
1637 break;
1638 default:
1639 return -EOPNOTSUPP;
1640 }
1641
1642 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1643 if (fs->m_ext.vlan_tci != 0xffff)
1644 return -EOPNOTSUPP;
1645 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1646 }
1647
1648 idr_for_each_entry(&chip->policies, policy, id) {
1649 if (policy->port == port && policy->mapping == mapping &&
1650 policy->action == action && policy->vid == vid &&
1651 ether_addr_equal(policy->addr, addr))
1652 return -EEXIST;
1653 }
1654
1655 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1656 if (!policy)
1657 return -ENOMEM;
1658
1659 fs->location = 0;
1660 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1661 GFP_KERNEL);
1662 if (err) {
1663 devm_kfree(chip->dev, policy);
1664 return err;
1665 }
1666
1667 memcpy(&policy->fs, fs, sizeof(*fs));
1668 ether_addr_copy(policy->addr, addr);
1669 policy->mapping = mapping;
1670 policy->action = action;
1671 policy->port = port;
1672 policy->vid = vid;
1673
1674 err = mv88e6xxx_policy_apply(chip, port, policy);
1675 if (err) {
1676 idr_remove(&chip->policies, fs->location);
1677 devm_kfree(chip->dev, policy);
1678 return err;
1679 }
1680
1681 return 0;
1682}
1683
1684static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1685 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1686{
1687 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1688 struct mv88e6xxx_chip *chip = ds->priv;
1689 struct mv88e6xxx_policy *policy;
1690 int err;
1691 int id;
1692
1693 mv88e6xxx_reg_lock(chip);
1694
1695 switch (rxnfc->cmd) {
1696 case ETHTOOL_GRXCLSRLCNT:
1697 rxnfc->data = 0;
1698 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1699 rxnfc->rule_cnt = 0;
1700 idr_for_each_entry(&chip->policies, policy, id)
1701 if (policy->port == port)
1702 rxnfc->rule_cnt++;
1703 err = 0;
1704 break;
1705 case ETHTOOL_GRXCLSRULE:
1706 err = -ENOENT;
1707 policy = idr_find(&chip->policies, fs->location);
1708 if (policy) {
1709 memcpy(fs, &policy->fs, sizeof(*fs));
1710 err = 0;
1711 }
1712 break;
1713 case ETHTOOL_GRXCLSRLALL:
1714 rxnfc->data = 0;
1715 rxnfc->rule_cnt = 0;
1716 idr_for_each_entry(&chip->policies, policy, id)
1717 if (policy->port == port)
1718 rule_locs[rxnfc->rule_cnt++] = id;
1719 err = 0;
1720 break;
1721 default:
1722 err = -EOPNOTSUPP;
1723 break;
1724 }
1725
1726 mv88e6xxx_reg_unlock(chip);
1727
1728 return err;
1729}
1730
1731static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1732 struct ethtool_rxnfc *rxnfc)
1733{
1734 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1735 struct mv88e6xxx_chip *chip = ds->priv;
1736 struct mv88e6xxx_policy *policy;
1737 int err;
1738
1739 mv88e6xxx_reg_lock(chip);
1740
1741 switch (rxnfc->cmd) {
1742 case ETHTOOL_SRXCLSRLINS:
1743 err = mv88e6xxx_policy_insert(chip, port, fs);
1744 break;
1745 case ETHTOOL_SRXCLSRLDEL:
1746 err = -ENOENT;
1747 policy = idr_remove(&chip->policies, fs->location);
1748 if (policy) {
1749 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1750 err = mv88e6xxx_policy_apply(chip, port, policy);
1751 devm_kfree(chip->dev, policy);
1752 }
1753 break;
1754 default:
1755 err = -EOPNOTSUPP;
1756 break;
1757 }
1758
1759 mv88e6xxx_reg_unlock(chip);
1760
1761 return err;
1762}
1763
Andrew Lunn87fa8862017-11-09 22:29:56 +01001764static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1765 u16 vid)
1766{
1767 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1768 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1769
1770 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1771}
1772
1773static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1774{
1775 int port;
1776 int err;
1777
1778 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1779 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1780 if (err)
1781 return err;
1782 }
1783
1784 return 0;
1785}
1786
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001787static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001788 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001789{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001790 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001791 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001792 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001793
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001794 if (!vid)
1795 return -EOPNOTSUPP;
1796
1797 vlan.vid = vid - 1;
1798 vlan.valid = false;
1799
1800 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001801 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001802 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001803
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001804 if (vlan.vid != vid || !vlan.valid) {
1805 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001806
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001807 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1808 if (err)
1809 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001810
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001811 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1812 if (i == port)
1813 vlan.member[i] = member;
1814 else
1815 vlan.member[i] = non_member;
1816
1817 vlan.vid = vid;
1818 vlan.valid = true;
1819
1820 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1821 if (err)
1822 return err;
1823
1824 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1825 if (err)
1826 return err;
1827 } else if (vlan.member[port] != member) {
1828 vlan.member[port] = member;
1829
1830 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1831 if (err)
1832 return err;
1833 } else {
1834 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1835 port, vid);
1836 }
1837
1838 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001839}
1840
Vivien Didelotf81ec902016-05-09 13:22:58 -04001841static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001842 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001843{
Vivien Didelot04bed142016-08-31 18:06:13 -04001844 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001845 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1846 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001847 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001848 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001849
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001850 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001851 return;
1852
Vivien Didelotc91498e2017-06-07 18:12:13 -04001853 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001854 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001855 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001856 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001857 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001858 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001859
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001860 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001861
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001862 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001863 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001864 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1865 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001866
Vivien Didelot77064f32016-11-04 03:23:30 +01001867 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001868 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1869 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001870
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001871 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001872}
1873
Vivien Didelot521098922019-08-01 14:36:36 -04001874static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1875 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001876{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001877 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001878 int i, err;
1879
Vivien Didelot521098922019-08-01 14:36:36 -04001880 if (!vid)
1881 return -EOPNOTSUPP;
1882
1883 vlan.vid = vid - 1;
1884 vlan.valid = false;
1885
1886 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001887 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001888 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001889
Vivien Didelot521098922019-08-01 14:36:36 -04001890 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1891 * tell switchdev that this VLAN is likely handled in software.
1892 */
1893 if (vlan.vid != vid || !vlan.valid ||
1894 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001895 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001896
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001897 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001898
1899 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001900 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001901 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001902 if (vlan.member[i] !=
1903 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001904 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001905 break;
1906 }
1907 }
1908
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001909 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001910 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001911 return err;
1912
Vivien Didelote606ca32017-03-11 16:12:55 -05001913 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001914}
1915
Vivien Didelotf81ec902016-05-09 13:22:58 -04001916static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1917 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001918{
Vivien Didelot04bed142016-08-31 18:06:13 -04001919 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001920 u16 pvid, vid;
1921 int err = 0;
1922
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001923 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001924 return -EOPNOTSUPP;
1925
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001926 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001927
Vivien Didelot77064f32016-11-04 03:23:30 +01001928 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001929 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001930 goto unlock;
1931
Vivien Didelot76e398a2015-11-01 12:33:55 -05001932 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001933 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001934 if (err)
1935 goto unlock;
1936
1937 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001938 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001939 if (err)
1940 goto unlock;
1941 }
1942 }
1943
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001944unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001945 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001946
1947 return err;
1948}
1949
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001950static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1951 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001952{
Vivien Didelot04bed142016-08-31 18:06:13 -04001953 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001954 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001955
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001956 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001957 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1958 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001959 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001960
1961 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001962}
1963
Vivien Didelotf81ec902016-05-09 13:22:58 -04001964static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001965 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001966{
Vivien Didelot04bed142016-08-31 18:06:13 -04001967 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001968 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001969
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001970 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04001971 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001972 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001973
Vivien Didelot83dabd12016-08-31 11:50:04 -04001974 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001975}
1976
Vivien Didelot83dabd12016-08-31 11:50:04 -04001977static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1978 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001979 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001980{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001981 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001982 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001983 int err;
1984
Vivien Didelotd8291a92019-09-07 16:00:47 -04001985 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001986 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001987
1988 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001989 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001990 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001991 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001992
Vivien Didelotd8291a92019-09-07 16:00:47 -04001993 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001994 break;
1995
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001996 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001997 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001998
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001999 if (!is_unicast_ether_addr(addr.mac))
2000 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002001
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002002 is_static = (addr.state ==
2003 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2004 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002005 if (err)
2006 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002007 } while (!is_broadcast_ether_addr(addr.mac));
2008
2009 return err;
2010}
2011
Vivien Didelot83dabd12016-08-31 11:50:04 -04002012static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002013 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002014{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002015 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002016 u16 fid;
2017 int err;
2018
2019 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002020 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002021 if (err)
2022 return err;
2023
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002024 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002025 if (err)
2026 return err;
2027
2028 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002029 vlan.vid = chip->info->max_vid;
2030 vlan.valid = false;
2031
Vivien Didelot83dabd12016-08-31 11:50:04 -04002032 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002033 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002034 if (err)
2035 return err;
2036
2037 if (!vlan.valid)
2038 break;
2039
2040 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002041 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002042 if (err)
2043 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002044 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002045
2046 return err;
2047}
2048
Vivien Didelotf81ec902016-05-09 13:22:58 -04002049static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002050 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002051{
Vivien Didelot04bed142016-08-31 18:06:13 -04002052 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002053 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002054
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002055 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002056 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002057 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002058
2059 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002060}
2061
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002062static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2063 struct net_device *br)
2064{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002065 struct dsa_switch *ds = chip->ds;
2066 struct dsa_switch_tree *dst = ds->dst;
2067 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002068 int err;
2069
Vivien Didelotef2025e2019-10-21 16:51:27 -04002070 list_for_each_entry(dp, &dst->ports, list) {
2071 if (dp->bridge_dev == br) {
2072 if (dp->ds == ds) {
2073 /* This is a local bridge group member,
2074 * remap its Port VLAN Map.
2075 */
2076 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2077 if (err)
2078 return err;
2079 } else {
2080 /* This is an external bridge group member,
2081 * remap its cross-chip Port VLAN Table entry.
2082 */
2083 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2084 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002085 if (err)
2086 return err;
2087 }
2088 }
2089 }
2090
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002091 return 0;
2092}
2093
Vivien Didelotf81ec902016-05-09 13:22:58 -04002094static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002095 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002096{
Vivien Didelot04bed142016-08-31 18:06:13 -04002097 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002098 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002099
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002100 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002101 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002102 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002103
Vivien Didelot466dfa02016-02-26 13:16:05 -05002104 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002105}
2106
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002107static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2108 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002109{
Vivien Didelot04bed142016-08-31 18:06:13 -04002110 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002111
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002112 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002113 if (mv88e6xxx_bridge_map(chip, br) ||
2114 mv88e6xxx_port_vlan_map(chip, port))
2115 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002116 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002117}
2118
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002119static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2120 int port, struct net_device *br)
2121{
2122 struct mv88e6xxx_chip *chip = ds->priv;
2123 int err;
2124
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002125 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002126 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002127 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002128
2129 return err;
2130}
2131
2132static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2133 int port, struct net_device *br)
2134{
2135 struct mv88e6xxx_chip *chip = ds->priv;
2136
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002137 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002138 if (mv88e6xxx_pvt_map(chip, dev, port))
2139 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002140 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002141}
2142
Vivien Didelot17e708b2016-12-05 17:30:27 -05002143static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2144{
2145 if (chip->info->ops->reset)
2146 return chip->info->ops->reset(chip);
2147
2148 return 0;
2149}
2150
Vivien Didelot309eca62016-12-05 17:30:26 -05002151static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2152{
2153 struct gpio_desc *gpiod = chip->reset;
2154
2155 /* If there is a GPIO connected to the reset pin, toggle it */
2156 if (gpiod) {
2157 gpiod_set_value_cansleep(gpiod, 1);
2158 usleep_range(10000, 20000);
2159 gpiod_set_value_cansleep(gpiod, 0);
2160 usleep_range(10000, 20000);
2161 }
2162}
2163
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002164static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2165{
2166 int i, err;
2167
2168 /* Set all ports to the Disabled state */
2169 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002170 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002171 if (err)
2172 return err;
2173 }
2174
2175 /* Wait for transmit queues to drain,
2176 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2177 */
2178 usleep_range(2000, 4000);
2179
2180 return 0;
2181}
2182
Vivien Didelotfad09c72016-06-21 12:28:20 -04002183static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002184{
Vivien Didelota935c052016-09-29 12:21:53 -04002185 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002186
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002187 err = mv88e6xxx_disable_ports(chip);
2188 if (err)
2189 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002190
Vivien Didelot309eca62016-12-05 17:30:26 -05002191 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002192
Vivien Didelot17e708b2016-12-05 17:30:27 -05002193 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002194}
2195
Vivien Didelot43145572017-03-11 16:12:59 -05002196static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002197 enum mv88e6xxx_frame_mode frame,
2198 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002199{
2200 int err;
2201
Vivien Didelot43145572017-03-11 16:12:59 -05002202 if (!chip->info->ops->port_set_frame_mode)
2203 return -EOPNOTSUPP;
2204
2205 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002206 if (err)
2207 return err;
2208
Vivien Didelot43145572017-03-11 16:12:59 -05002209 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2210 if (err)
2211 return err;
2212
2213 if (chip->info->ops->port_set_ether_type)
2214 return chip->info->ops->port_set_ether_type(chip, port, etype);
2215
2216 return 0;
2217}
2218
2219static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2220{
2221 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002222 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002223 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002224}
2225
2226static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2227{
2228 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002229 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002230 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002231}
2232
2233static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2234{
2235 return mv88e6xxx_set_port_mode(chip, port,
2236 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002237 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2238 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002239}
2240
2241static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2242{
2243 if (dsa_is_dsa_port(chip->ds, port))
2244 return mv88e6xxx_set_port_mode_dsa(chip, port);
2245
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002246 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002247 return mv88e6xxx_set_port_mode_normal(chip, port);
2248
2249 /* Setup CPU port mode depending on its supported tag format */
2250 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2251 return mv88e6xxx_set_port_mode_dsa(chip, port);
2252
2253 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2254 return mv88e6xxx_set_port_mode_edsa(chip, port);
2255
2256 return -EINVAL;
2257}
2258
Vivien Didelotea698f42017-03-11 16:12:50 -05002259static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2260{
2261 bool message = dsa_is_dsa_port(chip->ds, port);
2262
2263 return mv88e6xxx_port_set_message_port(chip, port, message);
2264}
2265
Vivien Didelot601aeed2017-03-11 16:13:00 -05002266static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2267{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002268 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002269 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002270
David S. Miller407308f2019-06-15 13:35:29 -07002271 /* Upstream ports flood frames with unknown unicast or multicast DA */
2272 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2273 if (chip->info->ops->port_set_egress_floods)
2274 return chip->info->ops->port_set_egress_floods(chip, port,
2275 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002276
David S. Miller407308f2019-06-15 13:35:29 -07002277 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002278}
2279
Vivien Didelot45de77f2019-08-31 16:18:36 -04002280static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2281{
2282 struct mv88e6xxx_port *mvp = dev_id;
2283 struct mv88e6xxx_chip *chip = mvp->chip;
2284 irqreturn_t ret = IRQ_NONE;
2285 int port = mvp->port;
2286 u8 lane;
2287
2288 mv88e6xxx_reg_lock(chip);
2289 lane = mv88e6xxx_serdes_get_lane(chip, port);
2290 if (lane)
2291 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2292 mv88e6xxx_reg_unlock(chip);
2293
2294 return ret;
2295}
2296
2297static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2298 u8 lane)
2299{
2300 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2301 unsigned int irq;
2302 int err;
2303
2304 /* Nothing to request if this SERDES port has no IRQ */
2305 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2306 if (!irq)
2307 return 0;
2308
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002309 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2310 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2311
Vivien Didelot45de77f2019-08-31 16:18:36 -04002312 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2313 mv88e6xxx_reg_unlock(chip);
2314 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002315 IRQF_ONESHOT, dev_id->serdes_irq_name,
2316 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002317 mv88e6xxx_reg_lock(chip);
2318 if (err)
2319 return err;
2320
2321 dev_id->serdes_irq = irq;
2322
2323 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2324}
2325
2326static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2327 u8 lane)
2328{
2329 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2330 unsigned int irq = dev_id->serdes_irq;
2331 int err;
2332
2333 /* Nothing to free if no IRQ has been requested */
2334 if (!irq)
2335 return 0;
2336
2337 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2338
2339 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2340 mv88e6xxx_reg_unlock(chip);
2341 free_irq(irq, dev_id);
2342 mv88e6xxx_reg_lock(chip);
2343
2344 dev_id->serdes_irq = 0;
2345
2346 return err;
2347}
2348
Andrew Lunn6d917822017-05-26 01:03:21 +02002349static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2350 bool on)
2351{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002352 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002353 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002354
Vivien Didelotdc272f62019-08-31 16:18:33 -04002355 lane = mv88e6xxx_serdes_get_lane(chip, port);
2356 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002357 return 0;
2358
2359 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002360 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002361 if (err)
2362 return err;
2363
Vivien Didelot45de77f2019-08-31 16:18:36 -04002364 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002365 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002366 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2367 if (err)
2368 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002369
Vivien Didelotdc272f62019-08-31 16:18:33 -04002370 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002371 }
2372
2373 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002374}
2375
Vivien Didelotfa371c82017-12-05 15:34:10 -05002376static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2377{
2378 struct dsa_switch *ds = chip->ds;
2379 int upstream_port;
2380 int err;
2381
Vivien Didelot07073c72017-12-05 15:34:13 -05002382 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002383 if (chip->info->ops->port_set_upstream_port) {
2384 err = chip->info->ops->port_set_upstream_port(chip, port,
2385 upstream_port);
2386 if (err)
2387 return err;
2388 }
2389
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002390 if (port == upstream_port) {
2391 if (chip->info->ops->set_cpu_port) {
2392 err = chip->info->ops->set_cpu_port(chip,
2393 upstream_port);
2394 if (err)
2395 return err;
2396 }
2397
2398 if (chip->info->ops->set_egress_port) {
2399 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002400 MV88E6XXX_EGRESS_DIR_INGRESS,
2401 upstream_port);
2402 if (err)
2403 return err;
2404
2405 err = chip->info->ops->set_egress_port(chip,
2406 MV88E6XXX_EGRESS_DIR_EGRESS,
2407 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002408 if (err)
2409 return err;
2410 }
2411 }
2412
Vivien Didelotfa371c82017-12-05 15:34:10 -05002413 return 0;
2414}
2415
Vivien Didelotfad09c72016-06-21 12:28:20 -04002416static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002417{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002418 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002419 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002420 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002421
Andrew Lunn7b898462018-08-09 15:38:47 +02002422 chip->ports[port].chip = chip;
2423 chip->ports[port].port = port;
2424
Vivien Didelotd78343d2016-11-04 03:23:36 +01002425 /* MAC Forcing register: don't force link, speed, duplex or flow control
2426 * state to any particular values on physical ports, but force the CPU
2427 * port and all DSA ports to their maximum bandwidth and full duplex.
2428 */
2429 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2430 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2431 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002432 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002433 PHY_INTERFACE_MODE_NA);
2434 else
2435 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2436 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002437 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002438 PHY_INTERFACE_MODE_NA);
2439 if (err)
2440 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002441
2442 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2443 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2444 * tunneling, determine priority by looking at 802.1p and IP
2445 * priority fields (IP prio has precedence), and set STP state
2446 * to Forwarding.
2447 *
2448 * If this is the CPU link, use DSA or EDSA tagging depending
2449 * on which tagging mode was configured.
2450 *
2451 * If this is a link to another switch, use DSA tagging mode.
2452 *
2453 * If this is the upstream port for this switch, enable
2454 * forwarding of unknown unicasts and multicasts.
2455 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002456 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2457 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2458 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2459 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002460 if (err)
2461 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002462
Vivien Didelot601aeed2017-03-11 16:13:00 -05002463 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002464 if (err)
2465 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002466
Vivien Didelot601aeed2017-03-11 16:13:00 -05002467 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002468 if (err)
2469 return err;
2470
Vivien Didelot8efdda42015-08-13 12:52:23 -04002471 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002472 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002473 * untagged frames on this port, do a destination address lookup on all
2474 * received packets as usual, disable ARP mirroring and don't send a
2475 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002476 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002477 err = mv88e6xxx_port_set_map_da(chip, port);
2478 if (err)
2479 return err;
2480
Vivien Didelotfa371c82017-12-05 15:34:10 -05002481 err = mv88e6xxx_setup_upstream_port(chip, port);
2482 if (err)
2483 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002484
Andrew Lunna23b2962017-02-04 20:15:28 +01002485 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002486 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002487 if (err)
2488 return err;
2489
Vivien Didelotcd782652017-06-08 18:34:13 -04002490 if (chip->info->ops->port_set_jumbo_size) {
2491 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002492 if (err)
2493 return err;
2494 }
2495
Andrew Lunn54d792f2015-05-06 01:09:47 +02002496 /* Port Association Vector: when learning source addresses
2497 * of packets, add the address to the address database using
2498 * a port bitmap that has only the bit for this port set and
2499 * the other bits clear.
2500 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002501 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002502 /* Disable learning for CPU port */
2503 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002504 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002505
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002506 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2507 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002508 if (err)
2509 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002510
2511 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002512 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2513 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002514 if (err)
2515 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002516
Vivien Didelot08984322017-06-08 18:34:12 -04002517 if (chip->info->ops->port_pause_limit) {
2518 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002519 if (err)
2520 return err;
2521 }
2522
Vivien Didelotc8c94892017-03-11 16:13:01 -05002523 if (chip->info->ops->port_disable_learn_limit) {
2524 err = chip->info->ops->port_disable_learn_limit(chip, port);
2525 if (err)
2526 return err;
2527 }
2528
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002529 if (chip->info->ops->port_disable_pri_override) {
2530 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002531 if (err)
2532 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002533 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002534
Andrew Lunnef0a7312016-12-03 04:35:16 +01002535 if (chip->info->ops->port_tag_remap) {
2536 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002537 if (err)
2538 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002539 }
2540
Andrew Lunnef70b112016-12-03 04:45:18 +01002541 if (chip->info->ops->port_egress_rate_limiting) {
2542 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002543 if (err)
2544 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002545 }
2546
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002547 if (chip->info->ops->port_setup_message_port) {
2548 err = chip->info->ops->port_setup_message_port(chip, port);
2549 if (err)
2550 return err;
2551 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002552
Vivien Didelot207afda2016-04-14 14:42:09 -04002553 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002554 * database, and allow bidirectional communication between the
2555 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002556 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002557 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002558 if (err)
2559 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002560
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002561 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002562 if (err)
2563 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002564
2565 /* Default VLAN ID and priority: don't set a default VLAN
2566 * ID, and set the default packet priority to zero.
2567 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002568 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002569}
2570
Andrew Lunn04aca992017-05-26 01:03:24 +02002571static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2572 struct phy_device *phydev)
2573{
2574 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002575 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002576
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002577 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002578 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002579 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002580
2581 return err;
2582}
2583
Andrew Lunn75104db2019-02-24 20:44:43 +01002584static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002585{
2586 struct mv88e6xxx_chip *chip = ds->priv;
2587
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002588 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002589 if (mv88e6xxx_serdes_power(chip, port, false))
2590 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002591 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002592}
2593
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002594static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2595 unsigned int ageing_time)
2596{
Vivien Didelot04bed142016-08-31 18:06:13 -04002597 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002598 int err;
2599
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002600 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002601 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002602 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002603
2604 return err;
2605}
2606
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002607static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002608{
2609 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002610
Andrew Lunnde2273872016-11-21 23:27:01 +01002611 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002612 if (chip->info->ops->stats_set_histogram) {
2613 err = chip->info->ops->stats_set_histogram(chip);
2614 if (err)
2615 return err;
2616 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002617
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002618 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002619}
2620
Andrew Lunnea890982019-01-09 00:24:03 +01002621/* Check if the errata has already been applied. */
2622static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2623{
2624 int port;
2625 int err;
2626 u16 val;
2627
2628 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002629 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002630 if (err) {
2631 dev_err(chip->dev,
2632 "Error reading hidden register: %d\n", err);
2633 return false;
2634 }
2635 if (val != 0x01c0)
2636 return false;
2637 }
2638
2639 return true;
2640}
2641
2642/* The 6390 copper ports have an errata which require poking magic
2643 * values into undocumented hidden registers and then performing a
2644 * software reset.
2645 */
2646static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2647{
2648 int port;
2649 int err;
2650
2651 if (mv88e6390_setup_errata_applied(chip))
2652 return 0;
2653
2654 /* Set the ports into blocking mode */
2655 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2656 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2657 if (err)
2658 return err;
2659 }
2660
2661 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002662 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002663 if (err)
2664 return err;
2665 }
2666
2667 return mv88e6xxx_software_reset(chip);
2668}
2669
Andrew Lunn23e8b472019-10-25 01:03:52 +02002670enum mv88e6xxx_devlink_param_id {
2671 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2672 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2673};
2674
2675static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2676 struct devlink_param_gset_ctx *ctx)
2677{
2678 struct mv88e6xxx_chip *chip = ds->priv;
2679 int err;
2680
2681 mv88e6xxx_reg_lock(chip);
2682
2683 switch (id) {
2684 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2685 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2686 break;
2687 default:
2688 err = -EOPNOTSUPP;
2689 break;
2690 }
2691
2692 mv88e6xxx_reg_unlock(chip);
2693
2694 return err;
2695}
2696
2697static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2698 struct devlink_param_gset_ctx *ctx)
2699{
2700 struct mv88e6xxx_chip *chip = ds->priv;
2701 int err;
2702
2703 mv88e6xxx_reg_lock(chip);
2704
2705 switch (id) {
2706 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2707 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2708 break;
2709 default:
2710 err = -EOPNOTSUPP;
2711 break;
2712 }
2713
2714 mv88e6xxx_reg_unlock(chip);
2715
2716 return err;
2717}
2718
2719static const struct devlink_param mv88e6xxx_devlink_params[] = {
2720 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2721 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2722 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2723};
2724
2725static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2726{
2727 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2728 ARRAY_SIZE(mv88e6xxx_devlink_params));
2729}
2730
2731static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2732{
2733 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2734 ARRAY_SIZE(mv88e6xxx_devlink_params));
2735}
2736
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002737enum mv88e6xxx_devlink_resource_id {
2738 MV88E6XXX_RESOURCE_ID_ATU,
2739 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2740 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2741 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2742 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2743};
2744
2745static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2746 u16 bin)
2747{
2748 u16 occupancy = 0;
2749 int err;
2750
2751 mv88e6xxx_reg_lock(chip);
2752
2753 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2754 bin);
2755 if (err) {
2756 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2757 goto unlock;
2758 }
2759
2760 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2761 if (err) {
2762 dev_err(chip->dev, "failed to perform ATU get next\n");
2763 goto unlock;
2764 }
2765
2766 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2767 if (err) {
2768 dev_err(chip->dev, "failed to get ATU stats\n");
2769 goto unlock;
2770 }
2771
2772unlock:
2773 mv88e6xxx_reg_unlock(chip);
2774
2775 return occupancy;
2776}
2777
2778static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2779{
2780 struct mv88e6xxx_chip *chip = priv;
2781
2782 return mv88e6xxx_devlink_atu_bin_get(chip,
2783 MV88E6XXX_G2_ATU_STATS_BIN_0);
2784}
2785
2786static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2787{
2788 struct mv88e6xxx_chip *chip = priv;
2789
2790 return mv88e6xxx_devlink_atu_bin_get(chip,
2791 MV88E6XXX_G2_ATU_STATS_BIN_1);
2792}
2793
2794static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2795{
2796 struct mv88e6xxx_chip *chip = priv;
2797
2798 return mv88e6xxx_devlink_atu_bin_get(chip,
2799 MV88E6XXX_G2_ATU_STATS_BIN_2);
2800}
2801
2802static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2803{
2804 struct mv88e6xxx_chip *chip = priv;
2805
2806 return mv88e6xxx_devlink_atu_bin_get(chip,
2807 MV88E6XXX_G2_ATU_STATS_BIN_3);
2808}
2809
2810static u64 mv88e6xxx_devlink_atu_get(void *priv)
2811{
2812 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2813 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2814 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2815 mv88e6xxx_devlink_atu_bin_3_get(priv);
2816}
2817
2818static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2819{
2820 struct devlink_resource_size_params size_params;
2821 struct mv88e6xxx_chip *chip = ds->priv;
2822 int err;
2823
2824 devlink_resource_size_params_init(&size_params,
2825 mv88e6xxx_num_macs(chip),
2826 mv88e6xxx_num_macs(chip),
2827 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2828
2829 err = dsa_devlink_resource_register(ds, "ATU",
2830 mv88e6xxx_num_macs(chip),
2831 MV88E6XXX_RESOURCE_ID_ATU,
2832 DEVLINK_RESOURCE_ID_PARENT_TOP,
2833 &size_params);
2834 if (err)
2835 goto out;
2836
2837 devlink_resource_size_params_init(&size_params,
2838 mv88e6xxx_num_macs(chip) / 4,
2839 mv88e6xxx_num_macs(chip) / 4,
2840 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2841
2842 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2843 mv88e6xxx_num_macs(chip) / 4,
2844 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2845 MV88E6XXX_RESOURCE_ID_ATU,
2846 &size_params);
2847 if (err)
2848 goto out;
2849
2850 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2851 mv88e6xxx_num_macs(chip) / 4,
2852 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2853 MV88E6XXX_RESOURCE_ID_ATU,
2854 &size_params);
2855 if (err)
2856 goto out;
2857
2858 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2859 mv88e6xxx_num_macs(chip) / 4,
2860 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2861 MV88E6XXX_RESOURCE_ID_ATU,
2862 &size_params);
2863 if (err)
2864 goto out;
2865
2866 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2867 mv88e6xxx_num_macs(chip) / 4,
2868 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2869 MV88E6XXX_RESOURCE_ID_ATU,
2870 &size_params);
2871 if (err)
2872 goto out;
2873
2874 dsa_devlink_resource_occ_get_register(ds,
2875 MV88E6XXX_RESOURCE_ID_ATU,
2876 mv88e6xxx_devlink_atu_get,
2877 chip);
2878
2879 dsa_devlink_resource_occ_get_register(ds,
2880 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2881 mv88e6xxx_devlink_atu_bin_0_get,
2882 chip);
2883
2884 dsa_devlink_resource_occ_get_register(ds,
2885 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2886 mv88e6xxx_devlink_atu_bin_1_get,
2887 chip);
2888
2889 dsa_devlink_resource_occ_get_register(ds,
2890 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2891 mv88e6xxx_devlink_atu_bin_2_get,
2892 chip);
2893
2894 dsa_devlink_resource_occ_get_register(ds,
2895 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2896 mv88e6xxx_devlink_atu_bin_3_get,
2897 chip);
2898
2899 return 0;
2900
2901out:
2902 dsa_devlink_resources_unregister(ds);
2903 return err;
2904}
2905
Andrew Lunn23e8b472019-10-25 01:03:52 +02002906static void mv88e6xxx_teardown(struct dsa_switch *ds)
2907{
2908 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002909 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002910}
2911
Vivien Didelotf81ec902016-05-09 13:22:58 -04002912static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002913{
Vivien Didelot04bed142016-08-31 18:06:13 -04002914 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002915 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002916 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002917 int i;
2918
Vivien Didelotfad09c72016-06-21 12:28:20 -04002919 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002920 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002921
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002922 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002923
Andrew Lunnea890982019-01-09 00:24:03 +01002924 if (chip->info->ops->setup_errata) {
2925 err = chip->info->ops->setup_errata(chip);
2926 if (err)
2927 goto unlock;
2928 }
2929
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002930 /* Cache the cmode of each port. */
2931 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2932 if (chip->info->ops->port_get_cmode) {
2933 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2934 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002935 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002936
2937 chip->ports[i].cmode = cmode;
2938 }
2939 }
2940
Vivien Didelot97299342016-07-18 20:45:30 -04002941 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002942 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002943 if (dsa_is_unused_port(ds, i))
2944 continue;
2945
Hubert Feursteinc8574862019-07-31 10:23:48 +02002946 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002947 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002948 dev_err(chip->dev, "port %d is invalid\n", i);
2949 err = -EINVAL;
2950 goto unlock;
2951 }
2952
Vivien Didelot97299342016-07-18 20:45:30 -04002953 err = mv88e6xxx_setup_port(chip, i);
2954 if (err)
2955 goto unlock;
2956 }
2957
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002958 err = mv88e6xxx_irl_setup(chip);
2959 if (err)
2960 goto unlock;
2961
Vivien Didelot04a69a12017-10-13 14:18:05 -04002962 err = mv88e6xxx_mac_setup(chip);
2963 if (err)
2964 goto unlock;
2965
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002966 err = mv88e6xxx_phy_setup(chip);
2967 if (err)
2968 goto unlock;
2969
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002970 err = mv88e6xxx_vtu_setup(chip);
2971 if (err)
2972 goto unlock;
2973
Vivien Didelot81228992017-03-30 17:37:08 -04002974 err = mv88e6xxx_pvt_setup(chip);
2975 if (err)
2976 goto unlock;
2977
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002978 err = mv88e6xxx_atu_setup(chip);
2979 if (err)
2980 goto unlock;
2981
Andrew Lunn87fa8862017-11-09 22:29:56 +01002982 err = mv88e6xxx_broadcast_setup(chip, 0);
2983 if (err)
2984 goto unlock;
2985
Vivien Didelot9e907d72017-07-17 13:03:43 -04002986 err = mv88e6xxx_pot_setup(chip);
2987 if (err)
2988 goto unlock;
2989
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002990 err = mv88e6xxx_rmu_setup(chip);
2991 if (err)
2992 goto unlock;
2993
Vivien Didelot51c901a2017-07-17 13:03:41 -04002994 err = mv88e6xxx_rsvd2cpu_setup(chip);
2995 if (err)
2996 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002997
Vivien Didelotb28f8722018-04-26 21:56:44 -04002998 err = mv88e6xxx_trunk_setup(chip);
2999 if (err)
3000 goto unlock;
3001
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003002 err = mv88e6xxx_devmap_setup(chip);
3003 if (err)
3004 goto unlock;
3005
Vivien Didelot93e18d62018-05-11 17:16:35 -04003006 err = mv88e6xxx_pri_setup(chip);
3007 if (err)
3008 goto unlock;
3009
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003010 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003011 if (chip->info->ptp_support) {
3012 err = mv88e6xxx_ptp_setup(chip);
3013 if (err)
3014 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003015
3016 err = mv88e6xxx_hwtstamp_setup(chip);
3017 if (err)
3018 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003019 }
3020
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003021 err = mv88e6xxx_stats_setup(chip);
3022 if (err)
3023 goto unlock;
3024
Vivien Didelot6b17e862015-08-13 12:52:18 -04003025unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003026 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003027
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003028 if (err)
3029 return err;
3030
3031 /* Have to be called without holding the register lock, since
3032 * they take the devlink lock, and we later take the locks in
3033 * the reverse order when getting/setting parameters or
3034 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003035 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003036 err = mv88e6xxx_setup_devlink_resources(ds);
3037 if (err)
3038 return err;
3039
3040 err = mv88e6xxx_setup_devlink_params(ds);
3041 if (err)
3042 dsa_devlink_resources_unregister(ds);
3043
3044 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003045}
3046
Vivien Didelote57e5e72016-08-15 17:19:00 -04003047static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003048{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003049 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3050 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003051 u16 val;
3052 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003053
Andrew Lunnee26a222017-01-24 14:53:48 +01003054 if (!chip->info->ops->phy_read)
3055 return -EOPNOTSUPP;
3056
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003057 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003058 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003059 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003060
Andrew Lunnda9f3302017-02-01 03:40:05 +01003061 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003062 /* Some internal PHYs don't have a model number. */
3063 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3064 /* Then there is the 6165 family. It gets is
3065 * PHYs correct. But it can also have two
3066 * SERDES interfaces in the PHY address
3067 * space. And these don't have a model
3068 * number. But they are not PHYs, so we don't
3069 * want to give them something a PHY driver
3070 * will recognise.
3071 *
3072 * Use the mv88e6390 family model number
3073 * instead, for anything which really could be
3074 * a PHY,
3075 */
3076 if (!(val & 0x3f0))
3077 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003078 }
3079
Vivien Didelote57e5e72016-08-15 17:19:00 -04003080 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003081}
3082
Vivien Didelote57e5e72016-08-15 17:19:00 -04003083static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003084{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003085 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3086 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003087 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003088
Andrew Lunnee26a222017-01-24 14:53:48 +01003089 if (!chip->info->ops->phy_write)
3090 return -EOPNOTSUPP;
3091
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003092 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003093 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003094 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003095
3096 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003097}
3098
Vivien Didelotfad09c72016-06-21 12:28:20 -04003099static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003100 struct device_node *np,
3101 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003102{
3103 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003104 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003105 struct mii_bus *bus;
3106 int err;
3107
Andrew Lunn2510bab2018-02-22 01:51:49 +01003108 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003109 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003110 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003111 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003112
3113 if (err)
3114 return err;
3115 }
3116
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003117 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003118 if (!bus)
3119 return -ENOMEM;
3120
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003121 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003122 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003123 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003124 INIT_LIST_HEAD(&mdio_bus->list);
3125 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003126
Andrew Lunnb516d452016-06-04 21:17:06 +02003127 if (np) {
3128 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003129 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003130 } else {
3131 bus->name = "mv88e6xxx SMI";
3132 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3133 }
3134
3135 bus->read = mv88e6xxx_mdio_read;
3136 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003137 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003138
Andrew Lunn6f882842018-03-17 20:32:05 +01003139 if (!external) {
3140 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3141 if (err)
3142 return err;
3143 }
3144
Florian Fainelli00e798c2018-05-15 16:56:19 -07003145 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003146 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003147 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003148 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003149 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003150 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003151
3152 if (external)
3153 list_add_tail(&mdio_bus->list, &chip->mdios);
3154 else
3155 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003156
3157 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003158}
3159
Andrew Lunna3c53be52017-01-24 14:53:50 +01003160static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3161 { .compatible = "marvell,mv88e6xxx-mdio-external",
3162 .data = (void *)true },
3163 { },
3164};
3165
Andrew Lunn3126aee2017-12-07 01:05:57 +01003166static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3167
3168{
3169 struct mv88e6xxx_mdio_bus *mdio_bus;
3170 struct mii_bus *bus;
3171
3172 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3173 bus = mdio_bus->bus;
3174
Andrew Lunn6f882842018-03-17 20:32:05 +01003175 if (!mdio_bus->external)
3176 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3177
Andrew Lunn3126aee2017-12-07 01:05:57 +01003178 mdiobus_unregister(bus);
3179 }
3180}
3181
Andrew Lunna3c53be52017-01-24 14:53:50 +01003182static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3183 struct device_node *np)
3184{
3185 const struct of_device_id *match;
3186 struct device_node *child;
3187 int err;
3188
3189 /* Always register one mdio bus for the internal/default mdio
3190 * bus. This maybe represented in the device tree, but is
3191 * optional.
3192 */
3193 child = of_get_child_by_name(np, "mdio");
3194 err = mv88e6xxx_mdio_register(chip, child, false);
3195 if (err)
3196 return err;
3197
3198 /* Walk the device tree, and see if there are any other nodes
3199 * which say they are compatible with the external mdio
3200 * bus.
3201 */
3202 for_each_available_child_of_node(np, child) {
3203 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3204 if (match) {
3205 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003206 if (err) {
3207 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303208 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003209 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003210 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003211 }
3212 }
3213
3214 return 0;
3215}
3216
Vivien Didelot855b1932016-07-20 18:18:35 -04003217static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3218{
Vivien Didelot04bed142016-08-31 18:06:13 -04003219 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003220
3221 return chip->eeprom_len;
3222}
3223
Vivien Didelot855b1932016-07-20 18:18:35 -04003224static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3225 struct ethtool_eeprom *eeprom, u8 *data)
3226{
Vivien Didelot04bed142016-08-31 18:06:13 -04003227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003228 int err;
3229
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003230 if (!chip->info->ops->get_eeprom)
3231 return -EOPNOTSUPP;
3232
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003233 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003234 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003235 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003236
3237 if (err)
3238 return err;
3239
3240 eeprom->magic = 0xc3ec4951;
3241
3242 return 0;
3243}
3244
Vivien Didelot855b1932016-07-20 18:18:35 -04003245static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3246 struct ethtool_eeprom *eeprom, u8 *data)
3247{
Vivien Didelot04bed142016-08-31 18:06:13 -04003248 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003249 int err;
3250
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003251 if (!chip->info->ops->set_eeprom)
3252 return -EOPNOTSUPP;
3253
Vivien Didelot855b1932016-07-20 18:18:35 -04003254 if (eeprom->magic != 0xc3ec4951)
3255 return -EINVAL;
3256
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003257 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003258 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003259 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003260
3261 return err;
3262}
3263
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003264static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003265 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003266 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3267 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003268 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003269 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003270 .phy_read = mv88e6185_phy_ppu_read,
3271 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003272 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003273 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003274 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003275 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003276 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003277 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003278 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003279 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003280 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003281 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003282 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003283 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003284 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003285 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003286 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003287 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003288 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3289 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003290 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003291 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3292 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003293 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003294 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003295 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003296 .ppu_enable = mv88e6185_g1_ppu_enable,
3297 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003298 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003299 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003300 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003301 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003302 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003303};
3304
3305static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003306 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003307 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3308 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003309 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003310 .phy_read = mv88e6185_phy_ppu_read,
3311 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003312 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003313 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003314 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003315 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003316 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003317 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003318 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003319 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003320 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003321 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003322 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003323 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3324 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003325 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003326 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003327 .ppu_enable = mv88e6185_g1_ppu_enable,
3328 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003329 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003330 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003331 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003332 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003333};
3334
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003335static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003336 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003337 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3338 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003339 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003340 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3341 .phy_read = mv88e6xxx_g2_smi_phy_read,
3342 .phy_write = mv88e6xxx_g2_smi_phy_write,
3343 .port_set_link = mv88e6xxx_port_set_link,
3344 .port_set_duplex = mv88e6xxx_port_set_duplex,
3345 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003346 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003347 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003348 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003349 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003350 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003351 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003352 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003353 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003354 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003355 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003356 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003357 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003358 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003359 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003360 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3361 .stats_get_strings = mv88e6095_stats_get_strings,
3362 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003363 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3364 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003365 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003366 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003367 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003368 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003369 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003370 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003371 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003372 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003373};
3374
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003375static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003376 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003377 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3378 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003379 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003380 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003381 .phy_read = mv88e6xxx_g2_smi_phy_read,
3382 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003383 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003384 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003385 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003386 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003387 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003388 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003389 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003390 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003391 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003392 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003393 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003394 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003395 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3396 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003397 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003398 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3399 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003400 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003401 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003402 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003403 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003404 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3405 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003406 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003407 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003408 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003409};
3410
3411static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003412 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003413 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3414 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003415 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003416 .phy_read = mv88e6185_phy_ppu_read,
3417 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003418 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003419 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003420 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003421 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003422 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003423 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003424 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003425 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003426 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003427 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003428 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003429 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003430 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003431 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003432 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003433 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003434 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003435 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3436 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003437 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003438 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3439 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003440 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003441 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003442 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003443 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003444 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003445 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003446 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003447 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003448 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449};
3450
Vivien Didelot990e27b2017-03-28 13:50:32 -04003451static const struct mv88e6xxx_ops mv88e6141_ops = {
3452 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003453 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3454 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003455 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003456 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3457 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3458 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3459 .phy_read = mv88e6xxx_g2_smi_phy_read,
3460 .phy_write = mv88e6xxx_g2_smi_phy_write,
3461 .port_set_link = mv88e6xxx_port_set_link,
3462 .port_set_duplex = mv88e6xxx_port_set_duplex,
3463 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003464 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003465 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003466 .port_tag_remap = mv88e6095_port_tag_remap,
3467 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3468 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3469 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003470 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003471 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003472 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003473 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3474 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003475 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003476 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003477 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003478 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003479 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003480 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003481 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3482 .stats_get_strings = mv88e6320_stats_get_strings,
3483 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003484 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3485 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003486 .watchdog_ops = &mv88e6390_watchdog_ops,
3487 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003488 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003489 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003490 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003491 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003492 .serdes_power = mv88e6390_serdes_power,
3493 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003494 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003495 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003496 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003497 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003498 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003499};
3500
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003501static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003502 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003503 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3504 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003505 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003506 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003507 .phy_read = mv88e6xxx_g2_smi_phy_read,
3508 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003509 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003510 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003511 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003512 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003513 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003514 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003515 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003516 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003517 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003518 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003519 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003520 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003521 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003522 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003523 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003524 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003525 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003526 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3527 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003528 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003529 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3530 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003531 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003532 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003533 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003534 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003535 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3536 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003537 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003538 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003539 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003540 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003541 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003542};
3543
3544static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003545 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003546 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3547 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003548 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003549 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003550 .phy_read = mv88e6165_phy_read,
3551 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003552 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003553 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003554 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003555 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003556 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003557 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003558 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003559 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003560 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003561 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003562 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3563 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003564 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003565 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3566 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003567 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003568 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003569 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003570 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003571 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3572 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003573 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003574 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003575 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003576 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003577 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003578};
3579
3580static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003581 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003582 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3583 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003584 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003585 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003586 .phy_read = mv88e6xxx_g2_smi_phy_read,
3587 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003588 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003589 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003590 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003591 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003592 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003593 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003594 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003595 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003596 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003597 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003598 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003599 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003600 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003601 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003602 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003603 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003604 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003605 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003606 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3607 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003608 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003609 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3610 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003611 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003612 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003613 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003614 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003615 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3616 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003617 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003618 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003619 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003620};
3621
3622static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003623 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003624 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3625 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003626 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003627 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3628 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003629 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003630 .phy_read = mv88e6xxx_g2_smi_phy_read,
3631 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003632 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003633 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003634 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003635 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003636 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003637 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003638 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003639 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003640 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003641 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003642 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003643 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003644 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003645 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003646 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003647 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003648 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003649 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003650 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003651 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3652 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003653 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003654 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3655 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003656 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003657 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003658 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003659 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003660 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003661 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3662 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003663 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003664 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003665 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003666 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003667 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003668 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003669};
3670
3671static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003672 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003673 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3674 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003675 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003676 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003677 .phy_read = mv88e6xxx_g2_smi_phy_read,
3678 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003679 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003680 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003681 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003682 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003683 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003684 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003685 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003686 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003687 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003688 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003689 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003690 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003691 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003692 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003693 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003694 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003695 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003696 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003697 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3698 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003699 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003700 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3701 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003702 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003703 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003704 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003705 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003706 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3707 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003708 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003709 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003710 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003711};
3712
3713static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003714 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003715 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3716 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003717 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003718 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3719 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003720 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003721 .phy_read = mv88e6xxx_g2_smi_phy_read,
3722 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003723 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003724 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003725 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003726 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003727 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003728 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003730 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003732 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003733 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003734 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003735 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003736 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003737 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003738 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003739 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003740 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003741 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003742 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3743 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003744 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003745 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3746 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003747 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003748 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003749 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003750 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003751 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003752 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3753 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003754 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003755 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003756 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003757 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003758 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003759 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003760 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003761 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003762 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003763};
3764
3765static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003766 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003767 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3768 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003769 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003770 .phy_read = mv88e6185_phy_ppu_read,
3771 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003772 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003773 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003774 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003775 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003776 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003777 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003778 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003779 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003780 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003781 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003782 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003783 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3786 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003788 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3789 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003790 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003791 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003792 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003793 .ppu_enable = mv88e6185_g1_ppu_enable,
3794 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003795 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003796 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003797 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003798 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003799};
3800
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003801static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003802 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003803 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003804 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003805 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3806 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003807 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3808 .phy_read = mv88e6xxx_g2_smi_phy_read,
3809 .phy_write = mv88e6xxx_g2_smi_phy_write,
3810 .port_set_link = mv88e6xxx_port_set_link,
3811 .port_set_duplex = mv88e6xxx_port_set_duplex,
3812 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3813 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003814 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003815 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003816 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003817 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003818 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003819 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003820 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003821 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003822 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003823 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003824 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003825 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003827 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003828 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003829 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3830 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003831 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003832 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3833 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003834 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003835 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003837 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003838 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003839 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3840 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003841 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3842 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003843 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003844 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003845 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003846 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003847 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003848 .serdes_get_strings = mv88e6390_serdes_get_strings,
3849 .serdes_get_stats = mv88e6390_serdes_get_stats,
3850 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003851 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003852 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003853};
3854
3855static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003856 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003857 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003858 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003859 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3860 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003861 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3862 .phy_read = mv88e6xxx_g2_smi_phy_read,
3863 .phy_write = mv88e6xxx_g2_smi_phy_write,
3864 .port_set_link = mv88e6xxx_port_set_link,
3865 .port_set_duplex = mv88e6xxx_port_set_duplex,
3866 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3867 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003868 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003869 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003870 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003871 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003872 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003873 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003874 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003875 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003876 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003877 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003878 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003879 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003880 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003881 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003882 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003883 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3884 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003885 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003886 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3887 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003888 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003889 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003890 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003891 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003892 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003893 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3894 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003895 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3896 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003897 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003898 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003899 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003900 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003901 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003902 .serdes_get_strings = mv88e6390_serdes_get_strings,
3903 .serdes_get_stats = mv88e6390_serdes_get_stats,
3904 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003905 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003906 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003907};
3908
3909static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003910 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003911 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003912 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003913 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3914 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003915 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3916 .phy_read = mv88e6xxx_g2_smi_phy_read,
3917 .phy_write = mv88e6xxx_g2_smi_phy_write,
3918 .port_set_link = mv88e6xxx_port_set_link,
3919 .port_set_duplex = mv88e6xxx_port_set_duplex,
3920 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3921 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003922 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003923 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003924 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003925 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003926 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003927 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003928 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003929 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003930 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003931 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003932 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003933 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003934 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003935 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003936 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3937 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003938 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003939 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3940 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003941 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003942 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003943 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003944 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003945 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003946 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3947 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003948 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3949 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003950 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003951 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003952 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003953 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003954 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003955 .serdes_get_strings = mv88e6390_serdes_get_strings,
3956 .serdes_get_stats = mv88e6390_serdes_get_stats,
3957 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003958 .avb_ops = &mv88e6390_avb_ops,
3959 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003960 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003961};
3962
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003963static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003964 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003965 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3966 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003967 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003968 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3969 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003970 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003971 .phy_read = mv88e6xxx_g2_smi_phy_read,
3972 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003973 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003974 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003975 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003976 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003977 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003978 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003979 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003980 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003981 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003982 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003983 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003984 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003985 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003986 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003987 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003988 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003989 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003990 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003991 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003992 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3993 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003994 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003995 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3996 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003997 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003998 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003999 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004000 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004001 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004002 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4003 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004004 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004005 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004006 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004007 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004008 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004009 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004010 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004011 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004012 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004013 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004014 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004015};
4016
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004017static const struct mv88e6xxx_ops mv88e6250_ops = {
4018 /* MV88E6XXX_FAMILY_6250 */
4019 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4020 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4021 .irl_init_all = mv88e6352_g2_irl_init_all,
4022 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4023 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4024 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4025 .phy_read = mv88e6xxx_g2_smi_phy_read,
4026 .phy_write = mv88e6xxx_g2_smi_phy_write,
4027 .port_set_link = mv88e6xxx_port_set_link,
4028 .port_set_duplex = mv88e6xxx_port_set_duplex,
4029 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4030 .port_set_speed = mv88e6250_port_set_speed,
4031 .port_tag_remap = mv88e6095_port_tag_remap,
4032 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4033 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4034 .port_set_ether_type = mv88e6351_port_set_ether_type,
4035 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4036 .port_pause_limit = mv88e6097_port_pause_limit,
4037 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4038 .port_link_state = mv88e6250_port_link_state,
4039 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4040 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4041 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4042 .stats_get_strings = mv88e6250_stats_get_strings,
4043 .stats_get_stats = mv88e6250_stats_get_stats,
4044 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4045 .set_egress_port = mv88e6095_g1_set_egress_port,
4046 .watchdog_ops = &mv88e6250_watchdog_ops,
4047 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4048 .pot_clear = mv88e6xxx_g2_pot_clear,
4049 .reset = mv88e6250_g1_reset,
4050 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4051 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004052 .avb_ops = &mv88e6352_avb_ops,
4053 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004054 .phylink_validate = mv88e6065_phylink_validate,
4055};
4056
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004057static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004058 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004059 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004060 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004061 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4062 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4064 .phy_read = mv88e6xxx_g2_smi_phy_read,
4065 .phy_write = mv88e6xxx_g2_smi_phy_write,
4066 .port_set_link = mv88e6xxx_port_set_link,
4067 .port_set_duplex = mv88e6xxx_port_set_duplex,
4068 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4069 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004070 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004071 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004072 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004073 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004074 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004075 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004076 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004077 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004078 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004079 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004080 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004081 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004082 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004083 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004084 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004085 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4086 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004087 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004088 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4089 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004090 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004091 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004092 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004093 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004094 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004095 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4096 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004097 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4098 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004099 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004100 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004101 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004102 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004103 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004104 .serdes_get_strings = mv88e6390_serdes_get_strings,
4105 .serdes_get_stats = mv88e6390_serdes_get_stats,
4106 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004107 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004108 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004109 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004110 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004111};
4112
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004113static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004114 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004115 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4116 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004117 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004118 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4119 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004120 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004121 .phy_read = mv88e6xxx_g2_smi_phy_read,
4122 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004123 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004124 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004125 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004126 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004127 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004128 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004129 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004130 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004131 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004132 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004133 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004134 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004135 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004136 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004137 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004138 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004139 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004140 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4141 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004142 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004143 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4144 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004145 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004146 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004147 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004148 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004149 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004150 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004151 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004152 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004153 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004154 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004155};
4156
4157static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004158 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004159 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4160 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004161 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004162 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4163 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004164 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004165 .phy_read = mv88e6xxx_g2_smi_phy_read,
4166 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004167 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004168 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004169 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004170 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004171 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004172 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004173 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004174 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004175 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004176 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004177 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004178 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004179 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004180 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004181 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004182 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004183 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004184 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4185 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004186 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004187 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4188 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004189 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004190 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004191 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004192 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004193 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004194 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004195 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004196 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004197};
4198
Vivien Didelot16e329a2017-03-28 13:50:33 -04004199static const struct mv88e6xxx_ops mv88e6341_ops = {
4200 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004201 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4202 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004203 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004204 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4205 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4206 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4207 .phy_read = mv88e6xxx_g2_smi_phy_read,
4208 .phy_write = mv88e6xxx_g2_smi_phy_write,
4209 .port_set_link = mv88e6xxx_port_set_link,
4210 .port_set_duplex = mv88e6xxx_port_set_duplex,
4211 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004212 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004213 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004214 .port_tag_remap = mv88e6095_port_tag_remap,
4215 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4216 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4217 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004218 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004219 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004220 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004221 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4222 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004223 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004224 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004225 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004226 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004227 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004228 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004229 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4230 .stats_get_strings = mv88e6320_stats_get_strings,
4231 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004232 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4233 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004234 .watchdog_ops = &mv88e6390_watchdog_ops,
4235 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004236 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004237 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004238 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004239 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004240 .serdes_power = mv88e6390_serdes_power,
4241 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004242 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004243 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004244 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004245 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004246 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004247 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004248 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004249};
4250
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004251static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004252 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004253 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4254 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004255 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004256 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004257 .phy_read = mv88e6xxx_g2_smi_phy_read,
4258 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004259 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004260 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004261 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004262 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004263 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004264 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004265 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004266 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004267 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004268 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004269 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004270 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004271 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004272 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004273 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004274 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004275 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004276 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004277 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4278 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004279 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004280 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4281 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004282 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004283 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004284 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004285 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004286 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4287 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004288 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004289 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004290 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004291};
4292
4293static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004294 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004295 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4296 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004297 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004298 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004299 .phy_read = mv88e6xxx_g2_smi_phy_read,
4300 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004301 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004302 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004303 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004304 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004305 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004306 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004307 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004308 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004309 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004310 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004311 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004312 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004313 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004314 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004315 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004316 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004317 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004318 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004319 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4320 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004321 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004322 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4323 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004324 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004325 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004326 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004327 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004328 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4329 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004330 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004331 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004332 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004333 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004334 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004335};
4336
4337static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004338 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004339 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4340 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004341 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004342 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4343 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004344 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004345 .phy_read = mv88e6xxx_g2_smi_phy_read,
4346 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004347 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004348 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004349 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004350 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004351 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004352 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004353 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004354 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004355 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004356 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004357 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004358 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004359 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004360 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004361 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004362 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004363 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004364 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004365 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004366 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4367 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004368 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004369 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4370 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004371 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004372 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004373 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004374 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004375 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004376 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4377 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004378 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004379 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004380 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004381 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004382 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004383 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004384 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004385 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004386 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004387 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004388 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4389 .serdes_get_strings = mv88e6352_serdes_get_strings,
4390 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004391 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004392};
4393
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004394static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004395 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004396 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004397 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004398 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4399 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004400 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4401 .phy_read = mv88e6xxx_g2_smi_phy_read,
4402 .phy_write = mv88e6xxx_g2_smi_phy_write,
4403 .port_set_link = mv88e6xxx_port_set_link,
4404 .port_set_duplex = mv88e6xxx_port_set_duplex,
4405 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4406 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004407 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004408 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004409 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004410 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004411 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004412 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004413 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004414 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004415 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004416 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004417 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004418 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004419 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004420 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004421 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004422 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004423 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004424 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4425 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004426 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004427 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4428 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004429 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004430 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004431 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004432 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004433 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004434 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4435 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004436 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4437 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004438 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004439 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004440 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004441 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004442 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004443 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004444 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004445 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004446 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4447 .serdes_get_strings = mv88e6390_serdes_get_strings,
4448 .serdes_get_stats = mv88e6390_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004449 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004450};
4451
4452static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004453 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004454 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004455 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004456 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4457 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004458 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4459 .phy_read = mv88e6xxx_g2_smi_phy_read,
4460 .phy_write = mv88e6xxx_g2_smi_phy_write,
4461 .port_set_link = mv88e6xxx_port_set_link,
4462 .port_set_duplex = mv88e6xxx_port_set_duplex,
4463 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4464 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004465 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004466 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004467 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004468 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004469 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004470 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004471 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004472 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004473 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004474 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004475 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004476 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004477 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004478 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004479 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004480 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004481 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004482 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4483 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004484 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004485 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4486 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004487 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004488 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004489 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004490 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004491 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004492 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4493 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004494 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4495 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004496 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004497 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004498 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004499 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004500 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004501 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4502 .serdes_get_strings = mv88e6390_serdes_get_strings,
4503 .serdes_get_stats = mv88e6390_serdes_get_stats,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004504 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004505 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004506 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004507 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004508};
4509
Vivien Didelotf81ec902016-05-09 13:22:58 -04004510static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4511 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004512 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004513 .family = MV88E6XXX_FAMILY_6097,
4514 .name = "Marvell 88E6085",
4515 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004516 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004517 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004518 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004519 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004520 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004521 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004522 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004523 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004524 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004525 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004526 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004527 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004528 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004529 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004530 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004531 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004532 },
4533
4534 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004535 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004536 .family = MV88E6XXX_FAMILY_6095,
4537 .name = "Marvell 88E6095/88E6095F",
4538 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004539 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004540 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004541 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004542 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004543 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004544 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004545 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004546 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004547 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004548 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004549 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004550 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004551 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004552 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004553 },
4554
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004555 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004556 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004557 .family = MV88E6XXX_FAMILY_6097,
4558 .name = "Marvell 88E6097/88E6097F",
4559 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004560 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004561 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004562 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004563 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004564 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004565 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004566 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004567 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004568 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004569 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004570 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004571 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004572 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004573 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004574 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004575 .ops = &mv88e6097_ops,
4576 },
4577
Vivien Didelotf81ec902016-05-09 13:22:58 -04004578 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004579 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004580 .family = MV88E6XXX_FAMILY_6165,
4581 .name = "Marvell 88E6123",
4582 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004583 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004585 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004586 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004587 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004588 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004589 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004590 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004591 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004592 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004593 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004594 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004595 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004596 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004597 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004598 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004599 },
4600
4601 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004602 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004603 .family = MV88E6XXX_FAMILY_6185,
4604 .name = "Marvell 88E6131",
4605 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004606 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004607 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004608 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004609 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004610 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004611 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004612 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004613 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004614 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004615 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004616 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004617 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004618 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004619 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004620 },
4621
Vivien Didelot990e27b2017-03-28 13:50:32 -04004622 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004623 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004624 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004625 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004626 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004627 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004628 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004629 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004630 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004631 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004632 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004633 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004634 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004635 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004636 .age_time_coeff = 3750,
4637 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004638 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004639 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004640 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004641 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004642 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004643 .ops = &mv88e6141_ops,
4644 },
4645
Vivien Didelotf81ec902016-05-09 13:22:58 -04004646 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004647 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004648 .family = MV88E6XXX_FAMILY_6165,
4649 .name = "Marvell 88E6161",
4650 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004651 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004652 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004653 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004654 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004655 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004656 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004657 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004658 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004659 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004660 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004661 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004662 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004663 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004664 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004665 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004666 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004667 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004668 },
4669
4670 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004671 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004672 .family = MV88E6XXX_FAMILY_6165,
4673 .name = "Marvell 88E6165",
4674 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004675 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004676 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004677 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004678 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004679 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004680 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004681 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004682 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004683 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004684 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004685 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004686 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004687 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004688 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004689 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004690 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004691 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004692 },
4693
4694 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004695 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004696 .family = MV88E6XXX_FAMILY_6351,
4697 .name = "Marvell 88E6171",
4698 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004699 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004700 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004701 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004702 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004703 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004704 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004705 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004706 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004707 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004708 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004709 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004710 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004711 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004712 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004713 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004714 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004715 },
4716
4717 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004718 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004719 .family = MV88E6XXX_FAMILY_6352,
4720 .name = "Marvell 88E6172",
4721 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004722 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004724 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004725 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004726 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004727 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004728 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004729 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004730 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004731 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004732 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004733 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004734 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004735 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004736 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004737 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004738 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004739 },
4740
4741 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004742 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004743 .family = MV88E6XXX_FAMILY_6351,
4744 .name = "Marvell 88E6175",
4745 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004746 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004748 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004749 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004750 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004751 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004752 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004753 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004754 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004755 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004756 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004757 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004758 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004759 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004760 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004761 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004762 },
4763
4764 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004765 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004766 .family = MV88E6XXX_FAMILY_6352,
4767 .name = "Marvell 88E6176",
4768 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004769 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004770 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004771 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004772 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004773 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004774 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004775 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004776 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004777 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004778 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004779 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004780 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004781 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004782 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004783 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004784 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004785 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004786 },
4787
4788 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004789 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004790 .family = MV88E6XXX_FAMILY_6185,
4791 .name = "Marvell 88E6185",
4792 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004793 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004794 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004795 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004796 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004797 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004798 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004799 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004800 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004801 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004802 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004803 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004804 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004805 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004806 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004807 },
4808
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004809 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004810 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004811 .family = MV88E6XXX_FAMILY_6390,
4812 .name = "Marvell 88E6190",
4813 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004814 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004815 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004816 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004817 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004818 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004819 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004820 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004821 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004822 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004823 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004824 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004825 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004826 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004827 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004828 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004829 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004830 .ops = &mv88e6190_ops,
4831 },
4832
4833 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004834 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004835 .family = MV88E6XXX_FAMILY_6390,
4836 .name = "Marvell 88E6190X",
4837 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004838 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004839 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004840 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004841 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004842 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004843 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004844 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004845 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004846 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004847 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004848 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004849 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004850 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004851 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004852 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004853 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004854 .ops = &mv88e6190x_ops,
4855 },
4856
4857 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004858 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004859 .family = MV88E6XXX_FAMILY_6390,
4860 .name = "Marvell 88E6191",
4861 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004862 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004863 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004864 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004865 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004866 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004867 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004868 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004869 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004870 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004871 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004872 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004873 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004874 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004875 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004876 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004877 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004878 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004879 },
4880
Hubert Feurstein49022642019-07-31 10:23:46 +02004881 [MV88E6220] = {
4882 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4883 .family = MV88E6XXX_FAMILY_6250,
4884 .name = "Marvell 88E6220",
4885 .num_databases = 64,
4886
4887 /* Ports 2-4 are not routed to pins
4888 * => usable ports 0, 1, 5, 6
4889 */
4890 .num_ports = 7,
4891 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004892 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004893 .max_vid = 4095,
4894 .port_base_addr = 0x08,
4895 .phy_base_addr = 0x00,
4896 .global1_addr = 0x0f,
4897 .global2_addr = 0x07,
4898 .age_time_coeff = 15000,
4899 .g1_irqs = 9,
4900 .g2_irqs = 10,
4901 .atu_move_port_mask = 0xf,
4902 .dual_chip = true,
4903 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004904 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004905 .ops = &mv88e6250_ops,
4906 },
4907
Vivien Didelotf81ec902016-05-09 13:22:58 -04004908 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004909 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004910 .family = MV88E6XXX_FAMILY_6352,
4911 .name = "Marvell 88E6240",
4912 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004913 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004914 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004915 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004916 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004917 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004918 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004919 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004920 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004921 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004922 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004923 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004924 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004925 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004926 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004927 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004928 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004929 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004930 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004931 },
4932
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004933 [MV88E6250] = {
4934 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4935 .family = MV88E6XXX_FAMILY_6250,
4936 .name = "Marvell 88E6250",
4937 .num_databases = 64,
4938 .num_ports = 7,
4939 .num_internal_phys = 5,
4940 .max_vid = 4095,
4941 .port_base_addr = 0x08,
4942 .phy_base_addr = 0x00,
4943 .global1_addr = 0x0f,
4944 .global2_addr = 0x07,
4945 .age_time_coeff = 15000,
4946 .g1_irqs = 9,
4947 .g2_irqs = 10,
4948 .atu_move_port_mask = 0xf,
4949 .dual_chip = true,
4950 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004951 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004952 .ops = &mv88e6250_ops,
4953 },
4954
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004955 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004956 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004957 .family = MV88E6XXX_FAMILY_6390,
4958 .name = "Marvell 88E6290",
4959 .num_databases = 4096,
4960 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004961 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004962 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004963 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004964 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004965 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004966 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004967 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004968 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004969 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004970 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004971 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004972 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004973 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004974 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004975 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004976 .ops = &mv88e6290_ops,
4977 },
4978
Vivien Didelotf81ec902016-05-09 13:22:58 -04004979 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004980 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004981 .family = MV88E6XXX_FAMILY_6320,
4982 .name = "Marvell 88E6320",
4983 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004984 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004985 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004986 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004987 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004988 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004989 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004990 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004991 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004992 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004993 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004994 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004995 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004996 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004997 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004998 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004999 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005000 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005001 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005002 },
5003
5004 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005005 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005006 .family = MV88E6XXX_FAMILY_6320,
5007 .name = "Marvell 88E6321",
5008 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005009 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005010 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005011 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005012 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005013 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005014 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005015 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005016 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005017 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005018 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005019 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005020 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005021 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005022 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005023 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005024 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005025 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005026 },
5027
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005028 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005029 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005030 .family = MV88E6XXX_FAMILY_6341,
5031 .name = "Marvell 88E6341",
5032 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005033 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005034 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005035 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005036 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005037 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005038 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005039 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005040 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005041 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005042 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005043 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005044 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005045 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005046 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005047 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005048 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005049 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005050 .ops = &mv88e6341_ops,
5051 },
5052
Vivien Didelotf81ec902016-05-09 13:22:58 -04005053 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005054 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005055 .family = MV88E6XXX_FAMILY_6351,
5056 .name = "Marvell 88E6350",
5057 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005058 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005059 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005060 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005061 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005062 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005063 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005064 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005065 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005066 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005067 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005068 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005069 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005070 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005071 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005072 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005073 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005074 },
5075
5076 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005077 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005078 .family = MV88E6XXX_FAMILY_6351,
5079 .name = "Marvell 88E6351",
5080 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005081 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005082 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005083 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005084 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005085 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005086 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005087 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005088 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005089 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005090 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005091 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005092 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005093 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005094 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005095 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005096 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005097 },
5098
5099 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005100 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005101 .family = MV88E6XXX_FAMILY_6352,
5102 .name = "Marvell 88E6352",
5103 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005104 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005105 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005106 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005107 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005108 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005109 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005110 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005111 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005112 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005113 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005114 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005115 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005116 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005117 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005118 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005119 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005120 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005121 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005122 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005123 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005124 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005125 .family = MV88E6XXX_FAMILY_6390,
5126 .name = "Marvell 88E6390",
5127 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005128 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005129 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005130 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005131 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005132 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005133 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005134 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005135 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005136 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005137 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005138 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005139 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005140 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005141 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005142 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005143 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005144 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005145 .ops = &mv88e6390_ops,
5146 },
5147 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005148 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005149 .family = MV88E6XXX_FAMILY_6390,
5150 .name = "Marvell 88E6390X",
5151 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005152 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005153 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005154 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005155 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005156 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005157 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005158 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005159 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005160 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005161 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005162 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005163 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005164 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005165 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005166 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005167 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005168 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005169 .ops = &mv88e6390x_ops,
5170 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005171};
5172
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005173static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005174{
Vivien Didelota439c062016-04-17 13:23:58 -04005175 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005176
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005177 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5178 if (mv88e6xxx_table[i].prod_num == prod_num)
5179 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005180
Vivien Didelotb9b37712015-10-30 19:39:48 -04005181 return NULL;
5182}
5183
Vivien Didelotfad09c72016-06-21 12:28:20 -04005184static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005185{
5186 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005187 unsigned int prod_num, rev;
5188 u16 id;
5189 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005190
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005191 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005192 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005193 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005194 if (err)
5195 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005196
Vivien Didelot107fcc12017-06-12 12:37:36 -04005197 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5198 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005199
5200 info = mv88e6xxx_lookup_info(prod_num);
5201 if (!info)
5202 return -ENODEV;
5203
Vivien Didelotcaac8542016-06-20 13:14:09 -04005204 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005205 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005206
Vivien Didelotca070c12016-09-02 14:45:34 -04005207 err = mv88e6xxx_g2_require(chip);
5208 if (err)
5209 return err;
5210
Vivien Didelotfad09c72016-06-21 12:28:20 -04005211 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5212 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005213
5214 return 0;
5215}
5216
Vivien Didelotfad09c72016-06-21 12:28:20 -04005217static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005218{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005219 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005220
Vivien Didelotfad09c72016-06-21 12:28:20 -04005221 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5222 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005223 return NULL;
5224
Vivien Didelotfad09c72016-06-21 12:28:20 -04005225 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005226
Vivien Didelotfad09c72016-06-21 12:28:20 -04005227 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005228 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005229 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005230
Vivien Didelotfad09c72016-06-21 12:28:20 -04005231 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005232}
5233
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005234static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005235 int port,
5236 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005237{
Vivien Didelot04bed142016-08-31 18:06:13 -04005238 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005239
Andrew Lunn443d5a12016-12-03 04:35:18 +01005240 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005241}
5242
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005243static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005244 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005245{
5246 /* We don't need any dynamic resource from the kernel (yet),
5247 * so skip the prepare phase.
5248 */
5249
5250 return 0;
5251}
5252
5253static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005254 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005255{
Vivien Didelot04bed142016-08-31 18:06:13 -04005256 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005257
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005258 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005259 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005260 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005261 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5262 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005263 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005264}
5265
5266static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5267 const struct switchdev_obj_port_mdb *mdb)
5268{
Vivien Didelot04bed142016-08-31 18:06:13 -04005269 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005270 int err;
5271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005272 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005273 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005274 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005275
5276 return err;
5277}
5278
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005279static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5280 struct dsa_mall_mirror_tc_entry *mirror,
5281 bool ingress)
5282{
5283 enum mv88e6xxx_egress_direction direction = ingress ?
5284 MV88E6XXX_EGRESS_DIR_INGRESS :
5285 MV88E6XXX_EGRESS_DIR_EGRESS;
5286 struct mv88e6xxx_chip *chip = ds->priv;
5287 bool other_mirrors = false;
5288 int i;
5289 int err;
5290
5291 if (!chip->info->ops->set_egress_port)
5292 return -EOPNOTSUPP;
5293
5294 mutex_lock(&chip->reg_lock);
5295 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5296 mirror->to_local_port) {
5297 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5298 other_mirrors |= ingress ?
5299 chip->ports[i].mirror_ingress :
5300 chip->ports[i].mirror_egress;
5301
5302 /* Can't change egress port when other mirror is active */
5303 if (other_mirrors) {
5304 err = -EBUSY;
5305 goto out;
5306 }
5307
5308 err = chip->info->ops->set_egress_port(chip,
5309 direction,
5310 mirror->to_local_port);
5311 if (err)
5312 goto out;
5313 }
5314
5315 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5316out:
5317 mutex_unlock(&chip->reg_lock);
5318
5319 return err;
5320}
5321
5322static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5323 struct dsa_mall_mirror_tc_entry *mirror)
5324{
5325 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5326 MV88E6XXX_EGRESS_DIR_INGRESS :
5327 MV88E6XXX_EGRESS_DIR_EGRESS;
5328 struct mv88e6xxx_chip *chip = ds->priv;
5329 bool other_mirrors = false;
5330 int i;
5331
5332 mutex_lock(&chip->reg_lock);
5333 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5334 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5335
5336 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5337 other_mirrors |= mirror->ingress ?
5338 chip->ports[i].mirror_ingress :
5339 chip->ports[i].mirror_egress;
5340
5341 /* Reset egress port when no other mirror is active */
5342 if (!other_mirrors) {
5343 if (chip->info->ops->set_egress_port(chip,
5344 direction,
5345 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005346 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005347 dev_err(ds->dev, "failed to set egress port\n");
5348 }
5349
5350 mutex_unlock(&chip->reg_lock);
5351}
5352
Russell King4f859012019-02-20 15:35:05 -08005353static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5354 bool unicast, bool multicast)
5355{
5356 struct mv88e6xxx_chip *chip = ds->priv;
5357 int err = -EOPNOTSUPP;
5358
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005359 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005360 if (chip->info->ops->port_set_egress_floods)
5361 err = chip->info->ops->port_set_egress_floods(chip, port,
5362 unicast,
5363 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005364 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005365
5366 return err;
5367}
5368
Florian Fainellia82f67a2017-01-08 14:52:08 -08005369static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005370 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005371 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005372 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005373 .phylink_validate = mv88e6xxx_validate,
5374 .phylink_mac_link_state = mv88e6xxx_link_state,
5375 .phylink_mac_config = mv88e6xxx_mac_config,
5376 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5377 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005378 .get_strings = mv88e6xxx_get_strings,
5379 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5380 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005381 .port_enable = mv88e6xxx_port_enable,
5382 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005383 .get_mac_eee = mv88e6xxx_get_mac_eee,
5384 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005385 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005386 .get_eeprom = mv88e6xxx_get_eeprom,
5387 .set_eeprom = mv88e6xxx_set_eeprom,
5388 .get_regs_len = mv88e6xxx_get_regs_len,
5389 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005390 .get_rxnfc = mv88e6xxx_get_rxnfc,
5391 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005392 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005393 .port_bridge_join = mv88e6xxx_port_bridge_join,
5394 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005395 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005396 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005397 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005398 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5399 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5400 .port_vlan_add = mv88e6xxx_port_vlan_add,
5401 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005402 .port_fdb_add = mv88e6xxx_port_fdb_add,
5403 .port_fdb_del = mv88e6xxx_port_fdb_del,
5404 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005405 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5406 .port_mdb_add = mv88e6xxx_port_mdb_add,
5407 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005408 .port_mirror_add = mv88e6xxx_port_mirror_add,
5409 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005410 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5411 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005412 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5413 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5414 .port_txtstamp = mv88e6xxx_port_txtstamp,
5415 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5416 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005417 .devlink_param_get = mv88e6xxx_devlink_param_get,
5418 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005419};
5420
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005421static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005422{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005423 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005424 struct dsa_switch *ds;
5425
Vivien Didelot7e99e342019-10-21 16:51:30 -04005426 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005427 if (!ds)
5428 return -ENOMEM;
5429
Vivien Didelot7e99e342019-10-21 16:51:30 -04005430 ds->dev = dev;
5431 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005432 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005433 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005434 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005435 ds->ageing_time_min = chip->info->age_time_coeff;
5436 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005437
5438 dev_set_drvdata(dev, ds);
5439
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005440 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005441}
5442
Vivien Didelotfad09c72016-06-21 12:28:20 -04005443static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005444{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005445 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005446}
5447
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005448static const void *pdata_device_get_match_data(struct device *dev)
5449{
5450 const struct of_device_id *matches = dev->driver->of_match_table;
5451 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5452
5453 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5454 matches++) {
5455 if (!strcmp(pdata->compatible, matches->compatible))
5456 return matches->data;
5457 }
5458 return NULL;
5459}
5460
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005461/* There is no suspend to RAM support at DSA level yet, the switch configuration
5462 * would be lost after a power cycle so prevent it to be suspended.
5463 */
5464static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5465{
5466 return -EOPNOTSUPP;
5467}
5468
5469static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5470{
5471 return 0;
5472}
5473
5474static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5475
Vivien Didelot57d32312016-06-20 13:13:58 -04005476static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005477{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005478 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005479 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005480 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005481 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005482 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005483 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005484 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005485
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005486 if (!np && !pdata)
5487 return -EINVAL;
5488
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005489 if (np)
5490 compat_info = of_device_get_match_data(dev);
5491
5492 if (pdata) {
5493 compat_info = pdata_device_get_match_data(dev);
5494
5495 if (!pdata->netdev)
5496 return -EINVAL;
5497
5498 for (port = 0; port < DSA_MAX_PORTS; port++) {
5499 if (!(pdata->enabled_ports & (1 << port)))
5500 continue;
5501 if (strcmp(pdata->cd.port_names[port], "cpu"))
5502 continue;
5503 pdata->cd.netdev[port] = &pdata->netdev->dev;
5504 break;
5505 }
5506 }
5507
Vivien Didelotcaac8542016-06-20 13:14:09 -04005508 if (!compat_info)
5509 return -EINVAL;
5510
Vivien Didelotfad09c72016-06-21 12:28:20 -04005511 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005512 if (!chip) {
5513 err = -ENOMEM;
5514 goto out;
5515 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005516
Vivien Didelotfad09c72016-06-21 12:28:20 -04005517 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005518
Vivien Didelotfad09c72016-06-21 12:28:20 -04005519 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005520 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005521 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005522
Andrew Lunnb4308f02016-11-21 23:26:55 +01005523 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005524 if (IS_ERR(chip->reset)) {
5525 err = PTR_ERR(chip->reset);
5526 goto out;
5527 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005528 if (chip->reset)
5529 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005530
Vivien Didelotfad09c72016-06-21 12:28:20 -04005531 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005532 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005533 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005534
Vivien Didelote57e5e72016-08-15 17:19:00 -04005535 mv88e6xxx_phy_init(chip);
5536
Andrew Lunn00baabe2018-05-19 22:31:35 +02005537 if (chip->info->ops->get_eeprom) {
5538 if (np)
5539 of_property_read_u32(np, "eeprom-length",
5540 &chip->eeprom_len);
5541 else
5542 chip->eeprom_len = pdata->eeprom_len;
5543 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005544
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005545 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005546 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005547 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005548 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005549 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005550
Andrew Lunna27415d2019-05-01 00:10:50 +02005551 if (np) {
5552 chip->irq = of_irq_get(np, 0);
5553 if (chip->irq == -EPROBE_DEFER) {
5554 err = chip->irq;
5555 goto out;
5556 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005557 }
5558
Andrew Lunna27415d2019-05-01 00:10:50 +02005559 if (pdata)
5560 chip->irq = pdata->irq;
5561
Andrew Lunn294d7112018-02-22 22:58:32 +01005562 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005563 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005564 * controllers
5565 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005566 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005567 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005568 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005569 else
5570 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005571 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005572
Andrew Lunn294d7112018-02-22 22:58:32 +01005573 if (err)
5574 goto out;
5575
5576 if (chip->info->g2_irqs > 0) {
5577 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005578 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005579 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005580 }
5581
Andrew Lunn294d7112018-02-22 22:58:32 +01005582 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5583 if (err)
5584 goto out_g2_irq;
5585
5586 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5587 if (err)
5588 goto out_g1_atu_prob_irq;
5589
Andrew Lunna3c53be52017-01-24 14:53:50 +01005590 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005591 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005592 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005593
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005594 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005595 if (err)
5596 goto out_mdio;
5597
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005598 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005599
5600out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005601 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005602out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005603 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005604out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005605 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005606out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005607 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005608 mv88e6xxx_g2_irq_free(chip);
5609out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005610 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005611 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005612 else
5613 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005614out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005615 if (pdata)
5616 dev_put(pdata->netdev);
5617
Andrew Lunndc30c352016-10-16 19:56:49 +02005618 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005619}
5620
5621static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5622{
5623 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005624 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005625
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005626 if (chip->info->ptp_support) {
5627 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005628 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005629 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005630
Andrew Lunn930188c2016-08-22 16:01:03 +02005631 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005632 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005633 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005634
Andrew Lunn76f38f12018-03-17 20:21:09 +01005635 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5636 mv88e6xxx_g1_atu_prob_irq_free(chip);
5637
5638 if (chip->info->g2_irqs > 0)
5639 mv88e6xxx_g2_irq_free(chip);
5640
Andrew Lunn76f38f12018-03-17 20:21:09 +01005641 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005642 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005643 else
5644 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005645}
5646
5647static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005648 {
5649 .compatible = "marvell,mv88e6085",
5650 .data = &mv88e6xxx_table[MV88E6085],
5651 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005652 {
5653 .compatible = "marvell,mv88e6190",
5654 .data = &mv88e6xxx_table[MV88E6190],
5655 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005656 {
5657 .compatible = "marvell,mv88e6250",
5658 .data = &mv88e6xxx_table[MV88E6250],
5659 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005660 { /* sentinel */ },
5661};
5662
5663MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5664
5665static struct mdio_driver mv88e6xxx_driver = {
5666 .probe = mv88e6xxx_probe,
5667 .remove = mv88e6xxx_remove,
5668 .mdiodrv.driver = {
5669 .name = "mv88e6085",
5670 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005671 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005672 },
5673};
5674
Andrew Lunn7324d502019-04-27 19:19:10 +02005675mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005676
5677MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5678MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5679MODULE_LICENSE("GPL");