blob: 54e88aafba2f4932ab3a998e46063649b2bd247d [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
Marek Behún7a3007d2019-08-26 23:31:55 +0200457 if (chip->info->ops->port_set_cmode_writable) {
458 err = chip->info->ops->port_set_cmode_writable(chip, port);
459 if (err && err != -EOPNOTSUPP)
460 goto restore_link;
461 }
462
Andrew Lunnf39908d2017-02-04 20:02:50 +0100463 if (chip->info->ops->port_set_cmode) {
464 err = chip->info->ops->port_set_cmode(chip, port, mode);
465 if (err && err != -EOPNOTSUPP)
466 goto restore_link;
467 }
468
Vivien Didelotd78343d2016-11-04 03:23:36 +0100469 err = 0;
470restore_link:
471 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400472 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100473
474 return err;
475}
476
Marek Vasutd700ec42018-09-12 00:15:24 +0200477static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
478{
479 struct mv88e6xxx_chip *chip = ds->priv;
480
481 return port < chip->info->num_internal_phys;
482}
483
Russell King6c422e32018-08-09 15:38:39 +0200484static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
485 unsigned long *mask,
486 struct phylink_link_state *state)
487{
488 if (!phy_interface_mode_is_8023z(state->interface)) {
489 /* 10M and 100M are only supported in non-802.3z mode */
490 phylink_set(mask, 10baseT_Half);
491 phylink_set(mask, 10baseT_Full);
492 phylink_set(mask, 100baseT_Half);
493 phylink_set(mask, 100baseT_Full);
494 }
495}
496
497static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
498 unsigned long *mask,
499 struct phylink_link_state *state)
500{
501 /* FIXME: if the port is in 1000Base-X mode, then it only supports
502 * 1000M FD speeds. In this case, CMODE will indicate 5.
503 */
504 phylink_set(mask, 1000baseT_Full);
505 phylink_set(mask, 1000baseX_Full);
506
507 mv88e6065_phylink_validate(chip, port, mask, state);
508}
509
Marek Behúne3af71a2019-02-25 12:39:55 +0100510static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
511 unsigned long *mask,
512 struct phylink_link_state *state)
513{
514 if (port >= 5)
515 phylink_set(mask, 2500baseX_Full);
516
517 /* No ethtool bits for 200Mbps */
518 phylink_set(mask, 1000baseT_Full);
519 phylink_set(mask, 1000baseX_Full);
520
521 mv88e6065_phylink_validate(chip, port, mask, state);
522}
523
Russell King6c422e32018-08-09 15:38:39 +0200524static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
525 unsigned long *mask,
526 struct phylink_link_state *state)
527{
528 /* No ethtool bits for 200Mbps */
529 phylink_set(mask, 1000baseT_Full);
530 phylink_set(mask, 1000baseX_Full);
531
532 mv88e6065_phylink_validate(chip, port, mask, state);
533}
534
535static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
536 unsigned long *mask,
537 struct phylink_link_state *state)
538{
Andrew Lunnec260162019-02-08 22:25:44 +0100539 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200540 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100541 phylink_set(mask, 2500baseT_Full);
542 }
Russell King6c422e32018-08-09 15:38:39 +0200543
544 /* No ethtool bits for 200Mbps */
545 phylink_set(mask, 1000baseT_Full);
546 phylink_set(mask, 1000baseX_Full);
547
548 mv88e6065_phylink_validate(chip, port, mask, state);
549}
550
551static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
552 unsigned long *mask,
553 struct phylink_link_state *state)
554{
555 if (port >= 9) {
556 phylink_set(mask, 10000baseT_Full);
557 phylink_set(mask, 10000baseKR_Full);
558 }
559
560 mv88e6390_phylink_validate(chip, port, mask, state);
561}
562
Russell Kingc9a23562018-05-10 13:17:35 -0700563static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
564 unsigned long *supported,
565 struct phylink_link_state *state)
566{
Russell King6c422e32018-08-09 15:38:39 +0200567 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
568 struct mv88e6xxx_chip *chip = ds->priv;
569
570 /* Allow all the expected bits */
571 phylink_set(mask, Autoneg);
572 phylink_set(mask, Pause);
573 phylink_set_port_modes(mask);
574
575 if (chip->info->ops->phylink_validate)
576 chip->info->ops->phylink_validate(chip, port, mask, state);
577
578 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
579 bitmap_and(state->advertising, state->advertising, mask,
580 __ETHTOOL_LINK_MODE_MASK_NBITS);
581
582 /* We can only operate at 2500BaseX or 1000BaseX. If requested
583 * to advertise both, only report advertising at 2500BaseX.
584 */
585 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700586}
587
588static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
589 struct phylink_link_state *state)
590{
591 struct mv88e6xxx_chip *chip = ds->priv;
592 int err;
593
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000594 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200595 if (chip->info->ops->port_link_state)
596 err = chip->info->ops->port_link_state(chip, port, state);
597 else
598 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000599 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700600
601 return err;
602}
603
604static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
605 unsigned int mode,
606 const struct phylink_link_state *state)
607{
608 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200609 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700610
Marek Vasutd700ec42018-09-12 00:15:24 +0200611 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700612 return;
613
614 if (mode == MLO_AN_FIXED) {
615 link = LINK_FORCED_UP;
616 speed = state->speed;
617 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200618 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
619 link = state->link;
620 speed = state->speed;
621 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700622 } else {
623 speed = SPEED_UNFORCED;
624 duplex = DUPLEX_UNFORCED;
625 link = LINK_UNFORCED;
626 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700628
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000629 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200630 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700631 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000632 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700633
634 if (err && err != -EOPNOTSUPP)
635 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
636}
637
638static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
639{
640 struct mv88e6xxx_chip *chip = ds->priv;
641 int err;
642
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000643 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700644 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000645 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700646
647 if (err)
648 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
649}
650
651static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
652 unsigned int mode,
653 phy_interface_t interface)
654{
655 if (mode == MLO_AN_FIXED)
656 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
657}
658
659static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
660 unsigned int mode, phy_interface_t interface,
661 struct phy_device *phydev)
662{
663 if (mode == MLO_AN_FIXED)
664 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
665}
666
Andrew Lunna605a0f2016-11-21 23:26:58 +0100667static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000668{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100669 if (!chip->info->ops->stats_snapshot)
670 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000671
Andrew Lunna605a0f2016-11-21 23:26:58 +0100672 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000673}
674
Andrew Lunne413e7e2015-04-02 04:06:38 +0200675static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100676 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
677 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
678 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
679 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
680 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
681 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
682 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
683 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
684 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
685 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
686 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
687 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
688 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
689 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
690 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
691 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
692 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
693 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
694 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
695 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
696 { "single", 4, 0x14, STATS_TYPE_BANK0, },
697 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
698 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
699 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
700 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
701 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
702 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
703 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
704 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
705 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
706 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
707 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
708 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
709 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
710 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
711 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
712 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
713 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
714 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
715 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
716 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
717 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
718 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
719 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
720 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
721 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
722 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
723 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
724 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
725 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
726 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
727 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
728 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
729 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
730 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
731 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
732 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
733 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
734 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200735};
736
Vivien Didelotfad09c72016-06-21 12:28:20 -0400737static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100738 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100739 int port, u16 bank1_select,
740 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200741{
Andrew Lunn80c46272015-06-20 18:42:30 +0200742 u32 low;
743 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100744 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200745 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200746 u64 value;
747
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100748 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100749 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200750 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
751 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800752 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200753
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200754 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100755 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200756 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
757 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800758 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000759 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200760 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100761 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100762 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100763 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100764 /* fall through */
765 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100766 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100767 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100768 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100769 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500770 break;
771 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800772 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200773 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100774 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200775 return value;
776}
777
Andrew Lunn436fe172018-03-01 02:02:29 +0100778static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
779 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100780{
781 struct mv88e6xxx_hw_stat *stat;
782 int i, j;
783
784 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
785 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100786 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100787 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
788 ETH_GSTRING_LEN);
789 j++;
790 }
791 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100792
793 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100794}
795
Andrew Lunn436fe172018-03-01 02:02:29 +0100796static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
797 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100798{
Andrew Lunn436fe172018-03-01 02:02:29 +0100799 return mv88e6xxx_stats_get_strings(chip, data,
800 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100801}
802
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000803static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
804 uint8_t *data)
805{
806 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
807}
808
Andrew Lunn436fe172018-03-01 02:02:29 +0100809static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
810 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100811{
Andrew Lunn436fe172018-03-01 02:02:29 +0100812 return mv88e6xxx_stats_get_strings(chip, data,
813 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100814}
815
Andrew Lunn65f60e42018-03-28 23:50:28 +0200816static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
817 "atu_member_violation",
818 "atu_miss_violation",
819 "atu_full_violation",
820 "vtu_member_violation",
821 "vtu_miss_violation",
822};
823
824static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
825{
826 unsigned int i;
827
828 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
829 strlcpy(data + i * ETH_GSTRING_LEN,
830 mv88e6xxx_atu_vtu_stats_strings[i],
831 ETH_GSTRING_LEN);
832}
833
Andrew Lunndfafe442016-11-21 23:27:02 +0100834static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700835 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100836{
Vivien Didelot04bed142016-08-31 18:06:13 -0400837 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100838 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100839
Florian Fainelli89f09042018-04-25 12:12:50 -0700840 if (stringset != ETH_SS_STATS)
841 return;
842
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000843 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100844
Andrew Lunndfafe442016-11-21 23:27:02 +0100845 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100846 count = chip->info->ops->stats_get_strings(chip, data);
847
848 if (chip->info->ops->serdes_get_strings) {
849 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200850 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100851 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100852
Andrew Lunn65f60e42018-03-28 23:50:28 +0200853 data += count * ETH_GSTRING_LEN;
854 mv88e6xxx_atu_vtu_get_strings(data);
855
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000856 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100857}
858
859static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
860 int types)
861{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100862 struct mv88e6xxx_hw_stat *stat;
863 int i, j;
864
865 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
866 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100867 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100868 j++;
869 }
870 return j;
871}
872
Andrew Lunndfafe442016-11-21 23:27:02 +0100873static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
874{
875 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
876 STATS_TYPE_PORT);
877}
878
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000879static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
880{
881 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
882}
883
Andrew Lunndfafe442016-11-21 23:27:02 +0100884static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
885{
886 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
887 STATS_TYPE_BANK1);
888}
889
Florian Fainelli89f09042018-04-25 12:12:50 -0700890static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100891{
892 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100893 int serdes_count = 0;
894 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100895
Florian Fainelli89f09042018-04-25 12:12:50 -0700896 if (sset != ETH_SS_STATS)
897 return 0;
898
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000899 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100900 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100901 count = chip->info->ops->stats_get_sset_count(chip);
902 if (count < 0)
903 goto out;
904
905 if (chip->info->ops->serdes_get_sset_count)
906 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
907 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200908 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100909 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200910 goto out;
911 }
912 count += serdes_count;
913 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000916 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100917
Andrew Lunn436fe172018-03-01 02:02:29 +0100918 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100919}
920
Andrew Lunn436fe172018-03-01 02:02:29 +0100921static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
922 uint64_t *data, int types,
923 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100924{
925 struct mv88e6xxx_hw_stat *stat;
926 int i, j;
927
928 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
929 stat = &mv88e6xxx_hw_stats[i];
930 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000931 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100932 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
933 bank1_select,
934 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000935 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100936
Andrew Lunn052f9472016-11-21 23:27:03 +0100937 j++;
938 }
939 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100940 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100941}
942
Andrew Lunn436fe172018-03-01 02:02:29 +0100943static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
944 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100945{
946 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100947 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400948 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100949}
950
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000951static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
952 uint64_t *data)
953{
954 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
955 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
956}
957
Andrew Lunn436fe172018-03-01 02:02:29 +0100958static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
959 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100960{
961 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100962 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400963 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
964 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100965}
966
Andrew Lunn436fe172018-03-01 02:02:29 +0100967static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
968 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100969{
970 return mv88e6xxx_stats_get_stats(chip, port, data,
971 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400972 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
973 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100974}
975
Andrew Lunn65f60e42018-03-28 23:50:28 +0200976static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
977 uint64_t *data)
978{
979 *data++ = chip->ports[port].atu_member_violation;
980 *data++ = chip->ports[port].atu_miss_violation;
981 *data++ = chip->ports[port].atu_full_violation;
982 *data++ = chip->ports[port].vtu_member_violation;
983 *data++ = chip->ports[port].vtu_miss_violation;
984}
985
Andrew Lunn052f9472016-11-21 23:27:03 +0100986static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
987 uint64_t *data)
988{
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 int count = 0;
990
Andrew Lunn052f9472016-11-21 23:27:03 +0100991 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 count = chip->info->ops->stats_get_stats(chip, port, data);
993
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000994 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 if (chip->info->ops->serdes_get_stats) {
996 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200997 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100998 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200999 data += count;
1000 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001001 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001002}
1003
Vivien Didelotf81ec902016-05-09 13:22:58 -04001004static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1005 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001006{
Vivien Didelot04bed142016-08-31 18:06:13 -04001007 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001008 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001009
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001010 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001011
Andrew Lunna605a0f2016-11-21 23:26:58 +01001012 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001013 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001014
1015 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001016 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001017
1018 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001019
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001020}
Ben Hutchings98e67302011-11-25 14:36:19 +00001021
Vivien Didelotf81ec902016-05-09 13:22:58 -04001022static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001023{
1024 return 32 * sizeof(u16);
1025}
1026
Vivien Didelotf81ec902016-05-09 13:22:58 -04001027static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1028 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001029{
Vivien Didelot04bed142016-08-31 18:06:13 -04001030 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001031 int err;
1032 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001033 u16 *p = _p;
1034 int i;
1035
Vivien Didelota5f39322018-12-17 16:05:21 -05001036 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037
1038 memset(p, 0xff, 32 * sizeof(u16));
1039
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001040 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001041
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001042 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001043
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001044 err = mv88e6xxx_port_read(chip, port, i, &reg);
1045 if (!err)
1046 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047 }
Vivien Didelot23062512016-05-09 13:22:45 -04001048
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001049 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001050}
1051
Vivien Didelot08f50062017-08-01 16:32:41 -04001052static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1053 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001054{
Vivien Didelot5480db62017-08-01 16:32:40 -04001055 /* Nothing to do on the port's MAC */
1056 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001057}
1058
Vivien Didelot08f50062017-08-01 16:32:41 -04001059static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1060 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001061{
Vivien Didelot5480db62017-08-01 16:32:40 -04001062 /* Nothing to do on the port's MAC */
1063 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001064}
1065
Vivien Didelote5887a22017-03-30 17:37:11 -04001066static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001067{
Vivien Didelote5887a22017-03-30 17:37:11 -04001068 struct dsa_switch *ds = NULL;
1069 struct net_device *br;
1070 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001071 int i;
1072
Vivien Didelote5887a22017-03-30 17:37:11 -04001073 if (dev < DSA_MAX_SWITCHES)
1074 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001075
Vivien Didelote5887a22017-03-30 17:37:11 -04001076 /* Prevent frames from unknown switch or port */
1077 if (!ds || port >= ds->num_ports)
1078 return 0;
1079
1080 /* Frames from DSA links and CPU ports can egress any local port */
1081 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1082 return mv88e6xxx_port_mask(chip);
1083
1084 br = ds->ports[port].bridge_dev;
1085 pvlan = 0;
1086
1087 /* Frames from user ports can egress any local DSA links and CPU ports,
1088 * as well as any local member of their bridge group.
1089 */
1090 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1091 if (dsa_is_cpu_port(chip->ds, i) ||
1092 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001093 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001094 pvlan |= BIT(i);
1095
1096 return pvlan;
1097}
1098
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001099static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001100{
1101 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001102
1103 /* prevent frames from going back out of the port they came in on */
1104 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001105
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001106 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001107}
1108
Vivien Didelotf81ec902016-05-09 13:22:58 -04001109static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1110 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001111{
Vivien Didelot04bed142016-08-31 18:06:13 -04001112 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001113 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001114
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001115 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001116 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001117 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001118
1119 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001120 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001121}
1122
Vivien Didelot93e18d62018-05-11 17:16:35 -04001123static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1124{
1125 int err;
1126
1127 if (chip->info->ops->ieee_pri_map) {
1128 err = chip->info->ops->ieee_pri_map(chip);
1129 if (err)
1130 return err;
1131 }
1132
1133 if (chip->info->ops->ip_pri_map) {
1134 err = chip->info->ops->ip_pri_map(chip);
1135 if (err)
1136 return err;
1137 }
1138
1139 return 0;
1140}
1141
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001142static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1143{
1144 int target, port;
1145 int err;
1146
1147 if (!chip->info->global2_addr)
1148 return 0;
1149
1150 /* Initialize the routing port to the 32 possible target devices */
1151 for (target = 0; target < 32; target++) {
1152 port = 0x1f;
1153 if (target < DSA_MAX_SWITCHES)
1154 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1155 port = chip->ds->rtable[target];
1156
1157 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1158 if (err)
1159 return err;
1160 }
1161
Vivien Didelot02317e62018-05-09 11:38:49 -04001162 if (chip->info->ops->set_cascade_port) {
1163 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1164 err = chip->info->ops->set_cascade_port(chip, port);
1165 if (err)
1166 return err;
1167 }
1168
Vivien Didelot23c98912018-05-09 11:38:50 -04001169 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1170 if (err)
1171 return err;
1172
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001173 return 0;
1174}
1175
Vivien Didelotb28f8722018-04-26 21:56:44 -04001176static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1177{
1178 /* Clear all trunk masks and mapping */
1179 if (chip->info->global2_addr)
1180 return mv88e6xxx_g2_trunk_clear(chip);
1181
1182 return 0;
1183}
1184
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001185static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1186{
1187 if (chip->info->ops->rmu_disable)
1188 return chip->info->ops->rmu_disable(chip);
1189
1190 return 0;
1191}
1192
Vivien Didelot9e907d72017-07-17 13:03:43 -04001193static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1194{
1195 if (chip->info->ops->pot_clear)
1196 return chip->info->ops->pot_clear(chip);
1197
1198 return 0;
1199}
1200
Vivien Didelot51c901a2017-07-17 13:03:41 -04001201static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1202{
1203 if (chip->info->ops->mgmt_rsvd2cpu)
1204 return chip->info->ops->mgmt_rsvd2cpu(chip);
1205
1206 return 0;
1207}
1208
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001209static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1210{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001211 int err;
1212
Vivien Didelotdaefc942017-03-11 16:12:54 -05001213 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1214 if (err)
1215 return err;
1216
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001217 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1218 if (err)
1219 return err;
1220
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001221 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1222}
1223
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001224static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1225{
1226 int port;
1227 int err;
1228
1229 if (!chip->info->ops->irl_init_all)
1230 return 0;
1231
1232 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1233 /* Disable ingress rate limiting by resetting all per port
1234 * ingress rate limit resources to their initial state.
1235 */
1236 err = chip->info->ops->irl_init_all(chip, port);
1237 if (err)
1238 return err;
1239 }
1240
1241 return 0;
1242}
1243
Vivien Didelot04a69a12017-10-13 14:18:05 -04001244static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1245{
1246 if (chip->info->ops->set_switch_mac) {
1247 u8 addr[ETH_ALEN];
1248
1249 eth_random_addr(addr);
1250
1251 return chip->info->ops->set_switch_mac(chip, addr);
1252 }
1253
1254 return 0;
1255}
1256
Vivien Didelot17a15942017-03-30 17:37:09 -04001257static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1258{
1259 u16 pvlan = 0;
1260
1261 if (!mv88e6xxx_has_pvt(chip))
1262 return -EOPNOTSUPP;
1263
1264 /* Skip the local source device, which uses in-chip port VLAN */
1265 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001266 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001267
1268 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1269}
1270
Vivien Didelot81228992017-03-30 17:37:08 -04001271static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1272{
Vivien Didelot17a15942017-03-30 17:37:09 -04001273 int dev, port;
1274 int err;
1275
Vivien Didelot81228992017-03-30 17:37:08 -04001276 if (!mv88e6xxx_has_pvt(chip))
1277 return 0;
1278
1279 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1280 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1281 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001282 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1283 if (err)
1284 return err;
1285
1286 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1287 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1288 err = mv88e6xxx_pvt_map(chip, dev, port);
1289 if (err)
1290 return err;
1291 }
1292 }
1293
1294 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001295}
1296
Vivien Didelot749efcb2016-09-22 16:49:24 -04001297static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1298{
1299 struct mv88e6xxx_chip *chip = ds->priv;
1300 int err;
1301
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001302 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001303 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001304 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001305
1306 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001307 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001308}
1309
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001310static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1311{
1312 if (!chip->info->max_vid)
1313 return 0;
1314
1315 return mv88e6xxx_g1_vtu_flush(chip);
1316}
1317
Vivien Didelotf1394b782017-05-01 14:05:22 -04001318static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1319 struct mv88e6xxx_vtu_entry *entry)
1320{
1321 if (!chip->info->ops->vtu_getnext)
1322 return -EOPNOTSUPP;
1323
1324 return chip->info->ops->vtu_getnext(chip, entry);
1325}
1326
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001327static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1328 struct mv88e6xxx_vtu_entry *entry)
1329{
1330 if (!chip->info->ops->vtu_loadpurge)
1331 return -EOPNOTSUPP;
1332
1333 return chip->info->ops->vtu_loadpurge(chip, entry);
1334}
1335
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001336static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001337{
1338 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001339 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001340 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001341
1342 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1343
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001344 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001345 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001346 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001347 if (err)
1348 return err;
1349
1350 set_bit(*fid, fid_bitmap);
1351 }
1352
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001353 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001354 vlan.vid = chip->info->max_vid;
1355 vlan.valid = false;
1356
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001357 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001358 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001359 if (err)
1360 return err;
1361
1362 if (!vlan.valid)
1363 break;
1364
1365 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001366 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001367
1368 /* The reset value 0x000 is used to indicate that multiple address
1369 * databases are not needed. Return the next positive available.
1370 */
1371 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001372 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001373 return -ENOSPC;
1374
1375 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001376 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001377}
1378
Vivien Didelotda9c3592016-02-12 12:09:40 -05001379static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1380 u16 vid_begin, u16 vid_end)
1381{
Vivien Didelot04bed142016-08-31 18:06:13 -04001382 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001383 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001384 int i, err;
1385
Andrew Lunndb06ae412017-09-25 23:32:20 +02001386 /* DSA and CPU ports have to be members of multiple vlans */
1387 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1388 return 0;
1389
Vivien Didelotda9c3592016-02-12 12:09:40 -05001390 if (!vid_begin)
1391 return -EOPNOTSUPP;
1392
Vivien Didelot425d2d32019-08-01 14:36:34 -04001393 vlan.vid = vid_begin - 1;
1394 vlan.valid = false;
1395
Vivien Didelotda9c3592016-02-12 12:09:40 -05001396 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001397 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001398 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001399 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001400
1401 if (!vlan.valid)
1402 break;
1403
1404 if (vlan.vid > vid_end)
1405 break;
1406
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001407 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001408 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1409 continue;
1410
Andrew Lunncd886462017-11-09 22:29:53 +01001411 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001412 continue;
1413
Vivien Didelotbd00e052017-05-01 14:05:11 -04001414 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001415 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001416 continue;
1417
Vivien Didelotc8652c82017-10-16 11:12:19 -04001418 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001419 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001420 break; /* same bridge, check next VLAN */
1421
Vivien Didelotc8652c82017-10-16 11:12:19 -04001422 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001423 continue;
1424
Andrew Lunn743fcc22017-11-09 22:29:54 +01001425 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1426 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001427 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001428 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001429 }
1430 } while (vlan.vid < vid_end);
1431
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001432 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001433}
1434
Vivien Didelotf81ec902016-05-09 13:22:58 -04001435static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1436 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001437{
Vivien Didelot04bed142016-08-31 18:06:13 -04001438 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001439 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1440 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001441 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001442
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001443 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001444 return -EOPNOTSUPP;
1445
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001446 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001447 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001448 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001449
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001450 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001451}
1452
Vivien Didelot57d32312016-06-20 13:13:58 -04001453static int
1454mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001455 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001456{
Vivien Didelot04bed142016-08-31 18:06:13 -04001457 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001458 int err;
1459
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001460 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001461 return -EOPNOTSUPP;
1462
Vivien Didelotda9c3592016-02-12 12:09:40 -05001463 /* If the requested port doesn't belong to the same bridge as the VLAN
1464 * members, do not support it (yet) and fallback to software VLAN.
1465 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001466 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001467 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1468 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001469 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001470
Vivien Didelot76e398a2015-11-01 12:33:55 -05001471 /* We don't need any dynamic resource from the kernel (yet),
1472 * so skip the prepare phase.
1473 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001474 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001475}
1476
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001477static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1478 const unsigned char *addr, u16 vid,
1479 u8 state)
1480{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001481 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001482 struct mv88e6xxx_vtu_entry vlan;
1483 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001484 int err;
1485
1486 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001487 if (vid == 0) {
1488 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1489 if (err)
1490 return err;
1491 } else {
1492 vlan.vid = vid - 1;
1493 vlan.valid = false;
1494
1495 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1496 if (err)
1497 return err;
1498
1499 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1500 if (vlan.vid != vid || !vlan.valid)
1501 return -EOPNOTSUPP;
1502
1503 fid = vlan.fid;
1504 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001505
1506 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1507 ether_addr_copy(entry.mac, addr);
1508 eth_addr_dec(entry.mac);
1509
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001510 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001511 if (err)
1512 return err;
1513
1514 /* Initialize a fresh ATU entry if it isn't found */
1515 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1516 !ether_addr_equal(entry.mac, addr)) {
1517 memset(&entry, 0, sizeof(entry));
1518 ether_addr_copy(entry.mac, addr);
1519 }
1520
1521 /* Purge the ATU entry only if no port is using it anymore */
1522 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1523 entry.portvec &= ~BIT(port);
1524 if (!entry.portvec)
1525 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1526 } else {
1527 entry.portvec |= BIT(port);
1528 entry.state = state;
1529 }
1530
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001531 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001532}
1533
Andrew Lunn87fa8862017-11-09 22:29:56 +01001534static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1535 u16 vid)
1536{
1537 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1538 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1539
1540 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1541}
1542
1543static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1544{
1545 int port;
1546 int err;
1547
1548 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1549 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1550 if (err)
1551 return err;
1552 }
1553
1554 return 0;
1555}
1556
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001557static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001558 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001559{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001560 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001561 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001562 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001563
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001564 if (!vid)
1565 return -EOPNOTSUPP;
1566
1567 vlan.vid = vid - 1;
1568 vlan.valid = false;
1569
1570 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001571 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001572 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001573
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001574 if (vlan.vid != vid || !vlan.valid) {
1575 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001576
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001577 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1578 if (err)
1579 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001580
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001581 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1582 if (i == port)
1583 vlan.member[i] = member;
1584 else
1585 vlan.member[i] = non_member;
1586
1587 vlan.vid = vid;
1588 vlan.valid = true;
1589
1590 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1591 if (err)
1592 return err;
1593
1594 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1595 if (err)
1596 return err;
1597 } else if (vlan.member[port] != member) {
1598 vlan.member[port] = member;
1599
1600 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1601 if (err)
1602 return err;
1603 } else {
1604 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1605 port, vid);
1606 }
1607
1608 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001609}
1610
Vivien Didelotf81ec902016-05-09 13:22:58 -04001611static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001612 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001613{
Vivien Didelot04bed142016-08-31 18:06:13 -04001614 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001615 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1616 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001617 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001618 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001619
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001620 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001621 return;
1622
Vivien Didelotc91498e2017-06-07 18:12:13 -04001623 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001624 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001625 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001626 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001627 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001628 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001629
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001630 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001631
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001632 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001633 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001634 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1635 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001636
Vivien Didelot77064f32016-11-04 03:23:30 +01001637 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001638 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1639 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001640
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001641 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001642}
1643
Vivien Didelot521098922019-08-01 14:36:36 -04001644static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1645 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001646{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001647 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001648 int i, err;
1649
Vivien Didelot521098922019-08-01 14:36:36 -04001650 if (!vid)
1651 return -EOPNOTSUPP;
1652
1653 vlan.vid = vid - 1;
1654 vlan.valid = false;
1655
1656 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001657 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001658 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001659
Vivien Didelot521098922019-08-01 14:36:36 -04001660 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1661 * tell switchdev that this VLAN is likely handled in software.
1662 */
1663 if (vlan.vid != vid || !vlan.valid ||
1664 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001665 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001666
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001667 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001668
1669 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001670 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001671 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001672 if (vlan.member[i] !=
1673 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001674 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001675 break;
1676 }
1677 }
1678
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001679 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001680 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001681 return err;
1682
Vivien Didelote606ca32017-03-11 16:12:55 -05001683 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001684}
1685
Vivien Didelotf81ec902016-05-09 13:22:58 -04001686static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1687 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001688{
Vivien Didelot04bed142016-08-31 18:06:13 -04001689 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001690 u16 pvid, vid;
1691 int err = 0;
1692
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001693 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001694 return -EOPNOTSUPP;
1695
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001696 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001697
Vivien Didelot77064f32016-11-04 03:23:30 +01001698 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001699 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001700 goto unlock;
1701
Vivien Didelot76e398a2015-11-01 12:33:55 -05001702 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001703 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704 if (err)
1705 goto unlock;
1706
1707 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001708 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001709 if (err)
1710 goto unlock;
1711 }
1712 }
1713
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001714unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001715 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001716
1717 return err;
1718}
1719
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001720static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1721 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001722{
Vivien Didelot04bed142016-08-31 18:06:13 -04001723 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001724 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001725
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001726 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001727 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1728 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001729 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001730
1731 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001732}
1733
Vivien Didelotf81ec902016-05-09 13:22:58 -04001734static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001735 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001736{
Vivien Didelot04bed142016-08-31 18:06:13 -04001737 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001738 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001739
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001740 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001741 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001742 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001743 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001744
Vivien Didelot83dabd12016-08-31 11:50:04 -04001745 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001746}
1747
Vivien Didelot83dabd12016-08-31 11:50:04 -04001748static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1749 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001750 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001751{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001752 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001753 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001754 int err;
1755
Vivien Didelot27c0e602017-06-15 12:14:01 -04001756 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001757 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001758
1759 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001760 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001761 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001762 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001763
Vivien Didelot27c0e602017-06-15 12:14:01 -04001764 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001765 break;
1766
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001767 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001768 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001769
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001770 if (!is_unicast_ether_addr(addr.mac))
1771 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001772
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001773 is_static = (addr.state ==
1774 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1775 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001776 if (err)
1777 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001778 } while (!is_broadcast_ether_addr(addr.mac));
1779
1780 return err;
1781}
1782
Vivien Didelot83dabd12016-08-31 11:50:04 -04001783static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001784 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001785{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001786 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001787 u16 fid;
1788 int err;
1789
1790 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001791 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001792 if (err)
1793 return err;
1794
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001795 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001796 if (err)
1797 return err;
1798
1799 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001800 vlan.vid = chip->info->max_vid;
1801 vlan.valid = false;
1802
Vivien Didelot83dabd12016-08-31 11:50:04 -04001803 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001804 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001805 if (err)
1806 return err;
1807
1808 if (!vlan.valid)
1809 break;
1810
1811 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001812 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001813 if (err)
1814 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001815 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001816
1817 return err;
1818}
1819
Vivien Didelotf81ec902016-05-09 13:22:58 -04001820static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001821 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001822{
Vivien Didelot04bed142016-08-31 18:06:13 -04001823 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04001824 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001825
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001826 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001827 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001828 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001829
1830 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001831}
1832
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001833static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1834 struct net_device *br)
1835{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001836 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001837 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001838 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001839 int err;
1840
1841 /* Remap the Port VLAN of each local bridge group member */
1842 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1843 if (chip->ds->ports[port].bridge_dev == br) {
1844 err = mv88e6xxx_port_vlan_map(chip, port);
1845 if (err)
1846 return err;
1847 }
1848 }
1849
Vivien Didelote96a6e02017-03-30 17:37:13 -04001850 if (!mv88e6xxx_has_pvt(chip))
1851 return 0;
1852
1853 /* Remap the Port VLAN of each cross-chip bridge group member */
1854 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1855 ds = chip->ds->dst->ds[dev];
1856 if (!ds)
1857 break;
1858
1859 for (port = 0; port < ds->num_ports; ++port) {
1860 if (ds->ports[port].bridge_dev == br) {
1861 err = mv88e6xxx_pvt_map(chip, dev, port);
1862 if (err)
1863 return err;
1864 }
1865 }
1866 }
1867
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001868 return 0;
1869}
1870
Vivien Didelotf81ec902016-05-09 13:22:58 -04001871static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001872 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001873{
Vivien Didelot04bed142016-08-31 18:06:13 -04001874 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001875 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001876
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001877 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001878 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001879 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05001880
Vivien Didelot466dfa02016-02-26 13:16:05 -05001881 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001882}
1883
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001884static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1885 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001886{
Vivien Didelot04bed142016-08-31 18:06:13 -04001887 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001888
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001889 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001890 if (mv88e6xxx_bridge_map(chip, br) ||
1891 mv88e6xxx_port_vlan_map(chip, port))
1892 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001893 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001894}
1895
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001896static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1897 int port, struct net_device *br)
1898{
1899 struct mv88e6xxx_chip *chip = ds->priv;
1900 int err;
1901
1902 if (!mv88e6xxx_has_pvt(chip))
1903 return 0;
1904
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001905 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001906 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001907 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001908
1909 return err;
1910}
1911
1912static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1913 int port, struct net_device *br)
1914{
1915 struct mv88e6xxx_chip *chip = ds->priv;
1916
1917 if (!mv88e6xxx_has_pvt(chip))
1918 return;
1919
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001920 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001921 if (mv88e6xxx_pvt_map(chip, dev, port))
1922 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001923 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001924}
1925
Vivien Didelot17e708b2016-12-05 17:30:27 -05001926static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1927{
1928 if (chip->info->ops->reset)
1929 return chip->info->ops->reset(chip);
1930
1931 return 0;
1932}
1933
Vivien Didelot309eca62016-12-05 17:30:26 -05001934static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1935{
1936 struct gpio_desc *gpiod = chip->reset;
1937
1938 /* If there is a GPIO connected to the reset pin, toggle it */
1939 if (gpiod) {
1940 gpiod_set_value_cansleep(gpiod, 1);
1941 usleep_range(10000, 20000);
1942 gpiod_set_value_cansleep(gpiod, 0);
1943 usleep_range(10000, 20000);
1944 }
1945}
1946
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001947static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1948{
1949 int i, err;
1950
1951 /* Set all ports to the Disabled state */
1952 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001953 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001954 if (err)
1955 return err;
1956 }
1957
1958 /* Wait for transmit queues to drain,
1959 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1960 */
1961 usleep_range(2000, 4000);
1962
1963 return 0;
1964}
1965
Vivien Didelotfad09c72016-06-21 12:28:20 -04001966static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001967{
Vivien Didelota935c052016-09-29 12:21:53 -04001968 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001969
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001970 err = mv88e6xxx_disable_ports(chip);
1971 if (err)
1972 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001973
Vivien Didelot309eca62016-12-05 17:30:26 -05001974 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001975
Vivien Didelot17e708b2016-12-05 17:30:27 -05001976 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001977}
1978
Vivien Didelot43145572017-03-11 16:12:59 -05001979static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001980 enum mv88e6xxx_frame_mode frame,
1981 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001982{
1983 int err;
1984
Vivien Didelot43145572017-03-11 16:12:59 -05001985 if (!chip->info->ops->port_set_frame_mode)
1986 return -EOPNOTSUPP;
1987
1988 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001989 if (err)
1990 return err;
1991
Vivien Didelot43145572017-03-11 16:12:59 -05001992 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1993 if (err)
1994 return err;
1995
1996 if (chip->info->ops->port_set_ether_type)
1997 return chip->info->ops->port_set_ether_type(chip, port, etype);
1998
1999 return 0;
2000}
2001
2002static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2003{
2004 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002005 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002006 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002007}
2008
2009static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2010{
2011 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002012 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002013 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002014}
2015
2016static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2017{
2018 return mv88e6xxx_set_port_mode(chip, port,
2019 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002020 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2021 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002022}
2023
2024static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2025{
2026 if (dsa_is_dsa_port(chip->ds, port))
2027 return mv88e6xxx_set_port_mode_dsa(chip, port);
2028
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002029 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002030 return mv88e6xxx_set_port_mode_normal(chip, port);
2031
2032 /* Setup CPU port mode depending on its supported tag format */
2033 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2034 return mv88e6xxx_set_port_mode_dsa(chip, port);
2035
2036 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2037 return mv88e6xxx_set_port_mode_edsa(chip, port);
2038
2039 return -EINVAL;
2040}
2041
Vivien Didelotea698f42017-03-11 16:12:50 -05002042static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2043{
2044 bool message = dsa_is_dsa_port(chip->ds, port);
2045
2046 return mv88e6xxx_port_set_message_port(chip, port, message);
2047}
2048
Vivien Didelot601aeed2017-03-11 16:13:00 -05002049static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2050{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002051 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002052 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002053
David S. Miller407308f2019-06-15 13:35:29 -07002054 /* Upstream ports flood frames with unknown unicast or multicast DA */
2055 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2056 if (chip->info->ops->port_set_egress_floods)
2057 return chip->info->ops->port_set_egress_floods(chip, port,
2058 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002059
David S. Miller407308f2019-06-15 13:35:29 -07002060 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002061}
2062
Andrew Lunn6d917822017-05-26 01:03:21 +02002063static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2064 bool on)
2065{
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002066 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002067
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002068 if (!chip->info->ops->serdes_power)
2069 return 0;
2070
2071 if (on) {
2072 err = chip->info->ops->serdes_power(chip, port, true);
2073 if (err)
2074 return err;
2075
2076 if (chip->info->ops->serdes_irq_setup)
2077 err = chip->info->ops->serdes_irq_setup(chip, port);
2078 } else {
2079 if (chip->info->ops->serdes_irq_free)
2080 chip->info->ops->serdes_irq_free(chip, port);
2081
2082 err = chip->info->ops->serdes_power(chip, port, false);
2083 }
2084
2085 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002086}
2087
Vivien Didelotfa371c82017-12-05 15:34:10 -05002088static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2089{
2090 struct dsa_switch *ds = chip->ds;
2091 int upstream_port;
2092 int err;
2093
Vivien Didelot07073c72017-12-05 15:34:13 -05002094 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002095 if (chip->info->ops->port_set_upstream_port) {
2096 err = chip->info->ops->port_set_upstream_port(chip, port,
2097 upstream_port);
2098 if (err)
2099 return err;
2100 }
2101
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002102 if (port == upstream_port) {
2103 if (chip->info->ops->set_cpu_port) {
2104 err = chip->info->ops->set_cpu_port(chip,
2105 upstream_port);
2106 if (err)
2107 return err;
2108 }
2109
2110 if (chip->info->ops->set_egress_port) {
2111 err = chip->info->ops->set_egress_port(chip,
2112 upstream_port);
2113 if (err)
2114 return err;
2115 }
2116 }
2117
Vivien Didelotfa371c82017-12-05 15:34:10 -05002118 return 0;
2119}
2120
Vivien Didelotfad09c72016-06-21 12:28:20 -04002121static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002122{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002123 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002124 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002125 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002126
Andrew Lunn7b898462018-08-09 15:38:47 +02002127 chip->ports[port].chip = chip;
2128 chip->ports[port].port = port;
2129
Vivien Didelotd78343d2016-11-04 03:23:36 +01002130 /* MAC Forcing register: don't force link, speed, duplex or flow control
2131 * state to any particular values on physical ports, but force the CPU
2132 * port and all DSA ports to their maximum bandwidth and full duplex.
2133 */
2134 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2135 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2136 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002137 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002138 PHY_INTERFACE_MODE_NA);
2139 else
2140 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2141 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002142 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002143 PHY_INTERFACE_MODE_NA);
2144 if (err)
2145 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002146
2147 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2148 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2149 * tunneling, determine priority by looking at 802.1p and IP
2150 * priority fields (IP prio has precedence), and set STP state
2151 * to Forwarding.
2152 *
2153 * If this is the CPU link, use DSA or EDSA tagging depending
2154 * on which tagging mode was configured.
2155 *
2156 * If this is a link to another switch, use DSA tagging mode.
2157 *
2158 * If this is the upstream port for this switch, enable
2159 * forwarding of unknown unicasts and multicasts.
2160 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002161 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2162 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2163 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2164 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002165 if (err)
2166 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002167
Vivien Didelot601aeed2017-03-11 16:13:00 -05002168 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002169 if (err)
2170 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002171
Vivien Didelot601aeed2017-03-11 16:13:00 -05002172 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002173 if (err)
2174 return err;
2175
Vivien Didelot8efdda42015-08-13 12:52:23 -04002176 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002177 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002178 * untagged frames on this port, do a destination address lookup on all
2179 * received packets as usual, disable ARP mirroring and don't send a
2180 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002181 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002182 err = mv88e6xxx_port_set_map_da(chip, port);
2183 if (err)
2184 return err;
2185
Vivien Didelotfa371c82017-12-05 15:34:10 -05002186 err = mv88e6xxx_setup_upstream_port(chip, port);
2187 if (err)
2188 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002189
Andrew Lunna23b2962017-02-04 20:15:28 +01002190 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002191 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002192 if (err)
2193 return err;
2194
Vivien Didelotcd782652017-06-08 18:34:13 -04002195 if (chip->info->ops->port_set_jumbo_size) {
2196 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002197 if (err)
2198 return err;
2199 }
2200
Andrew Lunn54d792f2015-05-06 01:09:47 +02002201 /* Port Association Vector: when learning source addresses
2202 * of packets, add the address to the address database using
2203 * a port bitmap that has only the bit for this port set and
2204 * the other bits clear.
2205 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002206 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002207 /* Disable learning for CPU port */
2208 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002209 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002210
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002211 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2212 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002213 if (err)
2214 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002215
2216 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002217 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2218 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002219 if (err)
2220 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002221
Vivien Didelot08984322017-06-08 18:34:12 -04002222 if (chip->info->ops->port_pause_limit) {
2223 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002224 if (err)
2225 return err;
2226 }
2227
Vivien Didelotc8c94892017-03-11 16:13:01 -05002228 if (chip->info->ops->port_disable_learn_limit) {
2229 err = chip->info->ops->port_disable_learn_limit(chip, port);
2230 if (err)
2231 return err;
2232 }
2233
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002234 if (chip->info->ops->port_disable_pri_override) {
2235 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002236 if (err)
2237 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002238 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002239
Andrew Lunnef0a7312016-12-03 04:35:16 +01002240 if (chip->info->ops->port_tag_remap) {
2241 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002242 if (err)
2243 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002244 }
2245
Andrew Lunnef70b112016-12-03 04:45:18 +01002246 if (chip->info->ops->port_egress_rate_limiting) {
2247 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002248 if (err)
2249 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002250 }
2251
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002252 if (chip->info->ops->port_setup_message_port) {
2253 err = chip->info->ops->port_setup_message_port(chip, port);
2254 if (err)
2255 return err;
2256 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002257
Vivien Didelot207afda2016-04-14 14:42:09 -04002258 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002259 * database, and allow bidirectional communication between the
2260 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002261 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002262 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002263 if (err)
2264 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002265
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002266 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002267 if (err)
2268 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002269
2270 /* Default VLAN ID and priority: don't set a default VLAN
2271 * ID, and set the default packet priority to zero.
2272 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002273 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002274}
2275
Andrew Lunn04aca992017-05-26 01:03:24 +02002276static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2277 struct phy_device *phydev)
2278{
2279 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002280 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002281
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002282 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002283 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002284 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002285
2286 return err;
2287}
2288
Andrew Lunn75104db2019-02-24 20:44:43 +01002289static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002290{
2291 struct mv88e6xxx_chip *chip = ds->priv;
2292
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002293 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002294 if (mv88e6xxx_serdes_power(chip, port, false))
2295 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002296 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002297}
2298
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002299static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2300 unsigned int ageing_time)
2301{
Vivien Didelot04bed142016-08-31 18:06:13 -04002302 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002303 int err;
2304
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002305 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002306 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002307 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002308
2309 return err;
2310}
2311
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002312static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002313{
2314 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002315
Andrew Lunnde2273872016-11-21 23:27:01 +01002316 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002317 if (chip->info->ops->stats_set_histogram) {
2318 err = chip->info->ops->stats_set_histogram(chip);
2319 if (err)
2320 return err;
2321 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002322
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002323 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002324}
2325
Andrew Lunnea890982019-01-09 00:24:03 +01002326/* Check if the errata has already been applied. */
2327static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2328{
2329 int port;
2330 int err;
2331 u16 val;
2332
2333 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002334 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002335 if (err) {
2336 dev_err(chip->dev,
2337 "Error reading hidden register: %d\n", err);
2338 return false;
2339 }
2340 if (val != 0x01c0)
2341 return false;
2342 }
2343
2344 return true;
2345}
2346
2347/* The 6390 copper ports have an errata which require poking magic
2348 * values into undocumented hidden registers and then performing a
2349 * software reset.
2350 */
2351static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2352{
2353 int port;
2354 int err;
2355
2356 if (mv88e6390_setup_errata_applied(chip))
2357 return 0;
2358
2359 /* Set the ports into blocking mode */
2360 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2361 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2362 if (err)
2363 return err;
2364 }
2365
2366 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002367 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002368 if (err)
2369 return err;
2370 }
2371
2372 return mv88e6xxx_software_reset(chip);
2373}
2374
Vivien Didelotf81ec902016-05-09 13:22:58 -04002375static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002376{
Vivien Didelot04bed142016-08-31 18:06:13 -04002377 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002378 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002379 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002380 int i;
2381
Vivien Didelotfad09c72016-06-21 12:28:20 -04002382 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002383 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002384
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002385 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002386
Andrew Lunnea890982019-01-09 00:24:03 +01002387 if (chip->info->ops->setup_errata) {
2388 err = chip->info->ops->setup_errata(chip);
2389 if (err)
2390 goto unlock;
2391 }
2392
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002393 /* Cache the cmode of each port. */
2394 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2395 if (chip->info->ops->port_get_cmode) {
2396 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2397 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002398 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002399
2400 chip->ports[i].cmode = cmode;
2401 }
2402 }
2403
Vivien Didelot97299342016-07-18 20:45:30 -04002404 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002405 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002406 if (dsa_is_unused_port(ds, i))
2407 continue;
2408
Hubert Feursteinc8574862019-07-31 10:23:48 +02002409 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002410 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002411 dev_err(chip->dev, "port %d is invalid\n", i);
2412 err = -EINVAL;
2413 goto unlock;
2414 }
2415
Vivien Didelot97299342016-07-18 20:45:30 -04002416 err = mv88e6xxx_setup_port(chip, i);
2417 if (err)
2418 goto unlock;
2419 }
2420
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002421 err = mv88e6xxx_irl_setup(chip);
2422 if (err)
2423 goto unlock;
2424
Vivien Didelot04a69a12017-10-13 14:18:05 -04002425 err = mv88e6xxx_mac_setup(chip);
2426 if (err)
2427 goto unlock;
2428
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002429 err = mv88e6xxx_phy_setup(chip);
2430 if (err)
2431 goto unlock;
2432
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002433 err = mv88e6xxx_vtu_setup(chip);
2434 if (err)
2435 goto unlock;
2436
Vivien Didelot81228992017-03-30 17:37:08 -04002437 err = mv88e6xxx_pvt_setup(chip);
2438 if (err)
2439 goto unlock;
2440
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002441 err = mv88e6xxx_atu_setup(chip);
2442 if (err)
2443 goto unlock;
2444
Andrew Lunn87fa8862017-11-09 22:29:56 +01002445 err = mv88e6xxx_broadcast_setup(chip, 0);
2446 if (err)
2447 goto unlock;
2448
Vivien Didelot9e907d72017-07-17 13:03:43 -04002449 err = mv88e6xxx_pot_setup(chip);
2450 if (err)
2451 goto unlock;
2452
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002453 err = mv88e6xxx_rmu_setup(chip);
2454 if (err)
2455 goto unlock;
2456
Vivien Didelot51c901a2017-07-17 13:03:41 -04002457 err = mv88e6xxx_rsvd2cpu_setup(chip);
2458 if (err)
2459 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002460
Vivien Didelotb28f8722018-04-26 21:56:44 -04002461 err = mv88e6xxx_trunk_setup(chip);
2462 if (err)
2463 goto unlock;
2464
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002465 err = mv88e6xxx_devmap_setup(chip);
2466 if (err)
2467 goto unlock;
2468
Vivien Didelot93e18d62018-05-11 17:16:35 -04002469 err = mv88e6xxx_pri_setup(chip);
2470 if (err)
2471 goto unlock;
2472
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002473 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002474 if (chip->info->ptp_support) {
2475 err = mv88e6xxx_ptp_setup(chip);
2476 if (err)
2477 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002478
2479 err = mv88e6xxx_hwtstamp_setup(chip);
2480 if (err)
2481 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002482 }
2483
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002484 err = mv88e6xxx_stats_setup(chip);
2485 if (err)
2486 goto unlock;
2487
Vivien Didelot6b17e862015-08-13 12:52:18 -04002488unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002489 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002490
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002491 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002492}
2493
Vivien Didelote57e5e72016-08-15 17:19:00 -04002494static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002495{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002496 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2497 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002498 u16 val;
2499 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002500
Andrew Lunnee26a222017-01-24 14:53:48 +01002501 if (!chip->info->ops->phy_read)
2502 return -EOPNOTSUPP;
2503
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002504 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002505 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002506 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002507
Andrew Lunnda9f3302017-02-01 03:40:05 +01002508 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002509 /* Some internal PHYs don't have a model number. */
2510 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2511 /* Then there is the 6165 family. It gets is
2512 * PHYs correct. But it can also have two
2513 * SERDES interfaces in the PHY address
2514 * space. And these don't have a model
2515 * number. But they are not PHYs, so we don't
2516 * want to give them something a PHY driver
2517 * will recognise.
2518 *
2519 * Use the mv88e6390 family model number
2520 * instead, for anything which really could be
2521 * a PHY,
2522 */
2523 if (!(val & 0x3f0))
2524 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002525 }
2526
Vivien Didelote57e5e72016-08-15 17:19:00 -04002527 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002528}
2529
Vivien Didelote57e5e72016-08-15 17:19:00 -04002530static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002531{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002532 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2533 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002534 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002535
Andrew Lunnee26a222017-01-24 14:53:48 +01002536 if (!chip->info->ops->phy_write)
2537 return -EOPNOTSUPP;
2538
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002539 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002540 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002541 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002542
2543 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002544}
2545
Vivien Didelotfad09c72016-06-21 12:28:20 -04002546static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002547 struct device_node *np,
2548 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002549{
2550 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002551 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002552 struct mii_bus *bus;
2553 int err;
2554
Andrew Lunn2510bab2018-02-22 01:51:49 +01002555 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002556 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002557 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002558 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002559
2560 if (err)
2561 return err;
2562 }
2563
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002564 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002565 if (!bus)
2566 return -ENOMEM;
2567
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002568 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002569 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002570 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002571 INIT_LIST_HEAD(&mdio_bus->list);
2572 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002573
Andrew Lunnb516d452016-06-04 21:17:06 +02002574 if (np) {
2575 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002576 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002577 } else {
2578 bus->name = "mv88e6xxx SMI";
2579 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2580 }
2581
2582 bus->read = mv88e6xxx_mdio_read;
2583 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002584 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002585
Andrew Lunn6f882842018-03-17 20:32:05 +01002586 if (!external) {
2587 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2588 if (err)
2589 return err;
2590 }
2591
Florian Fainelli00e798c2018-05-15 16:56:19 -07002592 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002593 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002594 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002595 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002596 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002597 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002598
2599 if (external)
2600 list_add_tail(&mdio_bus->list, &chip->mdios);
2601 else
2602 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002603
2604 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002605}
2606
Andrew Lunna3c53be52017-01-24 14:53:50 +01002607static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2608 { .compatible = "marvell,mv88e6xxx-mdio-external",
2609 .data = (void *)true },
2610 { },
2611};
2612
Andrew Lunn3126aee2017-12-07 01:05:57 +01002613static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2614
2615{
2616 struct mv88e6xxx_mdio_bus *mdio_bus;
2617 struct mii_bus *bus;
2618
2619 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2620 bus = mdio_bus->bus;
2621
Andrew Lunn6f882842018-03-17 20:32:05 +01002622 if (!mdio_bus->external)
2623 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2624
Andrew Lunn3126aee2017-12-07 01:05:57 +01002625 mdiobus_unregister(bus);
2626 }
2627}
2628
Andrew Lunna3c53be52017-01-24 14:53:50 +01002629static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2630 struct device_node *np)
2631{
2632 const struct of_device_id *match;
2633 struct device_node *child;
2634 int err;
2635
2636 /* Always register one mdio bus for the internal/default mdio
2637 * bus. This maybe represented in the device tree, but is
2638 * optional.
2639 */
2640 child = of_get_child_by_name(np, "mdio");
2641 err = mv88e6xxx_mdio_register(chip, child, false);
2642 if (err)
2643 return err;
2644
2645 /* Walk the device tree, and see if there are any other nodes
2646 * which say they are compatible with the external mdio
2647 * bus.
2648 */
2649 for_each_available_child_of_node(np, child) {
2650 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2651 if (match) {
2652 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002653 if (err) {
2654 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05302655 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002656 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002657 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002658 }
2659 }
2660
2661 return 0;
2662}
2663
Vivien Didelot855b1932016-07-20 18:18:35 -04002664static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2665{
Vivien Didelot04bed142016-08-31 18:06:13 -04002666 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002667
2668 return chip->eeprom_len;
2669}
2670
Vivien Didelot855b1932016-07-20 18:18:35 -04002671static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2672 struct ethtool_eeprom *eeprom, u8 *data)
2673{
Vivien Didelot04bed142016-08-31 18:06:13 -04002674 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002675 int err;
2676
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002677 if (!chip->info->ops->get_eeprom)
2678 return -EOPNOTSUPP;
2679
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002680 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002681 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002682 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002683
2684 if (err)
2685 return err;
2686
2687 eeprom->magic = 0xc3ec4951;
2688
2689 return 0;
2690}
2691
Vivien Didelot855b1932016-07-20 18:18:35 -04002692static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2693 struct ethtool_eeprom *eeprom, u8 *data)
2694{
Vivien Didelot04bed142016-08-31 18:06:13 -04002695 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002696 int err;
2697
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002698 if (!chip->info->ops->set_eeprom)
2699 return -EOPNOTSUPP;
2700
Vivien Didelot855b1932016-07-20 18:18:35 -04002701 if (eeprom->magic != 0xc3ec4951)
2702 return -EINVAL;
2703
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002704 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002705 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002706 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002707
2708 return err;
2709}
2710
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002711static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002712 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002713 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2714 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002715 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002716 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002717 .phy_read = mv88e6185_phy_ppu_read,
2718 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002719 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002720 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002721 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002722 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002723 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002724 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002725 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002726 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002727 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002728 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002729 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002730 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002731 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002732 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002733 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002734 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002735 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2736 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002737 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002738 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2739 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002740 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002741 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002742 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002743 .ppu_enable = mv88e6185_g1_ppu_enable,
2744 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002745 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002746 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002747 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002748 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002749 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002750};
2751
2752static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002753 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002754 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2755 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002756 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002757 .phy_read = mv88e6185_phy_ppu_read,
2758 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002759 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002760 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002761 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002762 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002763 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002764 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002765 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002766 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002767 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002768 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002769 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002770 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2771 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002772 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002773 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002774 .ppu_enable = mv88e6185_g1_ppu_enable,
2775 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002776 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002777 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002778 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002779 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002780};
2781
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002782static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002783 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002784 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2785 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002786 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002787 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2788 .phy_read = mv88e6xxx_g2_smi_phy_read,
2789 .phy_write = mv88e6xxx_g2_smi_phy_write,
2790 .port_set_link = mv88e6xxx_port_set_link,
2791 .port_set_duplex = mv88e6xxx_port_set_duplex,
2792 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002793 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002794 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002795 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002796 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002797 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002798 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002799 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002800 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002801 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002802 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002803 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002804 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002805 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002806 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002807 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2808 .stats_get_strings = mv88e6095_stats_get_strings,
2809 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002810 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2811 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002812 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002813 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002814 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002815 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002816 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002817 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002818 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002819 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002820};
2821
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002822static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002823 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002824 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2825 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002826 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002827 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002828 .phy_read = mv88e6xxx_g2_smi_phy_read,
2829 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002830 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002831 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002832 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002833 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002834 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002835 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002836 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002837 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002838 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002839 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002840 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002841 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002842 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2843 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002844 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002845 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2846 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002847 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002848 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002849 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002850 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002851 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002852 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002853 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002854};
2855
2856static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002857 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002858 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2859 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002860 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002861 .phy_read = mv88e6185_phy_ppu_read,
2862 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002863 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002864 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002865 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002866 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002867 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002868 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002869 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002870 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002871 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002872 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002873 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002874 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002875 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002876 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002877 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002878 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002879 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002880 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2881 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002882 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002883 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2884 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002885 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002886 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002887 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002888 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002889 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002890 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002891 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002892 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002893 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002894};
2895
Vivien Didelot990e27b2017-03-28 13:50:32 -04002896static const struct mv88e6xxx_ops mv88e6141_ops = {
2897 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002898 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2899 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002900 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002901 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2902 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2903 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2904 .phy_read = mv88e6xxx_g2_smi_phy_read,
2905 .phy_write = mv88e6xxx_g2_smi_phy_write,
2906 .port_set_link = mv88e6xxx_port_set_link,
2907 .port_set_duplex = mv88e6xxx_port_set_duplex,
2908 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002909 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002910 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002911 .port_tag_remap = mv88e6095_port_tag_remap,
2912 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2913 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2914 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002915 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002916 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002917 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002918 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2919 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002920 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002921 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02002922 .port_set_cmode_writable = mv88e6341_port_set_cmode_writable,
2923 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002924 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002925 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002926 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002927 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2928 .stats_get_strings = mv88e6320_stats_get_strings,
2929 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002930 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2931 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002932 .watchdog_ops = &mv88e6390_watchdog_ops,
2933 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002934 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002935 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002936 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002937 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02002938 .serdes_power = mv88e6390_serdes_power,
2939 .serdes_get_lane = mv88e6341_serdes_get_lane,
Marek Behún7a3007d2019-08-26 23:31:55 +02002940 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
2941 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002942 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01002943 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002944};
2945
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002946static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002947 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002948 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2949 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002950 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002951 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002952 .phy_read = mv88e6xxx_g2_smi_phy_read,
2953 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002954 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002955 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002956 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002957 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002958 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002959 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002960 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002961 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002962 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002963 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002964 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002965 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002966 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002967 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002968 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01002969 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002970 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002971 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2972 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002973 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002974 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2975 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002976 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002977 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002978 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002979 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002980 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002981 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002982 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002983 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002984 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002985};
2986
2987static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002988 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002989 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2990 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002991 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002992 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002993 .phy_read = mv88e6165_phy_read,
2994 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002995 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002996 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002997 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002998 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002999 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003000 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003001 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003002 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003003 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003004 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003005 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3006 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003007 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003008 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3009 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003010 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003011 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003012 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003013 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003014 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003015 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003016 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003017 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003018 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003019};
3020
3021static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003022 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003023 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3024 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003025 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003026 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003027 .phy_read = mv88e6xxx_g2_smi_phy_read,
3028 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003029 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003030 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003031 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003032 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003033 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003034 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003035 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003036 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003037 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003038 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003039 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003040 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003041 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003042 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003043 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003044 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003045 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003046 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003047 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3048 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003049 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003050 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3051 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003052 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003053 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003054 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003055 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003056 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003057 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003058 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003059};
3060
3061static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003062 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003063 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3064 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003065 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003066 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3067 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003068 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003069 .phy_read = mv88e6xxx_g2_smi_phy_read,
3070 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003071 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003072 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003073 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003074 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003075 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003076 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003077 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003078 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003079 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003080 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003081 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003082 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003083 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003084 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003085 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003086 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003087 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003088 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003089 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3090 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003091 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003092 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3093 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003094 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003095 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003096 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003097 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003098 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003099 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003100 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003101 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003102 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003103 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003104};
3105
3106static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003107 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003108 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3109 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003110 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003111 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003112 .phy_read = mv88e6xxx_g2_smi_phy_read,
3113 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003114 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003115 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003116 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003117 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003118 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003119 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003120 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003121 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003122 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003123 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003124 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003125 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003126 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003127 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003128 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003129 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003130 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003131 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003132 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3133 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003134 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003135 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3136 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003137 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003138 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003139 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003140 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003141 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003142 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003143 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003144};
3145
3146static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003147 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003148 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3149 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003150 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003151 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3152 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003153 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003154 .phy_read = mv88e6xxx_g2_smi_phy_read,
3155 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003156 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003157 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003158 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003159 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003160 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003161 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003162 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003163 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003164 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003165 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003166 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003167 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003168 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003169 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003170 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003171 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003172 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003173 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003174 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3175 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003176 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003177 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3178 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003179 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003180 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003181 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003182 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003183 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003184 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003185 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003186 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003187 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3188 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003189 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003190 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003191};
3192
3193static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003194 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003195 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3196 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003197 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003198 .phy_read = mv88e6185_phy_ppu_read,
3199 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003200 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003201 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003202 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003203 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003204 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003205 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003206 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003207 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003208 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003209 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003210 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003211 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003212 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003213 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3214 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003215 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003216 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3217 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003218 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003219 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003220 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003221 .ppu_enable = mv88e6185_g1_ppu_enable,
3222 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003223 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003224 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003225 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003226 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003227};
3228
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003229static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003230 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003231 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003232 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003233 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3234 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003235 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3236 .phy_read = mv88e6xxx_g2_smi_phy_read,
3237 .phy_write = mv88e6xxx_g2_smi_phy_write,
3238 .port_set_link = mv88e6xxx_port_set_link,
3239 .port_set_duplex = mv88e6xxx_port_set_duplex,
3240 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3241 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003242 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003243 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003244 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003245 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003246 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003247 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003248 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003249 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003250 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003251 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003252 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003253 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003254 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003255 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003256 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3257 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003258 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003259 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3260 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003261 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003262 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003263 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003264 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003265 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003266 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3267 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003268 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003269 .serdes_get_lane = mv88e6390_serdes_get_lane,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003270 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3271 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003272 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003273 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003274};
3275
3276static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003277 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003278 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003279 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003280 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3281 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003282 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3283 .phy_read = mv88e6xxx_g2_smi_phy_read,
3284 .phy_write = mv88e6xxx_g2_smi_phy_write,
3285 .port_set_link = mv88e6xxx_port_set_link,
3286 .port_set_duplex = mv88e6xxx_port_set_duplex,
3287 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3288 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003289 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003290 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003291 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003292 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003293 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003294 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003295 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003296 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003297 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003298 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003299 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003300 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003301 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003302 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003303 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3304 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003305 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003306 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3307 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003308 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003309 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003310 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003311 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003312 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003313 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3314 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003315 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003316 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003317 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3318 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003319 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003320 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003321};
3322
3323static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003324 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003325 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003326 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003327 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3328 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003329 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3330 .phy_read = mv88e6xxx_g2_smi_phy_read,
3331 .phy_write = mv88e6xxx_g2_smi_phy_write,
3332 .port_set_link = mv88e6xxx_port_set_link,
3333 .port_set_duplex = mv88e6xxx_port_set_duplex,
3334 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3335 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003336 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003337 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003338 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003339 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003340 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003341 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003342 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003343 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003344 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003345 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003346 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003347 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003348 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003349 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003350 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3351 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003352 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003353 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3354 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003355 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003356 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003357 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003358 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003359 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003360 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3361 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003362 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003363 .serdes_get_lane = mv88e6390_serdes_get_lane,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003364 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3365 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003366 .avb_ops = &mv88e6390_avb_ops,
3367 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003368 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003369};
3370
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003371static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003372 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003373 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3374 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003375 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003376 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3377 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003378 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003379 .phy_read = mv88e6xxx_g2_smi_phy_read,
3380 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003381 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003382 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003383 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003384 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003385 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003386 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003387 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003388 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003389 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003390 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003391 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003392 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003393 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003394 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003395 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003396 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003397 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003398 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003399 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3400 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003401 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003402 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3403 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003404 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003405 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003406 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003407 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003408 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003409 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003410 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003411 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003412 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3413 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003414 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003415 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003416 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003417 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003418};
3419
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003420static const struct mv88e6xxx_ops mv88e6250_ops = {
3421 /* MV88E6XXX_FAMILY_6250 */
3422 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3423 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3424 .irl_init_all = mv88e6352_g2_irl_init_all,
3425 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3426 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3427 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3428 .phy_read = mv88e6xxx_g2_smi_phy_read,
3429 .phy_write = mv88e6xxx_g2_smi_phy_write,
3430 .port_set_link = mv88e6xxx_port_set_link,
3431 .port_set_duplex = mv88e6xxx_port_set_duplex,
3432 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3433 .port_set_speed = mv88e6250_port_set_speed,
3434 .port_tag_remap = mv88e6095_port_tag_remap,
3435 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3436 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3437 .port_set_ether_type = mv88e6351_port_set_ether_type,
3438 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3439 .port_pause_limit = mv88e6097_port_pause_limit,
3440 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3441 .port_link_state = mv88e6250_port_link_state,
3442 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3443 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3444 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3445 .stats_get_strings = mv88e6250_stats_get_strings,
3446 .stats_get_stats = mv88e6250_stats_get_stats,
3447 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3448 .set_egress_port = mv88e6095_g1_set_egress_port,
3449 .watchdog_ops = &mv88e6250_watchdog_ops,
3450 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3451 .pot_clear = mv88e6xxx_g2_pot_clear,
3452 .reset = mv88e6250_g1_reset,
3453 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3454 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02003455 .avb_ops = &mv88e6352_avb_ops,
3456 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003457 .phylink_validate = mv88e6065_phylink_validate,
3458};
3459
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003460static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003461 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003462 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003463 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003464 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3465 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003466 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3467 .phy_read = mv88e6xxx_g2_smi_phy_read,
3468 .phy_write = mv88e6xxx_g2_smi_phy_write,
3469 .port_set_link = mv88e6xxx_port_set_link,
3470 .port_set_duplex = mv88e6xxx_port_set_duplex,
3471 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3472 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003473 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003474 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003475 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003476 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003477 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003478 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003479 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003480 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003481 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003482 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003483 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003484 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003485 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003486 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003487 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3488 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003489 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003490 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3491 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003492 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003493 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003494 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003495 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003496 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003497 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3498 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003499 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003500 .serdes_get_lane = mv88e6390_serdes_get_lane,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003501 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3502 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003503 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003504 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003505 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003506 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003507};
3508
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003509static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003510 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003511 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3512 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003513 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003514 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3515 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003516 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003517 .phy_read = mv88e6xxx_g2_smi_phy_read,
3518 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003519 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003520 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003521 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003522 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003523 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003524 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003525 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003526 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003527 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003528 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003529 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003530 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003531 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003532 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003533 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003534 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003535 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003536 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3537 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003538 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003539 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3540 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003541 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003542 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003543 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003544 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003545 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003546 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003547 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003548 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003549 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003550 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003551};
3552
3553static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003554 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003555 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3556 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003557 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003558 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3559 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003560 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003561 .phy_read = mv88e6xxx_g2_smi_phy_read,
3562 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003563 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003564 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003565 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003566 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003567 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003568 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003569 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003570 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003571 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003572 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003573 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003574 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003575 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003576 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003577 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003578 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003579 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003580 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3581 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003582 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003583 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3584 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003585 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003586 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003587 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003588 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003589 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003590 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003591 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003592 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003593};
3594
Vivien Didelot16e329a2017-03-28 13:50:33 -04003595static const struct mv88e6xxx_ops mv88e6341_ops = {
3596 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003597 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3598 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003599 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003600 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3601 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3602 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3603 .phy_read = mv88e6xxx_g2_smi_phy_read,
3604 .phy_write = mv88e6xxx_g2_smi_phy_write,
3605 .port_set_link = mv88e6xxx_port_set_link,
3606 .port_set_duplex = mv88e6xxx_port_set_duplex,
3607 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003608 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003609 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003610 .port_tag_remap = mv88e6095_port_tag_remap,
3611 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3612 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3613 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003614 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003615 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003616 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003617 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3618 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003619 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003620 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003621 .port_set_cmode_writable = mv88e6341_port_set_cmode_writable,
3622 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003623 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003624 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003625 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003626 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3627 .stats_get_strings = mv88e6320_stats_get_strings,
3628 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003629 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3630 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003631 .watchdog_ops = &mv88e6390_watchdog_ops,
3632 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003633 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003634 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003635 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003636 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003637 .serdes_power = mv88e6390_serdes_power,
3638 .serdes_get_lane = mv88e6341_serdes_get_lane,
Marek Behún7a3007d2019-08-26 23:31:55 +02003639 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3640 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003641 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003642 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003643 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003644 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003645};
3646
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003647static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003648 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003649 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3650 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003651 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003652 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003653 .phy_read = mv88e6xxx_g2_smi_phy_read,
3654 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003655 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003656 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003657 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003658 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003659 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003660 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003661 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003662 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003663 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003664 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003665 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003666 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003667 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003668 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003669 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003670 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003671 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003672 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003673 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3674 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003675 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003676 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3677 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003678 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003679 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003680 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003681 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003682 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003683 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003684 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003685};
3686
3687static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003688 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003689 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3690 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003691 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003692 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003693 .phy_read = mv88e6xxx_g2_smi_phy_read,
3694 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003695 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003696 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003697 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003698 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003699 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003700 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003701 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003702 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003703 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003704 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003705 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003706 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003707 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003708 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003709 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003710 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003711 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003712 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003713 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3714 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003715 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003716 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3717 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003718 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003719 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003720 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003721 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003722 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003723 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003724 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003725 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003726 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003727};
3728
3729static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003730 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003731 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3732 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003733 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003734 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3735 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003736 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003737 .phy_read = mv88e6xxx_g2_smi_phy_read,
3738 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003739 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003740 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003741 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003742 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003743 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003744 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003745 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003746 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003747 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003748 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003749 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003750 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003751 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003752 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003753 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003754 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003755 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003756 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003757 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3758 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003759 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003760 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3761 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003762 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003763 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003764 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003765 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003766 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003767 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003768 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003769 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003770 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3771 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003772 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003773 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003774 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003775 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3776 .serdes_get_strings = mv88e6352_serdes_get_strings,
3777 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003778 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003779};
3780
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003781static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003782 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003783 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003784 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003785 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3786 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003787 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3788 .phy_read = mv88e6xxx_g2_smi_phy_read,
3789 .phy_write = mv88e6xxx_g2_smi_phy_write,
3790 .port_set_link = mv88e6xxx_port_set_link,
3791 .port_set_duplex = mv88e6xxx_port_set_duplex,
3792 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3793 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003794 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003795 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003796 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003797 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003798 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003799 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003800 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003801 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003802 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003803 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003804 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003805 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003806 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003807 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003808 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003809 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003810 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3811 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003812 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003813 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3814 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003815 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003816 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003818 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003819 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003820 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3821 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003822 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003823 .serdes_get_lane = mv88e6390_serdes_get_lane,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003824 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3825 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003826 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003827 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003828 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003829 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003830};
3831
3832static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003833 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003834 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003835 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003836 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3837 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003838 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3839 .phy_read = mv88e6xxx_g2_smi_phy_read,
3840 .phy_write = mv88e6xxx_g2_smi_phy_write,
3841 .port_set_link = mv88e6xxx_port_set_link,
3842 .port_set_duplex = mv88e6xxx_port_set_duplex,
3843 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3844 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003845 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003846 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003847 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003848 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003849 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003850 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003851 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003852 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003853 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003854 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003855 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003856 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003857 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003858 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003859 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003860 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003861 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3862 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003863 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003864 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3865 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003866 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003867 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003868 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003869 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003870 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003871 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3872 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003873 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003874 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003875 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3876 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003877 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003878 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003879 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003880 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003881};
3882
Vivien Didelotf81ec902016-05-09 13:22:58 -04003883static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3884 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003885 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003886 .family = MV88E6XXX_FAMILY_6097,
3887 .name = "Marvell 88E6085",
3888 .num_databases = 4096,
3889 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003890 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003891 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003892 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003893 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003894 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003895 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003896 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003897 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003898 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003899 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003900 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003901 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003902 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003903 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003904 },
3905
3906 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003907 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003908 .family = MV88E6XXX_FAMILY_6095,
3909 .name = "Marvell 88E6095/88E6095F",
3910 .num_databases = 256,
3911 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003912 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003913 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003914 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003915 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003916 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003917 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003918 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003919 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003920 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003921 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003922 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003923 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003924 },
3925
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003926 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003927 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003928 .family = MV88E6XXX_FAMILY_6097,
3929 .name = "Marvell 88E6097/88E6097F",
3930 .num_databases = 4096,
3931 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003932 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003933 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003934 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003935 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003936 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003937 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003938 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003939 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003940 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003941 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003942 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003943 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003944 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003945 .ops = &mv88e6097_ops,
3946 },
3947
Vivien Didelotf81ec902016-05-09 13:22:58 -04003948 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003949 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003950 .family = MV88E6XXX_FAMILY_6165,
3951 .name = "Marvell 88E6123",
3952 .num_databases = 4096,
3953 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003954 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003955 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003956 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003957 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003958 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003959 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003960 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003961 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003962 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003963 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003964 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003965 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003966 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003967 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003968 },
3969
3970 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003971 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003972 .family = MV88E6XXX_FAMILY_6185,
3973 .name = "Marvell 88E6131",
3974 .num_databases = 256,
3975 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003976 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003977 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003978 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003979 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003980 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003981 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003982 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003983 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003984 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003985 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003986 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003987 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003988 },
3989
Vivien Didelot990e27b2017-03-28 13:50:32 -04003990 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003991 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003992 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003993 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003994 .num_databases = 4096,
3995 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003996 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003997 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003998 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003999 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004000 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004001 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004002 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004003 .age_time_coeff = 3750,
4004 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004005 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004006 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004007 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004008 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004009 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004010 .ops = &mv88e6141_ops,
4011 },
4012
Vivien Didelotf81ec902016-05-09 13:22:58 -04004013 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004014 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004015 .family = MV88E6XXX_FAMILY_6165,
4016 .name = "Marvell 88E6161",
4017 .num_databases = 4096,
4018 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004019 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004020 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004021 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004022 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004023 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004024 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004025 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004026 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004027 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004028 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004029 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004030 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004031 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004032 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004033 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004034 },
4035
4036 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004037 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004038 .family = MV88E6XXX_FAMILY_6165,
4039 .name = "Marvell 88E6165",
4040 .num_databases = 4096,
4041 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004042 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004043 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004044 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004045 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004046 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004047 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004048 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004049 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004050 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004051 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004052 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004053 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004054 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004055 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004056 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004057 },
4058
4059 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004060 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004061 .family = MV88E6XXX_FAMILY_6351,
4062 .name = "Marvell 88E6171",
4063 .num_databases = 4096,
4064 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004065 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004066 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004067 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004068 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004069 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004070 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004071 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004072 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004073 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004074 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004075 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004076 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004077 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004078 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004079 },
4080
4081 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004082 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004083 .family = MV88E6XXX_FAMILY_6352,
4084 .name = "Marvell 88E6172",
4085 .num_databases = 4096,
4086 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004087 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004088 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004089 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004090 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004091 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004092 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004093 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004094 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004095 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004096 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004097 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004098 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004099 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004100 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004101 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004102 },
4103
4104 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004105 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004106 .family = MV88E6XXX_FAMILY_6351,
4107 .name = "Marvell 88E6175",
4108 .num_databases = 4096,
4109 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004110 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004111 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004112 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004113 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004114 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004115 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004116 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004117 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004118 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004119 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004120 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004121 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004122 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004123 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004124 },
4125
4126 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004127 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004128 .family = MV88E6XXX_FAMILY_6352,
4129 .name = "Marvell 88E6176",
4130 .num_databases = 4096,
4131 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004132 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004133 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004134 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004135 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004136 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004137 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004138 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004139 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004140 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004141 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004142 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004143 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004144 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004145 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004146 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004147 },
4148
4149 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004150 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004151 .family = MV88E6XXX_FAMILY_6185,
4152 .name = "Marvell 88E6185",
4153 .num_databases = 256,
4154 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004155 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004156 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004157 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004158 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004159 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004160 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004161 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004162 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004163 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004164 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004165 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004166 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004167 },
4168
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004169 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004170 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004171 .family = MV88E6XXX_FAMILY_6390,
4172 .name = "Marvell 88E6190",
4173 .num_databases = 4096,
4174 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004175 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004176 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004177 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004178 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004179 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004180 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004181 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004182 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004183 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004184 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004185 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004186 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004187 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004188 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004189 .ops = &mv88e6190_ops,
4190 },
4191
4192 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004193 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004194 .family = MV88E6XXX_FAMILY_6390,
4195 .name = "Marvell 88E6190X",
4196 .num_databases = 4096,
4197 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004198 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004199 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004200 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004201 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004202 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004203 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004204 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004205 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004206 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004207 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004208 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004209 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004210 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004211 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004212 .ops = &mv88e6190x_ops,
4213 },
4214
4215 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004216 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004217 .family = MV88E6XXX_FAMILY_6390,
4218 .name = "Marvell 88E6191",
4219 .num_databases = 4096,
4220 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004221 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004222 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004223 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004224 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004225 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004226 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004227 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004228 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004229 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004230 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004231 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004232 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004233 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004234 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004235 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004236 },
4237
Hubert Feurstein49022642019-07-31 10:23:46 +02004238 [MV88E6220] = {
4239 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4240 .family = MV88E6XXX_FAMILY_6250,
4241 .name = "Marvell 88E6220",
4242 .num_databases = 64,
4243
4244 /* Ports 2-4 are not routed to pins
4245 * => usable ports 0, 1, 5, 6
4246 */
4247 .num_ports = 7,
4248 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004249 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004250 .max_vid = 4095,
4251 .port_base_addr = 0x08,
4252 .phy_base_addr = 0x00,
4253 .global1_addr = 0x0f,
4254 .global2_addr = 0x07,
4255 .age_time_coeff = 15000,
4256 .g1_irqs = 9,
4257 .g2_irqs = 10,
4258 .atu_move_port_mask = 0xf,
4259 .dual_chip = true,
4260 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004261 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004262 .ops = &mv88e6250_ops,
4263 },
4264
Vivien Didelotf81ec902016-05-09 13:22:58 -04004265 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004266 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004267 .family = MV88E6XXX_FAMILY_6352,
4268 .name = "Marvell 88E6240",
4269 .num_databases = 4096,
4270 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004271 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004272 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004273 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004274 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004275 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004276 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004277 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004278 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004279 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004280 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004281 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004282 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004283 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004284 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004285 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004286 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004287 },
4288
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004289 [MV88E6250] = {
4290 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4291 .family = MV88E6XXX_FAMILY_6250,
4292 .name = "Marvell 88E6250",
4293 .num_databases = 64,
4294 .num_ports = 7,
4295 .num_internal_phys = 5,
4296 .max_vid = 4095,
4297 .port_base_addr = 0x08,
4298 .phy_base_addr = 0x00,
4299 .global1_addr = 0x0f,
4300 .global2_addr = 0x07,
4301 .age_time_coeff = 15000,
4302 .g1_irqs = 9,
4303 .g2_irqs = 10,
4304 .atu_move_port_mask = 0xf,
4305 .dual_chip = true,
4306 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004307 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004308 .ops = &mv88e6250_ops,
4309 },
4310
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004311 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004312 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004313 .family = MV88E6XXX_FAMILY_6390,
4314 .name = "Marvell 88E6290",
4315 .num_databases = 4096,
4316 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004317 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004318 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004319 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004320 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004321 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004322 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004323 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004324 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004325 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004326 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004327 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004328 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004329 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004330 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004331 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004332 .ops = &mv88e6290_ops,
4333 },
4334
Vivien Didelotf81ec902016-05-09 13:22:58 -04004335 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004336 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004337 .family = MV88E6XXX_FAMILY_6320,
4338 .name = "Marvell 88E6320",
4339 .num_databases = 4096,
4340 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004341 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004342 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004343 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004344 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004345 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004346 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004347 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004348 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004349 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004350 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004351 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004352 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004353 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004354 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004355 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004356 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004357 },
4358
4359 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004360 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004361 .family = MV88E6XXX_FAMILY_6320,
4362 .name = "Marvell 88E6321",
4363 .num_databases = 4096,
4364 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004365 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004366 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004367 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004368 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004369 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004370 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004371 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004372 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004373 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004374 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004375 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004376 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004377 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004378 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004379 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004380 },
4381
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004382 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004383 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004384 .family = MV88E6XXX_FAMILY_6341,
4385 .name = "Marvell 88E6341",
4386 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004387 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004388 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004389 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004390 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004391 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004392 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004393 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004394 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004395 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004396 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004397 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004398 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004399 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004400 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004401 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004402 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004403 .ops = &mv88e6341_ops,
4404 },
4405
Vivien Didelotf81ec902016-05-09 13:22:58 -04004406 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004407 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004408 .family = MV88E6XXX_FAMILY_6351,
4409 .name = "Marvell 88E6350",
4410 .num_databases = 4096,
4411 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004412 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004413 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004414 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004415 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004416 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004417 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004418 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004419 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004420 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004421 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004422 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004423 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004424 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004425 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004426 },
4427
4428 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004429 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004430 .family = MV88E6XXX_FAMILY_6351,
4431 .name = "Marvell 88E6351",
4432 .num_databases = 4096,
4433 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004434 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004435 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004436 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004437 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004438 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004439 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004440 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004441 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004442 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004443 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004444 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004445 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004446 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004447 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004448 },
4449
4450 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004451 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004452 .family = MV88E6XXX_FAMILY_6352,
4453 .name = "Marvell 88E6352",
4454 .num_databases = 4096,
4455 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004456 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004457 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004458 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004459 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004460 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004461 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004462 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004463 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004464 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004465 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004466 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004467 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004468 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004469 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004470 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004471 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004472 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004473 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004474 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004475 .family = MV88E6XXX_FAMILY_6390,
4476 .name = "Marvell 88E6390",
4477 .num_databases = 4096,
4478 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004479 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004480 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004481 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004482 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004483 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004484 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004485 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004486 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004487 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004488 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004489 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004490 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004491 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004492 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004493 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004494 .ops = &mv88e6390_ops,
4495 },
4496 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004497 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004498 .family = MV88E6XXX_FAMILY_6390,
4499 .name = "Marvell 88E6390X",
4500 .num_databases = 4096,
4501 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004502 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004503 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004504 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004505 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004506 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004507 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004508 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004509 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004510 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004511 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004512 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004513 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004514 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004515 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004516 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004517 .ops = &mv88e6390x_ops,
4518 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004519};
4520
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004521static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004522{
Vivien Didelota439c062016-04-17 13:23:58 -04004523 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004524
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004525 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4526 if (mv88e6xxx_table[i].prod_num == prod_num)
4527 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004528
Vivien Didelotb9b37712015-10-30 19:39:48 -04004529 return NULL;
4530}
4531
Vivien Didelotfad09c72016-06-21 12:28:20 -04004532static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004533{
4534 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004535 unsigned int prod_num, rev;
4536 u16 id;
4537 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004538
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004539 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004540 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004541 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004542 if (err)
4543 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004544
Vivien Didelot107fcc12017-06-12 12:37:36 -04004545 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4546 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004547
4548 info = mv88e6xxx_lookup_info(prod_num);
4549 if (!info)
4550 return -ENODEV;
4551
Vivien Didelotcaac8542016-06-20 13:14:09 -04004552 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004553 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004554
Vivien Didelotca070c12016-09-02 14:45:34 -04004555 err = mv88e6xxx_g2_require(chip);
4556 if (err)
4557 return err;
4558
Vivien Didelotfad09c72016-06-21 12:28:20 -04004559 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4560 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004561
4562 return 0;
4563}
4564
Vivien Didelotfad09c72016-06-21 12:28:20 -04004565static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004566{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004567 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004568
Vivien Didelotfad09c72016-06-21 12:28:20 -04004569 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4570 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004571 return NULL;
4572
Vivien Didelotfad09c72016-06-21 12:28:20 -04004573 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004574
Vivien Didelotfad09c72016-06-21 12:28:20 -04004575 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004576 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004577
Vivien Didelotfad09c72016-06-21 12:28:20 -04004578 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004579}
4580
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004581static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4582 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004583{
Vivien Didelot04bed142016-08-31 18:06:13 -04004584 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004585
Andrew Lunn443d5a12016-12-03 04:35:18 +01004586 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004587}
4588
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004589static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004590 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004591{
4592 /* We don't need any dynamic resource from the kernel (yet),
4593 * so skip the prepare phase.
4594 */
4595
4596 return 0;
4597}
4598
4599static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004600 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004601{
Vivien Didelot04bed142016-08-31 18:06:13 -04004602 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004603
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004604 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004605 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004606 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004607 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4608 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004609 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004610}
4611
4612static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4613 const struct switchdev_obj_port_mdb *mdb)
4614{
Vivien Didelot04bed142016-08-31 18:06:13 -04004615 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004616 int err;
4617
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004618 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004619 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004620 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004621 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004622
4623 return err;
4624}
4625
Russell King4f859012019-02-20 15:35:05 -08004626static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4627 bool unicast, bool multicast)
4628{
4629 struct mv88e6xxx_chip *chip = ds->priv;
4630 int err = -EOPNOTSUPP;
4631
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004632 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08004633 if (chip->info->ops->port_set_egress_floods)
4634 err = chip->info->ops->port_set_egress_floods(chip, port,
4635 unicast,
4636 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004637 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08004638
4639 return err;
4640}
4641
Florian Fainellia82f67a2017-01-08 14:52:08 -08004642static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004643 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004644 .setup = mv88e6xxx_setup,
Russell Kingc9a23562018-05-10 13:17:35 -07004645 .phylink_validate = mv88e6xxx_validate,
4646 .phylink_mac_link_state = mv88e6xxx_link_state,
4647 .phylink_mac_config = mv88e6xxx_mac_config,
4648 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4649 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004650 .get_strings = mv88e6xxx_get_strings,
4651 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4652 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004653 .port_enable = mv88e6xxx_port_enable,
4654 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004655 .get_mac_eee = mv88e6xxx_get_mac_eee,
4656 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004657 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004658 .get_eeprom = mv88e6xxx_get_eeprom,
4659 .set_eeprom = mv88e6xxx_set_eeprom,
4660 .get_regs_len = mv88e6xxx_get_regs_len,
4661 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004662 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004663 .port_bridge_join = mv88e6xxx_port_bridge_join,
4664 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004665 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004667 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004668 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4669 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4670 .port_vlan_add = mv88e6xxx_port_vlan_add,
4671 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004672 .port_fdb_add = mv88e6xxx_port_fdb_add,
4673 .port_fdb_del = mv88e6xxx_port_fdb_del,
4674 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004675 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4676 .port_mdb_add = mv88e6xxx_port_mdb_add,
4677 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004678 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4679 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004680 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4681 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4682 .port_txtstamp = mv88e6xxx_port_txtstamp,
4683 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4684 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004685};
4686
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004687static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004688{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004689 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004690 struct dsa_switch *ds;
4691
Vivien Didelot73b12042017-03-30 17:37:10 -04004692 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004693 if (!ds)
4694 return -ENOMEM;
4695
Vivien Didelotfad09c72016-06-21 12:28:20 -04004696 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004697 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004698 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004699 ds->ageing_time_min = chip->info->age_time_coeff;
4700 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004701
4702 dev_set_drvdata(dev, ds);
4703
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004704 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004705}
4706
Vivien Didelotfad09c72016-06-21 12:28:20 -04004707static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004708{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004709 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004710}
4711
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004712static const void *pdata_device_get_match_data(struct device *dev)
4713{
4714 const struct of_device_id *matches = dev->driver->of_match_table;
4715 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4716
4717 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4718 matches++) {
4719 if (!strcmp(pdata->compatible, matches->compatible))
4720 return matches->data;
4721 }
4722 return NULL;
4723}
4724
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004725/* There is no suspend to RAM support at DSA level yet, the switch configuration
4726 * would be lost after a power cycle so prevent it to be suspended.
4727 */
4728static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4729{
4730 return -EOPNOTSUPP;
4731}
4732
4733static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4734{
4735 return 0;
4736}
4737
4738static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4739
Vivien Didelot57d32312016-06-20 13:13:58 -04004740static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004741{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004742 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004743 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004744 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004745 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004746 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004747 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004748 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004749
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004750 if (!np && !pdata)
4751 return -EINVAL;
4752
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004753 if (np)
4754 compat_info = of_device_get_match_data(dev);
4755
4756 if (pdata) {
4757 compat_info = pdata_device_get_match_data(dev);
4758
4759 if (!pdata->netdev)
4760 return -EINVAL;
4761
4762 for (port = 0; port < DSA_MAX_PORTS; port++) {
4763 if (!(pdata->enabled_ports & (1 << port)))
4764 continue;
4765 if (strcmp(pdata->cd.port_names[port], "cpu"))
4766 continue;
4767 pdata->cd.netdev[port] = &pdata->netdev->dev;
4768 break;
4769 }
4770 }
4771
Vivien Didelotcaac8542016-06-20 13:14:09 -04004772 if (!compat_info)
4773 return -EINVAL;
4774
Vivien Didelotfad09c72016-06-21 12:28:20 -04004775 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004776 if (!chip) {
4777 err = -ENOMEM;
4778 goto out;
4779 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004780
Vivien Didelotfad09c72016-06-21 12:28:20 -04004781 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004782
Vivien Didelotfad09c72016-06-21 12:28:20 -04004783 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004784 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004785 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004786
Andrew Lunnb4308f02016-11-21 23:26:55 +01004787 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004788 if (IS_ERR(chip->reset)) {
4789 err = PTR_ERR(chip->reset);
4790 goto out;
4791 }
Baruch Siach7b75e492019-06-27 21:17:39 +03004792 if (chip->reset)
4793 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01004794
Vivien Didelotfad09c72016-06-21 12:28:20 -04004795 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004796 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004797 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004798
Vivien Didelote57e5e72016-08-15 17:19:00 -04004799 mv88e6xxx_phy_init(chip);
4800
Andrew Lunn00baabe2018-05-19 22:31:35 +02004801 if (chip->info->ops->get_eeprom) {
4802 if (np)
4803 of_property_read_u32(np, "eeprom-length",
4804 &chip->eeprom_len);
4805 else
4806 chip->eeprom_len = pdata->eeprom_len;
4807 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004808
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004809 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004810 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004811 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02004812 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004813 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004814
Andrew Lunna27415d2019-05-01 00:10:50 +02004815 if (np) {
4816 chip->irq = of_irq_get(np, 0);
4817 if (chip->irq == -EPROBE_DEFER) {
4818 err = chip->irq;
4819 goto out;
4820 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004821 }
4822
Andrew Lunna27415d2019-05-01 00:10:50 +02004823 if (pdata)
4824 chip->irq = pdata->irq;
4825
Andrew Lunn294d7112018-02-22 22:58:32 +01004826 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004827 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004828 * controllers
4829 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004830 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004831 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004832 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004833 else
4834 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004835 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004836
Andrew Lunn294d7112018-02-22 22:58:32 +01004837 if (err)
4838 goto out;
4839
4840 if (chip->info->g2_irqs > 0) {
4841 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004842 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004843 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004844 }
4845
Andrew Lunn294d7112018-02-22 22:58:32 +01004846 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4847 if (err)
4848 goto out_g2_irq;
4849
4850 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4851 if (err)
4852 goto out_g1_atu_prob_irq;
4853
Andrew Lunna3c53be52017-01-24 14:53:50 +01004854 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004855 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004856 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004857
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004858 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004859 if (err)
4860 goto out_mdio;
4861
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004862 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004863
4864out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004865 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004866out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004867 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004868out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004869 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004870out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004871 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004872 mv88e6xxx_g2_irq_free(chip);
4873out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004874 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004875 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004876 else
4877 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004878out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004879 if (pdata)
4880 dev_put(pdata->netdev);
4881
Andrew Lunndc30c352016-10-16 19:56:49 +02004882 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004883}
4884
4885static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4886{
4887 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004888 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004889
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004890 if (chip->info->ptp_support) {
4891 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004892 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004893 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004894
Andrew Lunn930188c2016-08-22 16:01:03 +02004895 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004896 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004897 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004898
Andrew Lunn76f38f12018-03-17 20:21:09 +01004899 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4900 mv88e6xxx_g1_atu_prob_irq_free(chip);
4901
4902 if (chip->info->g2_irqs > 0)
4903 mv88e6xxx_g2_irq_free(chip);
4904
Andrew Lunn76f38f12018-03-17 20:21:09 +01004905 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004906 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004907 else
4908 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004909}
4910
4911static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004912 {
4913 .compatible = "marvell,mv88e6085",
4914 .data = &mv88e6xxx_table[MV88E6085],
4915 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004916 {
4917 .compatible = "marvell,mv88e6190",
4918 .data = &mv88e6xxx_table[MV88E6190],
4919 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004920 {
4921 .compatible = "marvell,mv88e6250",
4922 .data = &mv88e6xxx_table[MV88E6250],
4923 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004924 { /* sentinel */ },
4925};
4926
4927MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4928
4929static struct mdio_driver mv88e6xxx_driver = {
4930 .probe = mv88e6xxx_probe,
4931 .remove = mv88e6xxx_remove,
4932 .mdiodrv.driver = {
4933 .name = "mv88e6085",
4934 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004935 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004936 },
4937};
4938
Andrew Lunn7324d502019-04-27 19:19:10 +02004939mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004940
4941MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4942MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4943MODULE_LICENSE("GPL");