blob: 43a2ab8cf2c89002982a2b2eb0a348639a1673c1 [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
Russell King64d47d52020-03-14 10:15:38 +0000400static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
401 int port, phy_interface_t interface)
402{
403 int err;
404
405 if (chip->info->ops->port_set_rgmii_delay) {
406 err = chip->info->ops->port_set_rgmii_delay(chip, port,
407 interface);
408 if (err && err != -EOPNOTSUPP)
409 return err;
410 }
411
412 if (chip->info->ops->port_set_cmode) {
413 err = chip->info->ops->port_set_cmode(chip, port,
414 interface);
415 if (err && err != -EOPNOTSUPP)
416 return err;
417 }
418
419 return 0;
420}
421
Russell Kinga5a68582020-03-14 10:15:43 +0000422static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
423 int link, int speed, int duplex, int pause,
424 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425{
426 int err;
427
428 if (!chip->info->ops->port_set_link)
429 return 0;
430
431 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200432 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100433 if (err)
434 return err;
435
Russell Kingf365c6f2020-03-14 10:15:53 +0000436 if (chip->info->ops->port_set_speed_duplex) {
437 err = chip->info->ops->port_set_speed_duplex(chip, port,
438 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100439 if (err && err != -EOPNOTSUPP)
440 goto restore_link;
441 }
442
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100443 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
444 mode = chip->info->ops->port_max_speed_mode(port);
445
Andrew Lunn54186b92018-08-09 15:38:37 +0200446 if (chip->info->ops->port_set_pause) {
447 err = chip->info->ops->port_set_pause(chip, port, pause);
448 if (err)
449 goto restore_link;
450 }
451
Russell King64d47d52020-03-14 10:15:38 +0000452 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100453restore_link:
454 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400455 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100456
457 return err;
458}
459
Marek Vasutd700ec42018-09-12 00:15:24 +0200460static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
461{
462 struct mv88e6xxx_chip *chip = ds->priv;
463
464 return port < chip->info->num_internal_phys;
465}
466
Russell King5d5b2312020-03-14 10:16:03 +0000467static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
468{
469 u16 reg;
470 int err;
471
472 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
473 if (err) {
474 dev_err(chip->dev,
475 "p%d: %s: failed to read port status\n",
476 port, __func__);
477 return err;
478 }
479
480 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
481}
482
Russell Kinga5a68582020-03-14 10:15:43 +0000483static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
484 struct phylink_link_state *state)
485{
486 struct mv88e6xxx_chip *chip = ds->priv;
487 u8 lane;
488 int err;
489
490 mv88e6xxx_reg_lock(chip);
491 lane = mv88e6xxx_serdes_get_lane(chip, port);
492 if (lane && chip->info->ops->serdes_pcs_get_state)
493 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
494 state);
495 else
496 err = -EOPNOTSUPP;
497 mv88e6xxx_reg_unlock(chip);
498
499 return err;
500}
501
502static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
503 unsigned int mode,
504 phy_interface_t interface,
505 const unsigned long *advertise)
506{
507 const struct mv88e6xxx_ops *ops = chip->info->ops;
508 u8 lane;
509
510 if (ops->serdes_pcs_config) {
511 lane = mv88e6xxx_serdes_get_lane(chip, port);
512 if (lane)
513 return ops->serdes_pcs_config(chip, port, lane, mode,
514 interface, advertise);
515 }
516
517 return 0;
518}
519
520static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
521{
522 struct mv88e6xxx_chip *chip = ds->priv;
523 const struct mv88e6xxx_ops *ops;
524 int err = 0;
525 u8 lane;
526
527 ops = chip->info->ops;
528
529 if (ops->serdes_pcs_an_restart) {
530 mv88e6xxx_reg_lock(chip);
531 lane = mv88e6xxx_serdes_get_lane(chip, port);
532 if (lane)
533 err = ops->serdes_pcs_an_restart(chip, port, lane);
534 mv88e6xxx_reg_unlock(chip);
535
536 if (err)
537 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
538 }
539}
540
541static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
542 unsigned int mode,
543 int speed, int duplex)
544{
545 const struct mv88e6xxx_ops *ops = chip->info->ops;
546 u8 lane;
547
548 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
549 lane = mv88e6xxx_serdes_get_lane(chip, port);
550 if (lane)
551 return ops->serdes_pcs_link_up(chip, port, lane,
552 speed, duplex);
553 }
554
555 return 0;
556}
557
Russell King6c422e32018-08-09 15:38:39 +0200558static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
559 unsigned long *mask,
560 struct phylink_link_state *state)
561{
562 if (!phy_interface_mode_is_8023z(state->interface)) {
563 /* 10M and 100M are only supported in non-802.3z mode */
564 phylink_set(mask, 10baseT_Half);
565 phylink_set(mask, 10baseT_Full);
566 phylink_set(mask, 100baseT_Half);
567 phylink_set(mask, 100baseT_Full);
568 }
569}
570
571static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
572 unsigned long *mask,
573 struct phylink_link_state *state)
574{
575 /* FIXME: if the port is in 1000Base-X mode, then it only supports
576 * 1000M FD speeds. In this case, CMODE will indicate 5.
577 */
578 phylink_set(mask, 1000baseT_Full);
579 phylink_set(mask, 1000baseX_Full);
580
581 mv88e6065_phylink_validate(chip, port, mask, state);
582}
583
Marek Behúne3af71a2019-02-25 12:39:55 +0100584static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
585 unsigned long *mask,
586 struct phylink_link_state *state)
587{
588 if (port >= 5)
589 phylink_set(mask, 2500baseX_Full);
590
591 /* No ethtool bits for 200Mbps */
592 phylink_set(mask, 1000baseT_Full);
593 phylink_set(mask, 1000baseX_Full);
594
595 mv88e6065_phylink_validate(chip, port, mask, state);
596}
597
Russell King6c422e32018-08-09 15:38:39 +0200598static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
599 unsigned long *mask,
600 struct phylink_link_state *state)
601{
602 /* No ethtool bits for 200Mbps */
603 phylink_set(mask, 1000baseT_Full);
604 phylink_set(mask, 1000baseX_Full);
605
606 mv88e6065_phylink_validate(chip, port, mask, state);
607}
608
609static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
610 unsigned long *mask,
611 struct phylink_link_state *state)
612{
Andrew Lunnec260162019-02-08 22:25:44 +0100613 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200614 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100615 phylink_set(mask, 2500baseT_Full);
616 }
Russell King6c422e32018-08-09 15:38:39 +0200617
618 /* No ethtool bits for 200Mbps */
619 phylink_set(mask, 1000baseT_Full);
620 phylink_set(mask, 1000baseX_Full);
621
622 mv88e6065_phylink_validate(chip, port, mask, state);
623}
624
625static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
626 unsigned long *mask,
627 struct phylink_link_state *state)
628{
629 if (port >= 9) {
630 phylink_set(mask, 10000baseT_Full);
631 phylink_set(mask, 10000baseKR_Full);
632 }
633
634 mv88e6390_phylink_validate(chip, port, mask, state);
635}
636
Russell Kingc9a23562018-05-10 13:17:35 -0700637static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
638 unsigned long *supported,
639 struct phylink_link_state *state)
640{
Russell King6c422e32018-08-09 15:38:39 +0200641 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
642 struct mv88e6xxx_chip *chip = ds->priv;
643
644 /* Allow all the expected bits */
645 phylink_set(mask, Autoneg);
646 phylink_set(mask, Pause);
647 phylink_set_port_modes(mask);
648
649 if (chip->info->ops->phylink_validate)
650 chip->info->ops->phylink_validate(chip, port, mask, state);
651
652 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
653 bitmap_and(state->advertising, state->advertising, mask,
654 __ETHTOOL_LINK_MODE_MASK_NBITS);
655
656 /* We can only operate at 2500BaseX or 1000BaseX. If requested
657 * to advertise both, only report advertising at 2500BaseX.
658 */
659 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700660}
661
Russell Kingc9a23562018-05-10 13:17:35 -0700662static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
663 unsigned int mode,
664 const struct phylink_link_state *state)
665{
666 struct mv88e6xxx_chip *chip = ds->priv;
Russell King64d47d52020-03-14 10:15:38 +0000667 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700668
Russell King64d47d52020-03-14 10:15:38 +0000669 /* FIXME: is this the correct test? If we're in fixed mode on an
670 * internal port, why should we process this any different from
671 * PHY mode? On the other hand, the port may be automedia between
672 * an internal PHY and the serdes...
673 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200674 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700675 return;
676
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000677 mv88e6xxx_reg_lock(chip);
Russell King64d47d52020-03-14 10:15:38 +0000678 /* FIXME: should we force the link down here - but if we do, how
679 * do we restore the link force/unforce state? The driver layering
680 * gets in the way.
681 */
682 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000683 if (err && err != -EOPNOTSUPP)
684 goto err_unlock;
685
686 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
687 state->advertising);
688 /* FIXME: we should restart negotiation if something changed - which
689 * is something we get if we convert to using phylinks PCS operations.
690 */
691 if (err > 0)
692 err = 0;
693
694err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000695 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700696
697 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000698 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700699}
700
Russell Kingc9a23562018-05-10 13:17:35 -0700701static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
702 unsigned int mode,
703 phy_interface_t interface)
704{
Russell King30c4a5b2020-02-26 10:23:51 +0000705 struct mv88e6xxx_chip *chip = ds->priv;
706 const struct mv88e6xxx_ops *ops;
707 int err = 0;
708
709 ops = chip->info->ops;
710
Russell King5d5b2312020-03-14 10:16:03 +0000711 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200712 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
713 mode == MLO_AN_FIXED) && ops->port_set_link)
Russell King30c4a5b2020-02-26 10:23:51 +0000714 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Russell King5d5b2312020-03-14 10:16:03 +0000715 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000716
Russell King5d5b2312020-03-14 10:16:03 +0000717 if (err)
718 dev_err(chip->dev,
719 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700720}
721
722static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
723 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000724 struct phy_device *phydev,
725 int speed, int duplex,
726 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700727{
Russell King30c4a5b2020-02-26 10:23:51 +0000728 struct mv88e6xxx_chip *chip = ds->priv;
729 const struct mv88e6xxx_ops *ops;
730 int err = 0;
731
732 ops = chip->info->ops;
733
Russell King5d5b2312020-03-14 10:16:03 +0000734 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200735 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000736 /* FIXME: for an automedia port, should we force the link
737 * down here - what if the link comes up due to "other" media
738 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000739 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000740 * shared between internal PHY and Serdes.
741 */
Russell Kinga5a68582020-03-14 10:15:43 +0000742 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
743 duplex);
744 if (err)
745 goto error;
746
Russell Kingf365c6f2020-03-14 10:15:53 +0000747 if (ops->port_set_speed_duplex) {
748 err = ops->port_set_speed_duplex(chip, port,
749 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000750 if (err && err != -EOPNOTSUPP)
751 goto error;
752 }
753
754 if (ops->port_set_link)
755 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
Russell King30c4a5b2020-02-26 10:23:51 +0000756 }
Russell King5d5b2312020-03-14 10:16:03 +0000757error:
758 mv88e6xxx_reg_unlock(chip);
759
760 if (err && err != -EOPNOTSUPP)
761 dev_err(ds->dev,
762 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700763}
764
Andrew Lunna605a0f2016-11-21 23:26:58 +0100765static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000766{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100767 if (!chip->info->ops->stats_snapshot)
768 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000769
Andrew Lunna605a0f2016-11-21 23:26:58 +0100770 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000771}
772
Andrew Lunne413e7e2015-04-02 04:06:38 +0200773static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100774 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
775 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
776 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
777 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
778 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
779 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
780 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
781 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
782 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
783 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
784 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
785 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
786 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
787 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
788 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
789 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
790 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
791 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
792 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
793 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
794 { "single", 4, 0x14, STATS_TYPE_BANK0, },
795 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
796 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
797 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
798 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
799 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
800 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
801 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
802 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
803 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
804 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
805 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
806 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
807 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
808 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
809 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
810 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
811 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
812 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
813 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
814 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
815 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
816 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
817 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
818 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
819 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
820 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
821 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
822 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
823 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
824 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
825 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
826 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
827 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
828 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
829 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
830 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
831 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
832 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200833};
834
Vivien Didelotfad09c72016-06-21 12:28:20 -0400835static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100836 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100837 int port, u16 bank1_select,
838 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200839{
Andrew Lunn80c46272015-06-20 18:42:30 +0200840 u32 low;
841 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100842 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200843 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200844 u64 value;
845
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100846 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100847 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200848 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
849 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800850 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200851
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200852 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100853 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200854 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
855 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800856 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000857 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200858 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100860 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100861 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100862 /* fall through */
863 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100864 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100865 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100866 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100867 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500868 break;
869 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800870 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200871 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100872 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200873 return value;
874}
875
Andrew Lunn436fe172018-03-01 02:02:29 +0100876static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
877 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100878{
879 struct mv88e6xxx_hw_stat *stat;
880 int i, j;
881
882 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
883 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100884 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100885 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
886 ETH_GSTRING_LEN);
887 j++;
888 }
889 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100890
891 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100892}
893
Andrew Lunn436fe172018-03-01 02:02:29 +0100894static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
895 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100896{
Andrew Lunn436fe172018-03-01 02:02:29 +0100897 return mv88e6xxx_stats_get_strings(chip, data,
898 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100899}
900
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000901static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
902 uint8_t *data)
903{
904 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
905}
906
Andrew Lunn436fe172018-03-01 02:02:29 +0100907static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
908 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100909{
Andrew Lunn436fe172018-03-01 02:02:29 +0100910 return mv88e6xxx_stats_get_strings(chip, data,
911 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100912}
913
Andrew Lunn65f60e42018-03-28 23:50:28 +0200914static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
915 "atu_member_violation",
916 "atu_miss_violation",
917 "atu_full_violation",
918 "vtu_member_violation",
919 "vtu_miss_violation",
920};
921
922static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
923{
924 unsigned int i;
925
926 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
927 strlcpy(data + i * ETH_GSTRING_LEN,
928 mv88e6xxx_atu_vtu_stats_strings[i],
929 ETH_GSTRING_LEN);
930}
931
Andrew Lunndfafe442016-11-21 23:27:02 +0100932static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700933 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100934{
Vivien Didelot04bed142016-08-31 18:06:13 -0400935 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100936 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100937
Florian Fainelli89f09042018-04-25 12:12:50 -0700938 if (stringset != ETH_SS_STATS)
939 return;
940
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000941 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100942
Andrew Lunndfafe442016-11-21 23:27:02 +0100943 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100944 count = chip->info->ops->stats_get_strings(chip, data);
945
946 if (chip->info->ops->serdes_get_strings) {
947 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200948 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100950
Andrew Lunn65f60e42018-03-28 23:50:28 +0200951 data += count * ETH_GSTRING_LEN;
952 mv88e6xxx_atu_vtu_get_strings(data);
953
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000954 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100955}
956
957static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
958 int types)
959{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100960 struct mv88e6xxx_hw_stat *stat;
961 int i, j;
962
963 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
964 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100965 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100966 j++;
967 }
968 return j;
969}
970
Andrew Lunndfafe442016-11-21 23:27:02 +0100971static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
972{
973 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
974 STATS_TYPE_PORT);
975}
976
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000977static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
978{
979 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
980}
981
Andrew Lunndfafe442016-11-21 23:27:02 +0100982static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
983{
984 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
985 STATS_TYPE_BANK1);
986}
987
Florian Fainelli89f09042018-04-25 12:12:50 -0700988static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100989{
990 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 int serdes_count = 0;
992 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100993
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 if (sset != ETH_SS_STATS)
995 return 0;
996
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000997 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100998 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_sset_count(chip);
1000 if (count < 0)
1001 goto out;
1002
1003 if (chip->info->ops->serdes_get_sset_count)
1004 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1005 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 goto out;
1009 }
1010 count += serdes_count;
1011 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1012
Andrew Lunn436fe172018-03-01 02:02:29 +01001013out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001014 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001017}
1018
Andrew Lunn436fe172018-03-01 02:02:29 +01001019static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1020 uint64_t *data, int types,
1021 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001022{
1023 struct mv88e6xxx_hw_stat *stat;
1024 int i, j;
1025
1026 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1027 stat = &mv88e6xxx_hw_stats[i];
1028 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001029 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001030 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1031 bank1_select,
1032 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001033 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001034
Andrew Lunn052f9472016-11-21 23:27:03 +01001035 j++;
1036 }
1037 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001038 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001039}
1040
Andrew Lunn436fe172018-03-01 02:02:29 +01001041static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1042 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001043{
1044 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001045 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001046 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001049static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1050 uint64_t *data)
1051{
1052 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1053 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1054}
1055
Andrew Lunn436fe172018-03-01 02:02:29 +01001056static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1057 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001058{
1059 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001060 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001061 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1062 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001063}
1064
Andrew Lunn436fe172018-03-01 02:02:29 +01001065static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001067{
1068 return mv88e6xxx_stats_get_stats(chip, port, data,
1069 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001070 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1071 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001072}
1073
Andrew Lunn65f60e42018-03-28 23:50:28 +02001074static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1075 uint64_t *data)
1076{
1077 *data++ = chip->ports[port].atu_member_violation;
1078 *data++ = chip->ports[port].atu_miss_violation;
1079 *data++ = chip->ports[port].atu_full_violation;
1080 *data++ = chip->ports[port].vtu_member_violation;
1081 *data++ = chip->ports[port].vtu_miss_violation;
1082}
1083
Andrew Lunn052f9472016-11-21 23:27:03 +01001084static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1085 uint64_t *data)
1086{
Andrew Lunn436fe172018-03-01 02:02:29 +01001087 int count = 0;
1088
Andrew Lunn052f9472016-11-21 23:27:03 +01001089 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001090 count = chip->info->ops->stats_get_stats(chip, port, data);
1091
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001092 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001093 if (chip->info->ops->serdes_get_stats) {
1094 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001095 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001096 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001097 data += count;
1098 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001099 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001100}
1101
Vivien Didelotf81ec902016-05-09 13:22:58 -04001102static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1103 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001104{
Vivien Didelot04bed142016-08-31 18:06:13 -04001105 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001106 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001107
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001108 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001109
Andrew Lunna605a0f2016-11-21 23:26:58 +01001110 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001111 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001112
1113 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001114 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001115
1116 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001117
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001118}
Ben Hutchings98e67302011-11-25 14:36:19 +00001119
Vivien Didelotf81ec902016-05-09 13:22:58 -04001120static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001121{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001122 struct mv88e6xxx_chip *chip = ds->priv;
1123 int len;
1124
1125 len = 32 * sizeof(u16);
1126 if (chip->info->ops->serdes_get_regs_len)
1127 len += chip->info->ops->serdes_get_regs_len(chip, port);
1128
1129 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001130}
1131
Vivien Didelotf81ec902016-05-09 13:22:58 -04001132static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1133 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134{
Vivien Didelot04bed142016-08-31 18:06:13 -04001135 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001136 int err;
1137 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138 u16 *p = _p;
1139 int i;
1140
Vivien Didelota5f39322018-12-17 16:05:21 -05001141 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001142
1143 memset(p, 0xff, 32 * sizeof(u16));
1144
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001145 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001146
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001148
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001149 err = mv88e6xxx_port_read(chip, port, i, &reg);
1150 if (!err)
1151 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001152 }
Vivien Didelot23062512016-05-09 13:22:45 -04001153
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001154 if (chip->info->ops->serdes_get_regs)
1155 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1156
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001157 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001158}
1159
Vivien Didelot08f50062017-08-01 16:32:41 -04001160static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1161 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001162{
Vivien Didelot5480db62017-08-01 16:32:40 -04001163 /* Nothing to do on the port's MAC */
1164 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001165}
1166
Vivien Didelot08f50062017-08-01 16:32:41 -04001167static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1168 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001169{
Vivien Didelot5480db62017-08-01 16:32:40 -04001170 /* Nothing to do on the port's MAC */
1171 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001172}
1173
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001174/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001175static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001176{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001177 struct dsa_switch *ds = chip->ds;
1178 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001179 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001180 struct dsa_port *dp;
1181 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001182 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001183
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001184 list_for_each_entry(dp, &dst->ports, list) {
1185 if (dp->ds->index == dev && dp->index == port) {
1186 found = true;
1187 break;
1188 }
1189 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001190
Vivien Didelote5887a22017-03-30 17:37:11 -04001191 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001192 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001193 return 0;
1194
1195 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001196 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001197 return mv88e6xxx_port_mask(chip);
1198
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001199 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001200 pvlan = 0;
1201
1202 /* Frames from user ports can egress any local DSA links and CPU ports,
1203 * as well as any local member of their bridge group.
1204 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001205 list_for_each_entry(dp, &dst->ports, list)
1206 if (dp->ds == ds &&
1207 (dp->type == DSA_PORT_TYPE_CPU ||
1208 dp->type == DSA_PORT_TYPE_DSA ||
1209 (br && dp->bridge_dev == br)))
1210 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001211
1212 return pvlan;
1213}
1214
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001215static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001216{
1217 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001218
1219 /* prevent frames from going back out of the port they came in on */
1220 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001221
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001222 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001223}
1224
Vivien Didelotf81ec902016-05-09 13:22:58 -04001225static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1226 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001227{
Vivien Didelot04bed142016-08-31 18:06:13 -04001228 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001229 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001230
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001231 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001232 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001233 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001234
1235 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001236 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001237}
1238
Vivien Didelot93e18d62018-05-11 17:16:35 -04001239static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1240{
1241 int err;
1242
1243 if (chip->info->ops->ieee_pri_map) {
1244 err = chip->info->ops->ieee_pri_map(chip);
1245 if (err)
1246 return err;
1247 }
1248
1249 if (chip->info->ops->ip_pri_map) {
1250 err = chip->info->ops->ip_pri_map(chip);
1251 if (err)
1252 return err;
1253 }
1254
1255 return 0;
1256}
1257
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001258static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1259{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001260 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001261 int target, port;
1262 int err;
1263
1264 if (!chip->info->global2_addr)
1265 return 0;
1266
1267 /* Initialize the routing port to the 32 possible target devices */
1268 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001269 port = dsa_routing_port(ds, target);
1270 if (port == ds->num_ports)
1271 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001272
1273 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1274 if (err)
1275 return err;
1276 }
1277
Vivien Didelot02317e62018-05-09 11:38:49 -04001278 if (chip->info->ops->set_cascade_port) {
1279 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1280 err = chip->info->ops->set_cascade_port(chip, port);
1281 if (err)
1282 return err;
1283 }
1284
Vivien Didelot23c98912018-05-09 11:38:50 -04001285 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1286 if (err)
1287 return err;
1288
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001289 return 0;
1290}
1291
Vivien Didelotb28f8722018-04-26 21:56:44 -04001292static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1293{
1294 /* Clear all trunk masks and mapping */
1295 if (chip->info->global2_addr)
1296 return mv88e6xxx_g2_trunk_clear(chip);
1297
1298 return 0;
1299}
1300
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001301static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1302{
1303 if (chip->info->ops->rmu_disable)
1304 return chip->info->ops->rmu_disable(chip);
1305
1306 return 0;
1307}
1308
Vivien Didelot9e907d72017-07-17 13:03:43 -04001309static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1310{
1311 if (chip->info->ops->pot_clear)
1312 return chip->info->ops->pot_clear(chip);
1313
1314 return 0;
1315}
1316
Vivien Didelot51c901a2017-07-17 13:03:41 -04001317static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1318{
1319 if (chip->info->ops->mgmt_rsvd2cpu)
1320 return chip->info->ops->mgmt_rsvd2cpu(chip);
1321
1322 return 0;
1323}
1324
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001325static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1326{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001327 int err;
1328
Vivien Didelotdaefc942017-03-11 16:12:54 -05001329 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1330 if (err)
1331 return err;
1332
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001333 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1334 if (err)
1335 return err;
1336
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001337 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1338}
1339
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001340static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1341{
1342 int port;
1343 int err;
1344
1345 if (!chip->info->ops->irl_init_all)
1346 return 0;
1347
1348 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1349 /* Disable ingress rate limiting by resetting all per port
1350 * ingress rate limit resources to their initial state.
1351 */
1352 err = chip->info->ops->irl_init_all(chip, port);
1353 if (err)
1354 return err;
1355 }
1356
1357 return 0;
1358}
1359
Vivien Didelot04a69a12017-10-13 14:18:05 -04001360static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1361{
1362 if (chip->info->ops->set_switch_mac) {
1363 u8 addr[ETH_ALEN];
1364
1365 eth_random_addr(addr);
1366
1367 return chip->info->ops->set_switch_mac(chip, addr);
1368 }
1369
1370 return 0;
1371}
1372
Vivien Didelot17a15942017-03-30 17:37:09 -04001373static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1374{
1375 u16 pvlan = 0;
1376
1377 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001378 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001379
1380 /* Skip the local source device, which uses in-chip port VLAN */
1381 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001382 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001383
1384 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1385}
1386
Vivien Didelot81228992017-03-30 17:37:08 -04001387static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1388{
Vivien Didelot17a15942017-03-30 17:37:09 -04001389 int dev, port;
1390 int err;
1391
Vivien Didelot81228992017-03-30 17:37:08 -04001392 if (!mv88e6xxx_has_pvt(chip))
1393 return 0;
1394
1395 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1396 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1397 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001398 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1399 if (err)
1400 return err;
1401
1402 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1403 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1404 err = mv88e6xxx_pvt_map(chip, dev, port);
1405 if (err)
1406 return err;
1407 }
1408 }
1409
1410 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001411}
1412
Vivien Didelot749efcb2016-09-22 16:49:24 -04001413static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1414{
1415 struct mv88e6xxx_chip *chip = ds->priv;
1416 int err;
1417
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001418 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001419 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001420 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001421
1422 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001423 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001424}
1425
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001426static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1427{
1428 if (!chip->info->max_vid)
1429 return 0;
1430
1431 return mv88e6xxx_g1_vtu_flush(chip);
1432}
1433
Vivien Didelotf1394b782017-05-01 14:05:22 -04001434static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1435 struct mv88e6xxx_vtu_entry *entry)
1436{
1437 if (!chip->info->ops->vtu_getnext)
1438 return -EOPNOTSUPP;
1439
1440 return chip->info->ops->vtu_getnext(chip, entry);
1441}
1442
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001443static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1444 struct mv88e6xxx_vtu_entry *entry)
1445{
1446 if (!chip->info->ops->vtu_loadpurge)
1447 return -EOPNOTSUPP;
1448
1449 return chip->info->ops->vtu_loadpurge(chip, entry);
1450}
1451
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001452static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001453{
1454 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001455 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001456 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001457
1458 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1459
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001460 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001461 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001462 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001463 if (err)
1464 return err;
1465
1466 set_bit(*fid, fid_bitmap);
1467 }
1468
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001469 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001470 vlan.vid = chip->info->max_vid;
1471 vlan.valid = false;
1472
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001473 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001474 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001475 if (err)
1476 return err;
1477
1478 if (!vlan.valid)
1479 break;
1480
1481 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001482 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001483
1484 /* The reset value 0x000 is used to indicate that multiple address
1485 * databases are not needed. Return the next positive available.
1486 */
1487 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001488 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001489 return -ENOSPC;
1490
1491 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001492 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001493}
1494
Andrew Lunn23e8b472019-10-25 01:03:52 +02001495static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1496{
1497 if (chip->info->ops->atu_get_hash)
1498 return chip->info->ops->atu_get_hash(chip, hash);
1499
1500 return -EOPNOTSUPP;
1501}
1502
1503static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1504{
1505 if (chip->info->ops->atu_set_hash)
1506 return chip->info->ops->atu_set_hash(chip, hash);
1507
1508 return -EOPNOTSUPP;
1509}
1510
Vivien Didelotda9c3592016-02-12 12:09:40 -05001511static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1512 u16 vid_begin, u16 vid_end)
1513{
Vivien Didelot04bed142016-08-31 18:06:13 -04001514 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001515 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001516 int i, err;
1517
Andrew Lunndb06ae412017-09-25 23:32:20 +02001518 /* DSA and CPU ports have to be members of multiple vlans */
1519 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1520 return 0;
1521
Vivien Didelotda9c3592016-02-12 12:09:40 -05001522 if (!vid_begin)
1523 return -EOPNOTSUPP;
1524
Vivien Didelot425d2d32019-08-01 14:36:34 -04001525 vlan.vid = vid_begin - 1;
1526 vlan.valid = false;
1527
Vivien Didelotda9c3592016-02-12 12:09:40 -05001528 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001529 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001530 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001531 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001532
1533 if (!vlan.valid)
1534 break;
1535
1536 if (vlan.vid > vid_end)
1537 break;
1538
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001539 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001540 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1541 continue;
1542
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001543 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001544 continue;
1545
Vivien Didelotbd00e052017-05-01 14:05:11 -04001546 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001547 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001548 continue;
1549
Vivien Didelotc8652c82017-10-16 11:12:19 -04001550 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001551 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001552 break; /* same bridge, check next VLAN */
1553
Vivien Didelotc8652c82017-10-16 11:12:19 -04001554 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001555 continue;
1556
Andrew Lunn743fcc22017-11-09 22:29:54 +01001557 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1558 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001559 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001560 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 }
1562 } while (vlan.vid < vid_end);
1563
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001564 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565}
1566
Vivien Didelotf81ec902016-05-09 13:22:58 -04001567static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1568 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001569{
Vivien Didelot04bed142016-08-31 18:06:13 -04001570 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001571 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1572 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001573 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001574
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001575 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001576 return -EOPNOTSUPP;
1577
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001578 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001579 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001580 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001581
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001582 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001583}
1584
Vivien Didelot57d32312016-06-20 13:13:58 -04001585static int
1586mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001587 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001588{
Vivien Didelot04bed142016-08-31 18:06:13 -04001589 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001590 int err;
1591
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001592 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001593 return -EOPNOTSUPP;
1594
Vivien Didelotda9c3592016-02-12 12:09:40 -05001595 /* If the requested port doesn't belong to the same bridge as the VLAN
1596 * members, do not support it (yet) and fallback to software VLAN.
1597 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001598 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001599 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1600 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001601 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001602
Vivien Didelot76e398a2015-11-01 12:33:55 -05001603 /* We don't need any dynamic resource from the kernel (yet),
1604 * so skip the prepare phase.
1605 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001606 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001607}
1608
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001609static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1610 const unsigned char *addr, u16 vid,
1611 u8 state)
1612{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001613 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001614 struct mv88e6xxx_vtu_entry vlan;
1615 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001616 int err;
1617
1618 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001619 if (vid == 0) {
1620 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1621 if (err)
1622 return err;
1623 } else {
1624 vlan.vid = vid - 1;
1625 vlan.valid = false;
1626
1627 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1628 if (err)
1629 return err;
1630
1631 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1632 if (vlan.vid != vid || !vlan.valid)
1633 return -EOPNOTSUPP;
1634
1635 fid = vlan.fid;
1636 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001637
Vivien Didelotd8291a92019-09-07 16:00:47 -04001638 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001639 ether_addr_copy(entry.mac, addr);
1640 eth_addr_dec(entry.mac);
1641
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001642 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001643 if (err)
1644 return err;
1645
1646 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001647 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001648 memset(&entry, 0, sizeof(entry));
1649 ether_addr_copy(entry.mac, addr);
1650 }
1651
1652 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001653 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001654 entry.portvec &= ~BIT(port);
1655 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001656 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001657 } else {
1658 entry.portvec |= BIT(port);
1659 entry.state = state;
1660 }
1661
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001662 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001663}
1664
Vivien Didelotda7dc872019-09-07 16:00:49 -04001665static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1666 const struct mv88e6xxx_policy *policy)
1667{
1668 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1669 enum mv88e6xxx_policy_action action = policy->action;
1670 const u8 *addr = policy->addr;
1671 u16 vid = policy->vid;
1672 u8 state;
1673 int err;
1674 int id;
1675
1676 if (!chip->info->ops->port_set_policy)
1677 return -EOPNOTSUPP;
1678
1679 switch (mapping) {
1680 case MV88E6XXX_POLICY_MAPPING_DA:
1681 case MV88E6XXX_POLICY_MAPPING_SA:
1682 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1683 state = 0; /* Dissociate the port and address */
1684 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1685 is_multicast_ether_addr(addr))
1686 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1687 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1688 is_unicast_ether_addr(addr))
1689 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1690 else
1691 return -EOPNOTSUPP;
1692
1693 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1694 state);
1695 if (err)
1696 return err;
1697 break;
1698 default:
1699 return -EOPNOTSUPP;
1700 }
1701
1702 /* Skip the port's policy clearing if the mapping is still in use */
1703 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1704 idr_for_each_entry(&chip->policies, policy, id)
1705 if (policy->port == port &&
1706 policy->mapping == mapping &&
1707 policy->action != action)
1708 return 0;
1709
1710 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1711}
1712
1713static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1714 struct ethtool_rx_flow_spec *fs)
1715{
1716 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1717 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1718 enum mv88e6xxx_policy_mapping mapping;
1719 enum mv88e6xxx_policy_action action;
1720 struct mv88e6xxx_policy *policy;
1721 u16 vid = 0;
1722 u8 *addr;
1723 int err;
1724 int id;
1725
1726 if (fs->location != RX_CLS_LOC_ANY)
1727 return -EINVAL;
1728
1729 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1730 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1731 else
1732 return -EOPNOTSUPP;
1733
1734 switch (fs->flow_type & ~FLOW_EXT) {
1735 case ETHER_FLOW:
1736 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1737 is_zero_ether_addr(mac_mask->h_source)) {
1738 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1739 addr = mac_entry->h_dest;
1740 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1741 !is_zero_ether_addr(mac_mask->h_source)) {
1742 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1743 addr = mac_entry->h_source;
1744 } else {
1745 /* Cannot support DA and SA mapping in the same rule */
1746 return -EOPNOTSUPP;
1747 }
1748 break;
1749 default:
1750 return -EOPNOTSUPP;
1751 }
1752
1753 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001754 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001755 return -EOPNOTSUPP;
1756 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1757 }
1758
1759 idr_for_each_entry(&chip->policies, policy, id) {
1760 if (policy->port == port && policy->mapping == mapping &&
1761 policy->action == action && policy->vid == vid &&
1762 ether_addr_equal(policy->addr, addr))
1763 return -EEXIST;
1764 }
1765
1766 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1767 if (!policy)
1768 return -ENOMEM;
1769
1770 fs->location = 0;
1771 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1772 GFP_KERNEL);
1773 if (err) {
1774 devm_kfree(chip->dev, policy);
1775 return err;
1776 }
1777
1778 memcpy(&policy->fs, fs, sizeof(*fs));
1779 ether_addr_copy(policy->addr, addr);
1780 policy->mapping = mapping;
1781 policy->action = action;
1782 policy->port = port;
1783 policy->vid = vid;
1784
1785 err = mv88e6xxx_policy_apply(chip, port, policy);
1786 if (err) {
1787 idr_remove(&chip->policies, fs->location);
1788 devm_kfree(chip->dev, policy);
1789 return err;
1790 }
1791
1792 return 0;
1793}
1794
1795static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1796 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1797{
1798 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1799 struct mv88e6xxx_chip *chip = ds->priv;
1800 struct mv88e6xxx_policy *policy;
1801 int err;
1802 int id;
1803
1804 mv88e6xxx_reg_lock(chip);
1805
1806 switch (rxnfc->cmd) {
1807 case ETHTOOL_GRXCLSRLCNT:
1808 rxnfc->data = 0;
1809 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1810 rxnfc->rule_cnt = 0;
1811 idr_for_each_entry(&chip->policies, policy, id)
1812 if (policy->port == port)
1813 rxnfc->rule_cnt++;
1814 err = 0;
1815 break;
1816 case ETHTOOL_GRXCLSRULE:
1817 err = -ENOENT;
1818 policy = idr_find(&chip->policies, fs->location);
1819 if (policy) {
1820 memcpy(fs, &policy->fs, sizeof(*fs));
1821 err = 0;
1822 }
1823 break;
1824 case ETHTOOL_GRXCLSRLALL:
1825 rxnfc->data = 0;
1826 rxnfc->rule_cnt = 0;
1827 idr_for_each_entry(&chip->policies, policy, id)
1828 if (policy->port == port)
1829 rule_locs[rxnfc->rule_cnt++] = id;
1830 err = 0;
1831 break;
1832 default:
1833 err = -EOPNOTSUPP;
1834 break;
1835 }
1836
1837 mv88e6xxx_reg_unlock(chip);
1838
1839 return err;
1840}
1841
1842static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1843 struct ethtool_rxnfc *rxnfc)
1844{
1845 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1846 struct mv88e6xxx_chip *chip = ds->priv;
1847 struct mv88e6xxx_policy *policy;
1848 int err;
1849
1850 mv88e6xxx_reg_lock(chip);
1851
1852 switch (rxnfc->cmd) {
1853 case ETHTOOL_SRXCLSRLINS:
1854 err = mv88e6xxx_policy_insert(chip, port, fs);
1855 break;
1856 case ETHTOOL_SRXCLSRLDEL:
1857 err = -ENOENT;
1858 policy = idr_remove(&chip->policies, fs->location);
1859 if (policy) {
1860 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1861 err = mv88e6xxx_policy_apply(chip, port, policy);
1862 devm_kfree(chip->dev, policy);
1863 }
1864 break;
1865 default:
1866 err = -EOPNOTSUPP;
1867 break;
1868 }
1869
1870 mv88e6xxx_reg_unlock(chip);
1871
1872 return err;
1873}
1874
Andrew Lunn87fa8862017-11-09 22:29:56 +01001875static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1876 u16 vid)
1877{
1878 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1879 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1880
1881 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1882}
1883
1884static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1885{
1886 int port;
1887 int err;
1888
1889 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1890 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1891 if (err)
1892 return err;
1893 }
1894
1895 return 0;
1896}
1897
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001898static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001899 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001900{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001901 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001902 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001903 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001904
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001905 if (!vid)
1906 return -EOPNOTSUPP;
1907
1908 vlan.vid = vid - 1;
1909 vlan.valid = false;
1910
1911 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001912 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001913 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001914
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001915 if (vlan.vid != vid || !vlan.valid) {
1916 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001917
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001918 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1919 if (err)
1920 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001921
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001922 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1923 if (i == port)
1924 vlan.member[i] = member;
1925 else
1926 vlan.member[i] = non_member;
1927
1928 vlan.vid = vid;
1929 vlan.valid = true;
1930
1931 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1932 if (err)
1933 return err;
1934
1935 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1936 if (err)
1937 return err;
1938 } else if (vlan.member[port] != member) {
1939 vlan.member[port] = member;
1940
1941 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1942 if (err)
1943 return err;
Russell King933b4422020-02-26 17:14:26 +00001944 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001945 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1946 port, vid);
1947 }
1948
1949 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001950}
1951
Vivien Didelotf81ec902016-05-09 13:22:58 -04001952static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001953 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001954{
Vivien Didelot04bed142016-08-31 18:06:13 -04001955 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001956 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1957 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001958 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001959 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001960 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001961
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001962 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001963 return;
1964
Vivien Didelotc91498e2017-06-07 18:12:13 -04001965 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001966 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001967 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001968 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001969 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001970 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001971
Russell King933b4422020-02-26 17:14:26 +00001972 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1973 * and then the CPU port. Do not warn for duplicates for the CPU port.
1974 */
1975 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1976
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001977 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001978
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001979 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001980 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001981 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1982 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001983
Vivien Didelot77064f32016-11-04 03:23:30 +01001984 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001985 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1986 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001988 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001989}
1990
Vivien Didelot521098922019-08-01 14:36:36 -04001991static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1992 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001993{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001994 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001995 int i, err;
1996
Vivien Didelot521098922019-08-01 14:36:36 -04001997 if (!vid)
1998 return -EOPNOTSUPP;
1999
2000 vlan.vid = vid - 1;
2001 vlan.valid = false;
2002
2003 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002004 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002005 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002006
Vivien Didelot521098922019-08-01 14:36:36 -04002007 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2008 * tell switchdev that this VLAN is likely handled in software.
2009 */
2010 if (vlan.vid != vid || !vlan.valid ||
2011 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002012 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002013
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002014 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002015
2016 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002017 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002018 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002019 if (vlan.member[i] !=
2020 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002021 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002022 break;
2023 }
2024 }
2025
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002026 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002027 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002028 return err;
2029
Vivien Didelote606ca32017-03-11 16:12:55 -05002030 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002031}
2032
Vivien Didelotf81ec902016-05-09 13:22:58 -04002033static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2034 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002035{
Vivien Didelot04bed142016-08-31 18:06:13 -04002036 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002037 u16 pvid, vid;
2038 int err = 0;
2039
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002040 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002041 return -EOPNOTSUPP;
2042
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002043 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002044
Vivien Didelot77064f32016-11-04 03:23:30 +01002045 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002046 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002047 goto unlock;
2048
Vivien Didelot76e398a2015-11-01 12:33:55 -05002049 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002050 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002051 if (err)
2052 goto unlock;
2053
2054 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002055 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002056 if (err)
2057 goto unlock;
2058 }
2059 }
2060
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002061unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002062 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002063
2064 return err;
2065}
2066
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002067static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2068 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002069{
Vivien Didelot04bed142016-08-31 18:06:13 -04002070 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002071 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002072
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002073 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002074 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2075 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002076 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002077
2078 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002079}
2080
Vivien Didelotf81ec902016-05-09 13:22:58 -04002081static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002082 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002083{
Vivien Didelot04bed142016-08-31 18:06:13 -04002084 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002085 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002086
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002087 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002088 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002089 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002090
Vivien Didelot83dabd12016-08-31 11:50:04 -04002091 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002092}
2093
Vivien Didelot83dabd12016-08-31 11:50:04 -04002094static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2095 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002096 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002097{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002098 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002099 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002100 int err;
2101
Vivien Didelotd8291a92019-09-07 16:00:47 -04002102 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002103 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002104
2105 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002106 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002107 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002108 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002109
Vivien Didelotd8291a92019-09-07 16:00:47 -04002110 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002111 break;
2112
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002113 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002114 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002115
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002116 if (!is_unicast_ether_addr(addr.mac))
2117 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002118
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002119 is_static = (addr.state ==
2120 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2121 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002122 if (err)
2123 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002124 } while (!is_broadcast_ether_addr(addr.mac));
2125
2126 return err;
2127}
2128
Vivien Didelot83dabd12016-08-31 11:50:04 -04002129static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002130 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002131{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002132 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002133 u16 fid;
2134 int err;
2135
2136 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002137 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002138 if (err)
2139 return err;
2140
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002141 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002142 if (err)
2143 return err;
2144
2145 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002146 vlan.vid = chip->info->max_vid;
2147 vlan.valid = false;
2148
Vivien Didelot83dabd12016-08-31 11:50:04 -04002149 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002150 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002151 if (err)
2152 return err;
2153
2154 if (!vlan.valid)
2155 break;
2156
2157 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002158 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002159 if (err)
2160 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002161 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002162
2163 return err;
2164}
2165
Vivien Didelotf81ec902016-05-09 13:22:58 -04002166static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002167 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002168{
Vivien Didelot04bed142016-08-31 18:06:13 -04002169 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002170 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002171
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002172 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002173 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002174 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002175
2176 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002177}
2178
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002179static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2180 struct net_device *br)
2181{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002182 struct dsa_switch *ds = chip->ds;
2183 struct dsa_switch_tree *dst = ds->dst;
2184 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002185 int err;
2186
Vivien Didelotef2025e2019-10-21 16:51:27 -04002187 list_for_each_entry(dp, &dst->ports, list) {
2188 if (dp->bridge_dev == br) {
2189 if (dp->ds == ds) {
2190 /* This is a local bridge group member,
2191 * remap its Port VLAN Map.
2192 */
2193 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2194 if (err)
2195 return err;
2196 } else {
2197 /* This is an external bridge group member,
2198 * remap its cross-chip Port VLAN Table entry.
2199 */
2200 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2201 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002202 if (err)
2203 return err;
2204 }
2205 }
2206 }
2207
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002208 return 0;
2209}
2210
Vivien Didelotf81ec902016-05-09 13:22:58 -04002211static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002212 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002213{
Vivien Didelot04bed142016-08-31 18:06:13 -04002214 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002215 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002216
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002217 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002218 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002219 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002220
Vivien Didelot466dfa02016-02-26 13:16:05 -05002221 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002222}
2223
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002224static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2225 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002226{
Vivien Didelot04bed142016-08-31 18:06:13 -04002227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002228
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002229 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002230 if (mv88e6xxx_bridge_map(chip, br) ||
2231 mv88e6xxx_port_vlan_map(chip, port))
2232 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002233 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002234}
2235
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002236static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2237 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002238 int port, struct net_device *br)
2239{
2240 struct mv88e6xxx_chip *chip = ds->priv;
2241 int err;
2242
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002243 if (tree_index != ds->dst->index)
2244 return 0;
2245
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002246 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002247 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002248 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002249
2250 return err;
2251}
2252
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002253static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2254 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002255 int port, struct net_device *br)
2256{
2257 struct mv88e6xxx_chip *chip = ds->priv;
2258
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002259 if (tree_index != ds->dst->index)
2260 return;
2261
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002262 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002263 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002264 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002265 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002266}
2267
Vivien Didelot17e708b2016-12-05 17:30:27 -05002268static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2269{
2270 if (chip->info->ops->reset)
2271 return chip->info->ops->reset(chip);
2272
2273 return 0;
2274}
2275
Vivien Didelot309eca62016-12-05 17:30:26 -05002276static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2277{
2278 struct gpio_desc *gpiod = chip->reset;
2279
2280 /* If there is a GPIO connected to the reset pin, toggle it */
2281 if (gpiod) {
2282 gpiod_set_value_cansleep(gpiod, 1);
2283 usleep_range(10000, 20000);
2284 gpiod_set_value_cansleep(gpiod, 0);
2285 usleep_range(10000, 20000);
2286 }
2287}
2288
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002289static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2290{
2291 int i, err;
2292
2293 /* Set all ports to the Disabled state */
2294 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002295 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002296 if (err)
2297 return err;
2298 }
2299
2300 /* Wait for transmit queues to drain,
2301 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2302 */
2303 usleep_range(2000, 4000);
2304
2305 return 0;
2306}
2307
Vivien Didelotfad09c72016-06-21 12:28:20 -04002308static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002309{
Vivien Didelota935c052016-09-29 12:21:53 -04002310 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002311
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002312 err = mv88e6xxx_disable_ports(chip);
2313 if (err)
2314 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002315
Vivien Didelot309eca62016-12-05 17:30:26 -05002316 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002317
Vivien Didelot17e708b2016-12-05 17:30:27 -05002318 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002319}
2320
Vivien Didelot43145572017-03-11 16:12:59 -05002321static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002322 enum mv88e6xxx_frame_mode frame,
2323 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002324{
2325 int err;
2326
Vivien Didelot43145572017-03-11 16:12:59 -05002327 if (!chip->info->ops->port_set_frame_mode)
2328 return -EOPNOTSUPP;
2329
2330 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002331 if (err)
2332 return err;
2333
Vivien Didelot43145572017-03-11 16:12:59 -05002334 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2335 if (err)
2336 return err;
2337
2338 if (chip->info->ops->port_set_ether_type)
2339 return chip->info->ops->port_set_ether_type(chip, port, etype);
2340
2341 return 0;
2342}
2343
2344static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2345{
2346 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002347 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002348 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002349}
2350
2351static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2352{
2353 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002354 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002355 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002356}
2357
2358static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2359{
2360 return mv88e6xxx_set_port_mode(chip, port,
2361 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002362 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2363 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002364}
2365
2366static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2367{
2368 if (dsa_is_dsa_port(chip->ds, port))
2369 return mv88e6xxx_set_port_mode_dsa(chip, port);
2370
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002371 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002372 return mv88e6xxx_set_port_mode_normal(chip, port);
2373
2374 /* Setup CPU port mode depending on its supported tag format */
2375 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2376 return mv88e6xxx_set_port_mode_dsa(chip, port);
2377
2378 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2379 return mv88e6xxx_set_port_mode_edsa(chip, port);
2380
2381 return -EINVAL;
2382}
2383
Vivien Didelotea698f42017-03-11 16:12:50 -05002384static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2385{
2386 bool message = dsa_is_dsa_port(chip->ds, port);
2387
2388 return mv88e6xxx_port_set_message_port(chip, port, message);
2389}
2390
Vivien Didelot601aeed2017-03-11 16:13:00 -05002391static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2392{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002393 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002394 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002395
David S. Miller407308f2019-06-15 13:35:29 -07002396 /* Upstream ports flood frames with unknown unicast or multicast DA */
2397 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2398 if (chip->info->ops->port_set_egress_floods)
2399 return chip->info->ops->port_set_egress_floods(chip, port,
2400 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002401
David S. Miller407308f2019-06-15 13:35:29 -07002402 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002403}
2404
Vivien Didelot45de77f2019-08-31 16:18:36 -04002405static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2406{
2407 struct mv88e6xxx_port *mvp = dev_id;
2408 struct mv88e6xxx_chip *chip = mvp->chip;
2409 irqreturn_t ret = IRQ_NONE;
2410 int port = mvp->port;
2411 u8 lane;
2412
2413 mv88e6xxx_reg_lock(chip);
2414 lane = mv88e6xxx_serdes_get_lane(chip, port);
2415 if (lane)
2416 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2417 mv88e6xxx_reg_unlock(chip);
2418
2419 return ret;
2420}
2421
2422static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2423 u8 lane)
2424{
2425 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2426 unsigned int irq;
2427 int err;
2428
2429 /* Nothing to request if this SERDES port has no IRQ */
2430 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2431 if (!irq)
2432 return 0;
2433
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002434 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2435 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2436
Vivien Didelot45de77f2019-08-31 16:18:36 -04002437 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2438 mv88e6xxx_reg_unlock(chip);
2439 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002440 IRQF_ONESHOT, dev_id->serdes_irq_name,
2441 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002442 mv88e6xxx_reg_lock(chip);
2443 if (err)
2444 return err;
2445
2446 dev_id->serdes_irq = irq;
2447
2448 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2449}
2450
2451static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2452 u8 lane)
2453{
2454 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2455 unsigned int irq = dev_id->serdes_irq;
2456 int err;
2457
2458 /* Nothing to free if no IRQ has been requested */
2459 if (!irq)
2460 return 0;
2461
2462 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2463
2464 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2465 mv88e6xxx_reg_unlock(chip);
2466 free_irq(irq, dev_id);
2467 mv88e6xxx_reg_lock(chip);
2468
2469 dev_id->serdes_irq = 0;
2470
2471 return err;
2472}
2473
Andrew Lunn6d917822017-05-26 01:03:21 +02002474static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2475 bool on)
2476{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002477 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002478 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002479
Vivien Didelotdc272f62019-08-31 16:18:33 -04002480 lane = mv88e6xxx_serdes_get_lane(chip, port);
2481 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002482 return 0;
2483
2484 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002485 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002486 if (err)
2487 return err;
2488
Vivien Didelot45de77f2019-08-31 16:18:36 -04002489 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002490 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002491 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2492 if (err)
2493 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002494
Vivien Didelotdc272f62019-08-31 16:18:33 -04002495 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002496 }
2497
2498 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002499}
2500
Vivien Didelotfa371c82017-12-05 15:34:10 -05002501static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2502{
2503 struct dsa_switch *ds = chip->ds;
2504 int upstream_port;
2505 int err;
2506
Vivien Didelot07073c72017-12-05 15:34:13 -05002507 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002508 if (chip->info->ops->port_set_upstream_port) {
2509 err = chip->info->ops->port_set_upstream_port(chip, port,
2510 upstream_port);
2511 if (err)
2512 return err;
2513 }
2514
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002515 if (port == upstream_port) {
2516 if (chip->info->ops->set_cpu_port) {
2517 err = chip->info->ops->set_cpu_port(chip,
2518 upstream_port);
2519 if (err)
2520 return err;
2521 }
2522
2523 if (chip->info->ops->set_egress_port) {
2524 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002525 MV88E6XXX_EGRESS_DIR_INGRESS,
2526 upstream_port);
2527 if (err)
2528 return err;
2529
2530 err = chip->info->ops->set_egress_port(chip,
2531 MV88E6XXX_EGRESS_DIR_EGRESS,
2532 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002533 if (err)
2534 return err;
2535 }
2536 }
2537
Vivien Didelotfa371c82017-12-05 15:34:10 -05002538 return 0;
2539}
2540
Vivien Didelotfad09c72016-06-21 12:28:20 -04002541static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002542{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002543 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002544 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002545 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002546
Andrew Lunn7b898462018-08-09 15:38:47 +02002547 chip->ports[port].chip = chip;
2548 chip->ports[port].port = port;
2549
Vivien Didelotd78343d2016-11-04 03:23:36 +01002550 /* MAC Forcing register: don't force link, speed, duplex or flow control
2551 * state to any particular values on physical ports, but force the CPU
2552 * port and all DSA ports to their maximum bandwidth and full duplex.
2553 */
2554 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2555 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2556 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002557 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002558 PHY_INTERFACE_MODE_NA);
2559 else
2560 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2561 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002562 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002563 PHY_INTERFACE_MODE_NA);
2564 if (err)
2565 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002566
2567 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2568 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2569 * tunneling, determine priority by looking at 802.1p and IP
2570 * priority fields (IP prio has precedence), and set STP state
2571 * to Forwarding.
2572 *
2573 * If this is the CPU link, use DSA or EDSA tagging depending
2574 * on which tagging mode was configured.
2575 *
2576 * If this is a link to another switch, use DSA tagging mode.
2577 *
2578 * If this is the upstream port for this switch, enable
2579 * forwarding of unknown unicasts and multicasts.
2580 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002581 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2582 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2583 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2584 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002585 if (err)
2586 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002587
Vivien Didelot601aeed2017-03-11 16:13:00 -05002588 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002589 if (err)
2590 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002591
Vivien Didelot601aeed2017-03-11 16:13:00 -05002592 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002593 if (err)
2594 return err;
2595
Vivien Didelot8efdda42015-08-13 12:52:23 -04002596 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002597 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002598 * untagged frames on this port, do a destination address lookup on all
2599 * received packets as usual, disable ARP mirroring and don't send a
2600 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002601 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002602 err = mv88e6xxx_port_set_map_da(chip, port);
2603 if (err)
2604 return err;
2605
Vivien Didelotfa371c82017-12-05 15:34:10 -05002606 err = mv88e6xxx_setup_upstream_port(chip, port);
2607 if (err)
2608 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002609
Andrew Lunna23b2962017-02-04 20:15:28 +01002610 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002611 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002612 if (err)
2613 return err;
2614
Vivien Didelotcd782652017-06-08 18:34:13 -04002615 if (chip->info->ops->port_set_jumbo_size) {
2616 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002617 if (err)
2618 return err;
2619 }
2620
Andrew Lunn54d792f2015-05-06 01:09:47 +02002621 /* Port Association Vector: when learning source addresses
2622 * of packets, add the address to the address database using
2623 * a port bitmap that has only the bit for this port set and
2624 * the other bits clear.
2625 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002626 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002627 /* Disable learning for CPU port */
2628 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002629 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002630
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002631 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2632 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002633 if (err)
2634 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002635
2636 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002637 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2638 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002639 if (err)
2640 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002641
Vivien Didelot08984322017-06-08 18:34:12 -04002642 if (chip->info->ops->port_pause_limit) {
2643 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002644 if (err)
2645 return err;
2646 }
2647
Vivien Didelotc8c94892017-03-11 16:13:01 -05002648 if (chip->info->ops->port_disable_learn_limit) {
2649 err = chip->info->ops->port_disable_learn_limit(chip, port);
2650 if (err)
2651 return err;
2652 }
2653
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002654 if (chip->info->ops->port_disable_pri_override) {
2655 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002656 if (err)
2657 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002658 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002659
Andrew Lunnef0a7312016-12-03 04:35:16 +01002660 if (chip->info->ops->port_tag_remap) {
2661 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002662 if (err)
2663 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002664 }
2665
Andrew Lunnef70b112016-12-03 04:45:18 +01002666 if (chip->info->ops->port_egress_rate_limiting) {
2667 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002668 if (err)
2669 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002670 }
2671
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002672 if (chip->info->ops->port_setup_message_port) {
2673 err = chip->info->ops->port_setup_message_port(chip, port);
2674 if (err)
2675 return err;
2676 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002677
Vivien Didelot207afda2016-04-14 14:42:09 -04002678 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002679 * database, and allow bidirectional communication between the
2680 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002681 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002682 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002683 if (err)
2684 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002685
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002686 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002687 if (err)
2688 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002689
2690 /* Default VLAN ID and priority: don't set a default VLAN
2691 * ID, and set the default packet priority to zero.
2692 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002693 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002694}
2695
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002696static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2697{
2698 struct mv88e6xxx_chip *chip = ds->priv;
2699
2700 if (chip->info->ops->port_set_jumbo_size)
2701 return 10240;
2702 return 1522;
2703}
2704
2705static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2706{
2707 struct mv88e6xxx_chip *chip = ds->priv;
2708 int ret = 0;
2709
2710 mv88e6xxx_reg_lock(chip);
2711 if (chip->info->ops->port_set_jumbo_size)
2712 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
2713 else
2714 if (new_mtu > 1522)
2715 ret = -EINVAL;
2716 mv88e6xxx_reg_unlock(chip);
2717
2718 return ret;
2719}
2720
Andrew Lunn04aca992017-05-26 01:03:24 +02002721static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2722 struct phy_device *phydev)
2723{
2724 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002725 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002726
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002727 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002728 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002729 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002730
2731 return err;
2732}
2733
Andrew Lunn75104db2019-02-24 20:44:43 +01002734static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002735{
2736 struct mv88e6xxx_chip *chip = ds->priv;
2737
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002738 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002739 if (mv88e6xxx_serdes_power(chip, port, false))
2740 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002741 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002742}
2743
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002744static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2745 unsigned int ageing_time)
2746{
Vivien Didelot04bed142016-08-31 18:06:13 -04002747 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002748 int err;
2749
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002750 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002751 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002752 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002753
2754 return err;
2755}
2756
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002757static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002758{
2759 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002760
Andrew Lunnde2273872016-11-21 23:27:01 +01002761 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002762 if (chip->info->ops->stats_set_histogram) {
2763 err = chip->info->ops->stats_set_histogram(chip);
2764 if (err)
2765 return err;
2766 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002767
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002768 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002769}
2770
Andrew Lunnea890982019-01-09 00:24:03 +01002771/* Check if the errata has already been applied. */
2772static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2773{
2774 int port;
2775 int err;
2776 u16 val;
2777
2778 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002779 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002780 if (err) {
2781 dev_err(chip->dev,
2782 "Error reading hidden register: %d\n", err);
2783 return false;
2784 }
2785 if (val != 0x01c0)
2786 return false;
2787 }
2788
2789 return true;
2790}
2791
2792/* The 6390 copper ports have an errata which require poking magic
2793 * values into undocumented hidden registers and then performing a
2794 * software reset.
2795 */
2796static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2797{
2798 int port;
2799 int err;
2800
2801 if (mv88e6390_setup_errata_applied(chip))
2802 return 0;
2803
2804 /* Set the ports into blocking mode */
2805 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2806 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2807 if (err)
2808 return err;
2809 }
2810
2811 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002812 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002813 if (err)
2814 return err;
2815 }
2816
2817 return mv88e6xxx_software_reset(chip);
2818}
2819
Andrew Lunn23e8b472019-10-25 01:03:52 +02002820enum mv88e6xxx_devlink_param_id {
2821 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2822 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2823};
2824
2825static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2826 struct devlink_param_gset_ctx *ctx)
2827{
2828 struct mv88e6xxx_chip *chip = ds->priv;
2829 int err;
2830
2831 mv88e6xxx_reg_lock(chip);
2832
2833 switch (id) {
2834 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2835 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2836 break;
2837 default:
2838 err = -EOPNOTSUPP;
2839 break;
2840 }
2841
2842 mv88e6xxx_reg_unlock(chip);
2843
2844 return err;
2845}
2846
2847static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2848 struct devlink_param_gset_ctx *ctx)
2849{
2850 struct mv88e6xxx_chip *chip = ds->priv;
2851 int err;
2852
2853 mv88e6xxx_reg_lock(chip);
2854
2855 switch (id) {
2856 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2857 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2858 break;
2859 default:
2860 err = -EOPNOTSUPP;
2861 break;
2862 }
2863
2864 mv88e6xxx_reg_unlock(chip);
2865
2866 return err;
2867}
2868
2869static const struct devlink_param mv88e6xxx_devlink_params[] = {
2870 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2871 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2872 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2873};
2874
2875static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2876{
2877 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2878 ARRAY_SIZE(mv88e6xxx_devlink_params));
2879}
2880
2881static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2882{
2883 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2884 ARRAY_SIZE(mv88e6xxx_devlink_params));
2885}
2886
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002887enum mv88e6xxx_devlink_resource_id {
2888 MV88E6XXX_RESOURCE_ID_ATU,
2889 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2890 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2891 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2892 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2893};
2894
2895static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2896 u16 bin)
2897{
2898 u16 occupancy = 0;
2899 int err;
2900
2901 mv88e6xxx_reg_lock(chip);
2902
2903 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2904 bin);
2905 if (err) {
2906 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2907 goto unlock;
2908 }
2909
2910 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2911 if (err) {
2912 dev_err(chip->dev, "failed to perform ATU get next\n");
2913 goto unlock;
2914 }
2915
2916 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2917 if (err) {
2918 dev_err(chip->dev, "failed to get ATU stats\n");
2919 goto unlock;
2920 }
2921
Andrew Lunn012fc742020-03-11 21:02:31 +01002922 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2923
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002924unlock:
2925 mv88e6xxx_reg_unlock(chip);
2926
2927 return occupancy;
2928}
2929
2930static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2931{
2932 struct mv88e6xxx_chip *chip = priv;
2933
2934 return mv88e6xxx_devlink_atu_bin_get(chip,
2935 MV88E6XXX_G2_ATU_STATS_BIN_0);
2936}
2937
2938static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2939{
2940 struct mv88e6xxx_chip *chip = priv;
2941
2942 return mv88e6xxx_devlink_atu_bin_get(chip,
2943 MV88E6XXX_G2_ATU_STATS_BIN_1);
2944}
2945
2946static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2947{
2948 struct mv88e6xxx_chip *chip = priv;
2949
2950 return mv88e6xxx_devlink_atu_bin_get(chip,
2951 MV88E6XXX_G2_ATU_STATS_BIN_2);
2952}
2953
2954static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2955{
2956 struct mv88e6xxx_chip *chip = priv;
2957
2958 return mv88e6xxx_devlink_atu_bin_get(chip,
2959 MV88E6XXX_G2_ATU_STATS_BIN_3);
2960}
2961
2962static u64 mv88e6xxx_devlink_atu_get(void *priv)
2963{
2964 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2965 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2966 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2967 mv88e6xxx_devlink_atu_bin_3_get(priv);
2968}
2969
2970static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2971{
2972 struct devlink_resource_size_params size_params;
2973 struct mv88e6xxx_chip *chip = ds->priv;
2974 int err;
2975
2976 devlink_resource_size_params_init(&size_params,
2977 mv88e6xxx_num_macs(chip),
2978 mv88e6xxx_num_macs(chip),
2979 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2980
2981 err = dsa_devlink_resource_register(ds, "ATU",
2982 mv88e6xxx_num_macs(chip),
2983 MV88E6XXX_RESOURCE_ID_ATU,
2984 DEVLINK_RESOURCE_ID_PARENT_TOP,
2985 &size_params);
2986 if (err)
2987 goto out;
2988
2989 devlink_resource_size_params_init(&size_params,
2990 mv88e6xxx_num_macs(chip) / 4,
2991 mv88e6xxx_num_macs(chip) / 4,
2992 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2993
2994 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2995 mv88e6xxx_num_macs(chip) / 4,
2996 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2997 MV88E6XXX_RESOURCE_ID_ATU,
2998 &size_params);
2999 if (err)
3000 goto out;
3001
3002 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
3003 mv88e6xxx_num_macs(chip) / 4,
3004 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3005 MV88E6XXX_RESOURCE_ID_ATU,
3006 &size_params);
3007 if (err)
3008 goto out;
3009
3010 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
3011 mv88e6xxx_num_macs(chip) / 4,
3012 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3013 MV88E6XXX_RESOURCE_ID_ATU,
3014 &size_params);
3015 if (err)
3016 goto out;
3017
3018 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
3019 mv88e6xxx_num_macs(chip) / 4,
3020 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3021 MV88E6XXX_RESOURCE_ID_ATU,
3022 &size_params);
3023 if (err)
3024 goto out;
3025
3026 dsa_devlink_resource_occ_get_register(ds,
3027 MV88E6XXX_RESOURCE_ID_ATU,
3028 mv88e6xxx_devlink_atu_get,
3029 chip);
3030
3031 dsa_devlink_resource_occ_get_register(ds,
3032 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
3033 mv88e6xxx_devlink_atu_bin_0_get,
3034 chip);
3035
3036 dsa_devlink_resource_occ_get_register(ds,
3037 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3038 mv88e6xxx_devlink_atu_bin_1_get,
3039 chip);
3040
3041 dsa_devlink_resource_occ_get_register(ds,
3042 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3043 mv88e6xxx_devlink_atu_bin_2_get,
3044 chip);
3045
3046 dsa_devlink_resource_occ_get_register(ds,
3047 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3048 mv88e6xxx_devlink_atu_bin_3_get,
3049 chip);
3050
3051 return 0;
3052
3053out:
3054 dsa_devlink_resources_unregister(ds);
3055 return err;
3056}
3057
Andrew Lunn23e8b472019-10-25 01:03:52 +02003058static void mv88e6xxx_teardown(struct dsa_switch *ds)
3059{
3060 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003061 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003062}
3063
Vivien Didelotf81ec902016-05-09 13:22:58 -04003064static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003065{
Vivien Didelot04bed142016-08-31 18:06:13 -04003066 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003067 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003068 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003069 int i;
3070
Vivien Didelotfad09c72016-06-21 12:28:20 -04003071 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003072 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003073
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003074 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003075
Andrew Lunnea890982019-01-09 00:24:03 +01003076 if (chip->info->ops->setup_errata) {
3077 err = chip->info->ops->setup_errata(chip);
3078 if (err)
3079 goto unlock;
3080 }
3081
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003082 /* Cache the cmode of each port. */
3083 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3084 if (chip->info->ops->port_get_cmode) {
3085 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3086 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003087 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003088
3089 chip->ports[i].cmode = cmode;
3090 }
3091 }
3092
Vivien Didelot97299342016-07-18 20:45:30 -04003093 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003094 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003095 if (dsa_is_unused_port(ds, i))
3096 continue;
3097
Hubert Feursteinc8574862019-07-31 10:23:48 +02003098 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003099 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003100 dev_err(chip->dev, "port %d is invalid\n", i);
3101 err = -EINVAL;
3102 goto unlock;
3103 }
3104
Vivien Didelot97299342016-07-18 20:45:30 -04003105 err = mv88e6xxx_setup_port(chip, i);
3106 if (err)
3107 goto unlock;
3108 }
3109
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003110 err = mv88e6xxx_irl_setup(chip);
3111 if (err)
3112 goto unlock;
3113
Vivien Didelot04a69a12017-10-13 14:18:05 -04003114 err = mv88e6xxx_mac_setup(chip);
3115 if (err)
3116 goto unlock;
3117
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003118 err = mv88e6xxx_phy_setup(chip);
3119 if (err)
3120 goto unlock;
3121
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003122 err = mv88e6xxx_vtu_setup(chip);
3123 if (err)
3124 goto unlock;
3125
Vivien Didelot81228992017-03-30 17:37:08 -04003126 err = mv88e6xxx_pvt_setup(chip);
3127 if (err)
3128 goto unlock;
3129
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003130 err = mv88e6xxx_atu_setup(chip);
3131 if (err)
3132 goto unlock;
3133
Andrew Lunn87fa8862017-11-09 22:29:56 +01003134 err = mv88e6xxx_broadcast_setup(chip, 0);
3135 if (err)
3136 goto unlock;
3137
Vivien Didelot9e907d72017-07-17 13:03:43 -04003138 err = mv88e6xxx_pot_setup(chip);
3139 if (err)
3140 goto unlock;
3141
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003142 err = mv88e6xxx_rmu_setup(chip);
3143 if (err)
3144 goto unlock;
3145
Vivien Didelot51c901a2017-07-17 13:03:41 -04003146 err = mv88e6xxx_rsvd2cpu_setup(chip);
3147 if (err)
3148 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003149
Vivien Didelotb28f8722018-04-26 21:56:44 -04003150 err = mv88e6xxx_trunk_setup(chip);
3151 if (err)
3152 goto unlock;
3153
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003154 err = mv88e6xxx_devmap_setup(chip);
3155 if (err)
3156 goto unlock;
3157
Vivien Didelot93e18d62018-05-11 17:16:35 -04003158 err = mv88e6xxx_pri_setup(chip);
3159 if (err)
3160 goto unlock;
3161
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003162 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003163 if (chip->info->ptp_support) {
3164 err = mv88e6xxx_ptp_setup(chip);
3165 if (err)
3166 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003167
3168 err = mv88e6xxx_hwtstamp_setup(chip);
3169 if (err)
3170 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003171 }
3172
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003173 err = mv88e6xxx_stats_setup(chip);
3174 if (err)
3175 goto unlock;
3176
Vivien Didelot6b17e862015-08-13 12:52:18 -04003177unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003178 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003179
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003180 if (err)
3181 return err;
3182
3183 /* Have to be called without holding the register lock, since
3184 * they take the devlink lock, and we later take the locks in
3185 * the reverse order when getting/setting parameters or
3186 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003187 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003188 err = mv88e6xxx_setup_devlink_resources(ds);
3189 if (err)
3190 return err;
3191
3192 err = mv88e6xxx_setup_devlink_params(ds);
3193 if (err)
3194 dsa_devlink_resources_unregister(ds);
3195
3196 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003197}
3198
Vivien Didelote57e5e72016-08-15 17:19:00 -04003199static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003200{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003201 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3202 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003203 u16 val;
3204 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003205
Andrew Lunnee26a222017-01-24 14:53:48 +01003206 if (!chip->info->ops->phy_read)
3207 return -EOPNOTSUPP;
3208
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003209 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003210 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003211 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003212
Andrew Lunnda9f3302017-02-01 03:40:05 +01003213 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003214 /* Some internal PHYs don't have a model number. */
3215 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3216 /* Then there is the 6165 family. It gets is
3217 * PHYs correct. But it can also have two
3218 * SERDES interfaces in the PHY address
3219 * space. And these don't have a model
3220 * number. But they are not PHYs, so we don't
3221 * want to give them something a PHY driver
3222 * will recognise.
3223 *
3224 * Use the mv88e6390 family model number
3225 * instead, for anything which really could be
3226 * a PHY,
3227 */
3228 if (!(val & 0x3f0))
3229 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003230 }
3231
Vivien Didelote57e5e72016-08-15 17:19:00 -04003232 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003233}
3234
Vivien Didelote57e5e72016-08-15 17:19:00 -04003235static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003236{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003237 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3238 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003239 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003240
Andrew Lunnee26a222017-01-24 14:53:48 +01003241 if (!chip->info->ops->phy_write)
3242 return -EOPNOTSUPP;
3243
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003244 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003245 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003246 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003247
3248 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003249}
3250
Vivien Didelotfad09c72016-06-21 12:28:20 -04003251static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003252 struct device_node *np,
3253 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003254{
3255 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003256 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003257 struct mii_bus *bus;
3258 int err;
3259
Andrew Lunn2510bab2018-02-22 01:51:49 +01003260 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003261 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003262 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003263 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003264
3265 if (err)
3266 return err;
3267 }
3268
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003269 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003270 if (!bus)
3271 return -ENOMEM;
3272
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003273 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003274 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003275 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003276 INIT_LIST_HEAD(&mdio_bus->list);
3277 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003278
Andrew Lunnb516d452016-06-04 21:17:06 +02003279 if (np) {
3280 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003281 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003282 } else {
3283 bus->name = "mv88e6xxx SMI";
3284 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3285 }
3286
3287 bus->read = mv88e6xxx_mdio_read;
3288 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003289 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003290
Andrew Lunn6f882842018-03-17 20:32:05 +01003291 if (!external) {
3292 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3293 if (err)
3294 return err;
3295 }
3296
Florian Fainelli00e798c2018-05-15 16:56:19 -07003297 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003298 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003299 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003300 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003301 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003302 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003303
3304 if (external)
3305 list_add_tail(&mdio_bus->list, &chip->mdios);
3306 else
3307 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003308
3309 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003310}
3311
Andrew Lunna3c53be52017-01-24 14:53:50 +01003312static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3313 { .compatible = "marvell,mv88e6xxx-mdio-external",
3314 .data = (void *)true },
3315 { },
3316};
3317
Andrew Lunn3126aee2017-12-07 01:05:57 +01003318static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3319
3320{
3321 struct mv88e6xxx_mdio_bus *mdio_bus;
3322 struct mii_bus *bus;
3323
3324 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3325 bus = mdio_bus->bus;
3326
Andrew Lunn6f882842018-03-17 20:32:05 +01003327 if (!mdio_bus->external)
3328 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3329
Andrew Lunn3126aee2017-12-07 01:05:57 +01003330 mdiobus_unregister(bus);
3331 }
3332}
3333
Andrew Lunna3c53be52017-01-24 14:53:50 +01003334static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3335 struct device_node *np)
3336{
3337 const struct of_device_id *match;
3338 struct device_node *child;
3339 int err;
3340
3341 /* Always register one mdio bus for the internal/default mdio
3342 * bus. This maybe represented in the device tree, but is
3343 * optional.
3344 */
3345 child = of_get_child_by_name(np, "mdio");
3346 err = mv88e6xxx_mdio_register(chip, child, false);
3347 if (err)
3348 return err;
3349
3350 /* Walk the device tree, and see if there are any other nodes
3351 * which say they are compatible with the external mdio
3352 * bus.
3353 */
3354 for_each_available_child_of_node(np, child) {
3355 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3356 if (match) {
3357 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003358 if (err) {
3359 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303360 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003361 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003362 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003363 }
3364 }
3365
3366 return 0;
3367}
3368
Vivien Didelot855b1932016-07-20 18:18:35 -04003369static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3370{
Vivien Didelot04bed142016-08-31 18:06:13 -04003371 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003372
3373 return chip->eeprom_len;
3374}
3375
Vivien Didelot855b1932016-07-20 18:18:35 -04003376static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3377 struct ethtool_eeprom *eeprom, u8 *data)
3378{
Vivien Didelot04bed142016-08-31 18:06:13 -04003379 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003380 int err;
3381
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003382 if (!chip->info->ops->get_eeprom)
3383 return -EOPNOTSUPP;
3384
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003385 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003386 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003387 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003388
3389 if (err)
3390 return err;
3391
3392 eeprom->magic = 0xc3ec4951;
3393
3394 return 0;
3395}
3396
Vivien Didelot855b1932016-07-20 18:18:35 -04003397static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3398 struct ethtool_eeprom *eeprom, u8 *data)
3399{
Vivien Didelot04bed142016-08-31 18:06:13 -04003400 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003401 int err;
3402
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003403 if (!chip->info->ops->set_eeprom)
3404 return -EOPNOTSUPP;
3405
Vivien Didelot855b1932016-07-20 18:18:35 -04003406 if (eeprom->magic != 0xc3ec4951)
3407 return -EINVAL;
3408
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003409 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003410 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003411 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003412
3413 return err;
3414}
3415
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003416static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003417 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003418 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3419 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003420 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003421 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003422 .phy_read = mv88e6185_phy_ppu_read,
3423 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003424 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003425 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003426 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003427 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003428 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003429 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003430 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003431 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003432 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003433 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003434 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003435 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003436 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003437 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003438 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3439 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003440 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003441 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3442 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003443 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003444 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003445 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003446 .ppu_enable = mv88e6185_g1_ppu_enable,
3447 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003448 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003449 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003450 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003451 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003452 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003453};
3454
3455static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003456 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003457 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3458 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003459 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003460 .phy_read = mv88e6185_phy_ppu_read,
3461 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003462 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003463 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003464 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003465 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003466 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003467 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003468 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003469 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003470 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003471 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3472 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003473 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003474 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003475 .ppu_enable = mv88e6185_g1_ppu_enable,
3476 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003477 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003478 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003479 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003480 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003481};
3482
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003483static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003484 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003485 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3486 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003487 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003488 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3489 .phy_read = mv88e6xxx_g2_smi_phy_read,
3490 .phy_write = mv88e6xxx_g2_smi_phy_write,
3491 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003492 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003493 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003494 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003495 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003496 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003497 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003498 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003499 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003500 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003501 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003502 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003503 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003504 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003505 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3506 .stats_get_strings = mv88e6095_stats_get_strings,
3507 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003508 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3509 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003510 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003511 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003512 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003513 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003514 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003515 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003516 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003517 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003518};
3519
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003520static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003521 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003522 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3523 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003524 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003525 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003526 .phy_read = mv88e6xxx_g2_smi_phy_read,
3527 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003528 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003529 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003530 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003531 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003532 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003533 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003534 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003535 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003536 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003537 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003538 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3539 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003540 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003541 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3542 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003543 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003544 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003545 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003546 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003547 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3548 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003549 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003550 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003551 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003552};
3553
3554static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003555 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003556 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3557 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003558 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003559 .phy_read = mv88e6185_phy_ppu_read,
3560 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003561 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003562 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003563 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003564 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003565 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003566 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003567 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003568 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003569 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003570 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003571 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003572 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003573 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003574 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003575 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003576 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3577 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003578 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003579 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3580 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003581 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003582 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003583 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003584 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003585 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003586 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003587 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003588 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003589 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003590};
3591
Vivien Didelot990e27b2017-03-28 13:50:32 -04003592static const struct mv88e6xxx_ops mv88e6141_ops = {
3593 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003594 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3595 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003596 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003597 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3598 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3599 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3600 .phy_read = mv88e6xxx_g2_smi_phy_read,
3601 .phy_write = mv88e6xxx_g2_smi_phy_write,
3602 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003603 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003604 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003605 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003606 .port_tag_remap = mv88e6095_port_tag_remap,
3607 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3608 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3609 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003610 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003611 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003612 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003613 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3614 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003615 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003616 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003617 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003618 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003619 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003620 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3621 .stats_get_strings = mv88e6320_stats_get_strings,
3622 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003623 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3624 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003625 .watchdog_ops = &mv88e6390_watchdog_ops,
3626 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003627 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003628 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003629 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003630 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003631 .serdes_power = mv88e6390_serdes_power,
3632 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003633 /* Check status register pause & lpa register */
3634 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3635 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3636 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3637 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003638 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003639 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003640 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003641 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003642 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003643};
3644
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003645static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003646 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003647 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3648 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003649 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003650 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003651 .phy_read = mv88e6xxx_g2_smi_phy_read,
3652 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003653 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003654 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003655 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003656 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003657 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003658 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003659 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003660 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003661 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003662 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003663 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003664 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003665 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003666 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003667 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003668 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3669 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003670 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003671 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3672 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003673 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003674 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003675 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003676 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003677 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3678 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003679 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003680 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003681 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003682 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003683 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003684};
3685
3686static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003687 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003688 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3689 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003690 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003691 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003692 .phy_read = mv88e6165_phy_read,
3693 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003694 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003695 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003696 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003697 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003698 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003699 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003700 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003701 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003702 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3703 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003704 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003705 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3706 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003707 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003708 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003709 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003710 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003711 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3712 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003713 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003714 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003715 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003716 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003717 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003718};
3719
3720static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003721 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003722 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3723 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003724 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003725 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003726 .phy_read = mv88e6xxx_g2_smi_phy_read,
3727 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003728 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003729 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003730 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003731 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003732 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003733 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003734 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003735 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003736 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003737 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003738 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003739 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003740 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003741 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003742 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003743 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003744 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3745 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003746 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003747 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3748 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003749 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003750 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003751 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003752 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003753 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3754 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003755 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003756 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003757 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003758};
3759
3760static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003761 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003762 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3763 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003764 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003765 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3766 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003767 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003768 .phy_read = mv88e6xxx_g2_smi_phy_read,
3769 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003770 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003771 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003772 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003773 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003774 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003775 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003776 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003777 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003778 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003779 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003780 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003781 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003782 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003783 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003784 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003785 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003786 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003787 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3788 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003789 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003790 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3791 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003792 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003793 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003794 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003795 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003796 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003797 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3798 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003799 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003800 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003801 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003802 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3803 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3804 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3805 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003806 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003807 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3808 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003809 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003810 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003811};
3812
3813static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003814 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003815 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3816 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003817 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003818 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003819 .phy_read = mv88e6xxx_g2_smi_phy_read,
3820 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003821 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003822 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003823 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003824 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003825 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003826 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003827 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003828 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003829 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003830 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003831 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003832 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003833 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003834 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003835 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003836 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003837 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3838 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003839 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003840 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3841 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003842 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003843 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003844 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003845 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003846 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3847 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003848 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003849 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003850 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003851};
3852
3853static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003854 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003855 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3856 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003857 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003858 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3859 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003860 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003861 .phy_read = mv88e6xxx_g2_smi_phy_read,
3862 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003863 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003864 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003865 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003866 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003867 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003868 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003869 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003870 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003871 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003872 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003873 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003874 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003875 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003876 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003877 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003878 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003879 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003880 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3881 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003882 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003883 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3884 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003885 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003886 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003887 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003888 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003889 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003890 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3891 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003892 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003893 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003894 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003895 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3896 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3897 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3898 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003899 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003900 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003901 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003902 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003903 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3904 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003905 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003906 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003907};
3908
3909static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003910 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003911 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3912 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003913 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003914 .phy_read = mv88e6185_phy_ppu_read,
3915 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003916 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003917 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003918 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003919 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003920 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003921 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003922 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003923 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003924 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003925 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003926 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003927 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3928 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003929 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003930 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3931 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003932 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003933 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003934 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003935 .ppu_enable = mv88e6185_g1_ppu_enable,
3936 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003937 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003938 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003939 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003940 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003941};
3942
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003943static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003944 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003945 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003946 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003947 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3948 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003949 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3950 .phy_read = mv88e6xxx_g2_smi_phy_read,
3951 .phy_write = mv88e6xxx_g2_smi_phy_write,
3952 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003953 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003954 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003955 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003956 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003957 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003958 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003959 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003960 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003961 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003962 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003963 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003964 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003965 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003966 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003967 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003968 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003969 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003970 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3971 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003972 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003973 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3974 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003975 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003976 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003977 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003978 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003979 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003980 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3981 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003982 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3983 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003984 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003985 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003986 /* Check status register pause & lpa register */
3987 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3988 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3989 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3990 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003991 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003992 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003993 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003994 .serdes_get_strings = mv88e6390_serdes_get_strings,
3995 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003996 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3997 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003998 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003999 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004000};
4001
4002static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004003 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004004 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004005 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004006 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4007 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004008 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4009 .phy_read = mv88e6xxx_g2_smi_phy_read,
4010 .phy_write = mv88e6xxx_g2_smi_phy_write,
4011 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004012 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004013 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004014 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004015 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004016 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004017 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004018 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004019 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004020 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004021 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004022 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004023 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004024 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004025 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004026 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004027 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004028 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004029 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4030 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004031 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004032 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4033 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004034 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004035 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004036 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004037 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004038 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004039 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4040 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004041 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4042 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004043 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004044 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004045 /* Check status register pause & lpa register */
4046 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4047 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4048 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4049 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004050 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004051 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004052 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004053 .serdes_get_strings = mv88e6390_serdes_get_strings,
4054 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004055 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4056 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004057 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004058 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004059};
4060
4061static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004062 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004063 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004064 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004065 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4066 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004067 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4068 .phy_read = mv88e6xxx_g2_smi_phy_read,
4069 .phy_write = mv88e6xxx_g2_smi_phy_write,
4070 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004071 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004072 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004073 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004074 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004075 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004076 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004077 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004078 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004079 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004080 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004081 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004082 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004083 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004084 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004085 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004086 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4087 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004088 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004089 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4090 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004091 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004092 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004093 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004094 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004095 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004096 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4097 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004098 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4099 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004100 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004101 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004102 /* Check status register pause & lpa register */
4103 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4104 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4105 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4106 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004107 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004108 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004109 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004110 .serdes_get_strings = mv88e6390_serdes_get_strings,
4111 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004112 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4113 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004114 .avb_ops = &mv88e6390_avb_ops,
4115 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004116 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004117};
4118
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004119static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004120 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004121 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4122 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004123 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004124 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4125 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004126 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004127 .phy_read = mv88e6xxx_g2_smi_phy_read,
4128 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004129 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004130 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004131 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004132 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004133 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004134 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004135 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004136 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004137 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004138 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004139 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004140 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004141 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004142 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004143 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004144 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004145 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004146 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4147 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004148 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004149 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4150 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004151 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004152 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004153 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004154 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004155 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004156 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4157 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004158 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004159 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004160 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004161 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4162 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4163 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4164 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004165 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004166 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004167 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004168 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004169 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4170 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004171 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004172 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004173 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004174 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004175};
4176
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004177static const struct mv88e6xxx_ops mv88e6250_ops = {
4178 /* MV88E6XXX_FAMILY_6250 */
4179 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4180 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4181 .irl_init_all = mv88e6352_g2_irl_init_all,
4182 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4183 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4184 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4185 .phy_read = mv88e6xxx_g2_smi_phy_read,
4186 .phy_write = mv88e6xxx_g2_smi_phy_write,
4187 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004188 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004189 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004190 .port_tag_remap = mv88e6095_port_tag_remap,
4191 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4192 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4193 .port_set_ether_type = mv88e6351_port_set_ether_type,
4194 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4195 .port_pause_limit = mv88e6097_port_pause_limit,
4196 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004197 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4198 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4199 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4200 .stats_get_strings = mv88e6250_stats_get_strings,
4201 .stats_get_stats = mv88e6250_stats_get_stats,
4202 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4203 .set_egress_port = mv88e6095_g1_set_egress_port,
4204 .watchdog_ops = &mv88e6250_watchdog_ops,
4205 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4206 .pot_clear = mv88e6xxx_g2_pot_clear,
4207 .reset = mv88e6250_g1_reset,
4208 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4209 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004210 .avb_ops = &mv88e6352_avb_ops,
4211 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004212 .phylink_validate = mv88e6065_phylink_validate,
4213};
4214
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004215static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004216 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004217 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004218 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004219 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4220 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4222 .phy_read = mv88e6xxx_g2_smi_phy_read,
4223 .phy_write = mv88e6xxx_g2_smi_phy_write,
4224 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004225 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004226 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004227 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004228 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004229 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004230 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004231 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004232 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004233 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004234 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004235 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004236 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004237 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004238 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004239 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004240 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004241 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4242 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004243 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004244 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4245 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004246 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004247 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004248 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004249 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004250 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004251 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4252 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004253 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4254 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004255 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004256 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004257 /* Check status register pause & lpa register */
4258 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4259 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4260 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4261 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004262 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004263 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004264 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004265 .serdes_get_strings = mv88e6390_serdes_get_strings,
4266 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004267 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4268 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004269 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004270 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004271 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004272 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004273};
4274
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004275static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004276 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004277 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4278 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004279 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004280 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4281 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004282 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004283 .phy_read = mv88e6xxx_g2_smi_phy_read,
4284 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004285 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004286 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004287 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004288 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004289 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004290 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004291 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004292 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004293 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004294 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004295 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004296 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004297 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004298 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004299 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004300 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4301 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004302 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004303 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4304 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004305 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004306 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004307 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004308 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004309 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004310 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004311 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004312 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004313 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004314 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004315};
4316
4317static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004318 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004319 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4320 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004321 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004322 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4323 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004324 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004325 .phy_read = mv88e6xxx_g2_smi_phy_read,
4326 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004327 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004328 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004329 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004330 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004331 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004332 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004333 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004334 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004335 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004336 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004337 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004338 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004339 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004340 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004341 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004342 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4343 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004344 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004345 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4346 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004347 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004348 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004349 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004350 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004351 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004352 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004353 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004354 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004355};
4356
Vivien Didelot16e329a2017-03-28 13:50:33 -04004357static const struct mv88e6xxx_ops mv88e6341_ops = {
4358 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004359 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4360 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004361 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004362 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4363 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4364 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4365 .phy_read = mv88e6xxx_g2_smi_phy_read,
4366 .phy_write = mv88e6xxx_g2_smi_phy_write,
4367 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004368 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004369 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004370 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004371 .port_tag_remap = mv88e6095_port_tag_remap,
4372 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4373 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4374 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004375 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004376 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004377 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004378 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4379 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004380 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004381 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004382 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004383 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004384 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004385 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4386 .stats_get_strings = mv88e6320_stats_get_strings,
4387 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004388 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4389 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004390 .watchdog_ops = &mv88e6390_watchdog_ops,
4391 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004392 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004393 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004394 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004395 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004396 .serdes_power = mv88e6390_serdes_power,
4397 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004398 /* Check status register pause & lpa register */
4399 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4400 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4401 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4402 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004403 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004404 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004405 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004406 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004407 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004408 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004409 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004410};
4411
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004412static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004413 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004414 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4415 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004416 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004417 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004418 .phy_read = mv88e6xxx_g2_smi_phy_read,
4419 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004420 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004421 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004422 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004423 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004424 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004425 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004426 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004427 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004428 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004429 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004430 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004431 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004432 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004433 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004434 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004435 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004436 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4437 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004438 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004439 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4440 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004441 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004442 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004443 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004444 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004445 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4446 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004447 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004448 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004449 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004450};
4451
4452static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004453 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004454 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4455 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004456 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004457 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004458 .phy_read = mv88e6xxx_g2_smi_phy_read,
4459 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004460 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004461 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004462 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004463 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004464 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004465 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004466 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004467 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004468 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004469 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004470 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004471 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004472 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004473 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004474 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004475 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004476 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4477 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004478 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004479 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4480 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004481 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004482 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004483 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004484 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004485 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4486 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004487 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004488 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004489 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004490 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004491 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004492};
4493
4494static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004495 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004496 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4497 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004498 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004499 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4500 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004501 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004502 .phy_read = mv88e6xxx_g2_smi_phy_read,
4503 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004504 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004505 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004506 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004507 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004508 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004509 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004510 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004511 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004512 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004513 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004514 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004515 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004516 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004517 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004518 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004519 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004520 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004521 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4522 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004523 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004524 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4525 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004526 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004527 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004528 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004529 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004530 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004531 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4532 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004533 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004534 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004535 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004536 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4537 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4538 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4539 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004540 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004541 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004542 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004543 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004544 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004545 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004546 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004547 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4548 .serdes_get_strings = mv88e6352_serdes_get_strings,
4549 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004550 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4551 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004552 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004553};
4554
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004555static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004556 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004557 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004558 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004559 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4560 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004561 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4562 .phy_read = mv88e6xxx_g2_smi_phy_read,
4563 .phy_write = mv88e6xxx_g2_smi_phy_write,
4564 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004565 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004566 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004567 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004568 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004569 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004570 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004571 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004572 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004573 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004574 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004575 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004576 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004577 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004578 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004579 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004580 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004581 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004582 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004583 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4584 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004585 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004586 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4587 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004588 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004589 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004590 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004591 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004592 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004593 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4594 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004595 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4596 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004597 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004598 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004599 /* Check status register pause & lpa register */
4600 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4601 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4602 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4603 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004604 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004605 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004606 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004607 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004608 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004609 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004610 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4611 .serdes_get_strings = mv88e6390_serdes_get_strings,
4612 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004613 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4614 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004615 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004616};
4617
4618static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004619 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004620 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004621 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004622 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4623 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004624 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4625 .phy_read = mv88e6xxx_g2_smi_phy_read,
4626 .phy_write = mv88e6xxx_g2_smi_phy_write,
4627 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004628 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004629 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004630 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004631 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004632 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004633 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004634 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004635 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004636 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004637 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004638 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004639 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004640 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004641 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004642 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004643 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004644 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004645 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004646 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4647 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004648 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004649 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4650 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004651 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004652 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004653 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004654 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004655 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004656 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4657 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004658 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4659 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004660 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004661 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004662 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4663 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4664 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4665 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004666 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004667 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004668 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004669 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4670 .serdes_get_strings = mv88e6390_serdes_get_strings,
4671 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004672 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4673 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004674 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004675 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004676 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004677 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004678};
4679
Vivien Didelotf81ec902016-05-09 13:22:58 -04004680static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4681 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004682 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004683 .family = MV88E6XXX_FAMILY_6097,
4684 .name = "Marvell 88E6085",
4685 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004686 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004687 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004688 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004689 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004690 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004691 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004692 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004693 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004694 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004695 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004696 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004697 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004698 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004699 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004700 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004701 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004702 },
4703
4704 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004705 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004706 .family = MV88E6XXX_FAMILY_6095,
4707 .name = "Marvell 88E6095/88E6095F",
4708 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004709 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004710 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004711 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004712 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004713 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004714 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004715 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004716 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004717 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004718 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004719 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004720 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004721 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004722 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723 },
4724
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004725 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004726 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004727 .family = MV88E6XXX_FAMILY_6097,
4728 .name = "Marvell 88E6097/88E6097F",
4729 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004730 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004731 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004732 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004733 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004734 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004735 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004736 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004737 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004738 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004739 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004740 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004741 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004742 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004743 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004744 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004745 .ops = &mv88e6097_ops,
4746 },
4747
Vivien Didelotf81ec902016-05-09 13:22:58 -04004748 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004749 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004750 .family = MV88E6XXX_FAMILY_6165,
4751 .name = "Marvell 88E6123",
4752 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004753 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004755 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004756 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004757 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004758 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004759 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004760 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004761 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004762 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004763 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004764 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004765 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004766 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004767 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004768 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004769 },
4770
4771 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004772 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004773 .family = MV88E6XXX_FAMILY_6185,
4774 .name = "Marvell 88E6131",
4775 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004776 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004777 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004778 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004779 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004780 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004781 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004782 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004783 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004784 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004785 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004786 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004787 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004788 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004789 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004790 },
4791
Vivien Didelot990e27b2017-03-28 13:50:32 -04004792 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004793 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004794 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004795 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004796 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004797 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004798 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004799 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004800 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004801 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004802 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004803 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004804 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004805 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004806 .age_time_coeff = 3750,
4807 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004808 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004809 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004810 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004811 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004812 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004813 .ops = &mv88e6141_ops,
4814 },
4815
Vivien Didelotf81ec902016-05-09 13:22:58 -04004816 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004817 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004818 .family = MV88E6XXX_FAMILY_6165,
4819 .name = "Marvell 88E6161",
4820 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004821 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004822 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004823 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004824 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004825 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004826 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004827 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004828 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004829 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004830 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004831 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004832 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004833 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004834 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004835 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004836 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004837 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004838 },
4839
4840 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004841 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004842 .family = MV88E6XXX_FAMILY_6165,
4843 .name = "Marvell 88E6165",
4844 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004845 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004846 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004847 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004848 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004849 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004850 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004851 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004852 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004853 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004854 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004855 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004856 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004857 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004858 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004859 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004860 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004861 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004862 },
4863
4864 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004865 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004866 .family = MV88E6XXX_FAMILY_6351,
4867 .name = "Marvell 88E6171",
4868 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004869 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004870 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004871 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004872 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004873 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004874 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004875 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004876 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004877 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004878 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004879 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004880 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004881 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004882 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004883 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004884 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004885 },
4886
4887 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004888 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004889 .family = MV88E6XXX_FAMILY_6352,
4890 .name = "Marvell 88E6172",
4891 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004892 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004893 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004894 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004895 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004896 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004897 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004898 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004899 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004900 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004901 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004902 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004903 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004904 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004905 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004906 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004907 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004908 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004909 },
4910
4911 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004912 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004913 .family = MV88E6XXX_FAMILY_6351,
4914 .name = "Marvell 88E6175",
4915 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004916 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004917 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004918 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004919 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004920 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004921 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004922 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004923 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004924 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004925 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004926 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004927 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004928 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004929 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004930 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004931 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004932 },
4933
4934 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004935 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004936 .family = MV88E6XXX_FAMILY_6352,
4937 .name = "Marvell 88E6176",
4938 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004939 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004940 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004941 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004942 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004943 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004944 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004945 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004946 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004947 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004948 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004949 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004950 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004951 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004952 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004953 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004954 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004955 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004956 },
4957
4958 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004959 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004960 .family = MV88E6XXX_FAMILY_6185,
4961 .name = "Marvell 88E6185",
4962 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004963 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004964 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004965 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004966 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004967 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004968 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004969 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004970 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004971 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004972 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004973 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004974 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004975 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004976 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004977 },
4978
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004979 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004980 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004981 .family = MV88E6XXX_FAMILY_6390,
4982 .name = "Marvell 88E6190",
4983 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004984 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004985 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004986 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004987 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004988 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004989 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004990 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004991 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004992 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004993 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004994 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004995 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004996 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004997 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004998 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004999 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005000 .ops = &mv88e6190_ops,
5001 },
5002
5003 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005004 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005005 .family = MV88E6XXX_FAMILY_6390,
5006 .name = "Marvell 88E6190X",
5007 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005008 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005009 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005010 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005011 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005012 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005013 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005014 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005015 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005016 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005017 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005018 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005019 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005020 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005021 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005022 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005023 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005024 .ops = &mv88e6190x_ops,
5025 },
5026
5027 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005028 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005029 .family = MV88E6XXX_FAMILY_6390,
5030 .name = "Marvell 88E6191",
5031 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005032 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005033 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005034 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005035 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005036 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005037 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005038 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005039 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005040 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005041 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005042 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005043 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005044 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005045 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005046 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005047 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005048 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005049 },
5050
Hubert Feurstein49022642019-07-31 10:23:46 +02005051 [MV88E6220] = {
5052 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5053 .family = MV88E6XXX_FAMILY_6250,
5054 .name = "Marvell 88E6220",
5055 .num_databases = 64,
5056
5057 /* Ports 2-4 are not routed to pins
5058 * => usable ports 0, 1, 5, 6
5059 */
5060 .num_ports = 7,
5061 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005062 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005063 .max_vid = 4095,
5064 .port_base_addr = 0x08,
5065 .phy_base_addr = 0x00,
5066 .global1_addr = 0x0f,
5067 .global2_addr = 0x07,
5068 .age_time_coeff = 15000,
5069 .g1_irqs = 9,
5070 .g2_irqs = 10,
5071 .atu_move_port_mask = 0xf,
5072 .dual_chip = true,
5073 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005074 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005075 .ops = &mv88e6250_ops,
5076 },
5077
Vivien Didelotf81ec902016-05-09 13:22:58 -04005078 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005079 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005080 .family = MV88E6XXX_FAMILY_6352,
5081 .name = "Marvell 88E6240",
5082 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005083 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005084 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005085 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005086 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005087 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005088 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005089 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005090 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005091 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005092 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005093 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005094 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005095 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005096 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005097 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005098 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005099 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005100 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005101 },
5102
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005103 [MV88E6250] = {
5104 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5105 .family = MV88E6XXX_FAMILY_6250,
5106 .name = "Marvell 88E6250",
5107 .num_databases = 64,
5108 .num_ports = 7,
5109 .num_internal_phys = 5,
5110 .max_vid = 4095,
5111 .port_base_addr = 0x08,
5112 .phy_base_addr = 0x00,
5113 .global1_addr = 0x0f,
5114 .global2_addr = 0x07,
5115 .age_time_coeff = 15000,
5116 .g1_irqs = 9,
5117 .g2_irqs = 10,
5118 .atu_move_port_mask = 0xf,
5119 .dual_chip = true,
5120 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005121 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005122 .ops = &mv88e6250_ops,
5123 },
5124
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005125 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005126 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005127 .family = MV88E6XXX_FAMILY_6390,
5128 .name = "Marvell 88E6290",
5129 .num_databases = 4096,
5130 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005131 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005132 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005133 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005134 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005135 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005136 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005137 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005138 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005139 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005140 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005141 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005142 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005143 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005144 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005145 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005146 .ops = &mv88e6290_ops,
5147 },
5148
Vivien Didelotf81ec902016-05-09 13:22:58 -04005149 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005150 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005151 .family = MV88E6XXX_FAMILY_6320,
5152 .name = "Marvell 88E6320",
5153 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005154 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005155 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005156 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005157 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005158 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005159 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005160 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005161 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005162 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005163 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005164 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005165 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005166 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005167 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005168 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005169 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005170 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005171 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005172 },
5173
5174 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005175 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005176 .family = MV88E6XXX_FAMILY_6320,
5177 .name = "Marvell 88E6321",
5178 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005179 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005180 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005181 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005182 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005183 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005184 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005185 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005186 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005187 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005188 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005189 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005190 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005191 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005192 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005193 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005194 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005195 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005196 },
5197
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005198 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005199 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005200 .family = MV88E6XXX_FAMILY_6341,
5201 .name = "Marvell 88E6341",
5202 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005203 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005204 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005205 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005206 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005207 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005208 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005209 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005210 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005211 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005212 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005213 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005214 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005215 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005216 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005217 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005218 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005219 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005220 .ops = &mv88e6341_ops,
5221 },
5222
Vivien Didelotf81ec902016-05-09 13:22:58 -04005223 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005224 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005225 .family = MV88E6XXX_FAMILY_6351,
5226 .name = "Marvell 88E6350",
5227 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005228 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005229 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005230 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005231 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005232 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005233 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005234 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005235 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005236 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005237 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005238 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005239 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005240 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005241 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005242 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005243 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005244 },
5245
5246 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005247 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005248 .family = MV88E6XXX_FAMILY_6351,
5249 .name = "Marvell 88E6351",
5250 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005251 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005252 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005253 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005254 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005255 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005256 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005257 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005258 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005259 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005260 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005261 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005262 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005263 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005264 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005265 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005266 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005267 },
5268
5269 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005270 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005271 .family = MV88E6XXX_FAMILY_6352,
5272 .name = "Marvell 88E6352",
5273 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005274 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005275 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005276 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005277 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005278 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005279 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005280 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005281 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005282 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005283 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005284 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005285 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005286 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005287 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005288 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005289 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005290 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005291 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005292 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005293 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005294 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005295 .family = MV88E6XXX_FAMILY_6390,
5296 .name = "Marvell 88E6390",
5297 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005298 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005299 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005300 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005301 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005302 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005303 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005304 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005305 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005306 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005307 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005308 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005309 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005310 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005311 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005312 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005313 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005314 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005315 .ops = &mv88e6390_ops,
5316 },
5317 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005318 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005319 .family = MV88E6XXX_FAMILY_6390,
5320 .name = "Marvell 88E6390X",
5321 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005322 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005323 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005324 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005325 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005326 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005327 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005328 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005329 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005330 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005331 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005332 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005333 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005334 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005335 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005336 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005337 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005338 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005339 .ops = &mv88e6390x_ops,
5340 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005341};
5342
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005343static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005344{
Vivien Didelota439c062016-04-17 13:23:58 -04005345 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005346
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005347 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5348 if (mv88e6xxx_table[i].prod_num == prod_num)
5349 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005350
Vivien Didelotb9b37712015-10-30 19:39:48 -04005351 return NULL;
5352}
5353
Vivien Didelotfad09c72016-06-21 12:28:20 -04005354static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005355{
5356 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005357 unsigned int prod_num, rev;
5358 u16 id;
5359 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005360
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005361 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005362 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005363 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005364 if (err)
5365 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005366
Vivien Didelot107fcc12017-06-12 12:37:36 -04005367 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5368 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005369
5370 info = mv88e6xxx_lookup_info(prod_num);
5371 if (!info)
5372 return -ENODEV;
5373
Vivien Didelotcaac8542016-06-20 13:14:09 -04005374 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005375 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005376
Vivien Didelotca070c12016-09-02 14:45:34 -04005377 err = mv88e6xxx_g2_require(chip);
5378 if (err)
5379 return err;
5380
Vivien Didelotfad09c72016-06-21 12:28:20 -04005381 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5382 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005383
5384 return 0;
5385}
5386
Vivien Didelotfad09c72016-06-21 12:28:20 -04005387static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005388{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005389 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005390
Vivien Didelotfad09c72016-06-21 12:28:20 -04005391 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5392 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005393 return NULL;
5394
Vivien Didelotfad09c72016-06-21 12:28:20 -04005395 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005396
Vivien Didelotfad09c72016-06-21 12:28:20 -04005397 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005398 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005399 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005400
Vivien Didelotfad09c72016-06-21 12:28:20 -04005401 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005402}
5403
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005404static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005405 int port,
5406 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005407{
Vivien Didelot04bed142016-08-31 18:06:13 -04005408 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005409
Andrew Lunn443d5a12016-12-03 04:35:18 +01005410 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005411}
5412
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005413static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005414 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005415{
5416 /* We don't need any dynamic resource from the kernel (yet),
5417 * so skip the prepare phase.
5418 */
5419
5420 return 0;
5421}
5422
5423static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005424 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005425{
Vivien Didelot04bed142016-08-31 18:06:13 -04005426 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005427
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005428 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005429 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005430 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005431 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5432 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005433 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005434}
5435
5436static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5437 const struct switchdev_obj_port_mdb *mdb)
5438{
Vivien Didelot04bed142016-08-31 18:06:13 -04005439 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005440 int err;
5441
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005442 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005443 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005444 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005445
5446 return err;
5447}
5448
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005449static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5450 struct dsa_mall_mirror_tc_entry *mirror,
5451 bool ingress)
5452{
5453 enum mv88e6xxx_egress_direction direction = ingress ?
5454 MV88E6XXX_EGRESS_DIR_INGRESS :
5455 MV88E6XXX_EGRESS_DIR_EGRESS;
5456 struct mv88e6xxx_chip *chip = ds->priv;
5457 bool other_mirrors = false;
5458 int i;
5459 int err;
5460
5461 if (!chip->info->ops->set_egress_port)
5462 return -EOPNOTSUPP;
5463
5464 mutex_lock(&chip->reg_lock);
5465 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5466 mirror->to_local_port) {
5467 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5468 other_mirrors |= ingress ?
5469 chip->ports[i].mirror_ingress :
5470 chip->ports[i].mirror_egress;
5471
5472 /* Can't change egress port when other mirror is active */
5473 if (other_mirrors) {
5474 err = -EBUSY;
5475 goto out;
5476 }
5477
5478 err = chip->info->ops->set_egress_port(chip,
5479 direction,
5480 mirror->to_local_port);
5481 if (err)
5482 goto out;
5483 }
5484
5485 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5486out:
5487 mutex_unlock(&chip->reg_lock);
5488
5489 return err;
5490}
5491
5492static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5493 struct dsa_mall_mirror_tc_entry *mirror)
5494{
5495 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5496 MV88E6XXX_EGRESS_DIR_INGRESS :
5497 MV88E6XXX_EGRESS_DIR_EGRESS;
5498 struct mv88e6xxx_chip *chip = ds->priv;
5499 bool other_mirrors = false;
5500 int i;
5501
5502 mutex_lock(&chip->reg_lock);
5503 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5504 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5505
5506 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5507 other_mirrors |= mirror->ingress ?
5508 chip->ports[i].mirror_ingress :
5509 chip->ports[i].mirror_egress;
5510
5511 /* Reset egress port when no other mirror is active */
5512 if (!other_mirrors) {
5513 if (chip->info->ops->set_egress_port(chip,
5514 direction,
5515 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005516 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005517 dev_err(ds->dev, "failed to set egress port\n");
5518 }
5519
5520 mutex_unlock(&chip->reg_lock);
5521}
5522
Russell King4f859012019-02-20 15:35:05 -08005523static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5524 bool unicast, bool multicast)
5525{
5526 struct mv88e6xxx_chip *chip = ds->priv;
5527 int err = -EOPNOTSUPP;
5528
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005529 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005530 if (chip->info->ops->port_set_egress_floods)
5531 err = chip->info->ops->port_set_egress_floods(chip, port,
5532 unicast,
5533 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005534 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005535
5536 return err;
5537}
5538
Florian Fainellia82f67a2017-01-08 14:52:08 -08005539static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005540 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005541 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005542 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005543 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005544 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005545 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005546 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005547 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5548 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005549 .get_strings = mv88e6xxx_get_strings,
5550 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5551 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005552 .port_enable = mv88e6xxx_port_enable,
5553 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005554 .port_max_mtu = mv88e6xxx_get_max_mtu,
5555 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005556 .get_mac_eee = mv88e6xxx_get_mac_eee,
5557 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005558 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005559 .get_eeprom = mv88e6xxx_get_eeprom,
5560 .set_eeprom = mv88e6xxx_set_eeprom,
5561 .get_regs_len = mv88e6xxx_get_regs_len,
5562 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005563 .get_rxnfc = mv88e6xxx_get_rxnfc,
5564 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005565 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005566 .port_bridge_join = mv88e6xxx_port_bridge_join,
5567 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005568 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005569 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005570 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005571 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5572 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5573 .port_vlan_add = mv88e6xxx_port_vlan_add,
5574 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005575 .port_fdb_add = mv88e6xxx_port_fdb_add,
5576 .port_fdb_del = mv88e6xxx_port_fdb_del,
5577 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005578 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5579 .port_mdb_add = mv88e6xxx_port_mdb_add,
5580 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005581 .port_mirror_add = mv88e6xxx_port_mirror_add,
5582 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005583 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5584 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005585 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5586 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5587 .port_txtstamp = mv88e6xxx_port_txtstamp,
5588 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5589 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005590 .devlink_param_get = mv88e6xxx_devlink_param_get,
5591 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005592};
5593
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005594static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005595{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005596 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005597 struct dsa_switch *ds;
5598
Vivien Didelot7e99e342019-10-21 16:51:30 -04005599 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005600 if (!ds)
5601 return -ENOMEM;
5602
Vivien Didelot7e99e342019-10-21 16:51:30 -04005603 ds->dev = dev;
5604 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005605 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005606 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005607 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005608 ds->ageing_time_min = chip->info->age_time_coeff;
5609 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005610
5611 dev_set_drvdata(dev, ds);
5612
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005613 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005614}
5615
Vivien Didelotfad09c72016-06-21 12:28:20 -04005616static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005617{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005618 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005619}
5620
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005621static const void *pdata_device_get_match_data(struct device *dev)
5622{
5623 const struct of_device_id *matches = dev->driver->of_match_table;
5624 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5625
5626 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5627 matches++) {
5628 if (!strcmp(pdata->compatible, matches->compatible))
5629 return matches->data;
5630 }
5631 return NULL;
5632}
5633
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005634/* There is no suspend to RAM support at DSA level yet, the switch configuration
5635 * would be lost after a power cycle so prevent it to be suspended.
5636 */
5637static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5638{
5639 return -EOPNOTSUPP;
5640}
5641
5642static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5643{
5644 return 0;
5645}
5646
5647static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5648
Vivien Didelot57d32312016-06-20 13:13:58 -04005649static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005650{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005651 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005652 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005653 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005654 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005655 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005656 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005657 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005658
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005659 if (!np && !pdata)
5660 return -EINVAL;
5661
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005662 if (np)
5663 compat_info = of_device_get_match_data(dev);
5664
5665 if (pdata) {
5666 compat_info = pdata_device_get_match_data(dev);
5667
5668 if (!pdata->netdev)
5669 return -EINVAL;
5670
5671 for (port = 0; port < DSA_MAX_PORTS; port++) {
5672 if (!(pdata->enabled_ports & (1 << port)))
5673 continue;
5674 if (strcmp(pdata->cd.port_names[port], "cpu"))
5675 continue;
5676 pdata->cd.netdev[port] = &pdata->netdev->dev;
5677 break;
5678 }
5679 }
5680
Vivien Didelotcaac8542016-06-20 13:14:09 -04005681 if (!compat_info)
5682 return -EINVAL;
5683
Vivien Didelotfad09c72016-06-21 12:28:20 -04005684 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005685 if (!chip) {
5686 err = -ENOMEM;
5687 goto out;
5688 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005689
Vivien Didelotfad09c72016-06-21 12:28:20 -04005690 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005691
Vivien Didelotfad09c72016-06-21 12:28:20 -04005692 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005693 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005694 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005695
Andrew Lunnb4308f02016-11-21 23:26:55 +01005696 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005697 if (IS_ERR(chip->reset)) {
5698 err = PTR_ERR(chip->reset);
5699 goto out;
5700 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005701 if (chip->reset)
5702 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005703
Vivien Didelotfad09c72016-06-21 12:28:20 -04005704 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005705 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005706 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005707
Vivien Didelote57e5e72016-08-15 17:19:00 -04005708 mv88e6xxx_phy_init(chip);
5709
Andrew Lunn00baabe2018-05-19 22:31:35 +02005710 if (chip->info->ops->get_eeprom) {
5711 if (np)
5712 of_property_read_u32(np, "eeprom-length",
5713 &chip->eeprom_len);
5714 else
5715 chip->eeprom_len = pdata->eeprom_len;
5716 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005717
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005718 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005719 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005720 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005721 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005722 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005723
Andrew Lunna27415d2019-05-01 00:10:50 +02005724 if (np) {
5725 chip->irq = of_irq_get(np, 0);
5726 if (chip->irq == -EPROBE_DEFER) {
5727 err = chip->irq;
5728 goto out;
5729 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005730 }
5731
Andrew Lunna27415d2019-05-01 00:10:50 +02005732 if (pdata)
5733 chip->irq = pdata->irq;
5734
Andrew Lunn294d7112018-02-22 22:58:32 +01005735 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005736 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005737 * controllers
5738 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005739 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005740 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005741 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005742 else
5743 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005744 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005745
Andrew Lunn294d7112018-02-22 22:58:32 +01005746 if (err)
5747 goto out;
5748
5749 if (chip->info->g2_irqs > 0) {
5750 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005751 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005752 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005753 }
5754
Andrew Lunn294d7112018-02-22 22:58:32 +01005755 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5756 if (err)
5757 goto out_g2_irq;
5758
5759 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5760 if (err)
5761 goto out_g1_atu_prob_irq;
5762
Andrew Lunna3c53be52017-01-24 14:53:50 +01005763 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005764 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005765 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005766
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005767 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005768 if (err)
5769 goto out_mdio;
5770
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005771 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005772
5773out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005774 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005775out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005776 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005777out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005778 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005779out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005780 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005781 mv88e6xxx_g2_irq_free(chip);
5782out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005783 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005784 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005785 else
5786 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005787out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005788 if (pdata)
5789 dev_put(pdata->netdev);
5790
Andrew Lunndc30c352016-10-16 19:56:49 +02005791 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005792}
5793
5794static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5795{
5796 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005797 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005798
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005799 if (chip->info->ptp_support) {
5800 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005801 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005802 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005803
Andrew Lunn930188c2016-08-22 16:01:03 +02005804 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005805 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005806 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005807
Andrew Lunn76f38f12018-03-17 20:21:09 +01005808 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5809 mv88e6xxx_g1_atu_prob_irq_free(chip);
5810
5811 if (chip->info->g2_irqs > 0)
5812 mv88e6xxx_g2_irq_free(chip);
5813
Andrew Lunn76f38f12018-03-17 20:21:09 +01005814 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005815 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005816 else
5817 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005818}
5819
5820static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005821 {
5822 .compatible = "marvell,mv88e6085",
5823 .data = &mv88e6xxx_table[MV88E6085],
5824 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005825 {
5826 .compatible = "marvell,mv88e6190",
5827 .data = &mv88e6xxx_table[MV88E6190],
5828 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005829 {
5830 .compatible = "marvell,mv88e6250",
5831 .data = &mv88e6xxx_table[MV88E6250],
5832 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005833 { /* sentinel */ },
5834};
5835
5836MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5837
5838static struct mdio_driver mv88e6xxx_driver = {
5839 .probe = mv88e6xxx_probe,
5840 .remove = mv88e6xxx_remove,
5841 .mdiodrv.driver = {
5842 .name = "mv88e6085",
5843 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005844 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005845 },
5846};
5847
Andrew Lunn7324d502019-04-27 19:19:10 +02005848mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005849
5850MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5851MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5852MODULE_LICENSE("GPL");