blob: fee16c947c2e8ba723808944c59b1cbc79d22233 [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 Kingfad58192020-07-19 12:00:35 +0100667 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000668 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700669
Russell Kingfad58192020-07-19 12:00:35 +0100670 p = &chip->ports[port];
671
Russell King64d47d52020-03-14 10:15:38 +0000672 /* FIXME: is this the correct test? If we're in fixed mode on an
673 * internal port, why should we process this any different from
674 * PHY mode? On the other hand, the port may be automedia between
675 * an internal PHY and the serdes...
676 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200677 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700678 return;
679
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000680 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100681 /* In inband mode, the link may come up at any time while the link
682 * is not forced down. Force the link down while we reconfigure the
683 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000684 */
Russell Kingfad58192020-07-19 12:00:35 +0100685 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
686 chip->info->ops->port_set_link)
687 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
688
Russell King64d47d52020-03-14 10:15:38 +0000689 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000690 if (err && err != -EOPNOTSUPP)
691 goto err_unlock;
692
693 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
694 state->advertising);
695 /* FIXME: we should restart negotiation if something changed - which
696 * is something we get if we convert to using phylinks PCS operations.
697 */
698 if (err > 0)
699 err = 0;
700
Russell Kingfad58192020-07-19 12:00:35 +0100701 /* Undo the forced down state above after completing configuration
702 * irrespective of its state on entry, which allows the link to come up.
703 */
704 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
705 chip->info->ops->port_set_link)
706 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
707
708 p->interface = state->interface;
709
Russell Kinga5a68582020-03-14 10:15:43 +0000710err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000711 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700712
713 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000714 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700715}
716
Russell Kingc9a23562018-05-10 13:17:35 -0700717static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
718 unsigned int mode,
719 phy_interface_t interface)
720{
Russell King30c4a5b2020-02-26 10:23:51 +0000721 struct mv88e6xxx_chip *chip = ds->priv;
722 const struct mv88e6xxx_ops *ops;
723 int err = 0;
724
725 ops = chip->info->ops;
726
Russell King5d5b2312020-03-14 10:16:03 +0000727 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200728 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
729 mode == MLO_AN_FIXED) && ops->port_set_link)
Russell King30c4a5b2020-02-26 10:23:51 +0000730 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Russell King5d5b2312020-03-14 10:16:03 +0000731 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000732
Russell King5d5b2312020-03-14 10:16:03 +0000733 if (err)
734 dev_err(chip->dev,
735 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700736}
737
738static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
739 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000740 struct phy_device *phydev,
741 int speed, int duplex,
742 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700743{
Russell King30c4a5b2020-02-26 10:23:51 +0000744 struct mv88e6xxx_chip *chip = ds->priv;
745 const struct mv88e6xxx_ops *ops;
746 int err = 0;
747
748 ops = chip->info->ops;
749
Russell King5d5b2312020-03-14 10:16:03 +0000750 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200751 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000752 /* FIXME: for an automedia port, should we force the link
753 * down here - what if the link comes up due to "other" media
754 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000755 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000756 * shared between internal PHY and Serdes.
757 */
Russell Kinga5a68582020-03-14 10:15:43 +0000758 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
759 duplex);
760 if (err)
761 goto error;
762
Russell Kingf365c6f2020-03-14 10:15:53 +0000763 if (ops->port_set_speed_duplex) {
764 err = ops->port_set_speed_duplex(chip, port,
765 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000766 if (err && err != -EOPNOTSUPP)
767 goto error;
768 }
769
770 if (ops->port_set_link)
771 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
Russell King30c4a5b2020-02-26 10:23:51 +0000772 }
Russell King5d5b2312020-03-14 10:16:03 +0000773error:
774 mv88e6xxx_reg_unlock(chip);
775
776 if (err && err != -EOPNOTSUPP)
777 dev_err(ds->dev,
778 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700779}
780
Andrew Lunna605a0f2016-11-21 23:26:58 +0100781static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100783 if (!chip->info->ops->stats_snapshot)
784 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000785
Andrew Lunna605a0f2016-11-21 23:26:58 +0100786 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000787}
788
Andrew Lunne413e7e2015-04-02 04:06:38 +0200789static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100790 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
791 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
792 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
793 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
794 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
795 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
796 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
797 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
798 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
799 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
800 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
801 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
802 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
803 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
804 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
805 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
806 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
807 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
808 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
809 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
810 { "single", 4, 0x14, STATS_TYPE_BANK0, },
811 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
812 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
813 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
814 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
815 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
816 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
817 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
818 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
819 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
820 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
821 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
822 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
823 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
824 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
825 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
826 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
827 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
828 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
829 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
830 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
831 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
832 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
833 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
834 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
835 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
836 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
837 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
838 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
839 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
840 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
841 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
842 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
843 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
844 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
845 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
846 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
847 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
848 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200849};
850
Vivien Didelotfad09c72016-06-21 12:28:20 -0400851static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100852 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100853 int port, u16 bank1_select,
854 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200855{
Andrew Lunn80c46272015-06-20 18:42:30 +0200856 u32 low;
857 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100858 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200859 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200860 u64 value;
861
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100862 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100863 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200864 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
865 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800866 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200867
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200868 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100869 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200870 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
871 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800872 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000873 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200874 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100875 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100876 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100877 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100878 /* fall through */
879 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100880 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100881 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100882 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100883 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500884 break;
885 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800886 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200887 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100888 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200889 return value;
890}
891
Andrew Lunn436fe172018-03-01 02:02:29 +0100892static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
893 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100894{
895 struct mv88e6xxx_hw_stat *stat;
896 int i, j;
897
898 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
899 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100900 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100901 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
902 ETH_GSTRING_LEN);
903 j++;
904 }
905 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100906
907 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100908}
909
Andrew Lunn436fe172018-03-01 02:02:29 +0100910static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
911 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100912{
Andrew Lunn436fe172018-03-01 02:02:29 +0100913 return mv88e6xxx_stats_get_strings(chip, data,
914 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100915}
916
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000917static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
918 uint8_t *data)
919{
920 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
921}
922
Andrew Lunn436fe172018-03-01 02:02:29 +0100923static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
924 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100925{
Andrew Lunn436fe172018-03-01 02:02:29 +0100926 return mv88e6xxx_stats_get_strings(chip, data,
927 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100928}
929
Andrew Lunn65f60e42018-03-28 23:50:28 +0200930static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
931 "atu_member_violation",
932 "atu_miss_violation",
933 "atu_full_violation",
934 "vtu_member_violation",
935 "vtu_miss_violation",
936};
937
938static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
939{
940 unsigned int i;
941
942 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
943 strlcpy(data + i * ETH_GSTRING_LEN,
944 mv88e6xxx_atu_vtu_stats_strings[i],
945 ETH_GSTRING_LEN);
946}
947
Andrew Lunndfafe442016-11-21 23:27:02 +0100948static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700949 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100950{
Vivien Didelot04bed142016-08-31 18:06:13 -0400951 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100952 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100953
Florian Fainelli89f09042018-04-25 12:12:50 -0700954 if (stringset != ETH_SS_STATS)
955 return;
956
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000957 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100958
Andrew Lunndfafe442016-11-21 23:27:02 +0100959 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100960 count = chip->info->ops->stats_get_strings(chip, data);
961
962 if (chip->info->ops->serdes_get_strings) {
963 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200964 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100965 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100966
Andrew Lunn65f60e42018-03-28 23:50:28 +0200967 data += count * ETH_GSTRING_LEN;
968 mv88e6xxx_atu_vtu_get_strings(data);
969
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000970 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100971}
972
973static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
974 int types)
975{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100976 struct mv88e6xxx_hw_stat *stat;
977 int i, j;
978
979 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
980 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100981 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100982 j++;
983 }
984 return j;
985}
986
Andrew Lunndfafe442016-11-21 23:27:02 +0100987static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
988{
989 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
990 STATS_TYPE_PORT);
991}
992
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000993static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
994{
995 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
996}
997
Andrew Lunndfafe442016-11-21 23:27:02 +0100998static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
999{
1000 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1001 STATS_TYPE_BANK1);
1002}
1003
Florian Fainelli89f09042018-04-25 12:12:50 -07001004static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001005{
1006 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 int serdes_count = 0;
1008 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001009
Florian Fainelli89f09042018-04-25 12:12:50 -07001010 if (sset != ETH_SS_STATS)
1011 return 0;
1012
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001013 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001014 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001015 count = chip->info->ops->stats_get_sset_count(chip);
1016 if (count < 0)
1017 goto out;
1018
1019 if (chip->info->ops->serdes_get_sset_count)
1020 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1021 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001022 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001023 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001024 goto out;
1025 }
1026 count += serdes_count;
1027 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1028
Andrew Lunn436fe172018-03-01 02:02:29 +01001029out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001030 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001031
Andrew Lunn436fe172018-03-01 02:02:29 +01001032 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001033}
1034
Andrew Lunn436fe172018-03-01 02:02:29 +01001035static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1036 uint64_t *data, int types,
1037 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001038{
1039 struct mv88e6xxx_hw_stat *stat;
1040 int i, j;
1041
1042 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1043 stat = &mv88e6xxx_hw_stats[i];
1044 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001045 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001046 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1047 bank1_select,
1048 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001049 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001050
Andrew Lunn052f9472016-11-21 23:27:03 +01001051 j++;
1052 }
1053 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001054 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001055}
1056
Andrew Lunn436fe172018-03-01 02:02:29 +01001057static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1058 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001059{
1060 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001061 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001062 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001063}
1064
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001065static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
1067{
1068 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1069 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1070}
1071
Andrew Lunn436fe172018-03-01 02:02:29 +01001072static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1073 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001074{
1075 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001076 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001077 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1078 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001079}
1080
Andrew Lunn436fe172018-03-01 02:02:29 +01001081static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1082 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001083{
1084 return mv88e6xxx_stats_get_stats(chip, port, data,
1085 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001086 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1087 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001088}
1089
Andrew Lunn65f60e42018-03-28 23:50:28 +02001090static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1091 uint64_t *data)
1092{
1093 *data++ = chip->ports[port].atu_member_violation;
1094 *data++ = chip->ports[port].atu_miss_violation;
1095 *data++ = chip->ports[port].atu_full_violation;
1096 *data++ = chip->ports[port].vtu_member_violation;
1097 *data++ = chip->ports[port].vtu_miss_violation;
1098}
1099
Andrew Lunn052f9472016-11-21 23:27:03 +01001100static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1101 uint64_t *data)
1102{
Andrew Lunn436fe172018-03-01 02:02:29 +01001103 int count = 0;
1104
Andrew Lunn052f9472016-11-21 23:27:03 +01001105 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001106 count = chip->info->ops->stats_get_stats(chip, port, data);
1107
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001108 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001109 if (chip->info->ops->serdes_get_stats) {
1110 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001111 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001112 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001113 data += count;
1114 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001115 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001116}
1117
Vivien Didelotf81ec902016-05-09 13:22:58 -04001118static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1119 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001120{
Vivien Didelot04bed142016-08-31 18:06:13 -04001121 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001122 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001124 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001125
Andrew Lunna605a0f2016-11-21 23:26:58 +01001126 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001127 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001128
1129 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001130 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001131
1132 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001133
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001134}
Ben Hutchings98e67302011-11-25 14:36:19 +00001135
Vivien Didelotf81ec902016-05-09 13:22:58 -04001136static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001137{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001138 struct mv88e6xxx_chip *chip = ds->priv;
1139 int len;
1140
1141 len = 32 * sizeof(u16);
1142 if (chip->info->ops->serdes_get_regs_len)
1143 len += chip->info->ops->serdes_get_regs_len(chip, port);
1144
1145 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001146}
1147
Vivien Didelotf81ec902016-05-09 13:22:58 -04001148static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1149 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001150{
Vivien Didelot04bed142016-08-31 18:06:13 -04001151 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001152 int err;
1153 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001154 u16 *p = _p;
1155 int i;
1156
Vivien Didelota5f39322018-12-17 16:05:21 -05001157 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001158
1159 memset(p, 0xff, 32 * sizeof(u16));
1160
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001161 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001162
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001163 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001164
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001165 err = mv88e6xxx_port_read(chip, port, i, &reg);
1166 if (!err)
1167 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001168 }
Vivien Didelot23062512016-05-09 13:22:45 -04001169
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001170 if (chip->info->ops->serdes_get_regs)
1171 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1172
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001173 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001174}
1175
Vivien Didelot08f50062017-08-01 16:32:41 -04001176static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1177 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001178{
Vivien Didelot5480db62017-08-01 16:32:40 -04001179 /* Nothing to do on the port's MAC */
1180 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001181}
1182
Vivien Didelot08f50062017-08-01 16:32:41 -04001183static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1184 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001185{
Vivien Didelot5480db62017-08-01 16:32:40 -04001186 /* Nothing to do on the port's MAC */
1187 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001188}
1189
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001190/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001191static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001192{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001193 struct dsa_switch *ds = chip->ds;
1194 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001195 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001196 struct dsa_port *dp;
1197 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001198 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001199
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001200 list_for_each_entry(dp, &dst->ports, list) {
1201 if (dp->ds->index == dev && dp->index == port) {
1202 found = true;
1203 break;
1204 }
1205 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001206
Vivien Didelote5887a22017-03-30 17:37:11 -04001207 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001208 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001209 return 0;
1210
1211 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001212 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001213 return mv88e6xxx_port_mask(chip);
1214
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001215 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001216 pvlan = 0;
1217
1218 /* Frames from user ports can egress any local DSA links and CPU ports,
1219 * as well as any local member of their bridge group.
1220 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001221 list_for_each_entry(dp, &dst->ports, list)
1222 if (dp->ds == ds &&
1223 (dp->type == DSA_PORT_TYPE_CPU ||
1224 dp->type == DSA_PORT_TYPE_DSA ||
1225 (br && dp->bridge_dev == br)))
1226 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001227
1228 return pvlan;
1229}
1230
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001231static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001232{
1233 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001234
1235 /* prevent frames from going back out of the port they came in on */
1236 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001237
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001238 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001239}
1240
Vivien Didelotf81ec902016-05-09 13:22:58 -04001241static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1242 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001243{
Vivien Didelot04bed142016-08-31 18:06:13 -04001244 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001245 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001246
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001247 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001248 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001249 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001250
1251 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001252 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001253}
1254
Vivien Didelot93e18d62018-05-11 17:16:35 -04001255static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1256{
1257 int err;
1258
1259 if (chip->info->ops->ieee_pri_map) {
1260 err = chip->info->ops->ieee_pri_map(chip);
1261 if (err)
1262 return err;
1263 }
1264
1265 if (chip->info->ops->ip_pri_map) {
1266 err = chip->info->ops->ip_pri_map(chip);
1267 if (err)
1268 return err;
1269 }
1270
1271 return 0;
1272}
1273
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001274static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1275{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001276 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001277 int target, port;
1278 int err;
1279
1280 if (!chip->info->global2_addr)
1281 return 0;
1282
1283 /* Initialize the routing port to the 32 possible target devices */
1284 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001285 port = dsa_routing_port(ds, target);
1286 if (port == ds->num_ports)
1287 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001288
1289 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1290 if (err)
1291 return err;
1292 }
1293
Vivien Didelot02317e62018-05-09 11:38:49 -04001294 if (chip->info->ops->set_cascade_port) {
1295 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1296 err = chip->info->ops->set_cascade_port(chip, port);
1297 if (err)
1298 return err;
1299 }
1300
Vivien Didelot23c98912018-05-09 11:38:50 -04001301 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1302 if (err)
1303 return err;
1304
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001305 return 0;
1306}
1307
Vivien Didelotb28f8722018-04-26 21:56:44 -04001308static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1309{
1310 /* Clear all trunk masks and mapping */
1311 if (chip->info->global2_addr)
1312 return mv88e6xxx_g2_trunk_clear(chip);
1313
1314 return 0;
1315}
1316
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001317static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1318{
1319 if (chip->info->ops->rmu_disable)
1320 return chip->info->ops->rmu_disable(chip);
1321
1322 return 0;
1323}
1324
Vivien Didelot9e907d72017-07-17 13:03:43 -04001325static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1326{
1327 if (chip->info->ops->pot_clear)
1328 return chip->info->ops->pot_clear(chip);
1329
1330 return 0;
1331}
1332
Vivien Didelot51c901a2017-07-17 13:03:41 -04001333static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1334{
1335 if (chip->info->ops->mgmt_rsvd2cpu)
1336 return chip->info->ops->mgmt_rsvd2cpu(chip);
1337
1338 return 0;
1339}
1340
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001341static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1342{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001343 int err;
1344
Vivien Didelotdaefc942017-03-11 16:12:54 -05001345 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1346 if (err)
1347 return err;
1348
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001349 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1350 if (err)
1351 return err;
1352
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001353 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1354}
1355
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001356static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1357{
1358 int port;
1359 int err;
1360
1361 if (!chip->info->ops->irl_init_all)
1362 return 0;
1363
1364 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1365 /* Disable ingress rate limiting by resetting all per port
1366 * ingress rate limit resources to their initial state.
1367 */
1368 err = chip->info->ops->irl_init_all(chip, port);
1369 if (err)
1370 return err;
1371 }
1372
1373 return 0;
1374}
1375
Vivien Didelot04a69a12017-10-13 14:18:05 -04001376static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1377{
1378 if (chip->info->ops->set_switch_mac) {
1379 u8 addr[ETH_ALEN];
1380
1381 eth_random_addr(addr);
1382
1383 return chip->info->ops->set_switch_mac(chip, addr);
1384 }
1385
1386 return 0;
1387}
1388
Vivien Didelot17a15942017-03-30 17:37:09 -04001389static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1390{
1391 u16 pvlan = 0;
1392
1393 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001394 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001395
1396 /* Skip the local source device, which uses in-chip port VLAN */
1397 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001398 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001399
1400 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1401}
1402
Vivien Didelot81228992017-03-30 17:37:08 -04001403static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1404{
Vivien Didelot17a15942017-03-30 17:37:09 -04001405 int dev, port;
1406 int err;
1407
Vivien Didelot81228992017-03-30 17:37:08 -04001408 if (!mv88e6xxx_has_pvt(chip))
1409 return 0;
1410
1411 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1412 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1413 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001414 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1415 if (err)
1416 return err;
1417
1418 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1419 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1420 err = mv88e6xxx_pvt_map(chip, dev, port);
1421 if (err)
1422 return err;
1423 }
1424 }
1425
1426 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001427}
1428
Vivien Didelot749efcb2016-09-22 16:49:24 -04001429static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1430{
1431 struct mv88e6xxx_chip *chip = ds->priv;
1432 int err;
1433
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001434 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001435 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001436 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001437
1438 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001439 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001440}
1441
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001442static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1443{
1444 if (!chip->info->max_vid)
1445 return 0;
1446
1447 return mv88e6xxx_g1_vtu_flush(chip);
1448}
1449
Vivien Didelotf1394b782017-05-01 14:05:22 -04001450static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1451 struct mv88e6xxx_vtu_entry *entry)
1452{
1453 if (!chip->info->ops->vtu_getnext)
1454 return -EOPNOTSUPP;
1455
1456 return chip->info->ops->vtu_getnext(chip, entry);
1457}
1458
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001459static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1460 struct mv88e6xxx_vtu_entry *entry)
1461{
1462 if (!chip->info->ops->vtu_loadpurge)
1463 return -EOPNOTSUPP;
1464
1465 return chip->info->ops->vtu_loadpurge(chip, entry);
1466}
1467
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001468static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001469{
1470 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001471 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001472 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001473
1474 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1475
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001476 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001477 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001478 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001479 if (err)
1480 return err;
1481
1482 set_bit(*fid, fid_bitmap);
1483 }
1484
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001485 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001486 vlan.vid = chip->info->max_vid;
1487 vlan.valid = false;
1488
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001489 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001490 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001491 if (err)
1492 return err;
1493
1494 if (!vlan.valid)
1495 break;
1496
1497 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001498 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001499
1500 /* The reset value 0x000 is used to indicate that multiple address
1501 * databases are not needed. Return the next positive available.
1502 */
1503 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001504 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001505 return -ENOSPC;
1506
1507 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001508 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001509}
1510
Andrew Lunn23e8b472019-10-25 01:03:52 +02001511static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1512{
1513 if (chip->info->ops->atu_get_hash)
1514 return chip->info->ops->atu_get_hash(chip, hash);
1515
1516 return -EOPNOTSUPP;
1517}
1518
1519static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1520{
1521 if (chip->info->ops->atu_set_hash)
1522 return chip->info->ops->atu_set_hash(chip, hash);
1523
1524 return -EOPNOTSUPP;
1525}
1526
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1528 u16 vid_begin, u16 vid_end)
1529{
Vivien Didelot04bed142016-08-31 18:06:13 -04001530 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001531 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001532 int i, err;
1533
Andrew Lunndb06ae412017-09-25 23:32:20 +02001534 /* DSA and CPU ports have to be members of multiple vlans */
1535 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1536 return 0;
1537
Vivien Didelotda9c3592016-02-12 12:09:40 -05001538 if (!vid_begin)
1539 return -EOPNOTSUPP;
1540
Vivien Didelot425d2d32019-08-01 14:36:34 -04001541 vlan.vid = vid_begin - 1;
1542 vlan.valid = false;
1543
Vivien Didelotda9c3592016-02-12 12:09:40 -05001544 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001545 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001546 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001547 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001548
1549 if (!vlan.valid)
1550 break;
1551
1552 if (vlan.vid > vid_end)
1553 break;
1554
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001555 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001556 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1557 continue;
1558
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001559 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001560 continue;
1561
Vivien Didelotbd00e052017-05-01 14:05:11 -04001562 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001563 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001564 continue;
1565
Vivien Didelotc8652c82017-10-16 11:12:19 -04001566 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001567 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001568 break; /* same bridge, check next VLAN */
1569
Vivien Didelotc8652c82017-10-16 11:12:19 -04001570 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001571 continue;
1572
Andrew Lunn743fcc22017-11-09 22:29:54 +01001573 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1574 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001575 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001576 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001577 }
1578 } while (vlan.vid < vid_end);
1579
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001580 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001581}
1582
Vivien Didelotf81ec902016-05-09 13:22:58 -04001583static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1584 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001585{
Vivien Didelot04bed142016-08-31 18:06:13 -04001586 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001587 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1588 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001589 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001590
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001591 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001592 return -EOPNOTSUPP;
1593
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001594 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001595 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001596 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001597
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001598 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001599}
1600
Vivien Didelot57d32312016-06-20 13:13:58 -04001601static int
1602mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001603 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001604{
Vivien Didelot04bed142016-08-31 18:06:13 -04001605 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001606 int err;
1607
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001608 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001609 return -EOPNOTSUPP;
1610
Vivien Didelotda9c3592016-02-12 12:09:40 -05001611 /* If the requested port doesn't belong to the same bridge as the VLAN
1612 * members, do not support it (yet) and fallback to software VLAN.
1613 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001614 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001615 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1616 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001617 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001618
Vivien Didelot76e398a2015-11-01 12:33:55 -05001619 /* We don't need any dynamic resource from the kernel (yet),
1620 * so skip the prepare phase.
1621 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001622 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001623}
1624
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001625static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1626 const unsigned char *addr, u16 vid,
1627 u8 state)
1628{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001629 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001630 struct mv88e6xxx_vtu_entry vlan;
1631 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001632 int err;
1633
1634 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001635 if (vid == 0) {
1636 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1637 if (err)
1638 return err;
1639 } else {
1640 vlan.vid = vid - 1;
1641 vlan.valid = false;
1642
1643 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1644 if (err)
1645 return err;
1646
1647 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1648 if (vlan.vid != vid || !vlan.valid)
1649 return -EOPNOTSUPP;
1650
1651 fid = vlan.fid;
1652 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001653
Vivien Didelotd8291a92019-09-07 16:00:47 -04001654 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001655 ether_addr_copy(entry.mac, addr);
1656 eth_addr_dec(entry.mac);
1657
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001658 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001659 if (err)
1660 return err;
1661
1662 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001663 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001664 memset(&entry, 0, sizeof(entry));
1665 ether_addr_copy(entry.mac, addr);
1666 }
1667
1668 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001669 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001670 entry.portvec &= ~BIT(port);
1671 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001672 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001673 } else {
1674 entry.portvec |= BIT(port);
1675 entry.state = state;
1676 }
1677
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001678 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001679}
1680
Vivien Didelotda7dc872019-09-07 16:00:49 -04001681static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1682 const struct mv88e6xxx_policy *policy)
1683{
1684 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1685 enum mv88e6xxx_policy_action action = policy->action;
1686 const u8 *addr = policy->addr;
1687 u16 vid = policy->vid;
1688 u8 state;
1689 int err;
1690 int id;
1691
1692 if (!chip->info->ops->port_set_policy)
1693 return -EOPNOTSUPP;
1694
1695 switch (mapping) {
1696 case MV88E6XXX_POLICY_MAPPING_DA:
1697 case MV88E6XXX_POLICY_MAPPING_SA:
1698 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1699 state = 0; /* Dissociate the port and address */
1700 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1701 is_multicast_ether_addr(addr))
1702 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1703 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1704 is_unicast_ether_addr(addr))
1705 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1706 else
1707 return -EOPNOTSUPP;
1708
1709 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1710 state);
1711 if (err)
1712 return err;
1713 break;
1714 default:
1715 return -EOPNOTSUPP;
1716 }
1717
1718 /* Skip the port's policy clearing if the mapping is still in use */
1719 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1720 idr_for_each_entry(&chip->policies, policy, id)
1721 if (policy->port == port &&
1722 policy->mapping == mapping &&
1723 policy->action != action)
1724 return 0;
1725
1726 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1727}
1728
1729static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1730 struct ethtool_rx_flow_spec *fs)
1731{
1732 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1733 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1734 enum mv88e6xxx_policy_mapping mapping;
1735 enum mv88e6xxx_policy_action action;
1736 struct mv88e6xxx_policy *policy;
1737 u16 vid = 0;
1738 u8 *addr;
1739 int err;
1740 int id;
1741
1742 if (fs->location != RX_CLS_LOC_ANY)
1743 return -EINVAL;
1744
1745 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1746 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1747 else
1748 return -EOPNOTSUPP;
1749
1750 switch (fs->flow_type & ~FLOW_EXT) {
1751 case ETHER_FLOW:
1752 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1753 is_zero_ether_addr(mac_mask->h_source)) {
1754 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1755 addr = mac_entry->h_dest;
1756 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1757 !is_zero_ether_addr(mac_mask->h_source)) {
1758 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1759 addr = mac_entry->h_source;
1760 } else {
1761 /* Cannot support DA and SA mapping in the same rule */
1762 return -EOPNOTSUPP;
1763 }
1764 break;
1765 default:
1766 return -EOPNOTSUPP;
1767 }
1768
1769 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1770 if (fs->m_ext.vlan_tci != 0xffff)
1771 return -EOPNOTSUPP;
1772 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1773 }
1774
1775 idr_for_each_entry(&chip->policies, policy, id) {
1776 if (policy->port == port && policy->mapping == mapping &&
1777 policy->action == action && policy->vid == vid &&
1778 ether_addr_equal(policy->addr, addr))
1779 return -EEXIST;
1780 }
1781
1782 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1783 if (!policy)
1784 return -ENOMEM;
1785
1786 fs->location = 0;
1787 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1788 GFP_KERNEL);
1789 if (err) {
1790 devm_kfree(chip->dev, policy);
1791 return err;
1792 }
1793
1794 memcpy(&policy->fs, fs, sizeof(*fs));
1795 ether_addr_copy(policy->addr, addr);
1796 policy->mapping = mapping;
1797 policy->action = action;
1798 policy->port = port;
1799 policy->vid = vid;
1800
1801 err = mv88e6xxx_policy_apply(chip, port, policy);
1802 if (err) {
1803 idr_remove(&chip->policies, fs->location);
1804 devm_kfree(chip->dev, policy);
1805 return err;
1806 }
1807
1808 return 0;
1809}
1810
1811static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1812 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1813{
1814 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1815 struct mv88e6xxx_chip *chip = ds->priv;
1816 struct mv88e6xxx_policy *policy;
1817 int err;
1818 int id;
1819
1820 mv88e6xxx_reg_lock(chip);
1821
1822 switch (rxnfc->cmd) {
1823 case ETHTOOL_GRXCLSRLCNT:
1824 rxnfc->data = 0;
1825 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1826 rxnfc->rule_cnt = 0;
1827 idr_for_each_entry(&chip->policies, policy, id)
1828 if (policy->port == port)
1829 rxnfc->rule_cnt++;
1830 err = 0;
1831 break;
1832 case ETHTOOL_GRXCLSRULE:
1833 err = -ENOENT;
1834 policy = idr_find(&chip->policies, fs->location);
1835 if (policy) {
1836 memcpy(fs, &policy->fs, sizeof(*fs));
1837 err = 0;
1838 }
1839 break;
1840 case ETHTOOL_GRXCLSRLALL:
1841 rxnfc->data = 0;
1842 rxnfc->rule_cnt = 0;
1843 idr_for_each_entry(&chip->policies, policy, id)
1844 if (policy->port == port)
1845 rule_locs[rxnfc->rule_cnt++] = id;
1846 err = 0;
1847 break;
1848 default:
1849 err = -EOPNOTSUPP;
1850 break;
1851 }
1852
1853 mv88e6xxx_reg_unlock(chip);
1854
1855 return err;
1856}
1857
1858static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1859 struct ethtool_rxnfc *rxnfc)
1860{
1861 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1862 struct mv88e6xxx_chip *chip = ds->priv;
1863 struct mv88e6xxx_policy *policy;
1864 int err;
1865
1866 mv88e6xxx_reg_lock(chip);
1867
1868 switch (rxnfc->cmd) {
1869 case ETHTOOL_SRXCLSRLINS:
1870 err = mv88e6xxx_policy_insert(chip, port, fs);
1871 break;
1872 case ETHTOOL_SRXCLSRLDEL:
1873 err = -ENOENT;
1874 policy = idr_remove(&chip->policies, fs->location);
1875 if (policy) {
1876 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1877 err = mv88e6xxx_policy_apply(chip, port, policy);
1878 devm_kfree(chip->dev, policy);
1879 }
1880 break;
1881 default:
1882 err = -EOPNOTSUPP;
1883 break;
1884 }
1885
1886 mv88e6xxx_reg_unlock(chip);
1887
1888 return err;
1889}
1890
Andrew Lunn87fa8862017-11-09 22:29:56 +01001891static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1892 u16 vid)
1893{
1894 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1895 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1896
1897 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1898}
1899
1900static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1901{
1902 int port;
1903 int err;
1904
1905 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1906 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1907 if (err)
1908 return err;
1909 }
1910
1911 return 0;
1912}
1913
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001914static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001915 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001916{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001917 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001918 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001919 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001920
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001921 if (!vid)
1922 return -EOPNOTSUPP;
1923
1924 vlan.vid = vid - 1;
1925 vlan.valid = false;
1926
1927 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001928 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001929 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001930
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001931 if (vlan.vid != vid || !vlan.valid) {
1932 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001933
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001934 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1935 if (err)
1936 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001937
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001938 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1939 if (i == port)
1940 vlan.member[i] = member;
1941 else
1942 vlan.member[i] = non_member;
1943
1944 vlan.vid = vid;
1945 vlan.valid = true;
1946
1947 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1948 if (err)
1949 return err;
1950
1951 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1952 if (err)
1953 return err;
1954 } else if (vlan.member[port] != member) {
1955 vlan.member[port] = member;
1956
1957 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1958 if (err)
1959 return err;
Russell King933b4422020-02-26 17:14:26 +00001960 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001961 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1962 port, vid);
1963 }
1964
1965 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001966}
1967
Vivien Didelotf81ec902016-05-09 13:22:58 -04001968static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001969 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001970{
Vivien Didelot04bed142016-08-31 18:06:13 -04001971 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001972 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1973 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001974 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001975 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001976 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001977
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001978 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001979 return;
1980
Vivien Didelotc91498e2017-06-07 18:12:13 -04001981 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001982 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001983 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001984 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001985 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001986 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001987
Russell King933b4422020-02-26 17:14:26 +00001988 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1989 * and then the CPU port. Do not warn for duplicates for the CPU port.
1990 */
1991 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1992
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001993 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001994
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001995 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001996 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001997 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1998 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001999
Vivien Didelot77064f32016-11-04 03:23:30 +01002000 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04002001 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
2002 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002003
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002004 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002005}
2006
Vivien Didelot521098922019-08-01 14:36:36 -04002007static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2008 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002009{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002010 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002011 int i, err;
2012
Vivien Didelot521098922019-08-01 14:36:36 -04002013 if (!vid)
2014 return -EOPNOTSUPP;
2015
2016 vlan.vid = vid - 1;
2017 vlan.valid = false;
2018
2019 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002020 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002021 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002022
Vivien Didelot521098922019-08-01 14:36:36 -04002023 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2024 * tell switchdev that this VLAN is likely handled in software.
2025 */
2026 if (vlan.vid != vid || !vlan.valid ||
2027 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002028 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002029
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002030 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002031
2032 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002033 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002034 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002035 if (vlan.member[i] !=
2036 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002037 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002038 break;
2039 }
2040 }
2041
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002042 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002043 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002044 return err;
2045
Vivien Didelote606ca32017-03-11 16:12:55 -05002046 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002047}
2048
Vivien Didelotf81ec902016-05-09 13:22:58 -04002049static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2050 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002051{
Vivien Didelot04bed142016-08-31 18:06:13 -04002052 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002053 u16 pvid, vid;
2054 int err = 0;
2055
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002056 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002057 return -EOPNOTSUPP;
2058
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002059 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002060
Vivien Didelot77064f32016-11-04 03:23:30 +01002061 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002062 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002063 goto unlock;
2064
Vivien Didelot76e398a2015-11-01 12:33:55 -05002065 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002066 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002067 if (err)
2068 goto unlock;
2069
2070 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002071 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002072 if (err)
2073 goto unlock;
2074 }
2075 }
2076
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002077unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002078 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002079
2080 return err;
2081}
2082
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002083static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2084 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002085{
Vivien Didelot04bed142016-08-31 18:06:13 -04002086 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002087 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002088
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002089 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002090 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2091 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002092 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002093
2094 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002095}
2096
Vivien Didelotf81ec902016-05-09 13:22:58 -04002097static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002098 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002099{
Vivien Didelot04bed142016-08-31 18:06:13 -04002100 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002101 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002102
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002103 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002104 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002105 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002106
Vivien Didelot83dabd12016-08-31 11:50:04 -04002107 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002108}
2109
Vivien Didelot83dabd12016-08-31 11:50:04 -04002110static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2111 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002112 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002113{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002114 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002115 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002116 int err;
2117
Vivien Didelotd8291a92019-09-07 16:00:47 -04002118 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002119 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002120
2121 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002122 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002123 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002124 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002125
Vivien Didelotd8291a92019-09-07 16:00:47 -04002126 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002127 break;
2128
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002129 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002130 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002131
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002132 if (!is_unicast_ether_addr(addr.mac))
2133 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002134
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002135 is_static = (addr.state ==
2136 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2137 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002138 if (err)
2139 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002140 } while (!is_broadcast_ether_addr(addr.mac));
2141
2142 return err;
2143}
2144
Vivien Didelot83dabd12016-08-31 11:50:04 -04002145static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002146 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002147{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002148 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002149 u16 fid;
2150 int err;
2151
2152 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002153 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002154 if (err)
2155 return err;
2156
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002157 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002158 if (err)
2159 return err;
2160
2161 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002162 vlan.vid = chip->info->max_vid;
2163 vlan.valid = false;
2164
Vivien Didelot83dabd12016-08-31 11:50:04 -04002165 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002166 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002167 if (err)
2168 return err;
2169
2170 if (!vlan.valid)
2171 break;
2172
2173 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002174 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002175 if (err)
2176 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002177 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002178
2179 return err;
2180}
2181
Vivien Didelotf81ec902016-05-09 13:22:58 -04002182static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002183 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002184{
Vivien Didelot04bed142016-08-31 18:06:13 -04002185 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002186 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002187
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002188 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002189 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002190 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002191
2192 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002193}
2194
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002195static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2196 struct net_device *br)
2197{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002198 struct dsa_switch *ds = chip->ds;
2199 struct dsa_switch_tree *dst = ds->dst;
2200 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002201 int err;
2202
Vivien Didelotef2025e2019-10-21 16:51:27 -04002203 list_for_each_entry(dp, &dst->ports, list) {
2204 if (dp->bridge_dev == br) {
2205 if (dp->ds == ds) {
2206 /* This is a local bridge group member,
2207 * remap its Port VLAN Map.
2208 */
2209 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2210 if (err)
2211 return err;
2212 } else {
2213 /* This is an external bridge group member,
2214 * remap its cross-chip Port VLAN Table entry.
2215 */
2216 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2217 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002218 if (err)
2219 return err;
2220 }
2221 }
2222 }
2223
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002224 return 0;
2225}
2226
Vivien Didelotf81ec902016-05-09 13:22:58 -04002227static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002228 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002229{
Vivien Didelot04bed142016-08-31 18:06:13 -04002230 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002231 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002232
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002233 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002234 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002235 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002236
Vivien Didelot466dfa02016-02-26 13:16:05 -05002237 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002238}
2239
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002240static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2241 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002242{
Vivien Didelot04bed142016-08-31 18:06:13 -04002243 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002244
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002245 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002246 if (mv88e6xxx_bridge_map(chip, br) ||
2247 mv88e6xxx_port_vlan_map(chip, port))
2248 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002249 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002250}
2251
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002252static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2253 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002254 int port, struct net_device *br)
2255{
2256 struct mv88e6xxx_chip *chip = ds->priv;
2257 int err;
2258
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002259 if (tree_index != ds->dst->index)
2260 return 0;
2261
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002262 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002263 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002264 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002265
2266 return err;
2267}
2268
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002269static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2270 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002271 int port, struct net_device *br)
2272{
2273 struct mv88e6xxx_chip *chip = ds->priv;
2274
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002275 if (tree_index != ds->dst->index)
2276 return;
2277
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002278 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002279 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002280 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002281 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002282}
2283
Vivien Didelot17e708b2016-12-05 17:30:27 -05002284static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2285{
2286 if (chip->info->ops->reset)
2287 return chip->info->ops->reset(chip);
2288
2289 return 0;
2290}
2291
Vivien Didelot309eca62016-12-05 17:30:26 -05002292static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2293{
2294 struct gpio_desc *gpiod = chip->reset;
2295
2296 /* If there is a GPIO connected to the reset pin, toggle it */
2297 if (gpiod) {
2298 gpiod_set_value_cansleep(gpiod, 1);
2299 usleep_range(10000, 20000);
2300 gpiod_set_value_cansleep(gpiod, 0);
2301 usleep_range(10000, 20000);
2302 }
2303}
2304
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002305static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2306{
2307 int i, err;
2308
2309 /* Set all ports to the Disabled state */
2310 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002311 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002312 if (err)
2313 return err;
2314 }
2315
2316 /* Wait for transmit queues to drain,
2317 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2318 */
2319 usleep_range(2000, 4000);
2320
2321 return 0;
2322}
2323
Vivien Didelotfad09c72016-06-21 12:28:20 -04002324static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002325{
Vivien Didelota935c052016-09-29 12:21:53 -04002326 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002327
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002328 err = mv88e6xxx_disable_ports(chip);
2329 if (err)
2330 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002331
Vivien Didelot309eca62016-12-05 17:30:26 -05002332 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002333
Vivien Didelot17e708b2016-12-05 17:30:27 -05002334 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002335}
2336
Vivien Didelot43145572017-03-11 16:12:59 -05002337static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002338 enum mv88e6xxx_frame_mode frame,
2339 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002340{
2341 int err;
2342
Vivien Didelot43145572017-03-11 16:12:59 -05002343 if (!chip->info->ops->port_set_frame_mode)
2344 return -EOPNOTSUPP;
2345
2346 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002347 if (err)
2348 return err;
2349
Vivien Didelot43145572017-03-11 16:12:59 -05002350 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2351 if (err)
2352 return err;
2353
2354 if (chip->info->ops->port_set_ether_type)
2355 return chip->info->ops->port_set_ether_type(chip, port, etype);
2356
2357 return 0;
2358}
2359
2360static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2361{
2362 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002363 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002364 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002365}
2366
2367static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2368{
2369 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002370 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002371 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002372}
2373
2374static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2375{
2376 return mv88e6xxx_set_port_mode(chip, port,
2377 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002378 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2379 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002380}
2381
2382static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2383{
2384 if (dsa_is_dsa_port(chip->ds, port))
2385 return mv88e6xxx_set_port_mode_dsa(chip, port);
2386
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002387 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002388 return mv88e6xxx_set_port_mode_normal(chip, port);
2389
2390 /* Setup CPU port mode depending on its supported tag format */
2391 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2392 return mv88e6xxx_set_port_mode_dsa(chip, port);
2393
2394 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2395 return mv88e6xxx_set_port_mode_edsa(chip, port);
2396
2397 return -EINVAL;
2398}
2399
Vivien Didelotea698f42017-03-11 16:12:50 -05002400static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2401{
2402 bool message = dsa_is_dsa_port(chip->ds, port);
2403
2404 return mv88e6xxx_port_set_message_port(chip, port, message);
2405}
2406
Vivien Didelot601aeed2017-03-11 16:13:00 -05002407static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2408{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002409 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002410 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002411
David S. Miller407308f2019-06-15 13:35:29 -07002412 /* Upstream ports flood frames with unknown unicast or multicast DA */
2413 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2414 if (chip->info->ops->port_set_egress_floods)
2415 return chip->info->ops->port_set_egress_floods(chip, port,
2416 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002417
David S. Miller407308f2019-06-15 13:35:29 -07002418 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002419}
2420
Vivien Didelot45de77f2019-08-31 16:18:36 -04002421static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2422{
2423 struct mv88e6xxx_port *mvp = dev_id;
2424 struct mv88e6xxx_chip *chip = mvp->chip;
2425 irqreturn_t ret = IRQ_NONE;
2426 int port = mvp->port;
2427 u8 lane;
2428
2429 mv88e6xxx_reg_lock(chip);
2430 lane = mv88e6xxx_serdes_get_lane(chip, port);
2431 if (lane)
2432 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2433 mv88e6xxx_reg_unlock(chip);
2434
2435 return ret;
2436}
2437
2438static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2439 u8 lane)
2440{
2441 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2442 unsigned int irq;
2443 int err;
2444
2445 /* Nothing to request if this SERDES port has no IRQ */
2446 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2447 if (!irq)
2448 return 0;
2449
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002450 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2451 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2452
Vivien Didelot45de77f2019-08-31 16:18:36 -04002453 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2454 mv88e6xxx_reg_unlock(chip);
2455 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002456 IRQF_ONESHOT, dev_id->serdes_irq_name,
2457 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002458 mv88e6xxx_reg_lock(chip);
2459 if (err)
2460 return err;
2461
2462 dev_id->serdes_irq = irq;
2463
2464 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2465}
2466
2467static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2468 u8 lane)
2469{
2470 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2471 unsigned int irq = dev_id->serdes_irq;
2472 int err;
2473
2474 /* Nothing to free if no IRQ has been requested */
2475 if (!irq)
2476 return 0;
2477
2478 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2479
2480 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2481 mv88e6xxx_reg_unlock(chip);
2482 free_irq(irq, dev_id);
2483 mv88e6xxx_reg_lock(chip);
2484
2485 dev_id->serdes_irq = 0;
2486
2487 return err;
2488}
2489
Andrew Lunn6d917822017-05-26 01:03:21 +02002490static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2491 bool on)
2492{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002493 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002494 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002495
Vivien Didelotdc272f62019-08-31 16:18:33 -04002496 lane = mv88e6xxx_serdes_get_lane(chip, port);
2497 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002498 return 0;
2499
2500 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002501 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002502 if (err)
2503 return err;
2504
Vivien Didelot45de77f2019-08-31 16:18:36 -04002505 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002506 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002507 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2508 if (err)
2509 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002510
Vivien Didelotdc272f62019-08-31 16:18:33 -04002511 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002512 }
2513
2514 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002515}
2516
Vivien Didelotfa371c82017-12-05 15:34:10 -05002517static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2518{
2519 struct dsa_switch *ds = chip->ds;
2520 int upstream_port;
2521 int err;
2522
Vivien Didelot07073c72017-12-05 15:34:13 -05002523 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002524 if (chip->info->ops->port_set_upstream_port) {
2525 err = chip->info->ops->port_set_upstream_port(chip, port,
2526 upstream_port);
2527 if (err)
2528 return err;
2529 }
2530
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002531 if (port == upstream_port) {
2532 if (chip->info->ops->set_cpu_port) {
2533 err = chip->info->ops->set_cpu_port(chip,
2534 upstream_port);
2535 if (err)
2536 return err;
2537 }
2538
2539 if (chip->info->ops->set_egress_port) {
2540 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002541 MV88E6XXX_EGRESS_DIR_INGRESS,
2542 upstream_port);
2543 if (err)
2544 return err;
2545
2546 err = chip->info->ops->set_egress_port(chip,
2547 MV88E6XXX_EGRESS_DIR_EGRESS,
2548 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002549 if (err)
2550 return err;
2551 }
2552 }
2553
Vivien Didelotfa371c82017-12-05 15:34:10 -05002554 return 0;
2555}
2556
Vivien Didelotfad09c72016-06-21 12:28:20 -04002557static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002558{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002559 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002560 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002561 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002562
Andrew Lunn7b898462018-08-09 15:38:47 +02002563 chip->ports[port].chip = chip;
2564 chip->ports[port].port = port;
2565
Vivien Didelotd78343d2016-11-04 03:23:36 +01002566 /* MAC Forcing register: don't force link, speed, duplex or flow control
2567 * state to any particular values on physical ports, but force the CPU
2568 * port and all DSA ports to their maximum bandwidth and full duplex.
2569 */
2570 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2571 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2572 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002573 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002574 PHY_INTERFACE_MODE_NA);
2575 else
2576 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2577 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002578 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002579 PHY_INTERFACE_MODE_NA);
2580 if (err)
2581 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002582
2583 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2584 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2585 * tunneling, determine priority by looking at 802.1p and IP
2586 * priority fields (IP prio has precedence), and set STP state
2587 * to Forwarding.
2588 *
2589 * If this is the CPU link, use DSA or EDSA tagging depending
2590 * on which tagging mode was configured.
2591 *
2592 * If this is a link to another switch, use DSA tagging mode.
2593 *
2594 * If this is the upstream port for this switch, enable
2595 * forwarding of unknown unicasts and multicasts.
2596 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002597 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2598 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2599 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2600 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002601 if (err)
2602 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002603
Vivien Didelot601aeed2017-03-11 16:13:00 -05002604 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002605 if (err)
2606 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002607
Vivien Didelot601aeed2017-03-11 16:13:00 -05002608 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002609 if (err)
2610 return err;
2611
Vivien Didelot8efdda42015-08-13 12:52:23 -04002612 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002613 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002614 * untagged frames on this port, do a destination address lookup on all
2615 * received packets as usual, disable ARP mirroring and don't send a
2616 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002617 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002618 err = mv88e6xxx_port_set_map_da(chip, port);
2619 if (err)
2620 return err;
2621
Vivien Didelotfa371c82017-12-05 15:34:10 -05002622 err = mv88e6xxx_setup_upstream_port(chip, port);
2623 if (err)
2624 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002625
Andrew Lunna23b2962017-02-04 20:15:28 +01002626 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002627 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002628 if (err)
2629 return err;
2630
Vivien Didelotcd782652017-06-08 18:34:13 -04002631 if (chip->info->ops->port_set_jumbo_size) {
2632 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002633 if (err)
2634 return err;
2635 }
2636
Andrew Lunn54d792f2015-05-06 01:09:47 +02002637 /* Port Association Vector: when learning source addresses
2638 * of packets, add the address to the address database using
2639 * a port bitmap that has only the bit for this port set and
2640 * the other bits clear.
2641 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002642 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002643 /* Disable learning for CPU port */
2644 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002645 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002646
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002647 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2648 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002649 if (err)
2650 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002651
2652 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002653 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2654 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002655 if (err)
2656 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002657
Vivien Didelot08984322017-06-08 18:34:12 -04002658 if (chip->info->ops->port_pause_limit) {
2659 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002660 if (err)
2661 return err;
2662 }
2663
Vivien Didelotc8c94892017-03-11 16:13:01 -05002664 if (chip->info->ops->port_disable_learn_limit) {
2665 err = chip->info->ops->port_disable_learn_limit(chip, port);
2666 if (err)
2667 return err;
2668 }
2669
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002670 if (chip->info->ops->port_disable_pri_override) {
2671 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002672 if (err)
2673 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002674 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002675
Andrew Lunnef0a7312016-12-03 04:35:16 +01002676 if (chip->info->ops->port_tag_remap) {
2677 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002678 if (err)
2679 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002680 }
2681
Andrew Lunnef70b112016-12-03 04:45:18 +01002682 if (chip->info->ops->port_egress_rate_limiting) {
2683 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002684 if (err)
2685 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002686 }
2687
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002688 if (chip->info->ops->port_setup_message_port) {
2689 err = chip->info->ops->port_setup_message_port(chip, port);
2690 if (err)
2691 return err;
2692 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002693
Vivien Didelot207afda2016-04-14 14:42:09 -04002694 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002695 * database, and allow bidirectional communication between the
2696 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002697 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002698 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002699 if (err)
2700 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002701
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002702 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002703 if (err)
2704 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002705
2706 /* Default VLAN ID and priority: don't set a default VLAN
2707 * ID, and set the default packet priority to zero.
2708 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002709 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002710}
2711
Andrew Lunn04aca992017-05-26 01:03:24 +02002712static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2713 struct phy_device *phydev)
2714{
2715 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002716 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002717
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002718 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002719 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002720 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002721
2722 return err;
2723}
2724
Andrew Lunn75104db2019-02-24 20:44:43 +01002725static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002726{
2727 struct mv88e6xxx_chip *chip = ds->priv;
2728
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002729 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002730 if (mv88e6xxx_serdes_power(chip, port, false))
2731 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002732 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002733}
2734
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002735static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2736 unsigned int ageing_time)
2737{
Vivien Didelot04bed142016-08-31 18:06:13 -04002738 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002739 int err;
2740
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002741 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002742 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002743 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002744
2745 return err;
2746}
2747
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002748static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002749{
2750 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002751
Andrew Lunnde2273872016-11-21 23:27:01 +01002752 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002753 if (chip->info->ops->stats_set_histogram) {
2754 err = chip->info->ops->stats_set_histogram(chip);
2755 if (err)
2756 return err;
2757 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002758
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002759 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002760}
2761
Andrew Lunnea890982019-01-09 00:24:03 +01002762/* Check if the errata has already been applied. */
2763static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2764{
2765 int port;
2766 int err;
2767 u16 val;
2768
2769 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002770 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002771 if (err) {
2772 dev_err(chip->dev,
2773 "Error reading hidden register: %d\n", err);
2774 return false;
2775 }
2776 if (val != 0x01c0)
2777 return false;
2778 }
2779
2780 return true;
2781}
2782
2783/* The 6390 copper ports have an errata which require poking magic
2784 * values into undocumented hidden registers and then performing a
2785 * software reset.
2786 */
2787static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2788{
2789 int port;
2790 int err;
2791
2792 if (mv88e6390_setup_errata_applied(chip))
2793 return 0;
2794
2795 /* Set the ports into blocking mode */
2796 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2797 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2798 if (err)
2799 return err;
2800 }
2801
2802 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002803 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002804 if (err)
2805 return err;
2806 }
2807
2808 return mv88e6xxx_software_reset(chip);
2809}
2810
Andrew Lunn23e8b472019-10-25 01:03:52 +02002811enum mv88e6xxx_devlink_param_id {
2812 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2813 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2814};
2815
2816static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2817 struct devlink_param_gset_ctx *ctx)
2818{
2819 struct mv88e6xxx_chip *chip = ds->priv;
2820 int err;
2821
2822 mv88e6xxx_reg_lock(chip);
2823
2824 switch (id) {
2825 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2826 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2827 break;
2828 default:
2829 err = -EOPNOTSUPP;
2830 break;
2831 }
2832
2833 mv88e6xxx_reg_unlock(chip);
2834
2835 return err;
2836}
2837
2838static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2839 struct devlink_param_gset_ctx *ctx)
2840{
2841 struct mv88e6xxx_chip *chip = ds->priv;
2842 int err;
2843
2844 mv88e6xxx_reg_lock(chip);
2845
2846 switch (id) {
2847 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2848 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2849 break;
2850 default:
2851 err = -EOPNOTSUPP;
2852 break;
2853 }
2854
2855 mv88e6xxx_reg_unlock(chip);
2856
2857 return err;
2858}
2859
2860static const struct devlink_param mv88e6xxx_devlink_params[] = {
2861 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2862 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2863 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2864};
2865
2866static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2867{
2868 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2869 ARRAY_SIZE(mv88e6xxx_devlink_params));
2870}
2871
2872static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2873{
2874 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2875 ARRAY_SIZE(mv88e6xxx_devlink_params));
2876}
2877
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002878enum mv88e6xxx_devlink_resource_id {
2879 MV88E6XXX_RESOURCE_ID_ATU,
2880 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2881 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2882 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2883 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2884};
2885
2886static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2887 u16 bin)
2888{
2889 u16 occupancy = 0;
2890 int err;
2891
2892 mv88e6xxx_reg_lock(chip);
2893
2894 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2895 bin);
2896 if (err) {
2897 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2898 goto unlock;
2899 }
2900
2901 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2902 if (err) {
2903 dev_err(chip->dev, "failed to perform ATU get next\n");
2904 goto unlock;
2905 }
2906
2907 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2908 if (err) {
2909 dev_err(chip->dev, "failed to get ATU stats\n");
2910 goto unlock;
2911 }
2912
Andrew Lunn012fc742020-03-11 21:02:31 +01002913 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2914
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002915unlock:
2916 mv88e6xxx_reg_unlock(chip);
2917
2918 return occupancy;
2919}
2920
2921static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2922{
2923 struct mv88e6xxx_chip *chip = priv;
2924
2925 return mv88e6xxx_devlink_atu_bin_get(chip,
2926 MV88E6XXX_G2_ATU_STATS_BIN_0);
2927}
2928
2929static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2930{
2931 struct mv88e6xxx_chip *chip = priv;
2932
2933 return mv88e6xxx_devlink_atu_bin_get(chip,
2934 MV88E6XXX_G2_ATU_STATS_BIN_1);
2935}
2936
2937static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2938{
2939 struct mv88e6xxx_chip *chip = priv;
2940
2941 return mv88e6xxx_devlink_atu_bin_get(chip,
2942 MV88E6XXX_G2_ATU_STATS_BIN_2);
2943}
2944
2945static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2946{
2947 struct mv88e6xxx_chip *chip = priv;
2948
2949 return mv88e6xxx_devlink_atu_bin_get(chip,
2950 MV88E6XXX_G2_ATU_STATS_BIN_3);
2951}
2952
2953static u64 mv88e6xxx_devlink_atu_get(void *priv)
2954{
2955 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2956 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2957 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2958 mv88e6xxx_devlink_atu_bin_3_get(priv);
2959}
2960
2961static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2962{
2963 struct devlink_resource_size_params size_params;
2964 struct mv88e6xxx_chip *chip = ds->priv;
2965 int err;
2966
2967 devlink_resource_size_params_init(&size_params,
2968 mv88e6xxx_num_macs(chip),
2969 mv88e6xxx_num_macs(chip),
2970 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2971
2972 err = dsa_devlink_resource_register(ds, "ATU",
2973 mv88e6xxx_num_macs(chip),
2974 MV88E6XXX_RESOURCE_ID_ATU,
2975 DEVLINK_RESOURCE_ID_PARENT_TOP,
2976 &size_params);
2977 if (err)
2978 goto out;
2979
2980 devlink_resource_size_params_init(&size_params,
2981 mv88e6xxx_num_macs(chip) / 4,
2982 mv88e6xxx_num_macs(chip) / 4,
2983 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2984
2985 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2986 mv88e6xxx_num_macs(chip) / 4,
2987 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2988 MV88E6XXX_RESOURCE_ID_ATU,
2989 &size_params);
2990 if (err)
2991 goto out;
2992
2993 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2994 mv88e6xxx_num_macs(chip) / 4,
2995 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2996 MV88E6XXX_RESOURCE_ID_ATU,
2997 &size_params);
2998 if (err)
2999 goto out;
3000
3001 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
3002 mv88e6xxx_num_macs(chip) / 4,
3003 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3004 MV88E6XXX_RESOURCE_ID_ATU,
3005 &size_params);
3006 if (err)
3007 goto out;
3008
3009 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
3010 mv88e6xxx_num_macs(chip) / 4,
3011 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3012 MV88E6XXX_RESOURCE_ID_ATU,
3013 &size_params);
3014 if (err)
3015 goto out;
3016
3017 dsa_devlink_resource_occ_get_register(ds,
3018 MV88E6XXX_RESOURCE_ID_ATU,
3019 mv88e6xxx_devlink_atu_get,
3020 chip);
3021
3022 dsa_devlink_resource_occ_get_register(ds,
3023 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
3024 mv88e6xxx_devlink_atu_bin_0_get,
3025 chip);
3026
3027 dsa_devlink_resource_occ_get_register(ds,
3028 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3029 mv88e6xxx_devlink_atu_bin_1_get,
3030 chip);
3031
3032 dsa_devlink_resource_occ_get_register(ds,
3033 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3034 mv88e6xxx_devlink_atu_bin_2_get,
3035 chip);
3036
3037 dsa_devlink_resource_occ_get_register(ds,
3038 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3039 mv88e6xxx_devlink_atu_bin_3_get,
3040 chip);
3041
3042 return 0;
3043
3044out:
3045 dsa_devlink_resources_unregister(ds);
3046 return err;
3047}
3048
Andrew Lunn23e8b472019-10-25 01:03:52 +02003049static void mv88e6xxx_teardown(struct dsa_switch *ds)
3050{
3051 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003052 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003053}
3054
Vivien Didelotf81ec902016-05-09 13:22:58 -04003055static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003056{
Vivien Didelot04bed142016-08-31 18:06:13 -04003057 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003058 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003059 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003060 int i;
3061
Vivien Didelotfad09c72016-06-21 12:28:20 -04003062 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003063 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003064
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003065 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003066
Andrew Lunnea890982019-01-09 00:24:03 +01003067 if (chip->info->ops->setup_errata) {
3068 err = chip->info->ops->setup_errata(chip);
3069 if (err)
3070 goto unlock;
3071 }
3072
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003073 /* Cache the cmode of each port. */
3074 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3075 if (chip->info->ops->port_get_cmode) {
3076 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3077 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003078 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003079
3080 chip->ports[i].cmode = cmode;
3081 }
3082 }
3083
Vivien Didelot97299342016-07-18 20:45:30 -04003084 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003085 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003086 if (dsa_is_unused_port(ds, i))
3087 continue;
3088
Hubert Feursteinc8574862019-07-31 10:23:48 +02003089 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003090 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003091 dev_err(chip->dev, "port %d is invalid\n", i);
3092 err = -EINVAL;
3093 goto unlock;
3094 }
3095
Vivien Didelot97299342016-07-18 20:45:30 -04003096 err = mv88e6xxx_setup_port(chip, i);
3097 if (err)
3098 goto unlock;
3099 }
3100
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003101 err = mv88e6xxx_irl_setup(chip);
3102 if (err)
3103 goto unlock;
3104
Vivien Didelot04a69a12017-10-13 14:18:05 -04003105 err = mv88e6xxx_mac_setup(chip);
3106 if (err)
3107 goto unlock;
3108
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003109 err = mv88e6xxx_phy_setup(chip);
3110 if (err)
3111 goto unlock;
3112
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003113 err = mv88e6xxx_vtu_setup(chip);
3114 if (err)
3115 goto unlock;
3116
Vivien Didelot81228992017-03-30 17:37:08 -04003117 err = mv88e6xxx_pvt_setup(chip);
3118 if (err)
3119 goto unlock;
3120
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003121 err = mv88e6xxx_atu_setup(chip);
3122 if (err)
3123 goto unlock;
3124
Andrew Lunn87fa8862017-11-09 22:29:56 +01003125 err = mv88e6xxx_broadcast_setup(chip, 0);
3126 if (err)
3127 goto unlock;
3128
Vivien Didelot9e907d72017-07-17 13:03:43 -04003129 err = mv88e6xxx_pot_setup(chip);
3130 if (err)
3131 goto unlock;
3132
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003133 err = mv88e6xxx_rmu_setup(chip);
3134 if (err)
3135 goto unlock;
3136
Vivien Didelot51c901a2017-07-17 13:03:41 -04003137 err = mv88e6xxx_rsvd2cpu_setup(chip);
3138 if (err)
3139 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003140
Vivien Didelotb28f8722018-04-26 21:56:44 -04003141 err = mv88e6xxx_trunk_setup(chip);
3142 if (err)
3143 goto unlock;
3144
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003145 err = mv88e6xxx_devmap_setup(chip);
3146 if (err)
3147 goto unlock;
3148
Vivien Didelot93e18d62018-05-11 17:16:35 -04003149 err = mv88e6xxx_pri_setup(chip);
3150 if (err)
3151 goto unlock;
3152
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003153 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003154 if (chip->info->ptp_support) {
3155 err = mv88e6xxx_ptp_setup(chip);
3156 if (err)
3157 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003158
3159 err = mv88e6xxx_hwtstamp_setup(chip);
3160 if (err)
3161 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003162 }
3163
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003164 err = mv88e6xxx_stats_setup(chip);
3165 if (err)
3166 goto unlock;
3167
Vivien Didelot6b17e862015-08-13 12:52:18 -04003168unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003169 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003170
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003171 if (err)
3172 return err;
3173
3174 /* Have to be called without holding the register lock, since
3175 * they take the devlink lock, and we later take the locks in
3176 * the reverse order when getting/setting parameters or
3177 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003178 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003179 err = mv88e6xxx_setup_devlink_resources(ds);
3180 if (err)
3181 return err;
3182
3183 err = mv88e6xxx_setup_devlink_params(ds);
3184 if (err)
3185 dsa_devlink_resources_unregister(ds);
3186
3187 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003188}
3189
Vivien Didelote57e5e72016-08-15 17:19:00 -04003190static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003191{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003192 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3193 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003194 u16 val;
3195 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003196
Andrew Lunnee26a222017-01-24 14:53:48 +01003197 if (!chip->info->ops->phy_read)
3198 return -EOPNOTSUPP;
3199
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003200 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003201 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003202 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003203
Andrew Lunnda9f3302017-02-01 03:40:05 +01003204 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003205 /* Some internal PHYs don't have a model number. */
3206 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3207 /* Then there is the 6165 family. It gets is
3208 * PHYs correct. But it can also have two
3209 * SERDES interfaces in the PHY address
3210 * space. And these don't have a model
3211 * number. But they are not PHYs, so we don't
3212 * want to give them something a PHY driver
3213 * will recognise.
3214 *
3215 * Use the mv88e6390 family model number
3216 * instead, for anything which really could be
3217 * a PHY,
3218 */
3219 if (!(val & 0x3f0))
3220 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003221 }
3222
Vivien Didelote57e5e72016-08-15 17:19:00 -04003223 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003224}
3225
Vivien Didelote57e5e72016-08-15 17:19:00 -04003226static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003227{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003228 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3229 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003230 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003231
Andrew Lunnee26a222017-01-24 14:53:48 +01003232 if (!chip->info->ops->phy_write)
3233 return -EOPNOTSUPP;
3234
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003235 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003236 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003237 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003238
3239 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003240}
3241
Vivien Didelotfad09c72016-06-21 12:28:20 -04003242static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003243 struct device_node *np,
3244 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003245{
3246 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003247 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003248 struct mii_bus *bus;
3249 int err;
3250
Andrew Lunn2510bab2018-02-22 01:51:49 +01003251 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003252 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003253 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003254 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003255
3256 if (err)
3257 return err;
3258 }
3259
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003260 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003261 if (!bus)
3262 return -ENOMEM;
3263
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003264 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003265 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003266 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003267 INIT_LIST_HEAD(&mdio_bus->list);
3268 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003269
Andrew Lunnb516d452016-06-04 21:17:06 +02003270 if (np) {
3271 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003272 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003273 } else {
3274 bus->name = "mv88e6xxx SMI";
3275 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3276 }
3277
3278 bus->read = mv88e6xxx_mdio_read;
3279 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003280 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003281
Andrew Lunn6f882842018-03-17 20:32:05 +01003282 if (!external) {
3283 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3284 if (err)
3285 return err;
3286 }
3287
Florian Fainelli00e798c2018-05-15 16:56:19 -07003288 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003289 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003290 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003291 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003292 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003293 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003294
3295 if (external)
3296 list_add_tail(&mdio_bus->list, &chip->mdios);
3297 else
3298 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003299
3300 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003301}
3302
Andrew Lunna3c53be52017-01-24 14:53:50 +01003303static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3304 { .compatible = "marvell,mv88e6xxx-mdio-external",
3305 .data = (void *)true },
3306 { },
3307};
3308
Andrew Lunn3126aee2017-12-07 01:05:57 +01003309static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3310
3311{
3312 struct mv88e6xxx_mdio_bus *mdio_bus;
3313 struct mii_bus *bus;
3314
3315 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3316 bus = mdio_bus->bus;
3317
Andrew Lunn6f882842018-03-17 20:32:05 +01003318 if (!mdio_bus->external)
3319 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3320
Andrew Lunn3126aee2017-12-07 01:05:57 +01003321 mdiobus_unregister(bus);
3322 }
3323}
3324
Andrew Lunna3c53be52017-01-24 14:53:50 +01003325static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3326 struct device_node *np)
3327{
3328 const struct of_device_id *match;
3329 struct device_node *child;
3330 int err;
3331
3332 /* Always register one mdio bus for the internal/default mdio
3333 * bus. This maybe represented in the device tree, but is
3334 * optional.
3335 */
3336 child = of_get_child_by_name(np, "mdio");
3337 err = mv88e6xxx_mdio_register(chip, child, false);
3338 if (err)
3339 return err;
3340
3341 /* Walk the device tree, and see if there are any other nodes
3342 * which say they are compatible with the external mdio
3343 * bus.
3344 */
3345 for_each_available_child_of_node(np, child) {
3346 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3347 if (match) {
3348 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003349 if (err) {
3350 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303351 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003352 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003353 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003354 }
3355 }
3356
3357 return 0;
3358}
3359
Vivien Didelot855b1932016-07-20 18:18:35 -04003360static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3361{
Vivien Didelot04bed142016-08-31 18:06:13 -04003362 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003363
3364 return chip->eeprom_len;
3365}
3366
Vivien Didelot855b1932016-07-20 18:18:35 -04003367static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3368 struct ethtool_eeprom *eeprom, u8 *data)
3369{
Vivien Didelot04bed142016-08-31 18:06:13 -04003370 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003371 int err;
3372
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003373 if (!chip->info->ops->get_eeprom)
3374 return -EOPNOTSUPP;
3375
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003376 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003377 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003378 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003379
3380 if (err)
3381 return err;
3382
3383 eeprom->magic = 0xc3ec4951;
3384
3385 return 0;
3386}
3387
Vivien Didelot855b1932016-07-20 18:18:35 -04003388static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3389 struct ethtool_eeprom *eeprom, u8 *data)
3390{
Vivien Didelot04bed142016-08-31 18:06:13 -04003391 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003392 int err;
3393
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003394 if (!chip->info->ops->set_eeprom)
3395 return -EOPNOTSUPP;
3396
Vivien Didelot855b1932016-07-20 18:18:35 -04003397 if (eeprom->magic != 0xc3ec4951)
3398 return -EINVAL;
3399
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003400 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003401 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003402 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003403
3404 return err;
3405}
3406
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003408 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003409 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3410 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003411 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003412 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003413 .phy_read = mv88e6185_phy_ppu_read,
3414 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003415 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003416 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003417 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003418 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003419 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003421 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003422 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003423 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003424 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003425 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003426 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003427 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003428 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003429 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3430 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003431 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003432 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3433 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003434 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003435 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003436 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003437 .ppu_enable = mv88e6185_g1_ppu_enable,
3438 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003439 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003440 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003441 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003442 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003443 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003444};
3445
3446static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003447 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003448 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3449 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003450 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003451 .phy_read = mv88e6185_phy_ppu_read,
3452 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003453 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003454 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003455 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003456 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003457 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003458 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003459 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003460 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003461 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003462 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3463 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003464 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003465 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003466 .ppu_enable = mv88e6185_g1_ppu_enable,
3467 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003468 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003469 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003470 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003471 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003472};
3473
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003474static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003475 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003476 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3477 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003478 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003479 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3480 .phy_read = mv88e6xxx_g2_smi_phy_read,
3481 .phy_write = mv88e6xxx_g2_smi_phy_write,
3482 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003483 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003484 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003485 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003486 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003487 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003488 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003489 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003490 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003491 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003492 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003493 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003494 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003495 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003496 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003497 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3498 .stats_get_strings = mv88e6095_stats_get_strings,
3499 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003500 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3501 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003502 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003503 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003504 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003505 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003506 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003507 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003508 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003509 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003510};
3511
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003512static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003513 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003514 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3515 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003516 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003517 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003518 .phy_read = mv88e6xxx_g2_smi_phy_read,
3519 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003520 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003521 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003522 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003523 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003524 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003525 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003526 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003527 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003528 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003529 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003530 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3531 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003532 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003533 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3534 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003535 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003536 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003537 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003538 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003539 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3540 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003541 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003542 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003543 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003544};
3545
3546static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003547 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003548 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3549 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003550 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003551 .phy_read = mv88e6185_phy_ppu_read,
3552 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003553 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003554 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003555 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003556 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003557 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003558 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003559 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003560 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003561 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003562 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003563 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003564 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003565 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003566 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003567 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003568 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3569 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003570 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003571 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3572 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003573 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003574 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003575 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003576 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003577 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003578 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003579 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003580 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003581 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003582};
3583
Vivien Didelot990e27b2017-03-28 13:50:32 -04003584static const struct mv88e6xxx_ops mv88e6141_ops = {
3585 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003586 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3587 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003588 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003589 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3590 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3591 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3592 .phy_read = mv88e6xxx_g2_smi_phy_read,
3593 .phy_write = mv88e6xxx_g2_smi_phy_write,
3594 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003595 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003596 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003597 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003598 .port_tag_remap = mv88e6095_port_tag_remap,
3599 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3600 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3601 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003602 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003603 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003604 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003605 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3606 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003607 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003608 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003609 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003610 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003611 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003612 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3613 .stats_get_strings = mv88e6320_stats_get_strings,
3614 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003615 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3616 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003617 .watchdog_ops = &mv88e6390_watchdog_ops,
3618 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003619 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003620 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003621 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003622 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003623 .serdes_power = mv88e6390_serdes_power,
3624 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003625 /* Check status register pause & lpa register */
3626 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3627 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3628 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3629 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003630 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003631 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003632 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003633 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003634 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003635};
3636
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003637static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003638 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003639 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3640 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003641 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003642 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003643 .phy_read = mv88e6xxx_g2_smi_phy_read,
3644 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003645 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003646 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003647 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003648 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003649 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003650 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003651 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003652 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003653 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003654 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003655 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003656 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003657 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003658 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003659 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003660 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3661 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003662 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003663 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3664 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003665 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003666 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003667 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003668 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003669 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3670 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003671 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003672 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003673 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003674 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003675 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003676};
3677
3678static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003679 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003680 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3681 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003682 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003683 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003684 .phy_read = mv88e6165_phy_read,
3685 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003686 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003687 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003688 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003689 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003690 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003691 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003692 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003693 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003694 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3695 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003696 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003697 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3698 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003699 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003700 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003701 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003702 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003703 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3704 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003705 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003706 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003707 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003708 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003709 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003710};
3711
3712static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003713 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003714 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3715 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003716 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003717 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003718 .phy_read = mv88e6xxx_g2_smi_phy_read,
3719 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003720 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003721 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003722 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003723 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003724 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003725 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003726 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003727 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003728 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003729 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003730 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003731 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003732 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003733 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003734 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003735 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003736 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3737 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003738 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003739 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3740 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003741 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003742 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003743 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003744 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003745 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3746 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003747 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003748 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003749 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003750};
3751
3752static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003753 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003754 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3755 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003756 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003757 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3758 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003759 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003760 .phy_read = mv88e6xxx_g2_smi_phy_read,
3761 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003762 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003763 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003764 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003765 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003766 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003767 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003768 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003769 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003770 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003771 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003772 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003773 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003774 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003775 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003776 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003777 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003778 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003779 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3780 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003781 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003782 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3783 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003784 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003785 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003786 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003787 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003788 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003789 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3790 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003791 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003792 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003793 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003794 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3795 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3796 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3797 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003798 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003799 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3800 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003801 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003802 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003803};
3804
3805static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003806 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003807 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3808 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003809 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003810 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003811 .phy_read = mv88e6xxx_g2_smi_phy_read,
3812 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003813 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003814 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003815 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003816 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003817 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003818 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003819 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003820 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003821 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003822 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003823 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003824 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003825 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003827 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003828 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003829 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3830 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003831 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003832 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3833 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003834 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003835 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003837 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003838 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3839 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003840 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003841 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003842 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003843};
3844
3845static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003846 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003847 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3848 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003849 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003850 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3851 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003852 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003853 .phy_read = mv88e6xxx_g2_smi_phy_read,
3854 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003855 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003856 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003857 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003858 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003859 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003860 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003861 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003862 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003863 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003864 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003865 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003866 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003867 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003868 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003869 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003870 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003871 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003872 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3873 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003874 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003875 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3876 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003877 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003878 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003879 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003880 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003881 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003882 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3883 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003884 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003885 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003886 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003887 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3888 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3889 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3890 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003891 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003892 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003893 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003894 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003895 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3896 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003897 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003898 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003899};
3900
3901static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003902 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003903 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3904 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003905 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003906 .phy_read = mv88e6185_phy_ppu_read,
3907 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003908 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003909 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003910 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003911 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003912 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003913 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003914 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003915 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003916 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003917 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003918 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003919 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3920 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003921 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003922 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3923 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003924 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003925 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003926 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003927 .ppu_enable = mv88e6185_g1_ppu_enable,
3928 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003929 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003930 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003931 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003932 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003933};
3934
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003935static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003936 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003937 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003938 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003939 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3940 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003941 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3942 .phy_read = mv88e6xxx_g2_smi_phy_read,
3943 .phy_write = mv88e6xxx_g2_smi_phy_write,
3944 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003945 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003946 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003947 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003948 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003949 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003950 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003951 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003952 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003953 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003954 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003955 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003956 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003957 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003958 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003959 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003960 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003961 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3962 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003963 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003964 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3965 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003966 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003967 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003968 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003969 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003970 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003971 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3972 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003973 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3974 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003975 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003976 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003977 /* Check status register pause & lpa register */
3978 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3979 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3980 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3981 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003982 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003983 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003984 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003985 .serdes_get_strings = mv88e6390_serdes_get_strings,
3986 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003987 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3988 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003989 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003990 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003991};
3992
3993static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003994 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003995 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003996 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003997 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3998 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003999 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4000 .phy_read = mv88e6xxx_g2_smi_phy_read,
4001 .phy_write = mv88e6xxx_g2_smi_phy_write,
4002 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004003 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004004 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004005 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004006 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004007 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004008 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004009 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004010 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004011 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004012 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004013 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004014 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004015 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004016 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004017 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004018 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004019 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4020 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004021 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004022 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4023 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004024 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004025 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004026 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004027 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004028 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004029 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4030 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004031 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4032 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004033 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004034 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004035 /* Check status register pause & lpa register */
4036 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4037 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4038 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4039 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004040 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004041 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004042 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004043 .serdes_get_strings = mv88e6390_serdes_get_strings,
4044 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004045 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4046 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004047 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004048 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004049};
4050
4051static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004052 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004053 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004054 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004055 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4056 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004057 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4058 .phy_read = mv88e6xxx_g2_smi_phy_read,
4059 .phy_write = mv88e6xxx_g2_smi_phy_write,
4060 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004061 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004062 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004063 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004064 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004065 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004066 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004067 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004068 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004069 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004070 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004071 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004072 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004073 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004074 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004075 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004076 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4077 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004078 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004079 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4080 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004081 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004082 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004083 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004084 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004085 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004086 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4087 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004088 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4089 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004090 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004091 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004092 /* Check status register pause & lpa register */
4093 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4094 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4095 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4096 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004097 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004098 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004099 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004100 .serdes_get_strings = mv88e6390_serdes_get_strings,
4101 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004102 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4103 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004104 .avb_ops = &mv88e6390_avb_ops,
4105 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004106 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004107};
4108
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004109static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004110 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004111 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4112 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004113 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004114 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4115 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004116 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004117 .phy_read = mv88e6xxx_g2_smi_phy_read,
4118 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004119 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004120 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004121 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004122 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004123 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004124 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004125 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004126 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004127 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004128 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004129 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004130 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004131 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004132 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004133 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004134 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004135 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004136 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4137 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004138 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004139 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4140 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004141 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004142 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004143 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004144 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004145 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004146 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4147 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004148 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004149 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004150 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004151 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4152 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4153 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4154 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004155 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004156 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004157 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004158 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004159 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4160 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004161 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004162 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004163 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004164 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004165};
4166
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004167static const struct mv88e6xxx_ops mv88e6250_ops = {
4168 /* MV88E6XXX_FAMILY_6250 */
4169 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4170 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4171 .irl_init_all = mv88e6352_g2_irl_init_all,
4172 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4173 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4174 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4175 .phy_read = mv88e6xxx_g2_smi_phy_read,
4176 .phy_write = mv88e6xxx_g2_smi_phy_write,
4177 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004178 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004179 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004180 .port_tag_remap = mv88e6095_port_tag_remap,
4181 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4182 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4183 .port_set_ether_type = mv88e6351_port_set_ether_type,
4184 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4185 .port_pause_limit = mv88e6097_port_pause_limit,
4186 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004187 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4188 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4189 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4190 .stats_get_strings = mv88e6250_stats_get_strings,
4191 .stats_get_stats = mv88e6250_stats_get_stats,
4192 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4193 .set_egress_port = mv88e6095_g1_set_egress_port,
4194 .watchdog_ops = &mv88e6250_watchdog_ops,
4195 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4196 .pot_clear = mv88e6xxx_g2_pot_clear,
4197 .reset = mv88e6250_g1_reset,
4198 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4199 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004200 .avb_ops = &mv88e6352_avb_ops,
4201 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004202 .phylink_validate = mv88e6065_phylink_validate,
4203};
4204
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004205static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004206 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004207 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004208 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004209 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4210 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004211 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4212 .phy_read = mv88e6xxx_g2_smi_phy_read,
4213 .phy_write = mv88e6xxx_g2_smi_phy_write,
4214 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004215 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004216 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004217 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004218 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004219 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004220 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004221 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004222 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004223 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004224 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004225 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004226 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004227 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004228 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004229 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004230 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004231 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4232 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004233 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004234 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4235 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004236 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004237 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004238 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004239 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004240 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004241 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4242 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004243 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4244 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004245 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004246 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004247 /* Check status register pause & lpa register */
4248 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4249 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4250 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4251 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004252 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004253 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004254 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004255 .serdes_get_strings = mv88e6390_serdes_get_strings,
4256 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004257 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4258 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004259 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004260 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004261 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004262 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004263};
4264
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004265static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004266 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004267 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4268 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004269 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004270 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4271 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004272 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004273 .phy_read = mv88e6xxx_g2_smi_phy_read,
4274 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004275 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004276 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004277 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004278 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004279 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004280 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004281 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004282 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004283 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004284 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004285 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004286 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004287 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004288 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004289 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004290 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4291 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004292 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004293 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4294 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004295 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004296 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004297 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004298 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004299 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004300 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004301 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004302 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004303 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004304 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004305};
4306
4307static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004308 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004309 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4310 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004311 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004312 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4313 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004314 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004315 .phy_read = mv88e6xxx_g2_smi_phy_read,
4316 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004317 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004318 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004319 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004320 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004321 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004322 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004323 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004324 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004325 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004326 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004327 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004328 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004329 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004330 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004331 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004332 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4333 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004334 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004335 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4336 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004337 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004338 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004339 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004340 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004341 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004342 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004343 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004344 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004345};
4346
Vivien Didelot16e329a2017-03-28 13:50:33 -04004347static const struct mv88e6xxx_ops mv88e6341_ops = {
4348 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004349 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4350 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004351 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004352 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4353 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4354 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4355 .phy_read = mv88e6xxx_g2_smi_phy_read,
4356 .phy_write = mv88e6xxx_g2_smi_phy_write,
4357 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004358 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004359 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004360 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004361 .port_tag_remap = mv88e6095_port_tag_remap,
4362 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4363 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4364 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004365 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004366 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004367 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004368 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4369 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004370 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004371 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004372 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004373 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004374 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004375 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4376 .stats_get_strings = mv88e6320_stats_get_strings,
4377 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004378 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4379 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004380 .watchdog_ops = &mv88e6390_watchdog_ops,
4381 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004382 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004383 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004384 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004385 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004386 .serdes_power = mv88e6390_serdes_power,
4387 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004388 /* Check status register pause & lpa register */
4389 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4390 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4391 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4392 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004393 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004394 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004395 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004396 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004397 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004398 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004399 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004400};
4401
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004402static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004403 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004404 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4405 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004406 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004407 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004408 .phy_read = mv88e6xxx_g2_smi_phy_read,
4409 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004410 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004411 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004412 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004413 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004414 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004415 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004416 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004417 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004418 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004419 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004420 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004421 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004422 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004423 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004424 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004425 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004426 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4427 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004428 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004429 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4430 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004431 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004432 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004433 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004434 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004435 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4436 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004437 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004438 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004439 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004440};
4441
4442static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004443 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004444 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4445 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004446 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004447 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004448 .phy_read = mv88e6xxx_g2_smi_phy_read,
4449 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004450 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004451 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004452 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004453 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004454 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004455 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004456 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004457 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004458 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004459 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004460 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004461 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004462 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004463 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004464 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004465 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004466 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4467 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004468 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004469 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4470 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004471 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004472 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004473 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004474 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004475 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4476 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004477 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004478 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004479 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004480 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004481 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004482};
4483
4484static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004485 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004486 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4487 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004488 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004489 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4490 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004491 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004492 .phy_read = mv88e6xxx_g2_smi_phy_read,
4493 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004494 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004495 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004496 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004497 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004498 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004499 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004500 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004501 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004502 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004503 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004504 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004505 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004506 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004507 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004508 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004509 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004510 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004511 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4512 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004513 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004514 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4515 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004516 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004517 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004518 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004519 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004520 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004521 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4522 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004523 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004524 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004525 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004526 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4527 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4528 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4529 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004530 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004531 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004532 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004533 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004534 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004535 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004536 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004537 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4538 .serdes_get_strings = mv88e6352_serdes_get_strings,
4539 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004540 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4541 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004542 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004543};
4544
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004545static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004546 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004547 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004548 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004549 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4550 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004551 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4552 .phy_read = mv88e6xxx_g2_smi_phy_read,
4553 .phy_write = mv88e6xxx_g2_smi_phy_write,
4554 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004555 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004556 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004557 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004558 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004559 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004560 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004561 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004562 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004563 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004564 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004565 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004566 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004567 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004568 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004569 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004570 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004571 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004572 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004573 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4574 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004575 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004576 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4577 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004578 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004579 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004580 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004581 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004582 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004583 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4584 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004585 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4586 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004587 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004588 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004589 /* Check status register pause & lpa register */
4590 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4591 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4592 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4593 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004594 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004595 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004596 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004597 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004598 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004599 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004600 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4601 .serdes_get_strings = mv88e6390_serdes_get_strings,
4602 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004603 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4604 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004605 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004606};
4607
4608static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004609 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004610 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004611 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004612 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4613 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004614 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4615 .phy_read = mv88e6xxx_g2_smi_phy_read,
4616 .phy_write = mv88e6xxx_g2_smi_phy_write,
4617 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004618 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004619 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004620 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004621 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004622 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004623 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004624 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004625 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004626 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004627 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004628 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004629 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004630 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004631 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004632 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004633 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004634 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004635 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004636 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4637 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004638 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004639 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4640 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004641 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004642 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004643 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004644 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004645 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004646 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4647 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004648 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4649 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004650 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004651 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004652 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4653 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4654 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4655 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004656 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004657 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004658 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004659 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4660 .serdes_get_strings = mv88e6390_serdes_get_strings,
4661 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004662 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4663 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004664 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004665 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004666 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004667 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004668};
4669
Vivien Didelotf81ec902016-05-09 13:22:58 -04004670static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4671 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004672 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004673 .family = MV88E6XXX_FAMILY_6097,
4674 .name = "Marvell 88E6085",
4675 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004676 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004677 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004678 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004679 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004680 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004681 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004682 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004683 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004684 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004685 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004686 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004687 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004688 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004689 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004690 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004691 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004692 },
4693
4694 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004695 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004696 .family = MV88E6XXX_FAMILY_6095,
4697 .name = "Marvell 88E6095/88E6095F",
4698 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004699 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004700 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004701 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004702 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004703 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004704 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004705 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004706 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004707 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004708 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004709 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004710 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004711 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004712 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004713 },
4714
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004715 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004716 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004717 .family = MV88E6XXX_FAMILY_6097,
4718 .name = "Marvell 88E6097/88E6097F",
4719 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004720 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004721 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004722 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004723 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004724 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004725 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004726 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004727 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004728 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004729 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004730 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004731 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004732 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004733 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004734 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004735 .ops = &mv88e6097_ops,
4736 },
4737
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004739 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004740 .family = MV88E6XXX_FAMILY_6165,
4741 .name = "Marvell 88E6123",
4742 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004743 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004744 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004745 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004746 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004747 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004748 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004749 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004750 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004751 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004752 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004753 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004754 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004755 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004756 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004757 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004758 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004759 },
4760
4761 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004762 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004763 .family = MV88E6XXX_FAMILY_6185,
4764 .name = "Marvell 88E6131",
4765 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004766 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004767 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004768 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004769 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004770 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004771 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004772 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004773 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004774 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004775 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004776 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004777 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004778 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004779 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004780 },
4781
Vivien Didelot990e27b2017-03-28 13:50:32 -04004782 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004783 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004784 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004785 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004786 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004787 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004788 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004789 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004790 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004791 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004792 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004793 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004794 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004795 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004796 .age_time_coeff = 3750,
4797 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004798 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004799 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004800 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004801 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004802 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004803 .ops = &mv88e6141_ops,
4804 },
4805
Vivien Didelotf81ec902016-05-09 13:22:58 -04004806 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004807 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004808 .family = MV88E6XXX_FAMILY_6165,
4809 .name = "Marvell 88E6161",
4810 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004811 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004812 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004813 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004814 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004815 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004816 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004817 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004818 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004819 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004820 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004821 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004822 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004823 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004824 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004825 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004826 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004827 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004828 },
4829
4830 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004831 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004832 .family = MV88E6XXX_FAMILY_6165,
4833 .name = "Marvell 88E6165",
4834 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004835 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004836 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004837 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004838 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004839 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004840 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004841 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004842 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004843 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004844 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004845 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004846 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004847 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004848 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004849 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004850 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004851 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004852 },
4853
4854 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004855 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004856 .family = MV88E6XXX_FAMILY_6351,
4857 .name = "Marvell 88E6171",
4858 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004859 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004860 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004861 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004862 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004863 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004864 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004865 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004866 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004867 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004868 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004869 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004870 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004871 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004872 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004873 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004874 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004875 },
4876
4877 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004878 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004879 .family = MV88E6XXX_FAMILY_6352,
4880 .name = "Marvell 88E6172",
4881 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004882 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004883 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004884 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004885 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004886 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004887 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004888 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004889 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004890 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004891 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004892 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004893 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004894 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004895 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004896 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004897 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004898 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004899 },
4900
4901 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004902 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004903 .family = MV88E6XXX_FAMILY_6351,
4904 .name = "Marvell 88E6175",
4905 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004906 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004907 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004908 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004909 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004910 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004911 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004912 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004913 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004914 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004915 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004916 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004917 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004918 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004919 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004920 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004921 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004922 },
4923
4924 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004925 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004926 .family = MV88E6XXX_FAMILY_6352,
4927 .name = "Marvell 88E6176",
4928 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004929 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004930 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004931 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004932 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004933 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004934 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004935 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004936 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004937 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004938 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004939 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004940 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004941 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004942 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004943 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004944 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004945 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004946 },
4947
4948 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004949 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004950 .family = MV88E6XXX_FAMILY_6185,
4951 .name = "Marvell 88E6185",
4952 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004953 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004954 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004955 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004956 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004957 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004958 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004959 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004960 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004961 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004962 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004963 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004964 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004965 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004966 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004967 },
4968
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004969 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004970 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004971 .family = MV88E6XXX_FAMILY_6390,
4972 .name = "Marvell 88E6190",
4973 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004974 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004975 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004976 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004977 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004978 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004979 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004980 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004981 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004982 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004983 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004984 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004985 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004986 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004987 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004988 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004989 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004990 .ops = &mv88e6190_ops,
4991 },
4992
4993 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004994 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004995 .family = MV88E6XXX_FAMILY_6390,
4996 .name = "Marvell 88E6190X",
4997 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004998 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004999 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005000 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005001 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005002 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005003 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005004 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005005 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005006 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005007 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005008 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005009 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005010 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005011 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005012 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005013 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005014 .ops = &mv88e6190x_ops,
5015 },
5016
5017 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005018 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005019 .family = MV88E6XXX_FAMILY_6390,
5020 .name = "Marvell 88E6191",
5021 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005022 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005023 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005024 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005025 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005026 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005027 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005028 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005029 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005030 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005031 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005032 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005033 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005034 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005035 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005036 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005037 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005038 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005039 },
5040
Hubert Feurstein49022642019-07-31 10:23:46 +02005041 [MV88E6220] = {
5042 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5043 .family = MV88E6XXX_FAMILY_6250,
5044 .name = "Marvell 88E6220",
5045 .num_databases = 64,
5046
5047 /* Ports 2-4 are not routed to pins
5048 * => usable ports 0, 1, 5, 6
5049 */
5050 .num_ports = 7,
5051 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005052 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005053 .max_vid = 4095,
5054 .port_base_addr = 0x08,
5055 .phy_base_addr = 0x00,
5056 .global1_addr = 0x0f,
5057 .global2_addr = 0x07,
5058 .age_time_coeff = 15000,
5059 .g1_irqs = 9,
5060 .g2_irqs = 10,
5061 .atu_move_port_mask = 0xf,
5062 .dual_chip = true,
5063 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005064 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005065 .ops = &mv88e6250_ops,
5066 },
5067
Vivien Didelotf81ec902016-05-09 13:22:58 -04005068 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005069 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005070 .family = MV88E6XXX_FAMILY_6352,
5071 .name = "Marvell 88E6240",
5072 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005073 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005074 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005075 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005076 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005077 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005078 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005079 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005080 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005081 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005082 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005083 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005084 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005085 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005086 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005087 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005088 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005089 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005090 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005091 },
5092
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005093 [MV88E6250] = {
5094 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5095 .family = MV88E6XXX_FAMILY_6250,
5096 .name = "Marvell 88E6250",
5097 .num_databases = 64,
5098 .num_ports = 7,
5099 .num_internal_phys = 5,
5100 .max_vid = 4095,
5101 .port_base_addr = 0x08,
5102 .phy_base_addr = 0x00,
5103 .global1_addr = 0x0f,
5104 .global2_addr = 0x07,
5105 .age_time_coeff = 15000,
5106 .g1_irqs = 9,
5107 .g2_irqs = 10,
5108 .atu_move_port_mask = 0xf,
5109 .dual_chip = true,
5110 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005111 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005112 .ops = &mv88e6250_ops,
5113 },
5114
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005115 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005116 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005117 .family = MV88E6XXX_FAMILY_6390,
5118 .name = "Marvell 88E6290",
5119 .num_databases = 4096,
5120 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005121 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005122 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005123 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005124 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005125 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005126 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005127 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005128 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005129 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005130 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005131 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005132 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005133 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005134 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005135 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005136 .ops = &mv88e6290_ops,
5137 },
5138
Vivien Didelotf81ec902016-05-09 13:22:58 -04005139 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005140 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005141 .family = MV88E6XXX_FAMILY_6320,
5142 .name = "Marvell 88E6320",
5143 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005144 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005145 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005146 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005147 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005148 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005149 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005150 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005151 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005152 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005153 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005154 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005155 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005156 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005157 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005158 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005159 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005160 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005161 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005162 },
5163
5164 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005165 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005166 .family = MV88E6XXX_FAMILY_6320,
5167 .name = "Marvell 88E6321",
5168 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005169 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005170 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005171 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005172 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005173 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005174 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005175 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005176 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005177 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005178 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005179 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005180 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005181 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005182 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005183 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005184 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005185 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005186 },
5187
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005188 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005189 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005190 .family = MV88E6XXX_FAMILY_6341,
5191 .name = "Marvell 88E6341",
5192 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005193 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005194 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005195 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005196 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005197 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005198 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005199 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005200 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005201 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005202 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005203 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005204 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005205 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005206 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005207 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005208 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005209 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005210 .ops = &mv88e6341_ops,
5211 },
5212
Vivien Didelotf81ec902016-05-09 13:22:58 -04005213 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005214 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005215 .family = MV88E6XXX_FAMILY_6351,
5216 .name = "Marvell 88E6350",
5217 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005218 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005219 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005220 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005221 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005222 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005223 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005224 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005225 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005226 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005227 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005228 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005229 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005230 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005231 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005232 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005233 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005234 },
5235
5236 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005237 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005238 .family = MV88E6XXX_FAMILY_6351,
5239 .name = "Marvell 88E6351",
5240 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005241 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005242 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005243 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005244 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005245 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005246 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005247 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005248 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005249 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005250 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005251 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005252 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005253 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005254 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005255 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005256 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005257 },
5258
5259 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005260 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005261 .family = MV88E6XXX_FAMILY_6352,
5262 .name = "Marvell 88E6352",
5263 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005264 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005265 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005266 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005267 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005268 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005269 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005270 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005271 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005272 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005273 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005274 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005275 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005276 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005277 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005278 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005279 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005280 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005281 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005282 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005283 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005284 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005285 .family = MV88E6XXX_FAMILY_6390,
5286 .name = "Marvell 88E6390",
5287 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005288 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005289 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005290 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005291 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005292 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005293 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005294 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005295 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005296 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005297 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005298 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005299 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005300 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005301 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005302 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005303 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005304 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005305 .ops = &mv88e6390_ops,
5306 },
5307 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005308 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005309 .family = MV88E6XXX_FAMILY_6390,
5310 .name = "Marvell 88E6390X",
5311 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005312 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005313 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005314 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005315 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005316 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005317 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005318 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005319 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005320 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005321 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005322 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005323 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005324 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005325 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005326 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005327 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005328 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005329 .ops = &mv88e6390x_ops,
5330 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005331};
5332
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005333static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005334{
Vivien Didelota439c062016-04-17 13:23:58 -04005335 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005336
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005337 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5338 if (mv88e6xxx_table[i].prod_num == prod_num)
5339 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005340
Vivien Didelotb9b37712015-10-30 19:39:48 -04005341 return NULL;
5342}
5343
Vivien Didelotfad09c72016-06-21 12:28:20 -04005344static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005345{
5346 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005347 unsigned int prod_num, rev;
5348 u16 id;
5349 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005350
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005351 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005352 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005353 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005354 if (err)
5355 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005356
Vivien Didelot107fcc12017-06-12 12:37:36 -04005357 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5358 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005359
5360 info = mv88e6xxx_lookup_info(prod_num);
5361 if (!info)
5362 return -ENODEV;
5363
Vivien Didelotcaac8542016-06-20 13:14:09 -04005364 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005365 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005366
Vivien Didelotca070c12016-09-02 14:45:34 -04005367 err = mv88e6xxx_g2_require(chip);
5368 if (err)
5369 return err;
5370
Vivien Didelotfad09c72016-06-21 12:28:20 -04005371 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5372 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005373
5374 return 0;
5375}
5376
Vivien Didelotfad09c72016-06-21 12:28:20 -04005377static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005378{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005379 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005380
Vivien Didelotfad09c72016-06-21 12:28:20 -04005381 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5382 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005383 return NULL;
5384
Vivien Didelotfad09c72016-06-21 12:28:20 -04005385 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005386
Vivien Didelotfad09c72016-06-21 12:28:20 -04005387 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005388 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005389 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005390
Vivien Didelotfad09c72016-06-21 12:28:20 -04005391 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005392}
5393
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005394static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005395 int port,
5396 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005397{
Vivien Didelot04bed142016-08-31 18:06:13 -04005398 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005399
Andrew Lunn443d5a12016-12-03 04:35:18 +01005400 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005401}
5402
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005403static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005404 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005405{
5406 /* We don't need any dynamic resource from the kernel (yet),
5407 * so skip the prepare phase.
5408 */
5409
5410 return 0;
5411}
5412
5413static void mv88e6xxx_port_mdb_add(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{
Vivien Didelot04bed142016-08-31 18:06:13 -04005416 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005417
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005418 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005419 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005420 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005421 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5422 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005423 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005424}
5425
5426static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5427 const struct switchdev_obj_port_mdb *mdb)
5428{
Vivien Didelot04bed142016-08-31 18:06:13 -04005429 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005430 int err;
5431
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005432 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005433 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005434 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005435
5436 return err;
5437}
5438
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005439static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5440 struct dsa_mall_mirror_tc_entry *mirror,
5441 bool ingress)
5442{
5443 enum mv88e6xxx_egress_direction direction = ingress ?
5444 MV88E6XXX_EGRESS_DIR_INGRESS :
5445 MV88E6XXX_EGRESS_DIR_EGRESS;
5446 struct mv88e6xxx_chip *chip = ds->priv;
5447 bool other_mirrors = false;
5448 int i;
5449 int err;
5450
5451 if (!chip->info->ops->set_egress_port)
5452 return -EOPNOTSUPP;
5453
5454 mutex_lock(&chip->reg_lock);
5455 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5456 mirror->to_local_port) {
5457 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5458 other_mirrors |= ingress ?
5459 chip->ports[i].mirror_ingress :
5460 chip->ports[i].mirror_egress;
5461
5462 /* Can't change egress port when other mirror is active */
5463 if (other_mirrors) {
5464 err = -EBUSY;
5465 goto out;
5466 }
5467
5468 err = chip->info->ops->set_egress_port(chip,
5469 direction,
5470 mirror->to_local_port);
5471 if (err)
5472 goto out;
5473 }
5474
5475 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5476out:
5477 mutex_unlock(&chip->reg_lock);
5478
5479 return err;
5480}
5481
5482static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5483 struct dsa_mall_mirror_tc_entry *mirror)
5484{
5485 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5486 MV88E6XXX_EGRESS_DIR_INGRESS :
5487 MV88E6XXX_EGRESS_DIR_EGRESS;
5488 struct mv88e6xxx_chip *chip = ds->priv;
5489 bool other_mirrors = false;
5490 int i;
5491
5492 mutex_lock(&chip->reg_lock);
5493 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5494 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5495
5496 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5497 other_mirrors |= mirror->ingress ?
5498 chip->ports[i].mirror_ingress :
5499 chip->ports[i].mirror_egress;
5500
5501 /* Reset egress port when no other mirror is active */
5502 if (!other_mirrors) {
5503 if (chip->info->ops->set_egress_port(chip,
5504 direction,
5505 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005506 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005507 dev_err(ds->dev, "failed to set egress port\n");
5508 }
5509
5510 mutex_unlock(&chip->reg_lock);
5511}
5512
Russell King4f859012019-02-20 15:35:05 -08005513static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5514 bool unicast, bool multicast)
5515{
5516 struct mv88e6xxx_chip *chip = ds->priv;
5517 int err = -EOPNOTSUPP;
5518
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005519 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005520 if (chip->info->ops->port_set_egress_floods)
5521 err = chip->info->ops->port_set_egress_floods(chip, port,
5522 unicast,
5523 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005524 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005525
5526 return err;
5527}
5528
Florian Fainellia82f67a2017-01-08 14:52:08 -08005529static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005530 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005531 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005532 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005533 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005534 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005535 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005536 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005537 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5538 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005539 .get_strings = mv88e6xxx_get_strings,
5540 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5541 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005542 .port_enable = mv88e6xxx_port_enable,
5543 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005544 .get_mac_eee = mv88e6xxx_get_mac_eee,
5545 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005546 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005547 .get_eeprom = mv88e6xxx_get_eeprom,
5548 .set_eeprom = mv88e6xxx_set_eeprom,
5549 .get_regs_len = mv88e6xxx_get_regs_len,
5550 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005551 .get_rxnfc = mv88e6xxx_get_rxnfc,
5552 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005553 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005554 .port_bridge_join = mv88e6xxx_port_bridge_join,
5555 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005556 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005557 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005558 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005559 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5560 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5561 .port_vlan_add = mv88e6xxx_port_vlan_add,
5562 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005563 .port_fdb_add = mv88e6xxx_port_fdb_add,
5564 .port_fdb_del = mv88e6xxx_port_fdb_del,
5565 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005566 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5567 .port_mdb_add = mv88e6xxx_port_mdb_add,
5568 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005569 .port_mirror_add = mv88e6xxx_port_mirror_add,
5570 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005571 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5572 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005573 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5574 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5575 .port_txtstamp = mv88e6xxx_port_txtstamp,
5576 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5577 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005578 .devlink_param_get = mv88e6xxx_devlink_param_get,
5579 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005580};
5581
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005582static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005583{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005584 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005585 struct dsa_switch *ds;
5586
Vivien Didelot7e99e342019-10-21 16:51:30 -04005587 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005588 if (!ds)
5589 return -ENOMEM;
5590
Vivien Didelot7e99e342019-10-21 16:51:30 -04005591 ds->dev = dev;
5592 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005593 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005594 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005595 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005596 ds->ageing_time_min = chip->info->age_time_coeff;
5597 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005598
5599 dev_set_drvdata(dev, ds);
5600
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005601 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005602}
5603
Vivien Didelotfad09c72016-06-21 12:28:20 -04005604static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005605{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005606 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005607}
5608
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005609static const void *pdata_device_get_match_data(struct device *dev)
5610{
5611 const struct of_device_id *matches = dev->driver->of_match_table;
5612 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5613
5614 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5615 matches++) {
5616 if (!strcmp(pdata->compatible, matches->compatible))
5617 return matches->data;
5618 }
5619 return NULL;
5620}
5621
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005622/* There is no suspend to RAM support at DSA level yet, the switch configuration
5623 * would be lost after a power cycle so prevent it to be suspended.
5624 */
5625static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5626{
5627 return -EOPNOTSUPP;
5628}
5629
5630static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5631{
5632 return 0;
5633}
5634
5635static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5636
Vivien Didelot57d32312016-06-20 13:13:58 -04005637static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005638{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005639 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005640 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005641 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005642 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005643 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005644 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005645 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005646
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005647 if (!np && !pdata)
5648 return -EINVAL;
5649
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005650 if (np)
5651 compat_info = of_device_get_match_data(dev);
5652
5653 if (pdata) {
5654 compat_info = pdata_device_get_match_data(dev);
5655
5656 if (!pdata->netdev)
5657 return -EINVAL;
5658
5659 for (port = 0; port < DSA_MAX_PORTS; port++) {
5660 if (!(pdata->enabled_ports & (1 << port)))
5661 continue;
5662 if (strcmp(pdata->cd.port_names[port], "cpu"))
5663 continue;
5664 pdata->cd.netdev[port] = &pdata->netdev->dev;
5665 break;
5666 }
5667 }
5668
Vivien Didelotcaac8542016-06-20 13:14:09 -04005669 if (!compat_info)
5670 return -EINVAL;
5671
Vivien Didelotfad09c72016-06-21 12:28:20 -04005672 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005673 if (!chip) {
5674 err = -ENOMEM;
5675 goto out;
5676 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005677
Vivien Didelotfad09c72016-06-21 12:28:20 -04005678 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005679
Vivien Didelotfad09c72016-06-21 12:28:20 -04005680 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005681 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005682 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005683
Andrew Lunnb4308f02016-11-21 23:26:55 +01005684 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005685 if (IS_ERR(chip->reset)) {
5686 err = PTR_ERR(chip->reset);
5687 goto out;
5688 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005689 if (chip->reset)
5690 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005691
Vivien Didelotfad09c72016-06-21 12:28:20 -04005692 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005693 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005694 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005695
Vivien Didelote57e5e72016-08-15 17:19:00 -04005696 mv88e6xxx_phy_init(chip);
5697
Andrew Lunn00baabe2018-05-19 22:31:35 +02005698 if (chip->info->ops->get_eeprom) {
5699 if (np)
5700 of_property_read_u32(np, "eeprom-length",
5701 &chip->eeprom_len);
5702 else
5703 chip->eeprom_len = pdata->eeprom_len;
5704 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005705
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005706 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005707 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005708 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005709 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005710 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005711
Andrew Lunna27415d2019-05-01 00:10:50 +02005712 if (np) {
5713 chip->irq = of_irq_get(np, 0);
5714 if (chip->irq == -EPROBE_DEFER) {
5715 err = chip->irq;
5716 goto out;
5717 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005718 }
5719
Andrew Lunna27415d2019-05-01 00:10:50 +02005720 if (pdata)
5721 chip->irq = pdata->irq;
5722
Andrew Lunn294d7112018-02-22 22:58:32 +01005723 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005724 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005725 * controllers
5726 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005727 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005728 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005729 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005730 else
5731 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005732 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005733
Andrew Lunn294d7112018-02-22 22:58:32 +01005734 if (err)
5735 goto out;
5736
5737 if (chip->info->g2_irqs > 0) {
5738 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005739 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005740 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005741 }
5742
Andrew Lunn294d7112018-02-22 22:58:32 +01005743 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5744 if (err)
5745 goto out_g2_irq;
5746
5747 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5748 if (err)
5749 goto out_g1_atu_prob_irq;
5750
Andrew Lunna3c53be52017-01-24 14:53:50 +01005751 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005752 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005753 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005754
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005755 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005756 if (err)
5757 goto out_mdio;
5758
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005759 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005760
5761out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005762 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005763out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005764 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005765out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005766 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005767out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005768 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005769 mv88e6xxx_g2_irq_free(chip);
5770out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005771 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005772 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005773 else
5774 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005775out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005776 if (pdata)
5777 dev_put(pdata->netdev);
5778
Andrew Lunndc30c352016-10-16 19:56:49 +02005779 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005780}
5781
5782static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5783{
5784 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005785 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005786
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005787 if (chip->info->ptp_support) {
5788 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005789 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005790 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005791
Andrew Lunn930188c2016-08-22 16:01:03 +02005792 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005793 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005794 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005795
Andrew Lunn76f38f12018-03-17 20:21:09 +01005796 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5797 mv88e6xxx_g1_atu_prob_irq_free(chip);
5798
5799 if (chip->info->g2_irqs > 0)
5800 mv88e6xxx_g2_irq_free(chip);
5801
Andrew Lunn76f38f12018-03-17 20:21:09 +01005802 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005803 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005804 else
5805 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005806}
5807
5808static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005809 {
5810 .compatible = "marvell,mv88e6085",
5811 .data = &mv88e6xxx_table[MV88E6085],
5812 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005813 {
5814 .compatible = "marvell,mv88e6190",
5815 .data = &mv88e6xxx_table[MV88E6190],
5816 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005817 {
5818 .compatible = "marvell,mv88e6250",
5819 .data = &mv88e6xxx_table[MV88E6250],
5820 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005821 { /* sentinel */ },
5822};
5823
5824MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5825
5826static struct mdio_driver mv88e6xxx_driver = {
5827 .probe = mv88e6xxx_probe,
5828 .remove = mv88e6xxx_remove,
5829 .mdiodrv.driver = {
5830 .name = "mv88e6085",
5831 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005832 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005833 },
5834};
5835
Andrew Lunn7324d502019-04-27 19:19:10 +02005836mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005837
5838MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5839MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5840MODULE_LICENSE("GPL");