blob: c72b3db75c54324be135a91b2ef3626f6277333f [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
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000343 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100344 err = request_threaded_irq(chip->irq, NULL,
345 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200346 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 dev_name(chip->dev), chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000348 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100349 if (err)
350 mv88e6xxx_g1_irq_free_common(chip);
351
352 return err;
353}
354
355static void mv88e6xxx_irq_poll(struct kthread_work *work)
356{
357 struct mv88e6xxx_chip *chip = container_of(work,
358 struct mv88e6xxx_chip,
359 irq_poll_work.work);
360 mv88e6xxx_g1_irq_thread_work(chip);
361
362 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
363 msecs_to_jiffies(100));
364}
365
366static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
367{
368 int err;
369
370 err = mv88e6xxx_g1_irq_setup_common(chip);
371 if (err)
372 return err;
373
374 kthread_init_delayed_work(&chip->irq_poll_work,
375 mv88e6xxx_irq_poll);
376
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800377 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100378 if (IS_ERR(chip->kworker))
379 return PTR_ERR(chip->kworker);
380
381 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
382 msecs_to_jiffies(100));
383
384 return 0;
385}
386
387static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
388{
389 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
390 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200391
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000392 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200393 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000394 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100395}
396
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100397int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
398 int speed, int duplex, int pause,
399 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100400{
Andrew Lunna26deec2019-04-18 03:11:39 +0200401 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100402 int err;
403
404 if (!chip->info->ops->port_set_link)
405 return 0;
406
Andrew Lunna26deec2019-04-18 03:11:39 +0200407 if (!chip->info->ops->port_link_state)
408 return 0;
409
410 err = chip->info->ops->port_link_state(chip, port, &state);
411 if (err)
412 return err;
413
414 /* Has anything actually changed? We don't expect the
415 * interface mode to change without one of the other
416 * parameters also changing
417 */
418 if (state.link == link &&
419 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200420 state.duplex == duplex &&
421 (state.interface == mode ||
422 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200423 return 0;
424
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200426 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100427 if (err)
428 return err;
429
430 if (chip->info->ops->port_set_speed) {
431 err = chip->info->ops->port_set_speed(chip, port, speed);
432 if (err && err != -EOPNOTSUPP)
433 goto restore_link;
434 }
435
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100436 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
437 mode = chip->info->ops->port_max_speed_mode(port);
438
Andrew Lunn54186b92018-08-09 15:38:37 +0200439 if (chip->info->ops->port_set_pause) {
440 err = chip->info->ops->port_set_pause(chip, port, pause);
441 if (err)
442 goto restore_link;
443 }
444
Vivien Didelotd78343d2016-11-04 03:23:36 +0100445 if (chip->info->ops->port_set_duplex) {
446 err = chip->info->ops->port_set_duplex(chip, port, duplex);
447 if (err && err != -EOPNOTSUPP)
448 goto restore_link;
449 }
450
451 if (chip->info->ops->port_set_rgmii_delay) {
452 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
453 if (err && err != -EOPNOTSUPP)
454 goto restore_link;
455 }
456
Andrew Lunnf39908d2017-02-04 20:02:50 +0100457 if (chip->info->ops->port_set_cmode) {
458 err = chip->info->ops->port_set_cmode(chip, port, mode);
459 if (err && err != -EOPNOTSUPP)
460 goto restore_link;
461 }
462
Vivien Didelotd78343d2016-11-04 03:23:36 +0100463 err = 0;
464restore_link:
465 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400466 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100467
468 return err;
469}
470
Marek Vasutd700ec42018-09-12 00:15:24 +0200471static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
472{
473 struct mv88e6xxx_chip *chip = ds->priv;
474
475 return port < chip->info->num_internal_phys;
476}
477
Russell King6c422e32018-08-09 15:38:39 +0200478static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
479 unsigned long *mask,
480 struct phylink_link_state *state)
481{
482 if (!phy_interface_mode_is_8023z(state->interface)) {
483 /* 10M and 100M are only supported in non-802.3z mode */
484 phylink_set(mask, 10baseT_Half);
485 phylink_set(mask, 10baseT_Full);
486 phylink_set(mask, 100baseT_Half);
487 phylink_set(mask, 100baseT_Full);
488 }
489}
490
491static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
492 unsigned long *mask,
493 struct phylink_link_state *state)
494{
495 /* FIXME: if the port is in 1000Base-X mode, then it only supports
496 * 1000M FD speeds. In this case, CMODE will indicate 5.
497 */
498 phylink_set(mask, 1000baseT_Full);
499 phylink_set(mask, 1000baseX_Full);
500
501 mv88e6065_phylink_validate(chip, port, mask, state);
502}
503
Marek Behúne3af71a2019-02-25 12:39:55 +0100504static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
505 unsigned long *mask,
506 struct phylink_link_state *state)
507{
508 if (port >= 5)
509 phylink_set(mask, 2500baseX_Full);
510
511 /* No ethtool bits for 200Mbps */
512 phylink_set(mask, 1000baseT_Full);
513 phylink_set(mask, 1000baseX_Full);
514
515 mv88e6065_phylink_validate(chip, port, mask, state);
516}
517
Russell King6c422e32018-08-09 15:38:39 +0200518static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
519 unsigned long *mask,
520 struct phylink_link_state *state)
521{
522 /* No ethtool bits for 200Mbps */
523 phylink_set(mask, 1000baseT_Full);
524 phylink_set(mask, 1000baseX_Full);
525
526 mv88e6065_phylink_validate(chip, port, mask, state);
527}
528
529static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
530 unsigned long *mask,
531 struct phylink_link_state *state)
532{
Andrew Lunnec260162019-02-08 22:25:44 +0100533 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200534 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100535 phylink_set(mask, 2500baseT_Full);
536 }
Russell King6c422e32018-08-09 15:38:39 +0200537
538 /* No ethtool bits for 200Mbps */
539 phylink_set(mask, 1000baseT_Full);
540 phylink_set(mask, 1000baseX_Full);
541
542 mv88e6065_phylink_validate(chip, port, mask, state);
543}
544
545static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
546 unsigned long *mask,
547 struct phylink_link_state *state)
548{
549 if (port >= 9) {
550 phylink_set(mask, 10000baseT_Full);
551 phylink_set(mask, 10000baseKR_Full);
552 }
553
554 mv88e6390_phylink_validate(chip, port, mask, state);
555}
556
Russell Kingc9a23562018-05-10 13:17:35 -0700557static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
558 unsigned long *supported,
559 struct phylink_link_state *state)
560{
Russell King6c422e32018-08-09 15:38:39 +0200561 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
562 struct mv88e6xxx_chip *chip = ds->priv;
563
564 /* Allow all the expected bits */
565 phylink_set(mask, Autoneg);
566 phylink_set(mask, Pause);
567 phylink_set_port_modes(mask);
568
569 if (chip->info->ops->phylink_validate)
570 chip->info->ops->phylink_validate(chip, port, mask, state);
571
572 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
573 bitmap_and(state->advertising, state->advertising, mask,
574 __ETHTOOL_LINK_MODE_MASK_NBITS);
575
576 /* We can only operate at 2500BaseX or 1000BaseX. If requested
577 * to advertise both, only report advertising at 2500BaseX.
578 */
579 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700580}
581
582static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
583 struct phylink_link_state *state)
584{
585 struct mv88e6xxx_chip *chip = ds->priv;
586 int err;
587
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000588 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200589 if (chip->info->ops->port_link_state)
590 err = chip->info->ops->port_link_state(chip, port, state);
591 else
592 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000593 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700594
595 return err;
596}
597
598static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
599 unsigned int mode,
600 const struct phylink_link_state *state)
601{
602 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200603 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700604
Marek Vasutd700ec42018-09-12 00:15:24 +0200605 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700606 return;
607
608 if (mode == MLO_AN_FIXED) {
609 link = LINK_FORCED_UP;
610 speed = state->speed;
611 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200612 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
613 link = state->link;
614 speed = state->speed;
615 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700616 } else {
617 speed = SPEED_UNFORCED;
618 duplex = DUPLEX_UNFORCED;
619 link = LINK_UNFORCED;
620 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200621 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700622
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000623 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700625 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700627
628 if (err && err != -EOPNOTSUPP)
629 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
630}
631
632static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
633{
634 struct mv88e6xxx_chip *chip = ds->priv;
635 int err;
636
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000637 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700638 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000639 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700640
641 if (err)
642 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
643}
644
645static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
646 unsigned int mode,
647 phy_interface_t interface)
648{
649 if (mode == MLO_AN_FIXED)
650 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
651}
652
653static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
654 unsigned int mode, phy_interface_t interface,
655 struct phy_device *phydev)
656{
657 if (mode == MLO_AN_FIXED)
658 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
659}
660
Andrew Lunna605a0f2016-11-21 23:26:58 +0100661static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000662{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100663 if (!chip->info->ops->stats_snapshot)
664 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000667}
668
Andrew Lunne413e7e2015-04-02 04:06:38 +0200669static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100670 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
671 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
672 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
673 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
674 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
675 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
676 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
677 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
678 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
679 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
680 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
681 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
682 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
683 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
684 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
685 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
686 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
687 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
688 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
689 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
690 { "single", 4, 0x14, STATS_TYPE_BANK0, },
691 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
692 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
693 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
694 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
695 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
696 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
697 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
698 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
699 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
700 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
701 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
702 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
703 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
704 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
705 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
706 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
707 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
708 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
709 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
710 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
711 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
712 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
713 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
714 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
715 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
716 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
717 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
718 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
719 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
720 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
721 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
722 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
723 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
724 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
725 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
726 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
727 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
728 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200729};
730
Vivien Didelotfad09c72016-06-21 12:28:20 -0400731static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100732 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100733 int port, u16 bank1_select,
734 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200735{
Andrew Lunn80c46272015-06-20 18:42:30 +0200736 u32 low;
737 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100738 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200739 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200740 u64 value;
741
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100742 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100743 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200744 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
745 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800746 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200747
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200748 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100749 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200750 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
751 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800752 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000753 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200754 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100755 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100756 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100757 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100758 /* fall through */
759 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100761 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100762 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100763 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500764 break;
765 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800766 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200767 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100768 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200769 return value;
770}
771
Andrew Lunn436fe172018-03-01 02:02:29 +0100772static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
773 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100774{
775 struct mv88e6xxx_hw_stat *stat;
776 int i, j;
777
778 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
779 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100780 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100781 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
782 ETH_GSTRING_LEN);
783 j++;
784 }
785 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100786
787 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100788}
789
Andrew Lunn436fe172018-03-01 02:02:29 +0100790static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
791 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100792{
Andrew Lunn436fe172018-03-01 02:02:29 +0100793 return mv88e6xxx_stats_get_strings(chip, data,
794 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100795}
796
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000797static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
798 uint8_t *data)
799{
800 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
801}
802
Andrew Lunn436fe172018-03-01 02:02:29 +0100803static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
804 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100805{
Andrew Lunn436fe172018-03-01 02:02:29 +0100806 return mv88e6xxx_stats_get_strings(chip, data,
807 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100808}
809
Andrew Lunn65f60e42018-03-28 23:50:28 +0200810static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
811 "atu_member_violation",
812 "atu_miss_violation",
813 "atu_full_violation",
814 "vtu_member_violation",
815 "vtu_miss_violation",
816};
817
818static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
819{
820 unsigned int i;
821
822 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
823 strlcpy(data + i * ETH_GSTRING_LEN,
824 mv88e6xxx_atu_vtu_stats_strings[i],
825 ETH_GSTRING_LEN);
826}
827
Andrew Lunndfafe442016-11-21 23:27:02 +0100828static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700829 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100830{
Vivien Didelot04bed142016-08-31 18:06:13 -0400831 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100832 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100833
Florian Fainelli89f09042018-04-25 12:12:50 -0700834 if (stringset != ETH_SS_STATS)
835 return;
836
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000837 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100838
Andrew Lunndfafe442016-11-21 23:27:02 +0100839 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100840 count = chip->info->ops->stats_get_strings(chip, data);
841
842 if (chip->info->ops->serdes_get_strings) {
843 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200844 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100845 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100846
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 data += count * ETH_GSTRING_LEN;
848 mv88e6xxx_atu_vtu_get_strings(data);
849
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000850 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100851}
852
853static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
854 int types)
855{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100856 struct mv88e6xxx_hw_stat *stat;
857 int i, j;
858
859 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
860 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100861 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100862 j++;
863 }
864 return j;
865}
866
Andrew Lunndfafe442016-11-21 23:27:02 +0100867static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
868{
869 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
870 STATS_TYPE_PORT);
871}
872
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000873static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
874{
875 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
876}
877
Andrew Lunndfafe442016-11-21 23:27:02 +0100878static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
879{
880 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
881 STATS_TYPE_BANK1);
882}
883
Florian Fainelli89f09042018-04-25 12:12:50 -0700884static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100885{
886 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100887 int serdes_count = 0;
888 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100889
Florian Fainelli89f09042018-04-25 12:12:50 -0700890 if (sset != ETH_SS_STATS)
891 return 0;
892
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000893 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100894 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100895 count = chip->info->ops->stats_get_sset_count(chip);
896 if (count < 0)
897 goto out;
898
899 if (chip->info->ops->serdes_get_sset_count)
900 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
901 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200902 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100903 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200904 goto out;
905 }
906 count += serdes_count;
907 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
908
Andrew Lunn436fe172018-03-01 02:02:29 +0100909out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000910 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100913}
914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
916 uint64_t *data, int types,
917 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100918{
919 struct mv88e6xxx_hw_stat *stat;
920 int i, j;
921
922 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
923 stat = &mv88e6xxx_hw_stats[i];
924 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000925 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100926 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
927 bank1_select,
928 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000929 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100930
Andrew Lunn052f9472016-11-21 23:27:03 +0100931 j++;
932 }
933 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100934 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100935}
936
Andrew Lunn436fe172018-03-01 02:02:29 +0100937static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
938 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100939{
940 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100941 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400942 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100943}
944
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000945static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
946 uint64_t *data)
947{
948 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
949 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
950}
951
Andrew Lunn436fe172018-03-01 02:02:29 +0100952static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
953 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100954{
955 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100956 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400957 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
958 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959}
960
Andrew Lunn436fe172018-03-01 02:02:29 +0100961static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
962 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100963{
964 return mv88e6xxx_stats_get_stats(chip, port, data,
965 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400966 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
967 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100968}
969
Andrew Lunn65f60e42018-03-28 23:50:28 +0200970static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
971 uint64_t *data)
972{
973 *data++ = chip->ports[port].atu_member_violation;
974 *data++ = chip->ports[port].atu_miss_violation;
975 *data++ = chip->ports[port].atu_full_violation;
976 *data++ = chip->ports[port].vtu_member_violation;
977 *data++ = chip->ports[port].vtu_miss_violation;
978}
979
Andrew Lunn052f9472016-11-21 23:27:03 +0100980static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
981 uint64_t *data)
982{
Andrew Lunn436fe172018-03-01 02:02:29 +0100983 int count = 0;
984
Andrew Lunn052f9472016-11-21 23:27:03 +0100985 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 count = chip->info->ops->stats_get_stats(chip, port, data);
987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000988 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 if (chip->info->ops->serdes_get_stats) {
990 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200991 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200993 data += count;
994 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000995 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100996}
997
Vivien Didelotf81ec902016-05-09 13:22:58 -0400998static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
999 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001000{
Vivien Didelot04bed142016-08-31 18:06:13 -04001001 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001002 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001004 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005
Andrew Lunna605a0f2016-11-21 23:26:58 +01001006 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001008
1009 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001010 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001011
1012 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001014}
Ben Hutchings98e67302011-11-25 14:36:19 +00001015
Vivien Didelotf81ec902016-05-09 13:22:58 -04001016static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001017{
1018 return 32 * sizeof(u16);
1019}
1020
Vivien Didelotf81ec902016-05-09 13:22:58 -04001021static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1022 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001023{
Vivien Didelot04bed142016-08-31 18:06:13 -04001024 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001025 int err;
1026 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001027 u16 *p = _p;
1028 int i;
1029
Vivien Didelota5f39322018-12-17 16:05:21 -05001030 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001031
1032 memset(p, 0xff, 32 * sizeof(u16));
1033
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001034 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001035
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001036 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001038 err = mv88e6xxx_port_read(chip, port, i, &reg);
1039 if (!err)
1040 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001041 }
Vivien Didelot23062512016-05-09 13:22:45 -04001042
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001043 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044}
1045
Vivien Didelot08f50062017-08-01 16:32:41 -04001046static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1047 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001048{
Vivien Didelot5480db62017-08-01 16:32:40 -04001049 /* Nothing to do on the port's MAC */
1050 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001051}
1052
Vivien Didelot08f50062017-08-01 16:32:41 -04001053static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1054 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001055{
Vivien Didelot5480db62017-08-01 16:32:40 -04001056 /* Nothing to do on the port's MAC */
1057 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001058}
1059
Vivien Didelote5887a22017-03-30 17:37:11 -04001060static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001061{
Vivien Didelote5887a22017-03-30 17:37:11 -04001062 struct dsa_switch *ds = NULL;
1063 struct net_device *br;
1064 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001065 int i;
1066
Vivien Didelote5887a22017-03-30 17:37:11 -04001067 if (dev < DSA_MAX_SWITCHES)
1068 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001069
Vivien Didelote5887a22017-03-30 17:37:11 -04001070 /* Prevent frames from unknown switch or port */
1071 if (!ds || port >= ds->num_ports)
1072 return 0;
1073
1074 /* Frames from DSA links and CPU ports can egress any local port */
1075 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1076 return mv88e6xxx_port_mask(chip);
1077
1078 br = ds->ports[port].bridge_dev;
1079 pvlan = 0;
1080
1081 /* Frames from user ports can egress any local DSA links and CPU ports,
1082 * as well as any local member of their bridge group.
1083 */
1084 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1085 if (dsa_is_cpu_port(chip->ds, i) ||
1086 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001087 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001088 pvlan |= BIT(i);
1089
1090 return pvlan;
1091}
1092
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001093static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001094{
1095 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001096
1097 /* prevent frames from going back out of the port they came in on */
1098 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001099
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001100 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001101}
1102
Vivien Didelotf81ec902016-05-09 13:22:58 -04001103static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1104 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001105{
Vivien Didelot04bed142016-08-31 18:06:13 -04001106 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001107 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001109 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001110 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001111 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001112
1113 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001114 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001115}
1116
Vivien Didelot93e18d62018-05-11 17:16:35 -04001117static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1118{
1119 int err;
1120
1121 if (chip->info->ops->ieee_pri_map) {
1122 err = chip->info->ops->ieee_pri_map(chip);
1123 if (err)
1124 return err;
1125 }
1126
1127 if (chip->info->ops->ip_pri_map) {
1128 err = chip->info->ops->ip_pri_map(chip);
1129 if (err)
1130 return err;
1131 }
1132
1133 return 0;
1134}
1135
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001136static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1137{
1138 int target, port;
1139 int err;
1140
1141 if (!chip->info->global2_addr)
1142 return 0;
1143
1144 /* Initialize the routing port to the 32 possible target devices */
1145 for (target = 0; target < 32; target++) {
1146 port = 0x1f;
1147 if (target < DSA_MAX_SWITCHES)
1148 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1149 port = chip->ds->rtable[target];
1150
1151 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1152 if (err)
1153 return err;
1154 }
1155
Vivien Didelot02317e62018-05-09 11:38:49 -04001156 if (chip->info->ops->set_cascade_port) {
1157 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1158 err = chip->info->ops->set_cascade_port(chip, port);
1159 if (err)
1160 return err;
1161 }
1162
Vivien Didelot23c98912018-05-09 11:38:50 -04001163 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1164 if (err)
1165 return err;
1166
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001167 return 0;
1168}
1169
Vivien Didelotb28f8722018-04-26 21:56:44 -04001170static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1171{
1172 /* Clear all trunk masks and mapping */
1173 if (chip->info->global2_addr)
1174 return mv88e6xxx_g2_trunk_clear(chip);
1175
1176 return 0;
1177}
1178
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001179static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1180{
1181 if (chip->info->ops->rmu_disable)
1182 return chip->info->ops->rmu_disable(chip);
1183
1184 return 0;
1185}
1186
Vivien Didelot9e907d72017-07-17 13:03:43 -04001187static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1188{
1189 if (chip->info->ops->pot_clear)
1190 return chip->info->ops->pot_clear(chip);
1191
1192 return 0;
1193}
1194
Vivien Didelot51c901a2017-07-17 13:03:41 -04001195static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1196{
1197 if (chip->info->ops->mgmt_rsvd2cpu)
1198 return chip->info->ops->mgmt_rsvd2cpu(chip);
1199
1200 return 0;
1201}
1202
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001203static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1204{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001205 int err;
1206
Vivien Didelotdaefc942017-03-11 16:12:54 -05001207 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1208 if (err)
1209 return err;
1210
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001211 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1212 if (err)
1213 return err;
1214
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001215 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1216}
1217
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001218static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1219{
1220 int port;
1221 int err;
1222
1223 if (!chip->info->ops->irl_init_all)
1224 return 0;
1225
1226 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1227 /* Disable ingress rate limiting by resetting all per port
1228 * ingress rate limit resources to their initial state.
1229 */
1230 err = chip->info->ops->irl_init_all(chip, port);
1231 if (err)
1232 return err;
1233 }
1234
1235 return 0;
1236}
1237
Vivien Didelot04a69a12017-10-13 14:18:05 -04001238static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1239{
1240 if (chip->info->ops->set_switch_mac) {
1241 u8 addr[ETH_ALEN];
1242
1243 eth_random_addr(addr);
1244
1245 return chip->info->ops->set_switch_mac(chip, addr);
1246 }
1247
1248 return 0;
1249}
1250
Vivien Didelot17a15942017-03-30 17:37:09 -04001251static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1252{
1253 u16 pvlan = 0;
1254
1255 if (!mv88e6xxx_has_pvt(chip))
1256 return -EOPNOTSUPP;
1257
1258 /* Skip the local source device, which uses in-chip port VLAN */
1259 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001260 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001261
1262 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1263}
1264
Vivien Didelot81228992017-03-30 17:37:08 -04001265static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1266{
Vivien Didelot17a15942017-03-30 17:37:09 -04001267 int dev, port;
1268 int err;
1269
Vivien Didelot81228992017-03-30 17:37:08 -04001270 if (!mv88e6xxx_has_pvt(chip))
1271 return 0;
1272
1273 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1274 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1275 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001276 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1277 if (err)
1278 return err;
1279
1280 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1281 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1282 err = mv88e6xxx_pvt_map(chip, dev, port);
1283 if (err)
1284 return err;
1285 }
1286 }
1287
1288 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001289}
1290
Vivien Didelot749efcb2016-09-22 16:49:24 -04001291static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1292{
1293 struct mv88e6xxx_chip *chip = ds->priv;
1294 int err;
1295
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001296 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001297 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001298 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001299
1300 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001301 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001302}
1303
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001304static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1305{
1306 if (!chip->info->max_vid)
1307 return 0;
1308
1309 return mv88e6xxx_g1_vtu_flush(chip);
1310}
1311
Vivien Didelotf1394b782017-05-01 14:05:22 -04001312static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1313 struct mv88e6xxx_vtu_entry *entry)
1314{
1315 if (!chip->info->ops->vtu_getnext)
1316 return -EOPNOTSUPP;
1317
1318 return chip->info->ops->vtu_getnext(chip, entry);
1319}
1320
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001321static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1322 struct mv88e6xxx_vtu_entry *entry)
1323{
1324 if (!chip->info->ops->vtu_loadpurge)
1325 return -EOPNOTSUPP;
1326
1327 return chip->info->ops->vtu_loadpurge(chip, entry);
1328}
1329
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001330static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001331{
1332 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001333 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001334 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001335
1336 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1337
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001338 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001339 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001340 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001341 if (err)
1342 return err;
1343
1344 set_bit(*fid, fid_bitmap);
1345 }
1346
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001347 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001348 vlan.vid = chip->info->max_vid;
1349 vlan.valid = false;
1350
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001351 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001352 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001353 if (err)
1354 return err;
1355
1356 if (!vlan.valid)
1357 break;
1358
1359 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001360 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001361
1362 /* The reset value 0x000 is used to indicate that multiple address
1363 * databases are not needed. Return the next positive available.
1364 */
1365 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001366 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001367 return -ENOSPC;
1368
1369 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001370 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001371}
1372
Vivien Didelotda9c3592016-02-12 12:09:40 -05001373static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1374 u16 vid_begin, u16 vid_end)
1375{
Vivien Didelot04bed142016-08-31 18:06:13 -04001376 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001377 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001378 int i, err;
1379
Andrew Lunndb06ae412017-09-25 23:32:20 +02001380 /* DSA and CPU ports have to be members of multiple vlans */
1381 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1382 return 0;
1383
Vivien Didelotda9c3592016-02-12 12:09:40 -05001384 if (!vid_begin)
1385 return -EOPNOTSUPP;
1386
Vivien Didelot425d2d32019-08-01 14:36:34 -04001387 vlan.vid = vid_begin - 1;
1388 vlan.valid = false;
1389
Vivien Didelotda9c3592016-02-12 12:09:40 -05001390 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001391 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001392 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001393 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001394
1395 if (!vlan.valid)
1396 break;
1397
1398 if (vlan.vid > vid_end)
1399 break;
1400
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001401 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001402 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1403 continue;
1404
Andrew Lunncd886462017-11-09 22:29:53 +01001405 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001406 continue;
1407
Vivien Didelotbd00e052017-05-01 14:05:11 -04001408 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001409 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001410 continue;
1411
Vivien Didelotc8652c82017-10-16 11:12:19 -04001412 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001413 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001414 break; /* same bridge, check next VLAN */
1415
Vivien Didelotc8652c82017-10-16 11:12:19 -04001416 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001417 continue;
1418
Andrew Lunn743fcc22017-11-09 22:29:54 +01001419 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1420 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001421 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001422 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001423 }
1424 } while (vlan.vid < vid_end);
1425
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001426 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001427}
1428
Vivien Didelotf81ec902016-05-09 13:22:58 -04001429static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1430 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001431{
Vivien Didelot04bed142016-08-31 18:06:13 -04001432 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001433 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1434 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001435 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001436
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001437 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001438 return -EOPNOTSUPP;
1439
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001440 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001441 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001442 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001443
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001444 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001445}
1446
Vivien Didelot57d32312016-06-20 13:13:58 -04001447static int
1448mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001449 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001450{
Vivien Didelot04bed142016-08-31 18:06:13 -04001451 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001452 int err;
1453
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001454 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001455 return -EOPNOTSUPP;
1456
Vivien Didelotda9c3592016-02-12 12:09:40 -05001457 /* If the requested port doesn't belong to the same bridge as the VLAN
1458 * members, do not support it (yet) and fallback to software VLAN.
1459 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001460 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001461 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1462 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001463 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001464
Vivien Didelot76e398a2015-11-01 12:33:55 -05001465 /* We don't need any dynamic resource from the kernel (yet),
1466 * so skip the prepare phase.
1467 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001468 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001469}
1470
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001471static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1472 const unsigned char *addr, u16 vid,
1473 u8 state)
1474{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001475 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001476 struct mv88e6xxx_vtu_entry vlan;
1477 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001478 int err;
1479
1480 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001481 if (vid == 0) {
1482 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1483 if (err)
1484 return err;
1485 } else {
1486 vlan.vid = vid - 1;
1487 vlan.valid = false;
1488
1489 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1490 if (err)
1491 return err;
1492
1493 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1494 if (vlan.vid != vid || !vlan.valid)
1495 return -EOPNOTSUPP;
1496
1497 fid = vlan.fid;
1498 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001499
1500 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1501 ether_addr_copy(entry.mac, addr);
1502 eth_addr_dec(entry.mac);
1503
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001504 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001505 if (err)
1506 return err;
1507
1508 /* Initialize a fresh ATU entry if it isn't found */
1509 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1510 !ether_addr_equal(entry.mac, addr)) {
1511 memset(&entry, 0, sizeof(entry));
1512 ether_addr_copy(entry.mac, addr);
1513 }
1514
1515 /* Purge the ATU entry only if no port is using it anymore */
1516 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1517 entry.portvec &= ~BIT(port);
1518 if (!entry.portvec)
1519 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1520 } else {
1521 entry.portvec |= BIT(port);
1522 entry.state = state;
1523 }
1524
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001525 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001526}
1527
Andrew Lunn87fa8862017-11-09 22:29:56 +01001528static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1529 u16 vid)
1530{
1531 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1532 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1533
1534 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1535}
1536
1537static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1538{
1539 int port;
1540 int err;
1541
1542 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1543 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1544 if (err)
1545 return err;
1546 }
1547
1548 return 0;
1549}
1550
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001551static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001552 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001553{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001554 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001555 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001556 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001557
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001558 if (!vid)
1559 return -EOPNOTSUPP;
1560
1561 vlan.vid = vid - 1;
1562 vlan.valid = false;
1563
1564 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001565 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001566 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001567
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001568 if (vlan.vid != vid || !vlan.valid) {
1569 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001570
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001571 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1572 if (err)
1573 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001574
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001575 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1576 if (i == port)
1577 vlan.member[i] = member;
1578 else
1579 vlan.member[i] = non_member;
1580
1581 vlan.vid = vid;
1582 vlan.valid = true;
1583
1584 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1585 if (err)
1586 return err;
1587
1588 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1589 if (err)
1590 return err;
1591 } else if (vlan.member[port] != member) {
1592 vlan.member[port] = member;
1593
1594 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1595 if (err)
1596 return err;
1597 } else {
1598 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1599 port, vid);
1600 }
1601
1602 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001603}
1604
Vivien Didelotf81ec902016-05-09 13:22:58 -04001605static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001606 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001607{
Vivien Didelot04bed142016-08-31 18:06:13 -04001608 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001609 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1610 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001611 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001612 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001613
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001614 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001615 return;
1616
Vivien Didelotc91498e2017-06-07 18:12:13 -04001617 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001618 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001619 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001620 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001621 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001622 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001623
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001624 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001625
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001626 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001627 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001628 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1629 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001630
Vivien Didelot77064f32016-11-04 03:23:30 +01001631 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001632 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1633 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001634
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001635 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001636}
1637
Vivien Didelot521098922019-08-01 14:36:36 -04001638static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1639 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001640{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001641 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001642 int i, err;
1643
Vivien Didelot521098922019-08-01 14:36:36 -04001644 if (!vid)
1645 return -EOPNOTSUPP;
1646
1647 vlan.vid = vid - 1;
1648 vlan.valid = false;
1649
1650 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001651 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001652 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001653
Vivien Didelot521098922019-08-01 14:36:36 -04001654 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1655 * tell switchdev that this VLAN is likely handled in software.
1656 */
1657 if (vlan.vid != vid || !vlan.valid ||
1658 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001659 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001660
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001661 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001662
1663 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001664 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001665 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001666 if (vlan.member[i] !=
1667 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001668 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001669 break;
1670 }
1671 }
1672
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001673 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001674 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001675 return err;
1676
Vivien Didelote606ca32017-03-11 16:12:55 -05001677 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001678}
1679
Vivien Didelotf81ec902016-05-09 13:22:58 -04001680static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1681 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001682{
Vivien Didelot04bed142016-08-31 18:06:13 -04001683 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001684 u16 pvid, vid;
1685 int err = 0;
1686
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001687 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001688 return -EOPNOTSUPP;
1689
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001690 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001691
Vivien Didelot77064f32016-11-04 03:23:30 +01001692 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001693 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001694 goto unlock;
1695
Vivien Didelot76e398a2015-11-01 12:33:55 -05001696 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001697 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698 if (err)
1699 goto unlock;
1700
1701 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001702 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703 if (err)
1704 goto unlock;
1705 }
1706 }
1707
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001708unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001709 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001710
1711 return err;
1712}
1713
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001714static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1715 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001716{
Vivien Didelot04bed142016-08-31 18:06:13 -04001717 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001718 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001719
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001720 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001721 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1722 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001723 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001724
1725 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001726}
1727
Vivien Didelotf81ec902016-05-09 13:22:58 -04001728static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001729 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001730{
Vivien Didelot04bed142016-08-31 18:06:13 -04001731 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001732 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001733
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001734 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001735 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001736 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001737 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001738
Vivien Didelot83dabd12016-08-31 11:50:04 -04001739 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001740}
1741
Vivien Didelot83dabd12016-08-31 11:50:04 -04001742static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1743 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001744 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001745{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001746 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001747 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001748 int err;
1749
Vivien Didelot27c0e602017-06-15 12:14:01 -04001750 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001751 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001752
1753 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001754 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001755 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001756 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001757
Vivien Didelot27c0e602017-06-15 12:14:01 -04001758 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001759 break;
1760
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001761 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001762 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001763
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001764 if (!is_unicast_ether_addr(addr.mac))
1765 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001766
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001767 is_static = (addr.state ==
1768 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1769 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001770 if (err)
1771 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001772 } while (!is_broadcast_ether_addr(addr.mac));
1773
1774 return err;
1775}
1776
Vivien Didelot83dabd12016-08-31 11:50:04 -04001777static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001778 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001779{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001780 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001781 u16 fid;
1782 int err;
1783
1784 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001785 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001786 if (err)
1787 return err;
1788
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001789 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001790 if (err)
1791 return err;
1792
1793 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001794 vlan.vid = chip->info->max_vid;
1795 vlan.valid = false;
1796
Vivien Didelot83dabd12016-08-31 11:50:04 -04001797 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001798 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001799 if (err)
1800 return err;
1801
1802 if (!vlan.valid)
1803 break;
1804
1805 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001806 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001807 if (err)
1808 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001809 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001810
1811 return err;
1812}
1813
Vivien Didelotf81ec902016-05-09 13:22:58 -04001814static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001815 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001816{
Vivien Didelot04bed142016-08-31 18:06:13 -04001817 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04001818 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001819
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001820 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001821 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001822 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001823
1824 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001825}
1826
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001827static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1828 struct net_device *br)
1829{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001830 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001831 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001832 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001833 int err;
1834
1835 /* Remap the Port VLAN of each local bridge group member */
1836 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1837 if (chip->ds->ports[port].bridge_dev == br) {
1838 err = mv88e6xxx_port_vlan_map(chip, port);
1839 if (err)
1840 return err;
1841 }
1842 }
1843
Vivien Didelote96a6e02017-03-30 17:37:13 -04001844 if (!mv88e6xxx_has_pvt(chip))
1845 return 0;
1846
1847 /* Remap the Port VLAN of each cross-chip bridge group member */
1848 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1849 ds = chip->ds->dst->ds[dev];
1850 if (!ds)
1851 break;
1852
1853 for (port = 0; port < ds->num_ports; ++port) {
1854 if (ds->ports[port].bridge_dev == br) {
1855 err = mv88e6xxx_pvt_map(chip, dev, port);
1856 if (err)
1857 return err;
1858 }
1859 }
1860 }
1861
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001862 return 0;
1863}
1864
Vivien Didelotf81ec902016-05-09 13:22:58 -04001865static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001866 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001867{
Vivien Didelot04bed142016-08-31 18:06:13 -04001868 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001869 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001870
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001871 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001872 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001873 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05001874
Vivien Didelot466dfa02016-02-26 13:16:05 -05001875 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001876}
1877
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001878static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1879 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001880{
Vivien Didelot04bed142016-08-31 18:06:13 -04001881 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001882
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001883 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001884 if (mv88e6xxx_bridge_map(chip, br) ||
1885 mv88e6xxx_port_vlan_map(chip, port))
1886 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001887 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001888}
1889
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001890static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1891 int port, struct net_device *br)
1892{
1893 struct mv88e6xxx_chip *chip = ds->priv;
1894 int err;
1895
1896 if (!mv88e6xxx_has_pvt(chip))
1897 return 0;
1898
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001899 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001900 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001901 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001902
1903 return err;
1904}
1905
1906static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1907 int port, struct net_device *br)
1908{
1909 struct mv88e6xxx_chip *chip = ds->priv;
1910
1911 if (!mv88e6xxx_has_pvt(chip))
1912 return;
1913
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001914 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001915 if (mv88e6xxx_pvt_map(chip, dev, port))
1916 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001917 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001918}
1919
Vivien Didelot17e708b2016-12-05 17:30:27 -05001920static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1921{
1922 if (chip->info->ops->reset)
1923 return chip->info->ops->reset(chip);
1924
1925 return 0;
1926}
1927
Vivien Didelot309eca62016-12-05 17:30:26 -05001928static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1929{
1930 struct gpio_desc *gpiod = chip->reset;
1931
1932 /* If there is a GPIO connected to the reset pin, toggle it */
1933 if (gpiod) {
1934 gpiod_set_value_cansleep(gpiod, 1);
1935 usleep_range(10000, 20000);
1936 gpiod_set_value_cansleep(gpiod, 0);
1937 usleep_range(10000, 20000);
1938 }
1939}
1940
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001941static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1942{
1943 int i, err;
1944
1945 /* Set all ports to the Disabled state */
1946 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001947 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001948 if (err)
1949 return err;
1950 }
1951
1952 /* Wait for transmit queues to drain,
1953 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1954 */
1955 usleep_range(2000, 4000);
1956
1957 return 0;
1958}
1959
Vivien Didelotfad09c72016-06-21 12:28:20 -04001960static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001961{
Vivien Didelota935c052016-09-29 12:21:53 -04001962 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001963
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001964 err = mv88e6xxx_disable_ports(chip);
1965 if (err)
1966 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001967
Vivien Didelot309eca62016-12-05 17:30:26 -05001968 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001969
Vivien Didelot17e708b2016-12-05 17:30:27 -05001970 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001971}
1972
Vivien Didelot43145572017-03-11 16:12:59 -05001973static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001974 enum mv88e6xxx_frame_mode frame,
1975 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001976{
1977 int err;
1978
Vivien Didelot43145572017-03-11 16:12:59 -05001979 if (!chip->info->ops->port_set_frame_mode)
1980 return -EOPNOTSUPP;
1981
1982 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001983 if (err)
1984 return err;
1985
Vivien Didelot43145572017-03-11 16:12:59 -05001986 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1987 if (err)
1988 return err;
1989
1990 if (chip->info->ops->port_set_ether_type)
1991 return chip->info->ops->port_set_ether_type(chip, port, etype);
1992
1993 return 0;
1994}
1995
1996static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1997{
1998 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001999 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002000 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002001}
2002
2003static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2004{
2005 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002006 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002007 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002008}
2009
2010static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2011{
2012 return mv88e6xxx_set_port_mode(chip, port,
2013 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002014 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2015 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002016}
2017
2018static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2019{
2020 if (dsa_is_dsa_port(chip->ds, port))
2021 return mv88e6xxx_set_port_mode_dsa(chip, port);
2022
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002023 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002024 return mv88e6xxx_set_port_mode_normal(chip, port);
2025
2026 /* Setup CPU port mode depending on its supported tag format */
2027 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2028 return mv88e6xxx_set_port_mode_dsa(chip, port);
2029
2030 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2031 return mv88e6xxx_set_port_mode_edsa(chip, port);
2032
2033 return -EINVAL;
2034}
2035
Vivien Didelotea698f42017-03-11 16:12:50 -05002036static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2037{
2038 bool message = dsa_is_dsa_port(chip->ds, port);
2039
2040 return mv88e6xxx_port_set_message_port(chip, port, message);
2041}
2042
Vivien Didelot601aeed2017-03-11 16:13:00 -05002043static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2044{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002045 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002046 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002047
David S. Miller407308f2019-06-15 13:35:29 -07002048 /* Upstream ports flood frames with unknown unicast or multicast DA */
2049 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2050 if (chip->info->ops->port_set_egress_floods)
2051 return chip->info->ops->port_set_egress_floods(chip, port,
2052 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002053
David S. Miller407308f2019-06-15 13:35:29 -07002054 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002055}
2056
Andrew Lunn6d917822017-05-26 01:03:21 +02002057static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2058 bool on)
2059{
Vivien Didelot523a8902017-05-26 18:02:42 -04002060 if (chip->info->ops->serdes_power)
2061 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002062
Vivien Didelot523a8902017-05-26 18:02:42 -04002063 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002064}
2065
Vivien Didelotfa371c82017-12-05 15:34:10 -05002066static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2067{
2068 struct dsa_switch *ds = chip->ds;
2069 int upstream_port;
2070 int err;
2071
Vivien Didelot07073c72017-12-05 15:34:13 -05002072 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002073 if (chip->info->ops->port_set_upstream_port) {
2074 err = chip->info->ops->port_set_upstream_port(chip, port,
2075 upstream_port);
2076 if (err)
2077 return err;
2078 }
2079
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002080 if (port == upstream_port) {
2081 if (chip->info->ops->set_cpu_port) {
2082 err = chip->info->ops->set_cpu_port(chip,
2083 upstream_port);
2084 if (err)
2085 return err;
2086 }
2087
2088 if (chip->info->ops->set_egress_port) {
2089 err = chip->info->ops->set_egress_port(chip,
2090 upstream_port);
2091 if (err)
2092 return err;
2093 }
2094 }
2095
Vivien Didelotfa371c82017-12-05 15:34:10 -05002096 return 0;
2097}
2098
Vivien Didelotfad09c72016-06-21 12:28:20 -04002099static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002100{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002101 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002102 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002103 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002104
Andrew Lunn7b898462018-08-09 15:38:47 +02002105 chip->ports[port].chip = chip;
2106 chip->ports[port].port = port;
2107
Vivien Didelotd78343d2016-11-04 03:23:36 +01002108 /* MAC Forcing register: don't force link, speed, duplex or flow control
2109 * state to any particular values on physical ports, but force the CPU
2110 * port and all DSA ports to their maximum bandwidth and full duplex.
2111 */
2112 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2113 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2114 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002115 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002116 PHY_INTERFACE_MODE_NA);
2117 else
2118 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2119 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002120 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002121 PHY_INTERFACE_MODE_NA);
2122 if (err)
2123 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002124
2125 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2126 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2127 * tunneling, determine priority by looking at 802.1p and IP
2128 * priority fields (IP prio has precedence), and set STP state
2129 * to Forwarding.
2130 *
2131 * If this is the CPU link, use DSA or EDSA tagging depending
2132 * on which tagging mode was configured.
2133 *
2134 * If this is a link to another switch, use DSA tagging mode.
2135 *
2136 * If this is the upstream port for this switch, enable
2137 * forwarding of unknown unicasts and multicasts.
2138 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002139 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2140 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2141 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2142 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002143 if (err)
2144 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002145
Vivien Didelot601aeed2017-03-11 16:13:00 -05002146 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002147 if (err)
2148 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002149
Vivien Didelot601aeed2017-03-11 16:13:00 -05002150 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002151 if (err)
2152 return err;
2153
Vivien Didelot8efdda42015-08-13 12:52:23 -04002154 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002155 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002156 * untagged frames on this port, do a destination address lookup on all
2157 * received packets as usual, disable ARP mirroring and don't send a
2158 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002159 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002160 err = mv88e6xxx_port_set_map_da(chip, port);
2161 if (err)
2162 return err;
2163
Vivien Didelotfa371c82017-12-05 15:34:10 -05002164 err = mv88e6xxx_setup_upstream_port(chip, port);
2165 if (err)
2166 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002167
Andrew Lunna23b2962017-02-04 20:15:28 +01002168 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002169 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002170 if (err)
2171 return err;
2172
Vivien Didelotcd782652017-06-08 18:34:13 -04002173 if (chip->info->ops->port_set_jumbo_size) {
2174 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002175 if (err)
2176 return err;
2177 }
2178
Andrew Lunn54d792f2015-05-06 01:09:47 +02002179 /* Port Association Vector: when learning source addresses
2180 * of packets, add the address to the address database using
2181 * a port bitmap that has only the bit for this port set and
2182 * the other bits clear.
2183 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002184 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002185 /* Disable learning for CPU port */
2186 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002187 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002188
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002189 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2190 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002191 if (err)
2192 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002193
2194 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002195 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2196 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002197 if (err)
2198 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002199
Vivien Didelot08984322017-06-08 18:34:12 -04002200 if (chip->info->ops->port_pause_limit) {
2201 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002202 if (err)
2203 return err;
2204 }
2205
Vivien Didelotc8c94892017-03-11 16:13:01 -05002206 if (chip->info->ops->port_disable_learn_limit) {
2207 err = chip->info->ops->port_disable_learn_limit(chip, port);
2208 if (err)
2209 return err;
2210 }
2211
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002212 if (chip->info->ops->port_disable_pri_override) {
2213 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002214 if (err)
2215 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002216 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002217
Andrew Lunnef0a7312016-12-03 04:35:16 +01002218 if (chip->info->ops->port_tag_remap) {
2219 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002220 if (err)
2221 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002222 }
2223
Andrew Lunnef70b112016-12-03 04:45:18 +01002224 if (chip->info->ops->port_egress_rate_limiting) {
2225 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002226 if (err)
2227 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002228 }
2229
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002230 if (chip->info->ops->port_setup_message_port) {
2231 err = chip->info->ops->port_setup_message_port(chip, port);
2232 if (err)
2233 return err;
2234 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002235
Vivien Didelot207afda2016-04-14 14:42:09 -04002236 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002237 * database, and allow bidirectional communication between the
2238 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002239 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002240 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002241 if (err)
2242 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002243
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002244 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002245 if (err)
2246 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002247
2248 /* Default VLAN ID and priority: don't set a default VLAN
2249 * ID, and set the default packet priority to zero.
2250 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002251 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002252}
2253
Andrew Lunn04aca992017-05-26 01:03:24 +02002254static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2255 struct phy_device *phydev)
2256{
2257 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002258 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002259
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002260 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002261
Vivien Didelot523a8902017-05-26 18:02:42 -04002262 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002263
2264 if (!err && chip->info->ops->serdes_irq_setup)
2265 err = chip->info->ops->serdes_irq_setup(chip, port);
2266
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002267 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002268
2269 return err;
2270}
2271
Andrew Lunn75104db2019-02-24 20:44:43 +01002272static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002273{
2274 struct mv88e6xxx_chip *chip = ds->priv;
2275
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002276 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002277
2278 if (chip->info->ops->serdes_irq_free)
2279 chip->info->ops->serdes_irq_free(chip, port);
2280
Vivien Didelot523a8902017-05-26 18:02:42 -04002281 if (mv88e6xxx_serdes_power(chip, port, false))
2282 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002283
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002284 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002285}
2286
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002287static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2288 unsigned int ageing_time)
2289{
Vivien Didelot04bed142016-08-31 18:06:13 -04002290 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002291 int err;
2292
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002293 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002294 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002295 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002296
2297 return err;
2298}
2299
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002300static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002301{
2302 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002303
Andrew Lunnde2273872016-11-21 23:27:01 +01002304 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002305 if (chip->info->ops->stats_set_histogram) {
2306 err = chip->info->ops->stats_set_histogram(chip);
2307 if (err)
2308 return err;
2309 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002310
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002311 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002312}
2313
Andrew Lunnea890982019-01-09 00:24:03 +01002314/* The mv88e6390 has some hidden registers used for debug and
2315 * development. The errata also makes use of them.
2316 */
2317static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2318 int reg, u16 val)
2319{
2320 u16 ctrl;
2321 int err;
2322
2323 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2324 PORT_RESERVED_1A, val);
2325 if (err)
2326 return err;
2327
2328 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2329 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2330 reg;
2331
2332 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2333 PORT_RESERVED_1A, ctrl);
2334}
2335
2336static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2337{
Vivien Didelot19fb7f62019-08-09 18:47:55 -04002338 int bit = __bf_shf(PORT_RESERVED_1A_BUSY);
2339
2340 return mv88e6xxx_wait_bit(chip, PORT_RESERVED_1A_CTRL_PORT,
2341 PORT_RESERVED_1A, bit, 0);
Andrew Lunnea890982019-01-09 00:24:03 +01002342}
2343
2344
2345static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2346 int reg, u16 *val)
2347{
2348 u16 ctrl;
2349 int err;
2350
2351 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2352 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2353 reg;
2354
2355 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2356 PORT_RESERVED_1A, ctrl);
2357 if (err)
2358 return err;
2359
2360 err = mv88e6390_hidden_wait(chip);
2361 if (err)
2362 return err;
2363
2364 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2365 PORT_RESERVED_1A, val);
2366}
2367
2368/* Check if the errata has already been applied. */
2369static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2370{
2371 int port;
2372 int err;
2373 u16 val;
2374
2375 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2376 err = mv88e6390_hidden_read(chip, port, 0, &val);
2377 if (err) {
2378 dev_err(chip->dev,
2379 "Error reading hidden register: %d\n", err);
2380 return false;
2381 }
2382 if (val != 0x01c0)
2383 return false;
2384 }
2385
2386 return true;
2387}
2388
2389/* The 6390 copper ports have an errata which require poking magic
2390 * values into undocumented hidden registers and then performing a
2391 * software reset.
2392 */
2393static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2394{
2395 int port;
2396 int err;
2397
2398 if (mv88e6390_setup_errata_applied(chip))
2399 return 0;
2400
2401 /* Set the ports into blocking mode */
2402 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2403 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2404 if (err)
2405 return err;
2406 }
2407
2408 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2409 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2410 if (err)
2411 return err;
2412 }
2413
2414 return mv88e6xxx_software_reset(chip);
2415}
2416
Vivien Didelotf81ec902016-05-09 13:22:58 -04002417static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002418{
Vivien Didelot04bed142016-08-31 18:06:13 -04002419 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002420 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002421 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002422 int i;
2423
Vivien Didelotfad09c72016-06-21 12:28:20 -04002424 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002425 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002426
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002427 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002428
Andrew Lunnea890982019-01-09 00:24:03 +01002429 if (chip->info->ops->setup_errata) {
2430 err = chip->info->ops->setup_errata(chip);
2431 if (err)
2432 goto unlock;
2433 }
2434
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002435 /* Cache the cmode of each port. */
2436 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2437 if (chip->info->ops->port_get_cmode) {
2438 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2439 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002440 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002441
2442 chip->ports[i].cmode = cmode;
2443 }
2444 }
2445
Vivien Didelot97299342016-07-18 20:45:30 -04002446 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002447 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002448 if (dsa_is_unused_port(ds, i))
2449 continue;
2450
Hubert Feursteinc8574862019-07-31 10:23:48 +02002451 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002452 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002453 dev_err(chip->dev, "port %d is invalid\n", i);
2454 err = -EINVAL;
2455 goto unlock;
2456 }
2457
Vivien Didelot97299342016-07-18 20:45:30 -04002458 err = mv88e6xxx_setup_port(chip, i);
2459 if (err)
2460 goto unlock;
2461 }
2462
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002463 err = mv88e6xxx_irl_setup(chip);
2464 if (err)
2465 goto unlock;
2466
Vivien Didelot04a69a12017-10-13 14:18:05 -04002467 err = mv88e6xxx_mac_setup(chip);
2468 if (err)
2469 goto unlock;
2470
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002471 err = mv88e6xxx_phy_setup(chip);
2472 if (err)
2473 goto unlock;
2474
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002475 err = mv88e6xxx_vtu_setup(chip);
2476 if (err)
2477 goto unlock;
2478
Vivien Didelot81228992017-03-30 17:37:08 -04002479 err = mv88e6xxx_pvt_setup(chip);
2480 if (err)
2481 goto unlock;
2482
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002483 err = mv88e6xxx_atu_setup(chip);
2484 if (err)
2485 goto unlock;
2486
Andrew Lunn87fa8862017-11-09 22:29:56 +01002487 err = mv88e6xxx_broadcast_setup(chip, 0);
2488 if (err)
2489 goto unlock;
2490
Vivien Didelot9e907d72017-07-17 13:03:43 -04002491 err = mv88e6xxx_pot_setup(chip);
2492 if (err)
2493 goto unlock;
2494
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002495 err = mv88e6xxx_rmu_setup(chip);
2496 if (err)
2497 goto unlock;
2498
Vivien Didelot51c901a2017-07-17 13:03:41 -04002499 err = mv88e6xxx_rsvd2cpu_setup(chip);
2500 if (err)
2501 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002502
Vivien Didelotb28f8722018-04-26 21:56:44 -04002503 err = mv88e6xxx_trunk_setup(chip);
2504 if (err)
2505 goto unlock;
2506
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002507 err = mv88e6xxx_devmap_setup(chip);
2508 if (err)
2509 goto unlock;
2510
Vivien Didelot93e18d62018-05-11 17:16:35 -04002511 err = mv88e6xxx_pri_setup(chip);
2512 if (err)
2513 goto unlock;
2514
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002515 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002516 if (chip->info->ptp_support) {
2517 err = mv88e6xxx_ptp_setup(chip);
2518 if (err)
2519 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002520
2521 err = mv88e6xxx_hwtstamp_setup(chip);
2522 if (err)
2523 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002524 }
2525
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002526 err = mv88e6xxx_stats_setup(chip);
2527 if (err)
2528 goto unlock;
2529
Vivien Didelot6b17e862015-08-13 12:52:18 -04002530unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002531 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002532
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002533 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002534}
2535
Vivien Didelote57e5e72016-08-15 17:19:00 -04002536static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002537{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002538 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2539 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002540 u16 val;
2541 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002542
Andrew Lunnee26a222017-01-24 14:53:48 +01002543 if (!chip->info->ops->phy_read)
2544 return -EOPNOTSUPP;
2545
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002546 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002547 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002548 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002549
Andrew Lunnda9f3302017-02-01 03:40:05 +01002550 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002551 /* Some internal PHYs don't have a model number. */
2552 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2553 /* Then there is the 6165 family. It gets is
2554 * PHYs correct. But it can also have two
2555 * SERDES interfaces in the PHY address
2556 * space. And these don't have a model
2557 * number. But they are not PHYs, so we don't
2558 * want to give them something a PHY driver
2559 * will recognise.
2560 *
2561 * Use the mv88e6390 family model number
2562 * instead, for anything which really could be
2563 * a PHY,
2564 */
2565 if (!(val & 0x3f0))
2566 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002567 }
2568
Vivien Didelote57e5e72016-08-15 17:19:00 -04002569 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002570}
2571
Vivien Didelote57e5e72016-08-15 17:19:00 -04002572static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002573{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002574 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2575 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002576 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002577
Andrew Lunnee26a222017-01-24 14:53:48 +01002578 if (!chip->info->ops->phy_write)
2579 return -EOPNOTSUPP;
2580
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002581 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002582 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002583 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002584
2585 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002586}
2587
Vivien Didelotfad09c72016-06-21 12:28:20 -04002588static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002589 struct device_node *np,
2590 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002591{
2592 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002593 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002594 struct mii_bus *bus;
2595 int err;
2596
Andrew Lunn2510bab2018-02-22 01:51:49 +01002597 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002598 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002599 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002600 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002601
2602 if (err)
2603 return err;
2604 }
2605
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002606 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002607 if (!bus)
2608 return -ENOMEM;
2609
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002610 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002611 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002612 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002613 INIT_LIST_HEAD(&mdio_bus->list);
2614 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002615
Andrew Lunnb516d452016-06-04 21:17:06 +02002616 if (np) {
2617 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002618 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002619 } else {
2620 bus->name = "mv88e6xxx SMI";
2621 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2622 }
2623
2624 bus->read = mv88e6xxx_mdio_read;
2625 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002626 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002627
Andrew Lunn6f882842018-03-17 20:32:05 +01002628 if (!external) {
2629 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2630 if (err)
2631 return err;
2632 }
2633
Florian Fainelli00e798c2018-05-15 16:56:19 -07002634 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002635 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002636 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002637 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002638 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002639 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002640
2641 if (external)
2642 list_add_tail(&mdio_bus->list, &chip->mdios);
2643 else
2644 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002645
2646 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002647}
2648
Andrew Lunna3c53be52017-01-24 14:53:50 +01002649static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2650 { .compatible = "marvell,mv88e6xxx-mdio-external",
2651 .data = (void *)true },
2652 { },
2653};
2654
Andrew Lunn3126aee2017-12-07 01:05:57 +01002655static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2656
2657{
2658 struct mv88e6xxx_mdio_bus *mdio_bus;
2659 struct mii_bus *bus;
2660
2661 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2662 bus = mdio_bus->bus;
2663
Andrew Lunn6f882842018-03-17 20:32:05 +01002664 if (!mdio_bus->external)
2665 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2666
Andrew Lunn3126aee2017-12-07 01:05:57 +01002667 mdiobus_unregister(bus);
2668 }
2669}
2670
Andrew Lunna3c53be52017-01-24 14:53:50 +01002671static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2672 struct device_node *np)
2673{
2674 const struct of_device_id *match;
2675 struct device_node *child;
2676 int err;
2677
2678 /* Always register one mdio bus for the internal/default mdio
2679 * bus. This maybe represented in the device tree, but is
2680 * optional.
2681 */
2682 child = of_get_child_by_name(np, "mdio");
2683 err = mv88e6xxx_mdio_register(chip, child, false);
2684 if (err)
2685 return err;
2686
2687 /* Walk the device tree, and see if there are any other nodes
2688 * which say they are compatible with the external mdio
2689 * bus.
2690 */
2691 for_each_available_child_of_node(np, child) {
2692 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2693 if (match) {
2694 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002695 if (err) {
2696 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05302697 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002698 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002699 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002700 }
2701 }
2702
2703 return 0;
2704}
2705
Vivien Didelot855b1932016-07-20 18:18:35 -04002706static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2707{
Vivien Didelot04bed142016-08-31 18:06:13 -04002708 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002709
2710 return chip->eeprom_len;
2711}
2712
Vivien Didelot855b1932016-07-20 18:18:35 -04002713static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2714 struct ethtool_eeprom *eeprom, u8 *data)
2715{
Vivien Didelot04bed142016-08-31 18:06:13 -04002716 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002717 int err;
2718
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002719 if (!chip->info->ops->get_eeprom)
2720 return -EOPNOTSUPP;
2721
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002722 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002723 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002724 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002725
2726 if (err)
2727 return err;
2728
2729 eeprom->magic = 0xc3ec4951;
2730
2731 return 0;
2732}
2733
Vivien Didelot855b1932016-07-20 18:18:35 -04002734static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2735 struct ethtool_eeprom *eeprom, u8 *data)
2736{
Vivien Didelot04bed142016-08-31 18:06:13 -04002737 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002738 int err;
2739
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002740 if (!chip->info->ops->set_eeprom)
2741 return -EOPNOTSUPP;
2742
Vivien Didelot855b1932016-07-20 18:18:35 -04002743 if (eeprom->magic != 0xc3ec4951)
2744 return -EINVAL;
2745
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002746 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002747 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002748 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002749
2750 return err;
2751}
2752
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002753static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002754 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002755 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2756 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002757 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002758 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002759 .phy_read = mv88e6185_phy_ppu_read,
2760 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002761 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002762 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002763 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002764 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002765 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002766 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002767 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002768 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002769 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002770 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002771 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002772 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002773 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002774 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002775 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002776 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002777 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2778 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002779 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002780 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2781 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002782 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002783 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002784 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002785 .ppu_enable = mv88e6185_g1_ppu_enable,
2786 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002787 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002788 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002789 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002790 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002791 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002792};
2793
2794static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002795 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002796 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2797 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002798 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002799 .phy_read = mv88e6185_phy_ppu_read,
2800 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002801 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002802 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002803 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002804 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002805 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002806 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002807 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002808 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002809 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002810 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002811 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002812 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2813 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002814 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002815 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002816 .ppu_enable = mv88e6185_g1_ppu_enable,
2817 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002819 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002820 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002821 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002822};
2823
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002824static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002825 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002826 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2827 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002828 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002829 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2830 .phy_read = mv88e6xxx_g2_smi_phy_read,
2831 .phy_write = mv88e6xxx_g2_smi_phy_write,
2832 .port_set_link = mv88e6xxx_port_set_link,
2833 .port_set_duplex = mv88e6xxx_port_set_duplex,
2834 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002835 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002836 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002837 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002838 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002839 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002840 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002841 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002842 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002843 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002844 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002845 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002846 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002847 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002848 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002849 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2850 .stats_get_strings = mv88e6095_stats_get_strings,
2851 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002852 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2853 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002854 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002855 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002856 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002857 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002858 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002859 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002860 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002861 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002862};
2863
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002864static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002865 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002866 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2867 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002868 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002869 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002870 .phy_read = mv88e6xxx_g2_smi_phy_read,
2871 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002872 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002873 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002874 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002875 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002876 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002877 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002878 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002879 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002880 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002881 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002882 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002883 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002884 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2885 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002886 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002887 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2888 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002889 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002890 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002891 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002892 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002893 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002894 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002895 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002896};
2897
2898static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002899 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002900 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2901 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002902 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002903 .phy_read = mv88e6185_phy_ppu_read,
2904 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002905 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002906 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002907 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002908 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002909 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002910 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002911 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002912 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002913 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002914 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002915 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002916 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002917 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002918 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002919 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002920 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002921 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002922 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2923 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002924 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002925 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2926 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002927 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002928 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002929 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002930 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002931 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002932 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002933 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002934 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002935 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002936};
2937
Vivien Didelot990e27b2017-03-28 13:50:32 -04002938static const struct mv88e6xxx_ops mv88e6141_ops = {
2939 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002940 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2941 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002942 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002943 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2944 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2945 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2946 .phy_read = mv88e6xxx_g2_smi_phy_read,
2947 .phy_write = mv88e6xxx_g2_smi_phy_write,
2948 .port_set_link = mv88e6xxx_port_set_link,
2949 .port_set_duplex = mv88e6xxx_port_set_duplex,
2950 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002951 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002952 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002953 .port_tag_remap = mv88e6095_port_tag_remap,
2954 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2955 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2956 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002957 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002958 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002959 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002960 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2961 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002962 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002963 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002964 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002965 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002966 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002967 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2968 .stats_get_strings = mv88e6320_stats_get_strings,
2969 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002970 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2971 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002972 .watchdog_ops = &mv88e6390_watchdog_ops,
2973 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002974 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002975 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002976 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002977 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002978 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002979 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01002980 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002981};
2982
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002983static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002984 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002985 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2986 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002987 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002988 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002989 .phy_read = mv88e6xxx_g2_smi_phy_read,
2990 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002991 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002992 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002993 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002994 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002995 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002996 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002997 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002998 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002999 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003000 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003001 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003002 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003003 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003004 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003005 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003006 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003007 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003008 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3009 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003010 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003011 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3012 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003013 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003014 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003015 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003016 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003017 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003018 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003019 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003020 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003021 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003022};
3023
3024static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003025 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003026 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3027 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003028 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003029 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003030 .phy_read = mv88e6165_phy_read,
3031 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003032 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003033 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003034 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003035 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003036 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003037 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003038 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003039 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003040 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003041 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003042 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3043 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003044 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003045 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3046 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003047 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003048 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003049 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003050 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003051 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003052 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003053 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003054 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003055 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003056};
3057
3058static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003059 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003060 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3061 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003062 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003064 .phy_read = mv88e6xxx_g2_smi_phy_read,
3065 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003066 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003067 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003068 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003069 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003070 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003071 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003072 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003073 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003074 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003075 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003076 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003077 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003078 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003079 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003080 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003081 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003082 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003083 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003084 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3085 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003086 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003087 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3088 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003089 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003090 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003091 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003092 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003093 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003094 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003095 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003096};
3097
3098static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003099 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003100 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3101 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003102 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003103 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3104 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003105 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003106 .phy_read = mv88e6xxx_g2_smi_phy_read,
3107 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003108 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003109 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003110 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003111 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003112 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003113 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003114 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003115 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003116 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003117 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003118 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003119 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003120 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003121 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003122 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003123 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003124 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003125 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003126 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3127 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003128 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003129 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3130 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003131 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003132 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003133 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003134 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003135 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003136 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003137 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003138 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003139 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003140 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003141};
3142
3143static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003144 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003145 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3146 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003147 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003148 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003149 .phy_read = mv88e6xxx_g2_smi_phy_read,
3150 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003151 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003152 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003153 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003154 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003155 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003156 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003157 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003158 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003159 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003160 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003161 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003162 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003163 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003164 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003165 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003166 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003167 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003168 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003169 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3170 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003171 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003172 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3173 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003174 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003175 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003176 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003177 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003178 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003179 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003180 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003181};
3182
3183static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003184 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003185 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3186 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003187 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003188 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3189 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003190 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003191 .phy_read = mv88e6xxx_g2_smi_phy_read,
3192 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003193 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003194 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003195 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003196 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003197 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003198 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003199 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003200 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003201 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003202 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003203 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003204 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003205 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003206 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003207 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003208 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003209 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003210 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003211 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3212 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003213 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003214 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3215 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003216 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003217 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003218 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003219 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003220 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003221 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003222 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003223 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003224 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3225 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003226 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003227 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003228};
3229
3230static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003231 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003232 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3233 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003234 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003235 .phy_read = mv88e6185_phy_ppu_read,
3236 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003237 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003238 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003239 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003240 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003241 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003242 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003243 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003244 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003245 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003246 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003247 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003248 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003249 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003250 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3251 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003252 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003253 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3254 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003255 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003256 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003257 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003258 .ppu_enable = mv88e6185_g1_ppu_enable,
3259 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003260 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003261 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003262 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003263 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003264};
3265
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003266static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003267 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003268 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003269 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003270 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3271 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003272 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3273 .phy_read = mv88e6xxx_g2_smi_phy_read,
3274 .phy_write = mv88e6xxx_g2_smi_phy_write,
3275 .port_set_link = mv88e6xxx_port_set_link,
3276 .port_set_duplex = mv88e6xxx_port_set_duplex,
3277 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3278 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003279 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003280 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003281 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003282 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003283 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003284 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003285 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003286 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003287 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003288 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003289 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003290 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003291 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003292 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003293 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3294 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003295 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003296 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3297 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003298 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003299 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003300 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003301 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003302 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003303 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3304 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003305 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003306 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3307 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003308 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003309 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003310};
3311
3312static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003313 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003314 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003315 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003316 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3317 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003318 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3319 .phy_read = mv88e6xxx_g2_smi_phy_read,
3320 .phy_write = mv88e6xxx_g2_smi_phy_write,
3321 .port_set_link = mv88e6xxx_port_set_link,
3322 .port_set_duplex = mv88e6xxx_port_set_duplex,
3323 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3324 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003325 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003326 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003327 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003328 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003329 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003330 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003331 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003332 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003333 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003334 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003335 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003336 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003337 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003338 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003339 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3340 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003341 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003342 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3343 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003344 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003345 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003346 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003347 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003348 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003349 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3350 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003351 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003352 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3353 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003354 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003355 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003356};
3357
3358static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003359 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003360 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003361 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003362 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3363 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003364 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3365 .phy_read = mv88e6xxx_g2_smi_phy_read,
3366 .phy_write = mv88e6xxx_g2_smi_phy_write,
3367 .port_set_link = mv88e6xxx_port_set_link,
3368 .port_set_duplex = mv88e6xxx_port_set_duplex,
3369 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3370 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003371 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003372 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003373 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003374 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003375 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003376 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003377 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003378 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003379 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003380 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003381 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003382 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003383 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003384 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003385 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3386 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003387 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003388 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3389 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003390 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003391 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003392 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003393 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003394 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003395 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3396 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003397 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003398 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3399 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003400 .avb_ops = &mv88e6390_avb_ops,
3401 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003402 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003403};
3404
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003405static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003406 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003407 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3408 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003409 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003410 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3411 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003412 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003413 .phy_read = mv88e6xxx_g2_smi_phy_read,
3414 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003415 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003416 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003417 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003418 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003419 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003421 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003422 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003423 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003424 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003425 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003426 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003427 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003428 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003429 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003430 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003431 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003432 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003433 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3434 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003435 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003436 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3437 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003438 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003439 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003440 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003441 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003442 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003443 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003444 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003445 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003446 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3447 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003448 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003449 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003450 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003451 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003452};
3453
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003454static const struct mv88e6xxx_ops mv88e6250_ops = {
3455 /* MV88E6XXX_FAMILY_6250 */
3456 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3457 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3458 .irl_init_all = mv88e6352_g2_irl_init_all,
3459 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3460 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3461 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3462 .phy_read = mv88e6xxx_g2_smi_phy_read,
3463 .phy_write = mv88e6xxx_g2_smi_phy_write,
3464 .port_set_link = mv88e6xxx_port_set_link,
3465 .port_set_duplex = mv88e6xxx_port_set_duplex,
3466 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3467 .port_set_speed = mv88e6250_port_set_speed,
3468 .port_tag_remap = mv88e6095_port_tag_remap,
3469 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3470 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3471 .port_set_ether_type = mv88e6351_port_set_ether_type,
3472 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3473 .port_pause_limit = mv88e6097_port_pause_limit,
3474 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3475 .port_link_state = mv88e6250_port_link_state,
3476 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3477 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3478 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3479 .stats_get_strings = mv88e6250_stats_get_strings,
3480 .stats_get_stats = mv88e6250_stats_get_stats,
3481 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3482 .set_egress_port = mv88e6095_g1_set_egress_port,
3483 .watchdog_ops = &mv88e6250_watchdog_ops,
3484 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3485 .pot_clear = mv88e6xxx_g2_pot_clear,
3486 .reset = mv88e6250_g1_reset,
3487 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3488 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02003489 .avb_ops = &mv88e6352_avb_ops,
3490 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003491 .phylink_validate = mv88e6065_phylink_validate,
3492};
3493
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003494static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003495 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003496 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003497 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003498 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3499 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003500 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3501 .phy_read = mv88e6xxx_g2_smi_phy_read,
3502 .phy_write = mv88e6xxx_g2_smi_phy_write,
3503 .port_set_link = mv88e6xxx_port_set_link,
3504 .port_set_duplex = mv88e6xxx_port_set_duplex,
3505 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3506 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003507 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003508 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003509 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003510 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003511 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003512 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003513 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003514 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003515 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003516 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003517 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003518 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003519 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003520 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003521 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3522 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003523 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003524 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3525 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003526 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003527 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003528 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003529 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003530 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003531 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3532 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003533 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003534 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3535 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003536 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003537 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003538 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003539 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003540};
3541
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003542static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003543 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003544 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3545 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003546 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003547 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3548 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003549 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003550 .phy_read = mv88e6xxx_g2_smi_phy_read,
3551 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003552 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003553 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003554 .port_set_speed = mv88e6185_port_set_speed,
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 = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003558 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003559 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003560 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003561 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003562 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003563 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003564 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003565 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003566 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003567 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003568 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003569 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3570 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003571 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003572 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3573 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003574 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003575 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003576 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003577 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003578 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003579 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003580 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003581 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003582 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003583 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003584};
3585
3586static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003587 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003588 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3589 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003590 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003591 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3592 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003593 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003594 .phy_read = mv88e6xxx_g2_smi_phy_read,
3595 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003596 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003597 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003598 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003599 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003600 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003601 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003602 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003603 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003604 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003605 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003606 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003607 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003608 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003609 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003610 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003611 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003612 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003613 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3614 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003615 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003616 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3617 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003618 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003619 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003620 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003621 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003622 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003623 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003624 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003625 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003626};
3627
Vivien Didelot16e329a2017-03-28 13:50:33 -04003628static const struct mv88e6xxx_ops mv88e6341_ops = {
3629 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003630 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3631 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003632 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003633 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3634 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3635 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3636 .phy_read = mv88e6xxx_g2_smi_phy_read,
3637 .phy_write = mv88e6xxx_g2_smi_phy_write,
3638 .port_set_link = mv88e6xxx_port_set_link,
3639 .port_set_duplex = mv88e6xxx_port_set_duplex,
3640 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003641 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003642 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003643 .port_tag_remap = mv88e6095_port_tag_remap,
3644 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3645 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3646 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003647 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003648 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003649 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003650 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3651 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003652 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003653 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003654 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003655 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003656 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003657 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3658 .stats_get_strings = mv88e6320_stats_get_strings,
3659 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003660 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3661 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003662 .watchdog_ops = &mv88e6390_watchdog_ops,
3663 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003664 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003665 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003666 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003667 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003668 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003669 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003670 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003671 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003672 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003673};
3674
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003675static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003676 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003677 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3678 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003679 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003680 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003681 .phy_read = mv88e6xxx_g2_smi_phy_read,
3682 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003683 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003684 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003685 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003686 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003687 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003688 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003689 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003690 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003691 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003692 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003693 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003694 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003695 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003696 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003697 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003698 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003699 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003700 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003701 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3702 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003703 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003704 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3705 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003706 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003707 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003708 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003709 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003710 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003711 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003712 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003713};
3714
3715static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003716 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003717 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3718 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003719 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003720 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003721 .phy_read = mv88e6xxx_g2_smi_phy_read,
3722 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003723 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003724 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003725 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003726 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003727 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003728 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003729 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003730 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003731 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003732 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003733 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003734 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003735 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003736 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003737 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003738 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003739 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003740 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003741 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3742 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003743 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003744 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3745 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003746 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003747 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003748 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003749 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003750 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003751 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003752 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003753 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003754 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003755};
3756
3757static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003758 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003759 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3760 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003761 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003762 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3763 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003764 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003765 .phy_read = mv88e6xxx_g2_smi_phy_read,
3766 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003767 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003768 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003769 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003770 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003771 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003772 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003773 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003774 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003775 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003776 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003777 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003778 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003779 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003780 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003781 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003782 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003783 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3786 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003788 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3789 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003790 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003791 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003792 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003793 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003794 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003795 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003796 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003797 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003798 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3799 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003800 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003801 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003802 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003803 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3804 .serdes_get_strings = mv88e6352_serdes_get_strings,
3805 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003806 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003807};
3808
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003809static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003810 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003811 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003812 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003813 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3814 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003815 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3816 .phy_read = mv88e6xxx_g2_smi_phy_read,
3817 .phy_write = mv88e6xxx_g2_smi_phy_write,
3818 .port_set_link = mv88e6xxx_port_set_link,
3819 .port_set_duplex = mv88e6xxx_port_set_duplex,
3820 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3821 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003822 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003823 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003824 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003825 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003826 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003827 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003828 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003829 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003830 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003831 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003832 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003833 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003834 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003835 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003836 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003837 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003838 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3839 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003840 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003841 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3842 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003843 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003844 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003845 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003846 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003847 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003848 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3849 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003850 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003851 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3852 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003853 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003854 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003855 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003856 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003857};
3858
3859static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003860 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003861 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003862 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003863 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3864 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003865 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3866 .phy_read = mv88e6xxx_g2_smi_phy_read,
3867 .phy_write = mv88e6xxx_g2_smi_phy_write,
3868 .port_set_link = mv88e6xxx_port_set_link,
3869 .port_set_duplex = mv88e6xxx_port_set_duplex,
3870 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3871 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003872 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003873 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003874 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003875 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003876 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003877 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003878 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003879 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003880 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003881 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003882 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003883 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003884 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003885 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003886 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003887 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003888 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3889 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003890 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003891 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3892 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003893 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003894 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003895 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003896 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003897 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003898 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3899 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003900 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003901 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3902 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003903 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003904 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003905 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003906 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003907};
3908
Vivien Didelotf81ec902016-05-09 13:22:58 -04003909static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3910 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003911 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003912 .family = MV88E6XXX_FAMILY_6097,
3913 .name = "Marvell 88E6085",
3914 .num_databases = 4096,
3915 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003916 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003917 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003918 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003919 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003920 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003921 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003922 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003923 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003924 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003925 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003926 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003927 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003928 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003929 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003930 },
3931
3932 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003933 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003934 .family = MV88E6XXX_FAMILY_6095,
3935 .name = "Marvell 88E6095/88E6095F",
3936 .num_databases = 256,
3937 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003938 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003939 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003940 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003941 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003942 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003943 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003944 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003945 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003946 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003947 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003948 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003949 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003950 },
3951
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003952 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003953 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003954 .family = MV88E6XXX_FAMILY_6097,
3955 .name = "Marvell 88E6097/88E6097F",
3956 .num_databases = 4096,
3957 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003958 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003959 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003960 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003961 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003962 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003963 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003964 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003965 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003966 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003967 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003968 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003969 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003970 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003971 .ops = &mv88e6097_ops,
3972 },
3973
Vivien Didelotf81ec902016-05-09 13:22:58 -04003974 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003975 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003976 .family = MV88E6XXX_FAMILY_6165,
3977 .name = "Marvell 88E6123",
3978 .num_databases = 4096,
3979 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003980 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003981 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003982 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003983 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003984 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003985 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003986 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003987 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003988 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003989 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003990 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003991 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003992 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003993 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003994 },
3995
3996 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003997 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003998 .family = MV88E6XXX_FAMILY_6185,
3999 .name = "Marvell 88E6131",
4000 .num_databases = 256,
4001 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004002 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004003 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004004 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004005 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004006 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004007 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004008 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004009 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004010 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004011 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004012 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004013 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004014 },
4015
Vivien Didelot990e27b2017-03-28 13:50:32 -04004016 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004017 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004018 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004019 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004020 .num_databases = 4096,
4021 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004022 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004023 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004024 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004025 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004026 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004027 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004028 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004029 .age_time_coeff = 3750,
4030 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004031 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004032 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004033 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004034 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004035 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004036 .ops = &mv88e6141_ops,
4037 },
4038
Vivien Didelotf81ec902016-05-09 13:22:58 -04004039 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004040 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004041 .family = MV88E6XXX_FAMILY_6165,
4042 .name = "Marvell 88E6161",
4043 .num_databases = 4096,
4044 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004045 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004046 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004047 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004048 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004049 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004050 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004051 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004052 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004053 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004054 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004055 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004056 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004057 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004058 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004059 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004060 },
4061
4062 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004063 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004064 .family = MV88E6XXX_FAMILY_6165,
4065 .name = "Marvell 88E6165",
4066 .num_databases = 4096,
4067 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004068 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004069 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004070 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004071 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004072 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004073 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004074 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004075 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004076 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004077 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004078 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004079 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004080 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004081 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004082 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004083 },
4084
4085 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004086 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004087 .family = MV88E6XXX_FAMILY_6351,
4088 .name = "Marvell 88E6171",
4089 .num_databases = 4096,
4090 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004091 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004092 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004093 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004094 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004095 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004096 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004097 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004098 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004099 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004100 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004101 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004102 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004103 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004104 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004105 },
4106
4107 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004108 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004109 .family = MV88E6XXX_FAMILY_6352,
4110 .name = "Marvell 88E6172",
4111 .num_databases = 4096,
4112 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004113 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004114 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004115 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004116 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004117 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004118 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004119 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004120 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004121 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004122 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004123 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004124 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004125 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004126 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004127 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004128 },
4129
4130 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004131 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004132 .family = MV88E6XXX_FAMILY_6351,
4133 .name = "Marvell 88E6175",
4134 .num_databases = 4096,
4135 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004136 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004137 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004138 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004139 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004140 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004141 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004142 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004143 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004144 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004145 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004146 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004147 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004148 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004149 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004150 },
4151
4152 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004153 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004154 .family = MV88E6XXX_FAMILY_6352,
4155 .name = "Marvell 88E6176",
4156 .num_databases = 4096,
4157 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004158 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004159 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004160 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004161 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004162 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004163 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004164 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004165 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004166 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004167 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004168 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004169 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004170 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004171 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004172 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004173 },
4174
4175 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004176 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004177 .family = MV88E6XXX_FAMILY_6185,
4178 .name = "Marvell 88E6185",
4179 .num_databases = 256,
4180 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004181 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004182 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004183 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004184 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004185 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004186 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004187 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004188 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004189 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004190 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004191 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004192 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004193 },
4194
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004195 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004196 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004197 .family = MV88E6XXX_FAMILY_6390,
4198 .name = "Marvell 88E6190",
4199 .num_databases = 4096,
4200 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004201 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004202 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004203 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004204 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004205 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004206 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004207 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004208 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004209 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004210 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004211 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004212 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004213 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004214 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004215 .ops = &mv88e6190_ops,
4216 },
4217
4218 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004219 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004220 .family = MV88E6XXX_FAMILY_6390,
4221 .name = "Marvell 88E6190X",
4222 .num_databases = 4096,
4223 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004224 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004225 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004226 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004227 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004228 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004229 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004230 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004231 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004232 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004233 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004234 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004235 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004236 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004237 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004238 .ops = &mv88e6190x_ops,
4239 },
4240
4241 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004242 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004243 .family = MV88E6XXX_FAMILY_6390,
4244 .name = "Marvell 88E6191",
4245 .num_databases = 4096,
4246 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004247 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004248 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004249 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004250 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004251 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004252 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004253 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004254 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004255 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004256 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004257 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004258 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004259 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004260 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004261 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004262 },
4263
Hubert Feurstein49022642019-07-31 10:23:46 +02004264 [MV88E6220] = {
4265 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4266 .family = MV88E6XXX_FAMILY_6250,
4267 .name = "Marvell 88E6220",
4268 .num_databases = 64,
4269
4270 /* Ports 2-4 are not routed to pins
4271 * => usable ports 0, 1, 5, 6
4272 */
4273 .num_ports = 7,
4274 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004275 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004276 .max_vid = 4095,
4277 .port_base_addr = 0x08,
4278 .phy_base_addr = 0x00,
4279 .global1_addr = 0x0f,
4280 .global2_addr = 0x07,
4281 .age_time_coeff = 15000,
4282 .g1_irqs = 9,
4283 .g2_irqs = 10,
4284 .atu_move_port_mask = 0xf,
4285 .dual_chip = true,
4286 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004287 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004288 .ops = &mv88e6250_ops,
4289 },
4290
Vivien Didelotf81ec902016-05-09 13:22:58 -04004291 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004292 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004293 .family = MV88E6XXX_FAMILY_6352,
4294 .name = "Marvell 88E6240",
4295 .num_databases = 4096,
4296 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004297 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004298 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004299 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004300 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004301 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004302 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004303 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004304 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004305 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004306 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004307 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004308 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004309 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004310 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004311 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004312 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004313 },
4314
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004315 [MV88E6250] = {
4316 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4317 .family = MV88E6XXX_FAMILY_6250,
4318 .name = "Marvell 88E6250",
4319 .num_databases = 64,
4320 .num_ports = 7,
4321 .num_internal_phys = 5,
4322 .max_vid = 4095,
4323 .port_base_addr = 0x08,
4324 .phy_base_addr = 0x00,
4325 .global1_addr = 0x0f,
4326 .global2_addr = 0x07,
4327 .age_time_coeff = 15000,
4328 .g1_irqs = 9,
4329 .g2_irqs = 10,
4330 .atu_move_port_mask = 0xf,
4331 .dual_chip = true,
4332 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004333 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004334 .ops = &mv88e6250_ops,
4335 },
4336
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004337 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004338 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004339 .family = MV88E6XXX_FAMILY_6390,
4340 .name = "Marvell 88E6290",
4341 .num_databases = 4096,
4342 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004343 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004344 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004345 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004346 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004347 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004348 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004349 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004350 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004351 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004352 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004353 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004354 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004355 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004356 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004357 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004358 .ops = &mv88e6290_ops,
4359 },
4360
Vivien Didelotf81ec902016-05-09 13:22:58 -04004361 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004362 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004363 .family = MV88E6XXX_FAMILY_6320,
4364 .name = "Marvell 88E6320",
4365 .num_databases = 4096,
4366 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004367 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004368 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004369 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004370 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004371 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004372 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004373 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004374 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004375 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004376 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004377 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004378 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004379 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004380 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004381 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004382 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004383 },
4384
4385 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004386 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004387 .family = MV88E6XXX_FAMILY_6320,
4388 .name = "Marvell 88E6321",
4389 .num_databases = 4096,
4390 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004391 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004392 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004393 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004394 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004395 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004396 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004397 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004398 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004399 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004400 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004401 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004402 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004403 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004404 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004405 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004406 },
4407
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004408 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004409 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004410 .family = MV88E6XXX_FAMILY_6341,
4411 .name = "Marvell 88E6341",
4412 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004413 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004414 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004415 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004416 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004417 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004418 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004419 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004420 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004421 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004422 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004423 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004424 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004425 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004426 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004427 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004428 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004429 .ops = &mv88e6341_ops,
4430 },
4431
Vivien Didelotf81ec902016-05-09 13:22:58 -04004432 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004433 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004434 .family = MV88E6XXX_FAMILY_6351,
4435 .name = "Marvell 88E6350",
4436 .num_databases = 4096,
4437 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004438 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004439 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004440 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004441 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004442 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004443 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004444 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004445 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004446 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004447 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004448 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004449 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004450 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004451 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004452 },
4453
4454 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004455 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004456 .family = MV88E6XXX_FAMILY_6351,
4457 .name = "Marvell 88E6351",
4458 .num_databases = 4096,
4459 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004460 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004461 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004462 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004463 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004464 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004465 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004466 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004468 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004469 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004470 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004471 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004472 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004473 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004474 },
4475
4476 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004477 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004478 .family = MV88E6XXX_FAMILY_6352,
4479 .name = "Marvell 88E6352",
4480 .num_databases = 4096,
4481 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004482 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004483 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004484 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004485 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004486 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004487 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004488 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004489 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004490 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004491 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004492 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004493 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004494 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004495 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004496 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004497 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004498 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004499 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004500 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004501 .family = MV88E6XXX_FAMILY_6390,
4502 .name = "Marvell 88E6390",
4503 .num_databases = 4096,
4504 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004505 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004506 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004507 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004508 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004509 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004510 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004511 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004512 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004513 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004514 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004515 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004516 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004517 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004518 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004519 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004520 .ops = &mv88e6390_ops,
4521 },
4522 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004523 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004524 .family = MV88E6XXX_FAMILY_6390,
4525 .name = "Marvell 88E6390X",
4526 .num_databases = 4096,
4527 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004528 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004529 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004530 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004531 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004532 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004533 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004534 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004535 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004536 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004537 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004538 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004539 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004540 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004541 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004542 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004543 .ops = &mv88e6390x_ops,
4544 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004545};
4546
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004547static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004548{
Vivien Didelota439c062016-04-17 13:23:58 -04004549 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004550
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004551 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4552 if (mv88e6xxx_table[i].prod_num == prod_num)
4553 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004554
Vivien Didelotb9b37712015-10-30 19:39:48 -04004555 return NULL;
4556}
4557
Vivien Didelotfad09c72016-06-21 12:28:20 -04004558static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004559{
4560 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004561 unsigned int prod_num, rev;
4562 u16 id;
4563 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004564
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004565 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004566 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004567 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004568 if (err)
4569 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004570
Vivien Didelot107fcc12017-06-12 12:37:36 -04004571 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4572 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004573
4574 info = mv88e6xxx_lookup_info(prod_num);
4575 if (!info)
4576 return -ENODEV;
4577
Vivien Didelotcaac8542016-06-20 13:14:09 -04004578 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004579 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004580
Vivien Didelotca070c12016-09-02 14:45:34 -04004581 err = mv88e6xxx_g2_require(chip);
4582 if (err)
4583 return err;
4584
Vivien Didelotfad09c72016-06-21 12:28:20 -04004585 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4586 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004587
4588 return 0;
4589}
4590
Vivien Didelotfad09c72016-06-21 12:28:20 -04004591static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004592{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004593 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004594
Vivien Didelotfad09c72016-06-21 12:28:20 -04004595 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4596 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004597 return NULL;
4598
Vivien Didelotfad09c72016-06-21 12:28:20 -04004599 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004600
Vivien Didelotfad09c72016-06-21 12:28:20 -04004601 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004602 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004603
Vivien Didelotfad09c72016-06-21 12:28:20 -04004604 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004605}
4606
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004607static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4608 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004609{
Vivien Didelot04bed142016-08-31 18:06:13 -04004610 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004611
Andrew Lunn443d5a12016-12-03 04:35:18 +01004612 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004613}
4614
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004615static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004616 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004617{
4618 /* We don't need any dynamic resource from the kernel (yet),
4619 * so skip the prepare phase.
4620 */
4621
4622 return 0;
4623}
4624
4625static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004626 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004627{
Vivien Didelot04bed142016-08-31 18:06:13 -04004628 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004629
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004630 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004631 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004632 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004633 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4634 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004635 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004636}
4637
4638static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4639 const struct switchdev_obj_port_mdb *mdb)
4640{
Vivien Didelot04bed142016-08-31 18:06:13 -04004641 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004642 int err;
4643
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004644 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004645 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004646 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004647 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004648
4649 return err;
4650}
4651
Russell King4f859012019-02-20 15:35:05 -08004652static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4653 bool unicast, bool multicast)
4654{
4655 struct mv88e6xxx_chip *chip = ds->priv;
4656 int err = -EOPNOTSUPP;
4657
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004658 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08004659 if (chip->info->ops->port_set_egress_floods)
4660 err = chip->info->ops->port_set_egress_floods(chip, port,
4661 unicast,
4662 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004663 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08004664
4665 return err;
4666}
4667
Florian Fainellia82f67a2017-01-08 14:52:08 -08004668static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004669 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004670 .setup = mv88e6xxx_setup,
Russell Kingc9a23562018-05-10 13:17:35 -07004671 .phylink_validate = mv88e6xxx_validate,
4672 .phylink_mac_link_state = mv88e6xxx_link_state,
4673 .phylink_mac_config = mv88e6xxx_mac_config,
4674 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4675 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004676 .get_strings = mv88e6xxx_get_strings,
4677 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4678 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004679 .port_enable = mv88e6xxx_port_enable,
4680 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004681 .get_mac_eee = mv88e6xxx_get_mac_eee,
4682 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004683 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004684 .get_eeprom = mv88e6xxx_get_eeprom,
4685 .set_eeprom = mv88e6xxx_set_eeprom,
4686 .get_regs_len = mv88e6xxx_get_regs_len,
4687 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004688 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004689 .port_bridge_join = mv88e6xxx_port_bridge_join,
4690 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004691 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004692 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004693 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004694 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4695 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4696 .port_vlan_add = mv88e6xxx_port_vlan_add,
4697 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004698 .port_fdb_add = mv88e6xxx_port_fdb_add,
4699 .port_fdb_del = mv88e6xxx_port_fdb_del,
4700 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004701 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4702 .port_mdb_add = mv88e6xxx_port_mdb_add,
4703 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004704 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4705 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004706 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4707 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4708 .port_txtstamp = mv88e6xxx_port_txtstamp,
4709 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4710 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004711};
4712
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004713static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004714{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004715 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004716 struct dsa_switch *ds;
4717
Vivien Didelot73b12042017-03-30 17:37:10 -04004718 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004719 if (!ds)
4720 return -ENOMEM;
4721
Vivien Didelotfad09c72016-06-21 12:28:20 -04004722 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004723 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004724 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004725 ds->ageing_time_min = chip->info->age_time_coeff;
4726 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004727
4728 dev_set_drvdata(dev, ds);
4729
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004730 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004731}
4732
Vivien Didelotfad09c72016-06-21 12:28:20 -04004733static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004734{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004735 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004736}
4737
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004738static const void *pdata_device_get_match_data(struct device *dev)
4739{
4740 const struct of_device_id *matches = dev->driver->of_match_table;
4741 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4742
4743 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4744 matches++) {
4745 if (!strcmp(pdata->compatible, matches->compatible))
4746 return matches->data;
4747 }
4748 return NULL;
4749}
4750
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004751/* There is no suspend to RAM support at DSA level yet, the switch configuration
4752 * would be lost after a power cycle so prevent it to be suspended.
4753 */
4754static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4755{
4756 return -EOPNOTSUPP;
4757}
4758
4759static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4760{
4761 return 0;
4762}
4763
4764static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4765
Vivien Didelot57d32312016-06-20 13:13:58 -04004766static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004767{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004768 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004769 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004770 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004771 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004772 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004773 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004774 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004775
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004776 if (!np && !pdata)
4777 return -EINVAL;
4778
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004779 if (np)
4780 compat_info = of_device_get_match_data(dev);
4781
4782 if (pdata) {
4783 compat_info = pdata_device_get_match_data(dev);
4784
4785 if (!pdata->netdev)
4786 return -EINVAL;
4787
4788 for (port = 0; port < DSA_MAX_PORTS; port++) {
4789 if (!(pdata->enabled_ports & (1 << port)))
4790 continue;
4791 if (strcmp(pdata->cd.port_names[port], "cpu"))
4792 continue;
4793 pdata->cd.netdev[port] = &pdata->netdev->dev;
4794 break;
4795 }
4796 }
4797
Vivien Didelotcaac8542016-06-20 13:14:09 -04004798 if (!compat_info)
4799 return -EINVAL;
4800
Vivien Didelotfad09c72016-06-21 12:28:20 -04004801 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004802 if (!chip) {
4803 err = -ENOMEM;
4804 goto out;
4805 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004806
Vivien Didelotfad09c72016-06-21 12:28:20 -04004807 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004808
Vivien Didelotfad09c72016-06-21 12:28:20 -04004809 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004810 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004811 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004812
Andrew Lunnb4308f02016-11-21 23:26:55 +01004813 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004814 if (IS_ERR(chip->reset)) {
4815 err = PTR_ERR(chip->reset);
4816 goto out;
4817 }
Baruch Siach7b75e492019-06-27 21:17:39 +03004818 if (chip->reset)
4819 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01004820
Vivien Didelotfad09c72016-06-21 12:28:20 -04004821 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004822 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004823 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004824
Vivien Didelote57e5e72016-08-15 17:19:00 -04004825 mv88e6xxx_phy_init(chip);
4826
Andrew Lunn00baabe2018-05-19 22:31:35 +02004827 if (chip->info->ops->get_eeprom) {
4828 if (np)
4829 of_property_read_u32(np, "eeprom-length",
4830 &chip->eeprom_len);
4831 else
4832 chip->eeprom_len = pdata->eeprom_len;
4833 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004834
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004835 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004836 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004837 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02004838 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004839 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004840
Andrew Lunna27415d2019-05-01 00:10:50 +02004841 if (np) {
4842 chip->irq = of_irq_get(np, 0);
4843 if (chip->irq == -EPROBE_DEFER) {
4844 err = chip->irq;
4845 goto out;
4846 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004847 }
4848
Andrew Lunna27415d2019-05-01 00:10:50 +02004849 if (pdata)
4850 chip->irq = pdata->irq;
4851
Andrew Lunn294d7112018-02-22 22:58:32 +01004852 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004853 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004854 * controllers
4855 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004856 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004857 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004858 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004859 else
4860 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004861 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004862
Andrew Lunn294d7112018-02-22 22:58:32 +01004863 if (err)
4864 goto out;
4865
4866 if (chip->info->g2_irqs > 0) {
4867 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004868 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004869 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004870 }
4871
Andrew Lunn294d7112018-02-22 22:58:32 +01004872 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4873 if (err)
4874 goto out_g2_irq;
4875
4876 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4877 if (err)
4878 goto out_g1_atu_prob_irq;
4879
Andrew Lunna3c53be52017-01-24 14:53:50 +01004880 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004881 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004882 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004883
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004884 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004885 if (err)
4886 goto out_mdio;
4887
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004888 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004889
4890out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004891 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004892out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004893 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004894out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004895 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004896out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004897 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004898 mv88e6xxx_g2_irq_free(chip);
4899out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004900 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004901 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004902 else
4903 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004904out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004905 if (pdata)
4906 dev_put(pdata->netdev);
4907
Andrew Lunndc30c352016-10-16 19:56:49 +02004908 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004909}
4910
4911static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4912{
4913 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004914 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004915
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004916 if (chip->info->ptp_support) {
4917 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004918 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004919 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004920
Andrew Lunn930188c2016-08-22 16:01:03 +02004921 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004922 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004923 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004924
Andrew Lunn76f38f12018-03-17 20:21:09 +01004925 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4926 mv88e6xxx_g1_atu_prob_irq_free(chip);
4927
4928 if (chip->info->g2_irqs > 0)
4929 mv88e6xxx_g2_irq_free(chip);
4930
Andrew Lunn76f38f12018-03-17 20:21:09 +01004931 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004932 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004933 else
4934 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004935}
4936
4937static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004938 {
4939 .compatible = "marvell,mv88e6085",
4940 .data = &mv88e6xxx_table[MV88E6085],
4941 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004942 {
4943 .compatible = "marvell,mv88e6190",
4944 .data = &mv88e6xxx_table[MV88E6190],
4945 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004946 {
4947 .compatible = "marvell,mv88e6250",
4948 .data = &mv88e6xxx_table[MV88E6250],
4949 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004950 { /* sentinel */ },
4951};
4952
4953MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4954
4955static struct mdio_driver mv88e6xxx_driver = {
4956 .probe = mv88e6xxx_probe,
4957 .remove = mv88e6xxx_remove,
4958 .mdiodrv.driver = {
4959 .name = "mv88e6085",
4960 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004961 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004962 },
4963};
4964
Andrew Lunn7324d502019-04-27 19:19:10 +02004965mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004966
4967MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4968MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4969MODULE_LICENSE("GPL");