blob: b7e0513c675a2d96dc0fe399629d0dbb9d75bf60 [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
Vivien Didelotec561272016-09-02 14:45:33 -0400397int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400398{
Vivien Didelot683f2242019-08-09 18:47:54 -0400399 return mv88e6xxx_wait_mask(chip, addr, reg, mask, 0x0000);
Vivien Didelot2d79af62016-08-15 17:18:57 -0400400}
401
Vivien Didelotf22ab642016-07-18 20:45:31 -0400402/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400403int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400404{
405 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200406 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400407
408 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200409 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
410 if (err)
411 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400412
413 /* Set the Update bit to trigger a write operation */
414 val = BIT(15) | update;
415
416 return mv88e6xxx_write(chip, addr, reg, val);
417}
418
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100419int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
420 int speed, int duplex, int pause,
421 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100422{
Andrew Lunna26deec2019-04-18 03:11:39 +0200423 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100424 int err;
425
426 if (!chip->info->ops->port_set_link)
427 return 0;
428
Andrew Lunna26deec2019-04-18 03:11:39 +0200429 if (!chip->info->ops->port_link_state)
430 return 0;
431
432 err = chip->info->ops->port_link_state(chip, port, &state);
433 if (err)
434 return err;
435
436 /* Has anything actually changed? We don't expect the
437 * interface mode to change without one of the other
438 * parameters also changing
439 */
440 if (state.link == link &&
441 state.speed == speed &&
442 state.duplex == duplex)
443 return 0;
444
Vivien Didelotd78343d2016-11-04 03:23:36 +0100445 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200446 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100447 if (err)
448 return err;
449
450 if (chip->info->ops->port_set_speed) {
451 err = chip->info->ops->port_set_speed(chip, port, speed);
452 if (err && err != -EOPNOTSUPP)
453 goto restore_link;
454 }
455
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100456 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
457 mode = chip->info->ops->port_max_speed_mode(port);
458
Andrew Lunn54186b92018-08-09 15:38:37 +0200459 if (chip->info->ops->port_set_pause) {
460 err = chip->info->ops->port_set_pause(chip, port, pause);
461 if (err)
462 goto restore_link;
463 }
464
Vivien Didelotd78343d2016-11-04 03:23:36 +0100465 if (chip->info->ops->port_set_duplex) {
466 err = chip->info->ops->port_set_duplex(chip, port, duplex);
467 if (err && err != -EOPNOTSUPP)
468 goto restore_link;
469 }
470
471 if (chip->info->ops->port_set_rgmii_delay) {
472 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
473 if (err && err != -EOPNOTSUPP)
474 goto restore_link;
475 }
476
Andrew Lunnf39908d2017-02-04 20:02:50 +0100477 if (chip->info->ops->port_set_cmode) {
478 err = chip->info->ops->port_set_cmode(chip, port, mode);
479 if (err && err != -EOPNOTSUPP)
480 goto restore_link;
481 }
482
Vivien Didelotd78343d2016-11-04 03:23:36 +0100483 err = 0;
484restore_link:
485 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400486 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100487
488 return err;
489}
490
Marek Vasutd700ec42018-09-12 00:15:24 +0200491static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
492{
493 struct mv88e6xxx_chip *chip = ds->priv;
494
495 return port < chip->info->num_internal_phys;
496}
497
Russell King6c422e32018-08-09 15:38:39 +0200498static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
499 unsigned long *mask,
500 struct phylink_link_state *state)
501{
502 if (!phy_interface_mode_is_8023z(state->interface)) {
503 /* 10M and 100M are only supported in non-802.3z mode */
504 phylink_set(mask, 10baseT_Half);
505 phylink_set(mask, 10baseT_Full);
506 phylink_set(mask, 100baseT_Half);
507 phylink_set(mask, 100baseT_Full);
508 }
509}
510
511static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
512 unsigned long *mask,
513 struct phylink_link_state *state)
514{
515 /* FIXME: if the port is in 1000Base-X mode, then it only supports
516 * 1000M FD speeds. In this case, CMODE will indicate 5.
517 */
518 phylink_set(mask, 1000baseT_Full);
519 phylink_set(mask, 1000baseX_Full);
520
521 mv88e6065_phylink_validate(chip, port, mask, state);
522}
523
Marek Behúne3af71a2019-02-25 12:39:55 +0100524static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
525 unsigned long *mask,
526 struct phylink_link_state *state)
527{
528 if (port >= 5)
529 phylink_set(mask, 2500baseX_Full);
530
531 /* No ethtool bits for 200Mbps */
532 phylink_set(mask, 1000baseT_Full);
533 phylink_set(mask, 1000baseX_Full);
534
535 mv88e6065_phylink_validate(chip, port, mask, state);
536}
537
Russell King6c422e32018-08-09 15:38:39 +0200538static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
539 unsigned long *mask,
540 struct phylink_link_state *state)
541{
542 /* No ethtool bits for 200Mbps */
543 phylink_set(mask, 1000baseT_Full);
544 phylink_set(mask, 1000baseX_Full);
545
546 mv88e6065_phylink_validate(chip, port, mask, state);
547}
548
549static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
550 unsigned long *mask,
551 struct phylink_link_state *state)
552{
Andrew Lunnec260162019-02-08 22:25:44 +0100553 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200554 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100555 phylink_set(mask, 2500baseT_Full);
556 }
Russell King6c422e32018-08-09 15:38:39 +0200557
558 /* No ethtool bits for 200Mbps */
559 phylink_set(mask, 1000baseT_Full);
560 phylink_set(mask, 1000baseX_Full);
561
562 mv88e6065_phylink_validate(chip, port, mask, state);
563}
564
565static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
566 unsigned long *mask,
567 struct phylink_link_state *state)
568{
569 if (port >= 9) {
570 phylink_set(mask, 10000baseT_Full);
571 phylink_set(mask, 10000baseKR_Full);
572 }
573
574 mv88e6390_phylink_validate(chip, port, mask, state);
575}
576
Russell Kingc9a23562018-05-10 13:17:35 -0700577static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
578 unsigned long *supported,
579 struct phylink_link_state *state)
580{
Russell King6c422e32018-08-09 15:38:39 +0200581 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
582 struct mv88e6xxx_chip *chip = ds->priv;
583
584 /* Allow all the expected bits */
585 phylink_set(mask, Autoneg);
586 phylink_set(mask, Pause);
587 phylink_set_port_modes(mask);
588
589 if (chip->info->ops->phylink_validate)
590 chip->info->ops->phylink_validate(chip, port, mask, state);
591
592 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
593 bitmap_and(state->advertising, state->advertising, mask,
594 __ETHTOOL_LINK_MODE_MASK_NBITS);
595
596 /* We can only operate at 2500BaseX or 1000BaseX. If requested
597 * to advertise both, only report advertising at 2500BaseX.
598 */
599 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700600}
601
602static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
603 struct phylink_link_state *state)
604{
605 struct mv88e6xxx_chip *chip = ds->priv;
606 int err;
607
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000608 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200609 if (chip->info->ops->port_link_state)
610 err = chip->info->ops->port_link_state(chip, port, state);
611 else
612 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000613 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700614
615 return err;
616}
617
618static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
619 unsigned int mode,
620 const struct phylink_link_state *state)
621{
622 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200623 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700624
Marek Vasutd700ec42018-09-12 00:15:24 +0200625 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700626 return;
627
628 if (mode == MLO_AN_FIXED) {
629 link = LINK_FORCED_UP;
630 speed = state->speed;
631 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200632 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
633 link = state->link;
634 speed = state->speed;
635 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700636 } else {
637 speed = SPEED_UNFORCED;
638 duplex = DUPLEX_UNFORCED;
639 link = LINK_UNFORCED;
640 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200641 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700642
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000643 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200644 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700645 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000646 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700647
648 if (err && err != -EOPNOTSUPP)
649 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
650}
651
652static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
653{
654 struct mv88e6xxx_chip *chip = ds->priv;
655 int err;
656
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000657 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700658 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000659 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700660
661 if (err)
662 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
663}
664
665static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
666 unsigned int mode,
667 phy_interface_t interface)
668{
669 if (mode == MLO_AN_FIXED)
670 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
671}
672
673static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
674 unsigned int mode, phy_interface_t interface,
675 struct phy_device *phydev)
676{
677 if (mode == MLO_AN_FIXED)
678 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
679}
680
Andrew Lunna605a0f2016-11-21 23:26:58 +0100681static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000682{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100683 if (!chip->info->ops->stats_snapshot)
684 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000685
Andrew Lunna605a0f2016-11-21 23:26:58 +0100686 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000687}
688
Andrew Lunne413e7e2015-04-02 04:06:38 +0200689static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100690 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
691 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
692 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
693 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
694 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
695 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
696 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
697 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
698 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
699 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
700 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
701 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
702 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
703 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
704 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
705 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
706 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
707 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
708 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
709 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
710 { "single", 4, 0x14, STATS_TYPE_BANK0, },
711 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
712 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
713 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
714 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
715 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
716 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
717 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
718 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
719 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
720 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
721 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
722 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
723 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
724 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
725 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
726 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
727 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
728 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
729 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
730 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
731 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
732 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
733 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
734 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
735 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
736 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
737 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
738 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
739 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
740 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
741 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
742 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
743 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
744 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
745 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
746 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
747 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
748 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200749};
750
Vivien Didelotfad09c72016-06-21 12:28:20 -0400751static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100752 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100753 int port, u16 bank1_select,
754 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200755{
Andrew Lunn80c46272015-06-20 18:42:30 +0200756 u32 low;
757 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100758 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200759 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200760 u64 value;
761
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100762 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100763 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200764 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
765 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800766 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200767
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200768 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100769 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200770 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
771 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800772 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000773 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200774 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100775 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100776 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100777 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100778 /* fall through */
779 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100780 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100781 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100782 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100783 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500784 break;
785 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800786 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200787 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100788 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200789 return value;
790}
791
Andrew Lunn436fe172018-03-01 02:02:29 +0100792static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
793 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100794{
795 struct mv88e6xxx_hw_stat *stat;
796 int i, j;
797
798 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
799 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100800 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100801 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
802 ETH_GSTRING_LEN);
803 j++;
804 }
805 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100806
807 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100808}
809
Andrew Lunn436fe172018-03-01 02:02:29 +0100810static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
811 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100812{
Andrew Lunn436fe172018-03-01 02:02:29 +0100813 return mv88e6xxx_stats_get_strings(chip, data,
814 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100815}
816
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000817static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
818 uint8_t *data)
819{
820 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
821}
822
Andrew Lunn436fe172018-03-01 02:02:29 +0100823static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
824 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100825{
Andrew Lunn436fe172018-03-01 02:02:29 +0100826 return mv88e6xxx_stats_get_strings(chip, data,
827 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100828}
829
Andrew Lunn65f60e42018-03-28 23:50:28 +0200830static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
831 "atu_member_violation",
832 "atu_miss_violation",
833 "atu_full_violation",
834 "vtu_member_violation",
835 "vtu_miss_violation",
836};
837
838static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
839{
840 unsigned int i;
841
842 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
843 strlcpy(data + i * ETH_GSTRING_LEN,
844 mv88e6xxx_atu_vtu_stats_strings[i],
845 ETH_GSTRING_LEN);
846}
847
Andrew Lunndfafe442016-11-21 23:27:02 +0100848static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700849 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100850{
Vivien Didelot04bed142016-08-31 18:06:13 -0400851 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100852 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100853
Florian Fainelli89f09042018-04-25 12:12:50 -0700854 if (stringset != ETH_SS_STATS)
855 return;
856
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000857 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100858
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100860 count = chip->info->ops->stats_get_strings(chip, data);
861
862 if (chip->info->ops->serdes_get_strings) {
863 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200864 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100865 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100866
Andrew Lunn65f60e42018-03-28 23:50:28 +0200867 data += count * ETH_GSTRING_LEN;
868 mv88e6xxx_atu_vtu_get_strings(data);
869
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000870 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100871}
872
873static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
874 int types)
875{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100876 struct mv88e6xxx_hw_stat *stat;
877 int i, j;
878
879 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
880 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100881 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100882 j++;
883 }
884 return j;
885}
886
Andrew Lunndfafe442016-11-21 23:27:02 +0100887static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
888{
889 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
890 STATS_TYPE_PORT);
891}
892
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000893static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
894{
895 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
896}
897
Andrew Lunndfafe442016-11-21 23:27:02 +0100898static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
899{
900 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
901 STATS_TYPE_BANK1);
902}
903
Florian Fainelli89f09042018-04-25 12:12:50 -0700904static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100905{
906 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100907 int serdes_count = 0;
908 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100909
Florian Fainelli89f09042018-04-25 12:12:50 -0700910 if (sset != ETH_SS_STATS)
911 return 0;
912
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000913 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100914 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 count = chip->info->ops->stats_get_sset_count(chip);
916 if (count < 0)
917 goto out;
918
919 if (chip->info->ops->serdes_get_sset_count)
920 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
921 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200922 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100923 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200924 goto out;
925 }
926 count += serdes_count;
927 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
928
Andrew Lunn436fe172018-03-01 02:02:29 +0100929out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000930 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100931
Andrew Lunn436fe172018-03-01 02:02:29 +0100932 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100933}
934
Andrew Lunn436fe172018-03-01 02:02:29 +0100935static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
936 uint64_t *data, int types,
937 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100938{
939 struct mv88e6xxx_hw_stat *stat;
940 int i, j;
941
942 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
943 stat = &mv88e6xxx_hw_stats[i];
944 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000945 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100946 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
947 bank1_select,
948 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000949 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100950
Andrew Lunn052f9472016-11-21 23:27:03 +0100951 j++;
952 }
953 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100955}
956
Andrew Lunn436fe172018-03-01 02:02:29 +0100957static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
958 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100959{
960 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100961 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400962 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100963}
964
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000965static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
966 uint64_t *data)
967{
968 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
969 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
970}
971
Andrew Lunn436fe172018-03-01 02:02:29 +0100972static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
973 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100974{
975 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100976 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400977 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
978 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100979}
980
Andrew Lunn436fe172018-03-01 02:02:29 +0100981static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
982 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100983{
984 return mv88e6xxx_stats_get_stats(chip, port, data,
985 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400986 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
987 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100988}
989
Andrew Lunn65f60e42018-03-28 23:50:28 +0200990static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
991 uint64_t *data)
992{
993 *data++ = chip->ports[port].atu_member_violation;
994 *data++ = chip->ports[port].atu_miss_violation;
995 *data++ = chip->ports[port].atu_full_violation;
996 *data++ = chip->ports[port].vtu_member_violation;
997 *data++ = chip->ports[port].vtu_miss_violation;
998}
999
Andrew Lunn052f9472016-11-21 23:27:03 +01001000static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1001 uint64_t *data)
1002{
Andrew Lunn436fe172018-03-01 02:02:29 +01001003 int count = 0;
1004
Andrew Lunn052f9472016-11-21 23:27:03 +01001005 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001006 count = chip->info->ops->stats_get_stats(chip, port, data);
1007
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001008 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001009 if (chip->info->ops->serdes_get_stats) {
1010 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001011 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001012 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001013 data += count;
1014 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001015 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001016}
1017
Vivien Didelotf81ec902016-05-09 13:22:58 -04001018static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1019 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001020{
Vivien Didelot04bed142016-08-31 18:06:13 -04001021 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001022 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001023
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001024 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001025
Andrew Lunna605a0f2016-11-21 23:26:58 +01001026 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001027 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001028
1029 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001030 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001031
1032 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001033
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001034}
Ben Hutchings98e67302011-11-25 14:36:19 +00001035
Vivien Didelotf81ec902016-05-09 13:22:58 -04001036static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037{
1038 return 32 * sizeof(u16);
1039}
1040
Vivien Didelotf81ec902016-05-09 13:22:58 -04001041static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1042 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001043{
Vivien Didelot04bed142016-08-31 18:06:13 -04001044 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001045 int err;
1046 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001047 u16 *p = _p;
1048 int i;
1049
Vivien Didelota5f39322018-12-17 16:05:21 -05001050 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001051
1052 memset(p, 0xff, 32 * sizeof(u16));
1053
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001054 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001055
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001056 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001057
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001058 err = mv88e6xxx_port_read(chip, port, i, &reg);
1059 if (!err)
1060 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001061 }
Vivien Didelot23062512016-05-09 13:22:45 -04001062
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001063 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001064}
1065
Vivien Didelot08f50062017-08-01 16:32:41 -04001066static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1067 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001068{
Vivien Didelot5480db62017-08-01 16:32:40 -04001069 /* Nothing to do on the port's MAC */
1070 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001071}
1072
Vivien Didelot08f50062017-08-01 16:32:41 -04001073static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1074 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001075{
Vivien Didelot5480db62017-08-01 16:32:40 -04001076 /* Nothing to do on the port's MAC */
1077 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001078}
1079
Vivien Didelote5887a22017-03-30 17:37:11 -04001080static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001081{
Vivien Didelote5887a22017-03-30 17:37:11 -04001082 struct dsa_switch *ds = NULL;
1083 struct net_device *br;
1084 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001085 int i;
1086
Vivien Didelote5887a22017-03-30 17:37:11 -04001087 if (dev < DSA_MAX_SWITCHES)
1088 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001089
Vivien Didelote5887a22017-03-30 17:37:11 -04001090 /* Prevent frames from unknown switch or port */
1091 if (!ds || port >= ds->num_ports)
1092 return 0;
1093
1094 /* Frames from DSA links and CPU ports can egress any local port */
1095 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1096 return mv88e6xxx_port_mask(chip);
1097
1098 br = ds->ports[port].bridge_dev;
1099 pvlan = 0;
1100
1101 /* Frames from user ports can egress any local DSA links and CPU ports,
1102 * as well as any local member of their bridge group.
1103 */
1104 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1105 if (dsa_is_cpu_port(chip->ds, i) ||
1106 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001107 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001108 pvlan |= BIT(i);
1109
1110 return pvlan;
1111}
1112
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001113static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001114{
1115 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001116
1117 /* prevent frames from going back out of the port they came in on */
1118 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001119
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001120 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001121}
1122
Vivien Didelotf81ec902016-05-09 13:22:58 -04001123static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1124 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001125{
Vivien Didelot04bed142016-08-31 18:06:13 -04001126 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001127 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001128
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001129 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001130 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001131 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001132
1133 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001134 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001135}
1136
Vivien Didelot93e18d62018-05-11 17:16:35 -04001137static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1138{
1139 int err;
1140
1141 if (chip->info->ops->ieee_pri_map) {
1142 err = chip->info->ops->ieee_pri_map(chip);
1143 if (err)
1144 return err;
1145 }
1146
1147 if (chip->info->ops->ip_pri_map) {
1148 err = chip->info->ops->ip_pri_map(chip);
1149 if (err)
1150 return err;
1151 }
1152
1153 return 0;
1154}
1155
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001156static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1157{
1158 int target, port;
1159 int err;
1160
1161 if (!chip->info->global2_addr)
1162 return 0;
1163
1164 /* Initialize the routing port to the 32 possible target devices */
1165 for (target = 0; target < 32; target++) {
1166 port = 0x1f;
1167 if (target < DSA_MAX_SWITCHES)
1168 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1169 port = chip->ds->rtable[target];
1170
1171 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1172 if (err)
1173 return err;
1174 }
1175
Vivien Didelot02317e62018-05-09 11:38:49 -04001176 if (chip->info->ops->set_cascade_port) {
1177 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1178 err = chip->info->ops->set_cascade_port(chip, port);
1179 if (err)
1180 return err;
1181 }
1182
Vivien Didelot23c98912018-05-09 11:38:50 -04001183 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1184 if (err)
1185 return err;
1186
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001187 return 0;
1188}
1189
Vivien Didelotb28f8722018-04-26 21:56:44 -04001190static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1191{
1192 /* Clear all trunk masks and mapping */
1193 if (chip->info->global2_addr)
1194 return mv88e6xxx_g2_trunk_clear(chip);
1195
1196 return 0;
1197}
1198
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001199static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1200{
1201 if (chip->info->ops->rmu_disable)
1202 return chip->info->ops->rmu_disable(chip);
1203
1204 return 0;
1205}
1206
Vivien Didelot9e907d72017-07-17 13:03:43 -04001207static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1208{
1209 if (chip->info->ops->pot_clear)
1210 return chip->info->ops->pot_clear(chip);
1211
1212 return 0;
1213}
1214
Vivien Didelot51c901a2017-07-17 13:03:41 -04001215static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1216{
1217 if (chip->info->ops->mgmt_rsvd2cpu)
1218 return chip->info->ops->mgmt_rsvd2cpu(chip);
1219
1220 return 0;
1221}
1222
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001223static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1224{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001225 int err;
1226
Vivien Didelotdaefc942017-03-11 16:12:54 -05001227 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1228 if (err)
1229 return err;
1230
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001231 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1232 if (err)
1233 return err;
1234
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001235 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1236}
1237
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001238static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1239{
1240 int port;
1241 int err;
1242
1243 if (!chip->info->ops->irl_init_all)
1244 return 0;
1245
1246 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1247 /* Disable ingress rate limiting by resetting all per port
1248 * ingress rate limit resources to their initial state.
1249 */
1250 err = chip->info->ops->irl_init_all(chip, port);
1251 if (err)
1252 return err;
1253 }
1254
1255 return 0;
1256}
1257
Vivien Didelot04a69a12017-10-13 14:18:05 -04001258static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1259{
1260 if (chip->info->ops->set_switch_mac) {
1261 u8 addr[ETH_ALEN];
1262
1263 eth_random_addr(addr);
1264
1265 return chip->info->ops->set_switch_mac(chip, addr);
1266 }
1267
1268 return 0;
1269}
1270
Vivien Didelot17a15942017-03-30 17:37:09 -04001271static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1272{
1273 u16 pvlan = 0;
1274
1275 if (!mv88e6xxx_has_pvt(chip))
1276 return -EOPNOTSUPP;
1277
1278 /* Skip the local source device, which uses in-chip port VLAN */
1279 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001280 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001281
1282 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1283}
1284
Vivien Didelot81228992017-03-30 17:37:08 -04001285static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1286{
Vivien Didelot17a15942017-03-30 17:37:09 -04001287 int dev, port;
1288 int err;
1289
Vivien Didelot81228992017-03-30 17:37:08 -04001290 if (!mv88e6xxx_has_pvt(chip))
1291 return 0;
1292
1293 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1294 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1295 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001296 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1297 if (err)
1298 return err;
1299
1300 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1301 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1302 err = mv88e6xxx_pvt_map(chip, dev, port);
1303 if (err)
1304 return err;
1305 }
1306 }
1307
1308 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001309}
1310
Vivien Didelot749efcb2016-09-22 16:49:24 -04001311static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1312{
1313 struct mv88e6xxx_chip *chip = ds->priv;
1314 int err;
1315
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001316 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001317 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001318 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001319
1320 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001321 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001322}
1323
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001324static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1325{
1326 if (!chip->info->max_vid)
1327 return 0;
1328
1329 return mv88e6xxx_g1_vtu_flush(chip);
1330}
1331
Vivien Didelotf1394b782017-05-01 14:05:22 -04001332static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1333 struct mv88e6xxx_vtu_entry *entry)
1334{
1335 if (!chip->info->ops->vtu_getnext)
1336 return -EOPNOTSUPP;
1337
1338 return chip->info->ops->vtu_getnext(chip, entry);
1339}
1340
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001341static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1342 struct mv88e6xxx_vtu_entry *entry)
1343{
1344 if (!chip->info->ops->vtu_loadpurge)
1345 return -EOPNOTSUPP;
1346
1347 return chip->info->ops->vtu_loadpurge(chip, entry);
1348}
1349
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001350static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001351{
1352 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001353 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001354 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001355
1356 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1357
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001358 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001359 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001360 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001361 if (err)
1362 return err;
1363
1364 set_bit(*fid, fid_bitmap);
1365 }
1366
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001367 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001368 vlan.vid = chip->info->max_vid;
1369 vlan.valid = false;
1370
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001371 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001372 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001373 if (err)
1374 return err;
1375
1376 if (!vlan.valid)
1377 break;
1378
1379 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001380 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001381
1382 /* The reset value 0x000 is used to indicate that multiple address
1383 * databases are not needed. Return the next positive available.
1384 */
1385 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001386 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001387 return -ENOSPC;
1388
1389 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001390 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001391}
1392
Vivien Didelotda9c3592016-02-12 12:09:40 -05001393static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1394 u16 vid_begin, u16 vid_end)
1395{
Vivien Didelot04bed142016-08-31 18:06:13 -04001396 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001397 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001398 int i, err;
1399
Andrew Lunndb06ae412017-09-25 23:32:20 +02001400 /* DSA and CPU ports have to be members of multiple vlans */
1401 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1402 return 0;
1403
Vivien Didelotda9c3592016-02-12 12:09:40 -05001404 if (!vid_begin)
1405 return -EOPNOTSUPP;
1406
Vivien Didelot425d2d32019-08-01 14:36:34 -04001407 vlan.vid = vid_begin - 1;
1408 vlan.valid = false;
1409
Vivien Didelotda9c3592016-02-12 12:09:40 -05001410 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001411 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001412 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001413 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001414
1415 if (!vlan.valid)
1416 break;
1417
1418 if (vlan.vid > vid_end)
1419 break;
1420
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001421 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001422 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1423 continue;
1424
Andrew Lunncd886462017-11-09 22:29:53 +01001425 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001426 continue;
1427
Vivien Didelotbd00e052017-05-01 14:05:11 -04001428 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001429 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001430 continue;
1431
Vivien Didelotc8652c82017-10-16 11:12:19 -04001432 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001433 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001434 break; /* same bridge, check next VLAN */
1435
Vivien Didelotc8652c82017-10-16 11:12:19 -04001436 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001437 continue;
1438
Andrew Lunn743fcc22017-11-09 22:29:54 +01001439 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1440 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001441 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001442 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001443 }
1444 } while (vlan.vid < vid_end);
1445
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001446 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001447}
1448
Vivien Didelotf81ec902016-05-09 13:22:58 -04001449static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1450 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001451{
Vivien Didelot04bed142016-08-31 18:06:13 -04001452 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001453 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1454 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001455 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001456
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001457 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001458 return -EOPNOTSUPP;
1459
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001460 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001461 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001462 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001463
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001464 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001465}
1466
Vivien Didelot57d32312016-06-20 13:13:58 -04001467static int
1468mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001469 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001470{
Vivien Didelot04bed142016-08-31 18:06:13 -04001471 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001472 int err;
1473
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001474 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001475 return -EOPNOTSUPP;
1476
Vivien Didelotda9c3592016-02-12 12:09:40 -05001477 /* If the requested port doesn't belong to the same bridge as the VLAN
1478 * members, do not support it (yet) and fallback to software VLAN.
1479 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001480 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001481 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1482 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001483 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001484
Vivien Didelot76e398a2015-11-01 12:33:55 -05001485 /* We don't need any dynamic resource from the kernel (yet),
1486 * so skip the prepare phase.
1487 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001488 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001489}
1490
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001491static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1492 const unsigned char *addr, u16 vid,
1493 u8 state)
1494{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001495 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001496 struct mv88e6xxx_vtu_entry vlan;
1497 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001498 int err;
1499
1500 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001501 if (vid == 0) {
1502 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1503 if (err)
1504 return err;
1505 } else {
1506 vlan.vid = vid - 1;
1507 vlan.valid = false;
1508
1509 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1510 if (err)
1511 return err;
1512
1513 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1514 if (vlan.vid != vid || !vlan.valid)
1515 return -EOPNOTSUPP;
1516
1517 fid = vlan.fid;
1518 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001519
1520 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1521 ether_addr_copy(entry.mac, addr);
1522 eth_addr_dec(entry.mac);
1523
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001524 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001525 if (err)
1526 return err;
1527
1528 /* Initialize a fresh ATU entry if it isn't found */
1529 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1530 !ether_addr_equal(entry.mac, addr)) {
1531 memset(&entry, 0, sizeof(entry));
1532 ether_addr_copy(entry.mac, addr);
1533 }
1534
1535 /* Purge the ATU entry only if no port is using it anymore */
1536 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1537 entry.portvec &= ~BIT(port);
1538 if (!entry.portvec)
1539 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1540 } else {
1541 entry.portvec |= BIT(port);
1542 entry.state = state;
1543 }
1544
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001545 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001546}
1547
Andrew Lunn87fa8862017-11-09 22:29:56 +01001548static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1549 u16 vid)
1550{
1551 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1552 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1553
1554 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1555}
1556
1557static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1558{
1559 int port;
1560 int err;
1561
1562 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1563 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1564 if (err)
1565 return err;
1566 }
1567
1568 return 0;
1569}
1570
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001571static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001572 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001573{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001574 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001575 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001576 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001577
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001578 if (!vid)
1579 return -EOPNOTSUPP;
1580
1581 vlan.vid = vid - 1;
1582 vlan.valid = false;
1583
1584 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001585 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001586 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001587
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001588 if (vlan.vid != vid || !vlan.valid) {
1589 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001590
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001591 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1592 if (err)
1593 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001594
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001595 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1596 if (i == port)
1597 vlan.member[i] = member;
1598 else
1599 vlan.member[i] = non_member;
1600
1601 vlan.vid = vid;
1602 vlan.valid = true;
1603
1604 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1605 if (err)
1606 return err;
1607
1608 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1609 if (err)
1610 return err;
1611 } else if (vlan.member[port] != member) {
1612 vlan.member[port] = member;
1613
1614 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1615 if (err)
1616 return err;
1617 } else {
1618 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1619 port, vid);
1620 }
1621
1622 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001623}
1624
Vivien Didelotf81ec902016-05-09 13:22:58 -04001625static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001626 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001627{
Vivien Didelot04bed142016-08-31 18:06:13 -04001628 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001629 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1630 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001631 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001632 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001633
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001634 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001635 return;
1636
Vivien Didelotc91498e2017-06-07 18:12:13 -04001637 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001638 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001639 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001640 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001641 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001642 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001643
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001644 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001645
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001646 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001647 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001648 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1649 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001650
Vivien Didelot77064f32016-11-04 03:23:30 +01001651 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001652 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1653 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001654
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001655 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001656}
1657
Vivien Didelot521098922019-08-01 14:36:36 -04001658static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1659 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001660{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001661 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001662 int i, err;
1663
Vivien Didelot521098922019-08-01 14:36:36 -04001664 if (!vid)
1665 return -EOPNOTSUPP;
1666
1667 vlan.vid = vid - 1;
1668 vlan.valid = false;
1669
1670 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001671 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001672 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001673
Vivien Didelot521098922019-08-01 14:36:36 -04001674 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1675 * tell switchdev that this VLAN is likely handled in software.
1676 */
1677 if (vlan.vid != vid || !vlan.valid ||
1678 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001679 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001680
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001681 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001682
1683 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001684 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001685 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001686 if (vlan.member[i] !=
1687 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001688 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001689 break;
1690 }
1691 }
1692
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001693 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001694 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001695 return err;
1696
Vivien Didelote606ca32017-03-11 16:12:55 -05001697 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698}
1699
Vivien Didelotf81ec902016-05-09 13:22:58 -04001700static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1701 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001702{
Vivien Didelot04bed142016-08-31 18:06:13 -04001703 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704 u16 pvid, vid;
1705 int err = 0;
1706
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001707 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001708 return -EOPNOTSUPP;
1709
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001710 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001711
Vivien Didelot77064f32016-11-04 03:23:30 +01001712 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001713 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001714 goto unlock;
1715
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001717 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001718 if (err)
1719 goto unlock;
1720
1721 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001722 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001723 if (err)
1724 goto unlock;
1725 }
1726 }
1727
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001728unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001729 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001730
1731 return err;
1732}
1733
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001734static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1735 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001736{
Vivien Didelot04bed142016-08-31 18:06:13 -04001737 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001738 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001739
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001740 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001741 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1742 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001743 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001744
1745 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001746}
1747
Vivien Didelotf81ec902016-05-09 13:22:58 -04001748static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001749 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001750{
Vivien Didelot04bed142016-08-31 18:06:13 -04001751 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001752 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001753
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001754 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001755 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001756 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001757 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001758
Vivien Didelot83dabd12016-08-31 11:50:04 -04001759 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001760}
1761
Vivien Didelot83dabd12016-08-31 11:50:04 -04001762static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1763 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001764 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001765{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001766 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001767 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001768 int err;
1769
Vivien Didelot27c0e602017-06-15 12:14:01 -04001770 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001771 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001772
1773 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001774 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001775 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001776 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001777
Vivien Didelot27c0e602017-06-15 12:14:01 -04001778 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001779 break;
1780
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001781 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001782 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001783
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001784 if (!is_unicast_ether_addr(addr.mac))
1785 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001786
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001787 is_static = (addr.state ==
1788 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1789 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001790 if (err)
1791 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001792 } while (!is_broadcast_ether_addr(addr.mac));
1793
1794 return err;
1795}
1796
Vivien Didelot83dabd12016-08-31 11:50:04 -04001797static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001798 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001799{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001800 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001801 u16 fid;
1802 int err;
1803
1804 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001805 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001806 if (err)
1807 return err;
1808
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001809 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001810 if (err)
1811 return err;
1812
1813 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001814 vlan.vid = chip->info->max_vid;
1815 vlan.valid = false;
1816
Vivien Didelot83dabd12016-08-31 11:50:04 -04001817 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001818 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001819 if (err)
1820 return err;
1821
1822 if (!vlan.valid)
1823 break;
1824
1825 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001826 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001827 if (err)
1828 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001829 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001830
1831 return err;
1832}
1833
Vivien Didelotf81ec902016-05-09 13:22:58 -04001834static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001835 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001836{
Vivien Didelot04bed142016-08-31 18:06:13 -04001837 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04001838 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001839
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001840 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001841 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001842 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04001843
1844 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001845}
1846
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001847static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1848 struct net_device *br)
1849{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001850 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001851 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001852 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001853 int err;
1854
1855 /* Remap the Port VLAN of each local bridge group member */
1856 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1857 if (chip->ds->ports[port].bridge_dev == br) {
1858 err = mv88e6xxx_port_vlan_map(chip, port);
1859 if (err)
1860 return err;
1861 }
1862 }
1863
Vivien Didelote96a6e02017-03-30 17:37:13 -04001864 if (!mv88e6xxx_has_pvt(chip))
1865 return 0;
1866
1867 /* Remap the Port VLAN of each cross-chip bridge group member */
1868 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1869 ds = chip->ds->dst->ds[dev];
1870 if (!ds)
1871 break;
1872
1873 for (port = 0; port < ds->num_ports; ++port) {
1874 if (ds->ports[port].bridge_dev == br) {
1875 err = mv88e6xxx_pvt_map(chip, dev, port);
1876 if (err)
1877 return err;
1878 }
1879 }
1880 }
1881
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001882 return 0;
1883}
1884
Vivien Didelotf81ec902016-05-09 13:22:58 -04001885static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001886 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001887{
Vivien Didelot04bed142016-08-31 18:06:13 -04001888 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001889 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001890
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001891 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001892 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001893 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05001894
Vivien Didelot466dfa02016-02-26 13:16:05 -05001895 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001896}
1897
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001898static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1899 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001900{
Vivien Didelot04bed142016-08-31 18:06:13 -04001901 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001902
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001903 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001904 if (mv88e6xxx_bridge_map(chip, br) ||
1905 mv88e6xxx_port_vlan_map(chip, port))
1906 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001907 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001908}
1909
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001910static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1911 int port, struct net_device *br)
1912{
1913 struct mv88e6xxx_chip *chip = ds->priv;
1914 int err;
1915
1916 if (!mv88e6xxx_has_pvt(chip))
1917 return 0;
1918
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001919 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001920 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001921 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001922
1923 return err;
1924}
1925
1926static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1927 int port, struct net_device *br)
1928{
1929 struct mv88e6xxx_chip *chip = ds->priv;
1930
1931 if (!mv88e6xxx_has_pvt(chip))
1932 return;
1933
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001934 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001935 if (mv88e6xxx_pvt_map(chip, dev, port))
1936 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001937 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001938}
1939
Vivien Didelot17e708b2016-12-05 17:30:27 -05001940static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1941{
1942 if (chip->info->ops->reset)
1943 return chip->info->ops->reset(chip);
1944
1945 return 0;
1946}
1947
Vivien Didelot309eca62016-12-05 17:30:26 -05001948static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1949{
1950 struct gpio_desc *gpiod = chip->reset;
1951
1952 /* If there is a GPIO connected to the reset pin, toggle it */
1953 if (gpiod) {
1954 gpiod_set_value_cansleep(gpiod, 1);
1955 usleep_range(10000, 20000);
1956 gpiod_set_value_cansleep(gpiod, 0);
1957 usleep_range(10000, 20000);
1958 }
1959}
1960
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001961static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1962{
1963 int i, err;
1964
1965 /* Set all ports to the Disabled state */
1966 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001967 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001968 if (err)
1969 return err;
1970 }
1971
1972 /* Wait for transmit queues to drain,
1973 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1974 */
1975 usleep_range(2000, 4000);
1976
1977 return 0;
1978}
1979
Vivien Didelotfad09c72016-06-21 12:28:20 -04001980static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001981{
Vivien Didelota935c052016-09-29 12:21:53 -04001982 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001983
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001984 err = mv88e6xxx_disable_ports(chip);
1985 if (err)
1986 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001987
Vivien Didelot309eca62016-12-05 17:30:26 -05001988 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001989
Vivien Didelot17e708b2016-12-05 17:30:27 -05001990 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001991}
1992
Vivien Didelot43145572017-03-11 16:12:59 -05001993static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001994 enum mv88e6xxx_frame_mode frame,
1995 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001996{
1997 int err;
1998
Vivien Didelot43145572017-03-11 16:12:59 -05001999 if (!chip->info->ops->port_set_frame_mode)
2000 return -EOPNOTSUPP;
2001
2002 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002003 if (err)
2004 return err;
2005
Vivien Didelot43145572017-03-11 16:12:59 -05002006 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2007 if (err)
2008 return err;
2009
2010 if (chip->info->ops->port_set_ether_type)
2011 return chip->info->ops->port_set_ether_type(chip, port, etype);
2012
2013 return 0;
2014}
2015
2016static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2017{
2018 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002019 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002020 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002021}
2022
2023static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2024{
2025 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002026 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002027 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002028}
2029
2030static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2031{
2032 return mv88e6xxx_set_port_mode(chip, port,
2033 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002034 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2035 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002036}
2037
2038static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2039{
2040 if (dsa_is_dsa_port(chip->ds, port))
2041 return mv88e6xxx_set_port_mode_dsa(chip, port);
2042
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002043 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002044 return mv88e6xxx_set_port_mode_normal(chip, port);
2045
2046 /* Setup CPU port mode depending on its supported tag format */
2047 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2048 return mv88e6xxx_set_port_mode_dsa(chip, port);
2049
2050 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2051 return mv88e6xxx_set_port_mode_edsa(chip, port);
2052
2053 return -EINVAL;
2054}
2055
Vivien Didelotea698f42017-03-11 16:12:50 -05002056static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2057{
2058 bool message = dsa_is_dsa_port(chip->ds, port);
2059
2060 return mv88e6xxx_port_set_message_port(chip, port, message);
2061}
2062
Vivien Didelot601aeed2017-03-11 16:13:00 -05002063static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2064{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002065 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002066 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002067
David S. Miller407308f2019-06-15 13:35:29 -07002068 /* Upstream ports flood frames with unknown unicast or multicast DA */
2069 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2070 if (chip->info->ops->port_set_egress_floods)
2071 return chip->info->ops->port_set_egress_floods(chip, port,
2072 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002073
David S. Miller407308f2019-06-15 13:35:29 -07002074 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002075}
2076
Andrew Lunn6d917822017-05-26 01:03:21 +02002077static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2078 bool on)
2079{
Vivien Didelot523a8902017-05-26 18:02:42 -04002080 if (chip->info->ops->serdes_power)
2081 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002082
Vivien Didelot523a8902017-05-26 18:02:42 -04002083 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002084}
2085
Vivien Didelotfa371c82017-12-05 15:34:10 -05002086static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2087{
2088 struct dsa_switch *ds = chip->ds;
2089 int upstream_port;
2090 int err;
2091
Vivien Didelot07073c72017-12-05 15:34:13 -05002092 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002093 if (chip->info->ops->port_set_upstream_port) {
2094 err = chip->info->ops->port_set_upstream_port(chip, port,
2095 upstream_port);
2096 if (err)
2097 return err;
2098 }
2099
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002100 if (port == upstream_port) {
2101 if (chip->info->ops->set_cpu_port) {
2102 err = chip->info->ops->set_cpu_port(chip,
2103 upstream_port);
2104 if (err)
2105 return err;
2106 }
2107
2108 if (chip->info->ops->set_egress_port) {
2109 err = chip->info->ops->set_egress_port(chip,
2110 upstream_port);
2111 if (err)
2112 return err;
2113 }
2114 }
2115
Vivien Didelotfa371c82017-12-05 15:34:10 -05002116 return 0;
2117}
2118
Vivien Didelotfad09c72016-06-21 12:28:20 -04002119static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002120{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002121 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002122 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002123 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002124
Andrew Lunn7b898462018-08-09 15:38:47 +02002125 chip->ports[port].chip = chip;
2126 chip->ports[port].port = port;
2127
Vivien Didelotd78343d2016-11-04 03:23:36 +01002128 /* MAC Forcing register: don't force link, speed, duplex or flow control
2129 * state to any particular values on physical ports, but force the CPU
2130 * port and all DSA ports to their maximum bandwidth and full duplex.
2131 */
2132 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2133 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2134 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002135 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002136 PHY_INTERFACE_MODE_NA);
2137 else
2138 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2139 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002140 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002141 PHY_INTERFACE_MODE_NA);
2142 if (err)
2143 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002144
2145 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2146 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2147 * tunneling, determine priority by looking at 802.1p and IP
2148 * priority fields (IP prio has precedence), and set STP state
2149 * to Forwarding.
2150 *
2151 * If this is the CPU link, use DSA or EDSA tagging depending
2152 * on which tagging mode was configured.
2153 *
2154 * If this is a link to another switch, use DSA tagging mode.
2155 *
2156 * If this is the upstream port for this switch, enable
2157 * forwarding of unknown unicasts and multicasts.
2158 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002159 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2160 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2161 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2162 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002163 if (err)
2164 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002165
Vivien Didelot601aeed2017-03-11 16:13:00 -05002166 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002167 if (err)
2168 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002169
Vivien Didelot601aeed2017-03-11 16:13:00 -05002170 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002171 if (err)
2172 return err;
2173
Andrew Lunn04aca992017-05-26 01:03:24 +02002174 /* Enable the SERDES interface for DSA and CPU ports. Normal
2175 * ports SERDES are enabled when the port is enabled, thus
2176 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002177 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002178 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2179 err = mv88e6xxx_serdes_power(chip, port, true);
2180 if (err)
2181 return err;
2182 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002183
Vivien Didelot8efdda42015-08-13 12:52:23 -04002184 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002185 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002186 * untagged frames on this port, do a destination address lookup on all
2187 * received packets as usual, disable ARP mirroring and don't send a
2188 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002189 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002190 err = mv88e6xxx_port_set_map_da(chip, port);
2191 if (err)
2192 return err;
2193
Vivien Didelotfa371c82017-12-05 15:34:10 -05002194 err = mv88e6xxx_setup_upstream_port(chip, port);
2195 if (err)
2196 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002197
Andrew Lunna23b2962017-02-04 20:15:28 +01002198 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002199 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002200 if (err)
2201 return err;
2202
Vivien Didelotcd782652017-06-08 18:34:13 -04002203 if (chip->info->ops->port_set_jumbo_size) {
2204 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002205 if (err)
2206 return err;
2207 }
2208
Andrew Lunn54d792f2015-05-06 01:09:47 +02002209 /* Port Association Vector: when learning source addresses
2210 * of packets, add the address to the address database using
2211 * a port bitmap that has only the bit for this port set and
2212 * the other bits clear.
2213 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002214 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002215 /* Disable learning for CPU port */
2216 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002217 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002218
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002219 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2220 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002221 if (err)
2222 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002223
2224 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002225 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2226 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002227 if (err)
2228 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002229
Vivien Didelot08984322017-06-08 18:34:12 -04002230 if (chip->info->ops->port_pause_limit) {
2231 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002232 if (err)
2233 return err;
2234 }
2235
Vivien Didelotc8c94892017-03-11 16:13:01 -05002236 if (chip->info->ops->port_disable_learn_limit) {
2237 err = chip->info->ops->port_disable_learn_limit(chip, port);
2238 if (err)
2239 return err;
2240 }
2241
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002242 if (chip->info->ops->port_disable_pri_override) {
2243 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002244 if (err)
2245 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002246 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002247
Andrew Lunnef0a7312016-12-03 04:35:16 +01002248 if (chip->info->ops->port_tag_remap) {
2249 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002250 if (err)
2251 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002252 }
2253
Andrew Lunnef70b112016-12-03 04:45:18 +01002254 if (chip->info->ops->port_egress_rate_limiting) {
2255 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002256 if (err)
2257 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002258 }
2259
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002260 if (chip->info->ops->port_setup_message_port) {
2261 err = chip->info->ops->port_setup_message_port(chip, port);
2262 if (err)
2263 return err;
2264 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002265
Vivien Didelot207afda2016-04-14 14:42:09 -04002266 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002267 * database, and allow bidirectional communication between the
2268 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002269 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002270 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002271 if (err)
2272 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002273
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002274 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002275 if (err)
2276 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002277
2278 /* Default VLAN ID and priority: don't set a default VLAN
2279 * ID, and set the default packet priority to zero.
2280 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002281 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002282}
2283
Andrew Lunn04aca992017-05-26 01:03:24 +02002284static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2285 struct phy_device *phydev)
2286{
2287 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002288 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002289
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002290 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002291
Vivien Didelot523a8902017-05-26 18:02:42 -04002292 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002293
2294 if (!err && chip->info->ops->serdes_irq_setup)
2295 err = chip->info->ops->serdes_irq_setup(chip, port);
2296
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002297 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002298
2299 return err;
2300}
2301
Andrew Lunn75104db2019-02-24 20:44:43 +01002302static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002303{
2304 struct mv88e6xxx_chip *chip = ds->priv;
2305
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002306 mv88e6xxx_reg_lock(chip);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002307
Andrew Lunn4a0eb732019-05-01 00:08:30 +02002308 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
2309 dev_err(chip->dev, "failed to disable port\n");
2310
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002311 if (chip->info->ops->serdes_irq_free)
2312 chip->info->ops->serdes_irq_free(chip, port);
2313
Vivien Didelot523a8902017-05-26 18:02:42 -04002314 if (mv88e6xxx_serdes_power(chip, port, false))
2315 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002316
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002317 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002318}
2319
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002320static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2321 unsigned int ageing_time)
2322{
Vivien Didelot04bed142016-08-31 18:06:13 -04002323 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002324 int err;
2325
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002326 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002327 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002328 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002329
2330 return err;
2331}
2332
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002333static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002334{
2335 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002336
Andrew Lunnde2273872016-11-21 23:27:01 +01002337 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002338 if (chip->info->ops->stats_set_histogram) {
2339 err = chip->info->ops->stats_set_histogram(chip);
2340 if (err)
2341 return err;
2342 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002343
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002344 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002345}
2346
Andrew Lunnea890982019-01-09 00:24:03 +01002347/* The mv88e6390 has some hidden registers used for debug and
2348 * development. The errata also makes use of them.
2349 */
2350static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2351 int reg, u16 val)
2352{
2353 u16 ctrl;
2354 int err;
2355
2356 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2357 PORT_RESERVED_1A, val);
2358 if (err)
2359 return err;
2360
2361 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2362 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2363 reg;
2364
2365 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2366 PORT_RESERVED_1A, ctrl);
2367}
2368
2369static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2370{
Vivien Didelot19fb7f62019-08-09 18:47:55 -04002371 int bit = __bf_shf(PORT_RESERVED_1A_BUSY);
2372
2373 return mv88e6xxx_wait_bit(chip, PORT_RESERVED_1A_CTRL_PORT,
2374 PORT_RESERVED_1A, bit, 0);
Andrew Lunnea890982019-01-09 00:24:03 +01002375}
2376
2377
2378static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2379 int reg, u16 *val)
2380{
2381 u16 ctrl;
2382 int err;
2383
2384 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2385 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2386 reg;
2387
2388 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2389 PORT_RESERVED_1A, ctrl);
2390 if (err)
2391 return err;
2392
2393 err = mv88e6390_hidden_wait(chip);
2394 if (err)
2395 return err;
2396
2397 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2398 PORT_RESERVED_1A, val);
2399}
2400
2401/* Check if the errata has already been applied. */
2402static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2403{
2404 int port;
2405 int err;
2406 u16 val;
2407
2408 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2409 err = mv88e6390_hidden_read(chip, port, 0, &val);
2410 if (err) {
2411 dev_err(chip->dev,
2412 "Error reading hidden register: %d\n", err);
2413 return false;
2414 }
2415 if (val != 0x01c0)
2416 return false;
2417 }
2418
2419 return true;
2420}
2421
2422/* The 6390 copper ports have an errata which require poking magic
2423 * values into undocumented hidden registers and then performing a
2424 * software reset.
2425 */
2426static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2427{
2428 int port;
2429 int err;
2430
2431 if (mv88e6390_setup_errata_applied(chip))
2432 return 0;
2433
2434 /* Set the ports into blocking mode */
2435 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2436 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2437 if (err)
2438 return err;
2439 }
2440
2441 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2442 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2443 if (err)
2444 return err;
2445 }
2446
2447 return mv88e6xxx_software_reset(chip);
2448}
2449
Vivien Didelotf81ec902016-05-09 13:22:58 -04002450static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002451{
Vivien Didelot04bed142016-08-31 18:06:13 -04002452 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002453 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002454 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002455 int i;
2456
Vivien Didelotfad09c72016-06-21 12:28:20 -04002457 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002458 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002459
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002460 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002461
Andrew Lunnea890982019-01-09 00:24:03 +01002462 if (chip->info->ops->setup_errata) {
2463 err = chip->info->ops->setup_errata(chip);
2464 if (err)
2465 goto unlock;
2466 }
2467
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002468 /* Cache the cmode of each port. */
2469 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2470 if (chip->info->ops->port_get_cmode) {
2471 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2472 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002473 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002474
2475 chip->ports[i].cmode = cmode;
2476 }
2477 }
2478
Vivien Didelot97299342016-07-18 20:45:30 -04002479 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002480 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002481 /* Prevent the use of an invalid port. */
2482 if (mv88e6xxx_is_invalid_port(chip, i) &&
2483 !dsa_is_unused_port(ds, i)) {
2484 dev_err(chip->dev, "port %d is invalid\n", i);
2485 err = -EINVAL;
2486 goto unlock;
2487 }
2488
Andrew Lunn100a9b92019-05-01 00:08:31 +02002489 if (dsa_is_unused_port(ds, i)) {
2490 err = mv88e6xxx_port_set_state(chip, i,
2491 BR_STATE_DISABLED);
2492 if (err)
2493 goto unlock;
2494
2495 err = mv88e6xxx_serdes_power(chip, i, false);
2496 if (err)
2497 goto unlock;
2498
Vivien Didelot91dee142017-10-26 11:22:52 -04002499 continue;
Andrew Lunn100a9b92019-05-01 00:08:31 +02002500 }
Vivien Didelot91dee142017-10-26 11:22:52 -04002501
Vivien Didelot97299342016-07-18 20:45:30 -04002502 err = mv88e6xxx_setup_port(chip, i);
2503 if (err)
2504 goto unlock;
2505 }
2506
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002507 err = mv88e6xxx_irl_setup(chip);
2508 if (err)
2509 goto unlock;
2510
Vivien Didelot04a69a12017-10-13 14:18:05 -04002511 err = mv88e6xxx_mac_setup(chip);
2512 if (err)
2513 goto unlock;
2514
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002515 err = mv88e6xxx_phy_setup(chip);
2516 if (err)
2517 goto unlock;
2518
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002519 err = mv88e6xxx_vtu_setup(chip);
2520 if (err)
2521 goto unlock;
2522
Vivien Didelot81228992017-03-30 17:37:08 -04002523 err = mv88e6xxx_pvt_setup(chip);
2524 if (err)
2525 goto unlock;
2526
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002527 err = mv88e6xxx_atu_setup(chip);
2528 if (err)
2529 goto unlock;
2530
Andrew Lunn87fa8862017-11-09 22:29:56 +01002531 err = mv88e6xxx_broadcast_setup(chip, 0);
2532 if (err)
2533 goto unlock;
2534
Vivien Didelot9e907d72017-07-17 13:03:43 -04002535 err = mv88e6xxx_pot_setup(chip);
2536 if (err)
2537 goto unlock;
2538
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002539 err = mv88e6xxx_rmu_setup(chip);
2540 if (err)
2541 goto unlock;
2542
Vivien Didelot51c901a2017-07-17 13:03:41 -04002543 err = mv88e6xxx_rsvd2cpu_setup(chip);
2544 if (err)
2545 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002546
Vivien Didelotb28f8722018-04-26 21:56:44 -04002547 err = mv88e6xxx_trunk_setup(chip);
2548 if (err)
2549 goto unlock;
2550
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002551 err = mv88e6xxx_devmap_setup(chip);
2552 if (err)
2553 goto unlock;
2554
Vivien Didelot93e18d62018-05-11 17:16:35 -04002555 err = mv88e6xxx_pri_setup(chip);
2556 if (err)
2557 goto unlock;
2558
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002559 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002560 if (chip->info->ptp_support) {
2561 err = mv88e6xxx_ptp_setup(chip);
2562 if (err)
2563 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002564
2565 err = mv88e6xxx_hwtstamp_setup(chip);
2566 if (err)
2567 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002568 }
2569
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002570 err = mv88e6xxx_stats_setup(chip);
2571 if (err)
2572 goto unlock;
2573
Vivien Didelot6b17e862015-08-13 12:52:18 -04002574unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002575 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002576
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002577 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002578}
2579
Vivien Didelote57e5e72016-08-15 17:19:00 -04002580static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002581{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002582 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2583 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002584 u16 val;
2585 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002586
Andrew Lunnee26a222017-01-24 14:53:48 +01002587 if (!chip->info->ops->phy_read)
2588 return -EOPNOTSUPP;
2589
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002590 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002591 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002592 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002593
Andrew Lunnda9f3302017-02-01 03:40:05 +01002594 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002595 /* Some internal PHYs don't have a model number. */
2596 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2597 /* Then there is the 6165 family. It gets is
2598 * PHYs correct. But it can also have two
2599 * SERDES interfaces in the PHY address
2600 * space. And these don't have a model
2601 * number. But they are not PHYs, so we don't
2602 * want to give them something a PHY driver
2603 * will recognise.
2604 *
2605 * Use the mv88e6390 family model number
2606 * instead, for anything which really could be
2607 * a PHY,
2608 */
2609 if (!(val & 0x3f0))
2610 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002611 }
2612
Vivien Didelote57e5e72016-08-15 17:19:00 -04002613 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002614}
2615
Vivien Didelote57e5e72016-08-15 17:19:00 -04002616static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002617{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002618 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2619 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002620 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002621
Andrew Lunnee26a222017-01-24 14:53:48 +01002622 if (!chip->info->ops->phy_write)
2623 return -EOPNOTSUPP;
2624
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002625 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01002626 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002627 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002628
2629 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002630}
2631
Vivien Didelotfad09c72016-06-21 12:28:20 -04002632static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002633 struct device_node *np,
2634 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002635{
2636 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002637 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002638 struct mii_bus *bus;
2639 int err;
2640
Andrew Lunn2510bab2018-02-22 01:51:49 +01002641 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002642 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002643 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002644 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01002645
2646 if (err)
2647 return err;
2648 }
2649
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002650 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002651 if (!bus)
2652 return -ENOMEM;
2653
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002654 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002655 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002656 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002657 INIT_LIST_HEAD(&mdio_bus->list);
2658 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002659
Andrew Lunnb516d452016-06-04 21:17:06 +02002660 if (np) {
2661 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002662 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002663 } else {
2664 bus->name = "mv88e6xxx SMI";
2665 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2666 }
2667
2668 bus->read = mv88e6xxx_mdio_read;
2669 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002670 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002671
Andrew Lunn6f882842018-03-17 20:32:05 +01002672 if (!external) {
2673 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2674 if (err)
2675 return err;
2676 }
2677
Florian Fainelli00e798c2018-05-15 16:56:19 -07002678 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002679 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002680 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002681 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002682 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002683 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002684
2685 if (external)
2686 list_add_tail(&mdio_bus->list, &chip->mdios);
2687 else
2688 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002689
2690 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002691}
2692
Andrew Lunna3c53be52017-01-24 14:53:50 +01002693static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2694 { .compatible = "marvell,mv88e6xxx-mdio-external",
2695 .data = (void *)true },
2696 { },
2697};
2698
Andrew Lunn3126aee2017-12-07 01:05:57 +01002699static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2700
2701{
2702 struct mv88e6xxx_mdio_bus *mdio_bus;
2703 struct mii_bus *bus;
2704
2705 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2706 bus = mdio_bus->bus;
2707
Andrew Lunn6f882842018-03-17 20:32:05 +01002708 if (!mdio_bus->external)
2709 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2710
Andrew Lunn3126aee2017-12-07 01:05:57 +01002711 mdiobus_unregister(bus);
2712 }
2713}
2714
Andrew Lunna3c53be52017-01-24 14:53:50 +01002715static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2716 struct device_node *np)
2717{
2718 const struct of_device_id *match;
2719 struct device_node *child;
2720 int err;
2721
2722 /* Always register one mdio bus for the internal/default mdio
2723 * bus. This maybe represented in the device tree, but is
2724 * optional.
2725 */
2726 child = of_get_child_by_name(np, "mdio");
2727 err = mv88e6xxx_mdio_register(chip, child, false);
2728 if (err)
2729 return err;
2730
2731 /* Walk the device tree, and see if there are any other nodes
2732 * which say they are compatible with the external mdio
2733 * bus.
2734 */
2735 for_each_available_child_of_node(np, child) {
2736 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2737 if (match) {
2738 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002739 if (err) {
2740 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05302741 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002742 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002743 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002744 }
2745 }
2746
2747 return 0;
2748}
2749
Vivien Didelot855b1932016-07-20 18:18:35 -04002750static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2751{
Vivien Didelot04bed142016-08-31 18:06:13 -04002752 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002753
2754 return chip->eeprom_len;
2755}
2756
Vivien Didelot855b1932016-07-20 18:18:35 -04002757static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2758 struct ethtool_eeprom *eeprom, u8 *data)
2759{
Vivien Didelot04bed142016-08-31 18:06:13 -04002760 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002761 int err;
2762
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002763 if (!chip->info->ops->get_eeprom)
2764 return -EOPNOTSUPP;
2765
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002766 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002767 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002768 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002769
2770 if (err)
2771 return err;
2772
2773 eeprom->magic = 0xc3ec4951;
2774
2775 return 0;
2776}
2777
Vivien Didelot855b1932016-07-20 18:18:35 -04002778static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2779 struct ethtool_eeprom *eeprom, u8 *data)
2780{
Vivien Didelot04bed142016-08-31 18:06:13 -04002781 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002782 int err;
2783
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002784 if (!chip->info->ops->set_eeprom)
2785 return -EOPNOTSUPP;
2786
Vivien Didelot855b1932016-07-20 18:18:35 -04002787 if (eeprom->magic != 0xc3ec4951)
2788 return -EINVAL;
2789
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002790 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002791 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002792 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04002793
2794 return err;
2795}
2796
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002797static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002798 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002799 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2800 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002801 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002802 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002803 .phy_read = mv88e6185_phy_ppu_read,
2804 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002805 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002806 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002807 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002808 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002809 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002810 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002811 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002812 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002813 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002814 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002815 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002816 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002817 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002818 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002819 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002820 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002821 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2822 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002823 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002824 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2825 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002826 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002827 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002828 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002829 .ppu_enable = mv88e6185_g1_ppu_enable,
2830 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002831 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002832 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002833 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002834 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002835 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002836};
2837
2838static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002839 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002840 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2841 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002842 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002843 .phy_read = mv88e6185_phy_ppu_read,
2844 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002845 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002846 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002847 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002848 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002849 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002850 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002851 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002852 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002853 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002854 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002855 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002856 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2857 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002858 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002859 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002860 .ppu_enable = mv88e6185_g1_ppu_enable,
2861 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002862 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002863 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002864 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002865 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002866};
2867
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002868static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002869 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002870 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2871 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002872 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002873 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2874 .phy_read = mv88e6xxx_g2_smi_phy_read,
2875 .phy_write = mv88e6xxx_g2_smi_phy_write,
2876 .port_set_link = mv88e6xxx_port_set_link,
2877 .port_set_duplex = mv88e6xxx_port_set_duplex,
2878 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002879 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002880 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002881 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002882 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002883 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002884 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002885 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002886 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002887 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002888 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002889 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002890 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002891 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002892 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002893 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2894 .stats_get_strings = mv88e6095_stats_get_strings,
2895 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002896 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2897 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002898 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002899 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002900 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002901 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002902 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002903 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002904 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002905 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002906};
2907
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002908static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002909 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002910 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2911 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002912 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002913 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002914 .phy_read = mv88e6xxx_g2_smi_phy_read,
2915 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002916 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002917 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002918 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002919 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002920 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002921 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002922 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002923 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002924 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002925 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002926 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002927 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002928 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2929 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002930 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002931 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2932 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002933 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002934 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002935 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002936 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002937 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002938 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002939 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002940};
2941
2942static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002943 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002944 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2945 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002946 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002947 .phy_read = mv88e6185_phy_ppu_read,
2948 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002949 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002950 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002951 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002952 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002953 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002954 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002955 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002956 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002957 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002958 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002959 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002960 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002961 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002962 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002963 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002964 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002965 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002966 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2967 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002968 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002969 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2970 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002971 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002972 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002973 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002974 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002975 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002976 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002977 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002978 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002979 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002980};
2981
Vivien Didelot990e27b2017-03-28 13:50:32 -04002982static const struct mv88e6xxx_ops mv88e6141_ops = {
2983 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002984 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2985 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002986 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002987 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2988 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2989 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2990 .phy_read = mv88e6xxx_g2_smi_phy_read,
2991 .phy_write = mv88e6xxx_g2_smi_phy_write,
2992 .port_set_link = mv88e6xxx_port_set_link,
2993 .port_set_duplex = mv88e6xxx_port_set_duplex,
2994 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002995 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01002996 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002997 .port_tag_remap = mv88e6095_port_tag_remap,
2998 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2999 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3000 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003001 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003002 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003003 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003004 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3005 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003006 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003007 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003008 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003009 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003010 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003011 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3012 .stats_get_strings = mv88e6320_stats_get_strings,
3013 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003014 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3015 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003016 .watchdog_ops = &mv88e6390_watchdog_ops,
3017 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003018 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003019 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003020 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003021 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003022 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003023 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003024 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003025};
3026
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003027static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003028 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003029 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3030 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003031 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003032 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003033 .phy_read = mv88e6xxx_g2_smi_phy_read,
3034 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003035 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003036 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003037 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003038 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003039 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003040 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003041 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003042 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003043 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003044 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003045 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003046 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003047 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003048 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003049 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003050 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003051 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003052 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3053 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003054 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003055 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3056 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003057 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003058 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003059 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003060 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003061 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003062 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003063 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003064 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003065 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003066};
3067
3068static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003069 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003070 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3071 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003072 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003073 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003074 .phy_read = mv88e6165_phy_read,
3075 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003076 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003077 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003078 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003079 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003080 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003081 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003082 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003083 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003084 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003085 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003086 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3087 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003088 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003089 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3090 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003091 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003092 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003093 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003094 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003095 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003096 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003097 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003098 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003099 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003100};
3101
3102static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003103 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003104 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3105 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003106 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003107 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003108 .phy_read = mv88e6xxx_g2_smi_phy_read,
3109 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003110 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003111 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003112 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003113 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003114 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003115 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003116 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003117 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003118 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003119 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003120 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003121 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003122 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003123 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003124 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003125 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003126 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003127 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003128 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3129 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003130 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003131 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3132 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003133 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003134 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003135 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003136 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003137 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003138 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003139 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003140};
3141
3142static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003143 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003144 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3145 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003146 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003147 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3148 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003149 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003150 .phy_read = mv88e6xxx_g2_smi_phy_read,
3151 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003152 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003153 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003154 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003155 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003156 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003157 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003158 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003159 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003160 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003161 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003162 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003163 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003164 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003165 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003166 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003167 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003168 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003169 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003170 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3171 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003172 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003173 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3174 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003175 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003176 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003177 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003178 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003179 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003180 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003181 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003182 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003183 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003184 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003185};
3186
3187static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003188 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003189 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3190 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003191 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003192 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003193 .phy_read = mv88e6xxx_g2_smi_phy_read,
3194 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003195 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003196 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003197 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003198 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003199 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003200 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003201 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003202 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003203 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003204 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003205 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003206 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003207 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003208 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003209 .port_get_cmode = mv88e6352_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 = mv88e6320_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 = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003220 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003221 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003222 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003223 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003224 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003225};
3226
3227static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003228 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003229 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3230 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003231 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003232 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3233 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003234 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003235 .phy_read = mv88e6xxx_g2_smi_phy_read,
3236 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003237 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003238 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003239 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003240 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003241 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003242 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003243 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003244 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003245 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003246 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003247 .port_pause_limit = mv88e6097_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,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003252 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003253 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003254 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003255 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3256 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003257 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003258 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3259 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003260 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003261 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003262 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003263 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003264 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003265 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003266 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003267 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003268 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3269 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003270 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003271 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003272};
3273
3274static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003275 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003276 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3277 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003278 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003279 .phy_read = mv88e6185_phy_ppu_read,
3280 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003281 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003282 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003283 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003284 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003285 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003286 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003287 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003288 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003289 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003290 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003291 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003292 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003293 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003294 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3295 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003296 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003297 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3298 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003299 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003300 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003301 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003302 .ppu_enable = mv88e6185_g1_ppu_enable,
3303 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003304 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003305 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003306 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003307 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003308};
3309
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003310static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003311 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003312 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003313 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003314 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3315 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003316 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3317 .phy_read = mv88e6xxx_g2_smi_phy_read,
3318 .phy_write = mv88e6xxx_g2_smi_phy_write,
3319 .port_set_link = mv88e6xxx_port_set_link,
3320 .port_set_duplex = mv88e6xxx_port_set_duplex,
3321 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3322 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003323 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003324 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003325 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003326 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003327 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003328 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003329 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003330 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003331 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003332 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003333 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003334 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003335 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003336 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003337 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3338 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003339 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003340 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3341 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003342 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003343 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003344 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003345 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003346 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003347 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3348 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003349 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003350 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3351 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003352 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003353 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003354};
3355
3356static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003357 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003358 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003359 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003360 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3361 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003362 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3363 .phy_read = mv88e6xxx_g2_smi_phy_read,
3364 .phy_write = mv88e6xxx_g2_smi_phy_write,
3365 .port_set_link = mv88e6xxx_port_set_link,
3366 .port_set_duplex = mv88e6xxx_port_set_duplex,
3367 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3368 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003369 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003370 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003371 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003372 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003373 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003374 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003375 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003376 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003377 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003378 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003379 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003380 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003381 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003382 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003383 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3384 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003385 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003386 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3387 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003388 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003389 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003390 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003391 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003392 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003393 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3394 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003395 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003396 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3397 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003398 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003399 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003400};
3401
3402static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003403 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003404 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003405 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003406 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3407 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003408 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3409 .phy_read = mv88e6xxx_g2_smi_phy_read,
3410 .phy_write = mv88e6xxx_g2_smi_phy_write,
3411 .port_set_link = mv88e6xxx_port_set_link,
3412 .port_set_duplex = mv88e6xxx_port_set_duplex,
3413 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3414 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003415 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003416 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003417 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003418 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003419 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003420 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003421 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003422 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003423 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003424 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003425 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003426 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003427 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003428 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003429 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3430 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003431 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003432 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3433 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003434 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003435 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003436 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003437 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003438 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003439 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3440 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003441 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003442 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3443 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003444 .avb_ops = &mv88e6390_avb_ops,
3445 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003446 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003447};
3448
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003450 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003451 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3452 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003453 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003454 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3455 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003456 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003457 .phy_read = mv88e6xxx_g2_smi_phy_read,
3458 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003459 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003460 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003461 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003462 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003463 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003464 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003465 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003466 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003467 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003468 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003469 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003470 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003471 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003472 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003473 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003474 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003475 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003476 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003477 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3478 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003479 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003480 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3481 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003482 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003483 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003484 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003485 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003486 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003487 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003488 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003489 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003490 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3491 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003492 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003493 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003494 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003495 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003496};
3497
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003498static const struct mv88e6xxx_ops mv88e6250_ops = {
3499 /* MV88E6XXX_FAMILY_6250 */
3500 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3501 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3502 .irl_init_all = mv88e6352_g2_irl_init_all,
3503 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3504 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
3505 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3506 .phy_read = mv88e6xxx_g2_smi_phy_read,
3507 .phy_write = mv88e6xxx_g2_smi_phy_write,
3508 .port_set_link = mv88e6xxx_port_set_link,
3509 .port_set_duplex = mv88e6xxx_port_set_duplex,
3510 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
3511 .port_set_speed = mv88e6250_port_set_speed,
3512 .port_tag_remap = mv88e6095_port_tag_remap,
3513 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3514 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3515 .port_set_ether_type = mv88e6351_port_set_ether_type,
3516 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3517 .port_pause_limit = mv88e6097_port_pause_limit,
3518 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3519 .port_link_state = mv88e6250_port_link_state,
3520 .stats_snapshot = mv88e6320_g1_stats_snapshot,
3521 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3522 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
3523 .stats_get_strings = mv88e6250_stats_get_strings,
3524 .stats_get_stats = mv88e6250_stats_get_stats,
3525 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3526 .set_egress_port = mv88e6095_g1_set_egress_port,
3527 .watchdog_ops = &mv88e6250_watchdog_ops,
3528 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3529 .pot_clear = mv88e6xxx_g2_pot_clear,
3530 .reset = mv88e6250_g1_reset,
3531 .vtu_getnext = mv88e6250_g1_vtu_getnext,
3532 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02003533 .avb_ops = &mv88e6352_avb_ops,
3534 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003535 .phylink_validate = mv88e6065_phylink_validate,
3536};
3537
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003538static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003539 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003540 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003541 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003542 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3543 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003544 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3545 .phy_read = mv88e6xxx_g2_smi_phy_read,
3546 .phy_write = mv88e6xxx_g2_smi_phy_write,
3547 .port_set_link = mv88e6xxx_port_set_link,
3548 .port_set_duplex = mv88e6xxx_port_set_duplex,
3549 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3550 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003551 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003552 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003553 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003554 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003555 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003556 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003557 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003558 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003559 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003560 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003561 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003562 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003563 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003564 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003565 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3566 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003567 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003568 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3569 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003570 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003571 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003572 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003573 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003574 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003575 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3576 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003577 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003578 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3579 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003580 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003581 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003582 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003583 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003584};
3585
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003586static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003587 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003588 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3589 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003590 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003591 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3592 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003593 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003594 .phy_read = mv88e6xxx_g2_smi_phy_read,
3595 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003596 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003597 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003598 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003599 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003600 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003601 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003602 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003603 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003604 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003605 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003606 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003607 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003608 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003609 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003610 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003611 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003612 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003613 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3614 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003615 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003616 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3617 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003618 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003619 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003620 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003621 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003622 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003623 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003624 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003625 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003626 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003627 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628};
3629
3630static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003631 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003632 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3633 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003634 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003635 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3636 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003637 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003638 .phy_read = mv88e6xxx_g2_smi_phy_read,
3639 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003640 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003641 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003642 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003643 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003644 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003645 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003646 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003647 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003648 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003649 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003650 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003651 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003652 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003653 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003654 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003655 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003656 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003657 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3658 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003659 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003660 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3661 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003662 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003663 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003664 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003665 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003666 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003667 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003668 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003669 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003670};
3671
Vivien Didelot16e329a2017-03-28 13:50:33 -04003672static const struct mv88e6xxx_ops mv88e6341_ops = {
3673 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003674 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3675 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003676 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003677 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3678 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3679 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3680 .phy_read = mv88e6xxx_g2_smi_phy_read,
3681 .phy_write = mv88e6xxx_g2_smi_phy_write,
3682 .port_set_link = mv88e6xxx_port_set_link,
3683 .port_set_duplex = mv88e6xxx_port_set_duplex,
3684 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003685 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003686 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003687 .port_tag_remap = mv88e6095_port_tag_remap,
3688 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3689 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3690 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003691 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003692 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003693 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003694 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3695 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003696 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003697 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003698 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003699 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003700 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003701 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3702 .stats_get_strings = mv88e6320_stats_get_strings,
3703 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003704 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3705 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003706 .watchdog_ops = &mv88e6390_watchdog_ops,
3707 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003708 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003709 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003710 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003711 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003712 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003713 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003714 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003715 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003716 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003717};
3718
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003719static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003720 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003721 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3722 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003723 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003724 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003725 .phy_read = mv88e6xxx_g2_smi_phy_read,
3726 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003727 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003728 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003729 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003730 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003731 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003732 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003733 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003734 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003735 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003736 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003737 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003738 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003739 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003740 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003741 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003742 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003743 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003744 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003745 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3746 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003747 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003748 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3749 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003750 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003751 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003752 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003753 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003754 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003755 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003756 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003757};
3758
3759static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003760 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003761 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3762 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003763 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003764 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003765 .phy_read = mv88e6xxx_g2_smi_phy_read,
3766 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003767 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003768 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003769 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003770 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003771 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003772 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003773 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003774 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003775 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003776 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003777 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003778 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003779 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003780 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003781 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003782 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003783 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3786 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003788 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3789 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003790 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003791 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003792 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003793 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003794 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003795 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003796 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003797 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003798 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003799};
3800
3801static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003802 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003803 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3804 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003805 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003806 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3807 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003808 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003809 .phy_read = mv88e6xxx_g2_smi_phy_read,
3810 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003811 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003812 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003813 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003814 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003815 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003816 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003817 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003818 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003819 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003820 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003821 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003822 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003823 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003824 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003825 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003826 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003827 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003828 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003829 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3830 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003831 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003832 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3833 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003834 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003835 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003837 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003838 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003839 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003840 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003841 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003842 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3843 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003844 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003845 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003846 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003847 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3848 .serdes_get_strings = mv88e6352_serdes_get_strings,
3849 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003850 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003851};
3852
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003853static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003854 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003855 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003856 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003857 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3858 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003859 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3860 .phy_read = mv88e6xxx_g2_smi_phy_read,
3861 .phy_write = mv88e6xxx_g2_smi_phy_write,
3862 .port_set_link = mv88e6xxx_port_set_link,
3863 .port_set_duplex = mv88e6xxx_port_set_duplex,
3864 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3865 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003866 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003867 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003868 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003869 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003870 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003871 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003872 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003873 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003874 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003875 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003876 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003877 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003878 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003879 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003880 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003881 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003882 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3883 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003884 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003885 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3886 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003887 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003888 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003889 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003890 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003891 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003892 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3893 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003894 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003895 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3896 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003897 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003898 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003899 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003900 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003901};
3902
3903static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003904 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003905 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003906 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003907 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3908 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003909 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3910 .phy_read = mv88e6xxx_g2_smi_phy_read,
3911 .phy_write = mv88e6xxx_g2_smi_phy_write,
3912 .port_set_link = mv88e6xxx_port_set_link,
3913 .port_set_duplex = mv88e6xxx_port_set_duplex,
3914 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3915 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003916 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003917 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003918 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003919 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003920 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003921 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003922 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003923 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003924 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003925 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003926 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003927 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003928 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003929 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003930 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003931 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003932 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3933 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003934 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003935 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3936 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003937 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003938 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003939 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003940 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003941 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003942 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3943 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003944 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003945 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3946 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003947 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003948 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003949 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003950 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003951};
3952
Vivien Didelotf81ec902016-05-09 13:22:58 -04003953static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3954 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003955 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003956 .family = MV88E6XXX_FAMILY_6097,
3957 .name = "Marvell 88E6085",
3958 .num_databases = 4096,
3959 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003960 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003961 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003962 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003963 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003964 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003965 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003966 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003967 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003968 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003969 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003970 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003971 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003972 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003973 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003974 },
3975
3976 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003977 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003978 .family = MV88E6XXX_FAMILY_6095,
3979 .name = "Marvell 88E6095/88E6095F",
3980 .num_databases = 256,
3981 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003982 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003983 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003984 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003985 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003986 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003987 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003988 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003989 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003990 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003991 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003992 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003993 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003994 },
3995
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003996 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003997 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003998 .family = MV88E6XXX_FAMILY_6097,
3999 .name = "Marvell 88E6097/88E6097F",
4000 .num_databases = 4096,
4001 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004002 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004003 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004004 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004005 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004006 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004007 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004008 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004009 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004010 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004011 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004012 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004013 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004014 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004015 .ops = &mv88e6097_ops,
4016 },
4017
Vivien Didelotf81ec902016-05-09 13:22:58 -04004018 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004019 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004020 .family = MV88E6XXX_FAMILY_6165,
4021 .name = "Marvell 88E6123",
4022 .num_databases = 4096,
4023 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004024 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004025 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004026 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004027 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004028 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004029 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004030 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004031 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004032 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004033 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004034 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004035 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004036 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004037 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004038 },
4039
4040 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004041 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004042 .family = MV88E6XXX_FAMILY_6185,
4043 .name = "Marvell 88E6131",
4044 .num_databases = 256,
4045 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004046 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004047 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004048 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004049 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004050 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004051 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004052 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004053 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004054 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004055 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004056 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004057 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004058 },
4059
Vivien Didelot990e27b2017-03-28 13:50:32 -04004060 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004061 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004062 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004063 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004064 .num_databases = 4096,
4065 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004066 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004067 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004068 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004069 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004070 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004071 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004072 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004073 .age_time_coeff = 3750,
4074 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004075 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004076 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004077 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004078 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004079 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004080 .ops = &mv88e6141_ops,
4081 },
4082
Vivien Didelotf81ec902016-05-09 13:22:58 -04004083 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004084 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004085 .family = MV88E6XXX_FAMILY_6165,
4086 .name = "Marvell 88E6161",
4087 .num_databases = 4096,
4088 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004089 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004090 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004091 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004092 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004093 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004094 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004095 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004096 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004097 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004098 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004099 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004100 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004101 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004102 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004103 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004104 },
4105
4106 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004107 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004108 .family = MV88E6XXX_FAMILY_6165,
4109 .name = "Marvell 88E6165",
4110 .num_databases = 4096,
4111 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004112 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004113 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004114 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004115 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004116 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004117 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004118 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004119 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004120 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004121 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004122 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004123 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004124 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004125 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004126 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004127 },
4128
4129 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004130 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004131 .family = MV88E6XXX_FAMILY_6351,
4132 .name = "Marvell 88E6171",
4133 .num_databases = 4096,
4134 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004135 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004136 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004137 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004138 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004139 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004140 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004141 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004142 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004143 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004144 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004145 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004146 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004147 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004148 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004149 },
4150
4151 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004152 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004153 .family = MV88E6XXX_FAMILY_6352,
4154 .name = "Marvell 88E6172",
4155 .num_databases = 4096,
4156 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004157 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004158 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004159 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004160 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004161 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004162 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004163 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004164 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004165 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004166 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004167 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004168 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004169 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004170 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004171 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004172 },
4173
4174 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004175 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004176 .family = MV88E6XXX_FAMILY_6351,
4177 .name = "Marvell 88E6175",
4178 .num_databases = 4096,
4179 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004180 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004181 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004182 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004183 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004184 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004185 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004186 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004187 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004188 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004189 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004190 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004191 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004192 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004193 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004194 },
4195
4196 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004197 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004198 .family = MV88E6XXX_FAMILY_6352,
4199 .name = "Marvell 88E6176",
4200 .num_databases = 4096,
4201 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004202 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004203 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004204 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004205 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004206 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004207 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004208 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004209 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004210 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004211 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004212 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004213 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004214 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004215 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004216 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004217 },
4218
4219 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004220 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004221 .family = MV88E6XXX_FAMILY_6185,
4222 .name = "Marvell 88E6185",
4223 .num_databases = 256,
4224 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004225 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004226 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004227 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004228 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004229 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004230 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004231 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004232 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004233 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004234 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004235 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004236 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004237 },
4238
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004239 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004240 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004241 .family = MV88E6XXX_FAMILY_6390,
4242 .name = "Marvell 88E6190",
4243 .num_databases = 4096,
4244 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004245 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004246 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004247 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004248 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004249 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004250 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004251 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004252 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004253 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004254 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004255 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004256 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004257 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004258 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004259 .ops = &mv88e6190_ops,
4260 },
4261
4262 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004263 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004264 .family = MV88E6XXX_FAMILY_6390,
4265 .name = "Marvell 88E6190X",
4266 .num_databases = 4096,
4267 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004268 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004269 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004270 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004271 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004272 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004273 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004274 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004275 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004276 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004277 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004278 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004279 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004280 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004281 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004282 .ops = &mv88e6190x_ops,
4283 },
4284
4285 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004286 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004287 .family = MV88E6XXX_FAMILY_6390,
4288 .name = "Marvell 88E6191",
4289 .num_databases = 4096,
4290 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004291 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004292 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004293 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004294 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004295 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004296 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004297 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004298 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004299 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004300 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004301 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004302 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004303 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004304 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004305 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004306 },
4307
Hubert Feurstein49022642019-07-31 10:23:46 +02004308 [MV88E6220] = {
4309 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4310 .family = MV88E6XXX_FAMILY_6250,
4311 .name = "Marvell 88E6220",
4312 .num_databases = 64,
4313
4314 /* Ports 2-4 are not routed to pins
4315 * => usable ports 0, 1, 5, 6
4316 */
4317 .num_ports = 7,
4318 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004319 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004320 .max_vid = 4095,
4321 .port_base_addr = 0x08,
4322 .phy_base_addr = 0x00,
4323 .global1_addr = 0x0f,
4324 .global2_addr = 0x07,
4325 .age_time_coeff = 15000,
4326 .g1_irqs = 9,
4327 .g2_irqs = 10,
4328 .atu_move_port_mask = 0xf,
4329 .dual_chip = true,
4330 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004331 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004332 .ops = &mv88e6250_ops,
4333 },
4334
Vivien Didelotf81ec902016-05-09 13:22:58 -04004335 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004336 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004337 .family = MV88E6XXX_FAMILY_6352,
4338 .name = "Marvell 88E6240",
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 = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004350 .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 = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004357 },
4358
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004359 [MV88E6250] = {
4360 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4361 .family = MV88E6XXX_FAMILY_6250,
4362 .name = "Marvell 88E6250",
4363 .num_databases = 64,
4364 .num_ports = 7,
4365 .num_internal_phys = 5,
4366 .max_vid = 4095,
4367 .port_base_addr = 0x08,
4368 .phy_base_addr = 0x00,
4369 .global1_addr = 0x0f,
4370 .global2_addr = 0x07,
4371 .age_time_coeff = 15000,
4372 .g1_irqs = 9,
4373 .g2_irqs = 10,
4374 .atu_move_port_mask = 0xf,
4375 .dual_chip = true,
4376 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004377 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004378 .ops = &mv88e6250_ops,
4379 },
4380
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004381 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004382 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004383 .family = MV88E6XXX_FAMILY_6390,
4384 .name = "Marvell 88E6290",
4385 .num_databases = 4096,
4386 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004387 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004388 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004389 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004390 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004391 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004392 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004393 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004394 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004395 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004396 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004397 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004398 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004399 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004400 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004401 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004402 .ops = &mv88e6290_ops,
4403 },
4404
Vivien Didelotf81ec902016-05-09 13:22:58 -04004405 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004406 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004407 .family = MV88E6XXX_FAMILY_6320,
4408 .name = "Marvell 88E6320",
4409 .num_databases = 4096,
4410 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004411 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004412 .num_gpio = 15,
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 = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004420 .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,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004425 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004426 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004427 },
4428
4429 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004430 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004431 .family = MV88E6XXX_FAMILY_6320,
4432 .name = "Marvell 88E6321",
4433 .num_databases = 4096,
4434 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004435 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004436 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004437 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004438 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004439 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004440 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004441 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004442 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004443 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004444 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004445 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004446 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004447 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004448 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004449 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004450 },
4451
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004452 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004453 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004454 .family = MV88E6XXX_FAMILY_6341,
4455 .name = "Marvell 88E6341",
4456 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004457 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004458 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004459 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004460 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004461 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004462 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004463 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004464 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004465 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004466 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004468 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004469 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004470 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004471 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004472 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004473 .ops = &mv88e6341_ops,
4474 },
4475
Vivien Didelotf81ec902016-05-09 13:22:58 -04004476 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004477 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004478 .family = MV88E6XXX_FAMILY_6351,
4479 .name = "Marvell 88E6350",
4480 .num_databases = 4096,
4481 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004482 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004483 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004484 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004485 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004486 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004487 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004488 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004489 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004490 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004491 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004492 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004493 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004494 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004495 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004496 },
4497
4498 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004499 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004500 .family = MV88E6XXX_FAMILY_6351,
4501 .name = "Marvell 88E6351",
4502 .num_databases = 4096,
4503 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004504 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004505 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004506 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004507 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004508 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004509 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004510 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004511 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004512 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004513 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004514 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004515 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004516 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004517 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004518 },
4519
4520 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004521 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004522 .family = MV88E6XXX_FAMILY_6352,
4523 .name = "Marvell 88E6352",
4524 .num_databases = 4096,
4525 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004526 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004527 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004528 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004529 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004530 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004531 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004532 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004533 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004534 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004535 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004536 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004537 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004538 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004539 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004540 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004541 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004542 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004543 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004544 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004545 .family = MV88E6XXX_FAMILY_6390,
4546 .name = "Marvell 88E6390",
4547 .num_databases = 4096,
4548 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004549 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004550 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004551 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004552 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004553 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004554 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004555 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004556 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004557 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004558 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004559 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004560 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004561 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004562 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004563 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004564 .ops = &mv88e6390_ops,
4565 },
4566 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004567 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004568 .family = MV88E6XXX_FAMILY_6390,
4569 .name = "Marvell 88E6390X",
4570 .num_databases = 4096,
4571 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004572 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004573 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004574 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004575 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004576 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004577 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004578 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004579 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004580 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004581 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004582 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004583 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004584 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004585 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004586 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004587 .ops = &mv88e6390x_ops,
4588 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004589};
4590
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004591static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004592{
Vivien Didelota439c062016-04-17 13:23:58 -04004593 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004594
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004595 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4596 if (mv88e6xxx_table[i].prod_num == prod_num)
4597 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004598
Vivien Didelotb9b37712015-10-30 19:39:48 -04004599 return NULL;
4600}
4601
Vivien Didelotfad09c72016-06-21 12:28:20 -04004602static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004603{
4604 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004605 unsigned int prod_num, rev;
4606 u16 id;
4607 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004608
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004609 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004610 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004611 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004612 if (err)
4613 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004614
Vivien Didelot107fcc12017-06-12 12:37:36 -04004615 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4616 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004617
4618 info = mv88e6xxx_lookup_info(prod_num);
4619 if (!info)
4620 return -ENODEV;
4621
Vivien Didelotcaac8542016-06-20 13:14:09 -04004622 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004623 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004624
Vivien Didelotca070c12016-09-02 14:45:34 -04004625 err = mv88e6xxx_g2_require(chip);
4626 if (err)
4627 return err;
4628
Vivien Didelotfad09c72016-06-21 12:28:20 -04004629 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4630 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004631
4632 return 0;
4633}
4634
Vivien Didelotfad09c72016-06-21 12:28:20 -04004635static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004636{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004637 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004638
Vivien Didelotfad09c72016-06-21 12:28:20 -04004639 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4640 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004641 return NULL;
4642
Vivien Didelotfad09c72016-06-21 12:28:20 -04004643 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004644
Vivien Didelotfad09c72016-06-21 12:28:20 -04004645 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004646 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004647
Vivien Didelotfad09c72016-06-21 12:28:20 -04004648 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004649}
4650
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004651static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4652 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004653{
Vivien Didelot04bed142016-08-31 18:06:13 -04004654 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004655
Andrew Lunn443d5a12016-12-03 04:35:18 +01004656 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004657}
4658
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004659static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004660 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004661{
4662 /* We don't need any dynamic resource from the kernel (yet),
4663 * so skip the prepare phase.
4664 */
4665
4666 return 0;
4667}
4668
4669static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004670 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004671{
Vivien Didelot04bed142016-08-31 18:06:13 -04004672 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004673
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004674 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004675 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004676 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004677 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4678 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004679 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004680}
4681
4682static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4683 const struct switchdev_obj_port_mdb *mdb)
4684{
Vivien Didelot04bed142016-08-31 18:06:13 -04004685 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004686 int err;
4687
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004688 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004689 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004690 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004691 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004692
4693 return err;
4694}
4695
Russell King4f859012019-02-20 15:35:05 -08004696static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4697 bool unicast, bool multicast)
4698{
4699 struct mv88e6xxx_chip *chip = ds->priv;
4700 int err = -EOPNOTSUPP;
4701
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004702 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08004703 if (chip->info->ops->port_set_egress_floods)
4704 err = chip->info->ops->port_set_egress_floods(chip, port,
4705 unicast,
4706 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004707 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08004708
4709 return err;
4710}
4711
Florian Fainellia82f67a2017-01-08 14:52:08 -08004712static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02004713 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004714 .setup = mv88e6xxx_setup,
Russell Kingc9a23562018-05-10 13:17:35 -07004715 .phylink_validate = mv88e6xxx_validate,
4716 .phylink_mac_link_state = mv88e6xxx_link_state,
4717 .phylink_mac_config = mv88e6xxx_mac_config,
4718 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4719 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004720 .get_strings = mv88e6xxx_get_strings,
4721 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4722 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004723 .port_enable = mv88e6xxx_port_enable,
4724 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004725 .get_mac_eee = mv88e6xxx_get_mac_eee,
4726 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004727 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 .get_eeprom = mv88e6xxx_get_eeprom,
4729 .set_eeprom = mv88e6xxx_set_eeprom,
4730 .get_regs_len = mv88e6xxx_get_regs_len,
4731 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004732 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004733 .port_bridge_join = mv88e6xxx_port_bridge_join,
4734 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004735 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004736 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004737 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4739 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4740 .port_vlan_add = mv88e6xxx_port_vlan_add,
4741 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004742 .port_fdb_add = mv88e6xxx_port_fdb_add,
4743 .port_fdb_del = mv88e6xxx_port_fdb_del,
4744 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004745 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4746 .port_mdb_add = mv88e6xxx_port_mdb_add,
4747 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004748 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4749 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004750 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4751 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4752 .port_txtstamp = mv88e6xxx_port_txtstamp,
4753 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4754 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004755};
4756
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004757static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004758{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004759 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004760 struct dsa_switch *ds;
4761
Vivien Didelot73b12042017-03-30 17:37:10 -04004762 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004763 if (!ds)
4764 return -ENOMEM;
4765
Vivien Didelotfad09c72016-06-21 12:28:20 -04004766 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004767 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004768 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004769 ds->ageing_time_min = chip->info->age_time_coeff;
4770 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004771
4772 dev_set_drvdata(dev, ds);
4773
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004774 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004775}
4776
Vivien Didelotfad09c72016-06-21 12:28:20 -04004777static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004778{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004779 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004780}
4781
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004782static const void *pdata_device_get_match_data(struct device *dev)
4783{
4784 const struct of_device_id *matches = dev->driver->of_match_table;
4785 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4786
4787 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4788 matches++) {
4789 if (!strcmp(pdata->compatible, matches->compatible))
4790 return matches->data;
4791 }
4792 return NULL;
4793}
4794
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004795/* There is no suspend to RAM support at DSA level yet, the switch configuration
4796 * would be lost after a power cycle so prevent it to be suspended.
4797 */
4798static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4799{
4800 return -EOPNOTSUPP;
4801}
4802
4803static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4804{
4805 return 0;
4806}
4807
4808static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4809
Vivien Didelot57d32312016-06-20 13:13:58 -04004810static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004811{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004812 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004813 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004814 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004815 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004816 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004817 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004818 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004819
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004820 if (!np && !pdata)
4821 return -EINVAL;
4822
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004823 if (np)
4824 compat_info = of_device_get_match_data(dev);
4825
4826 if (pdata) {
4827 compat_info = pdata_device_get_match_data(dev);
4828
4829 if (!pdata->netdev)
4830 return -EINVAL;
4831
4832 for (port = 0; port < DSA_MAX_PORTS; port++) {
4833 if (!(pdata->enabled_ports & (1 << port)))
4834 continue;
4835 if (strcmp(pdata->cd.port_names[port], "cpu"))
4836 continue;
4837 pdata->cd.netdev[port] = &pdata->netdev->dev;
4838 break;
4839 }
4840 }
4841
Vivien Didelotcaac8542016-06-20 13:14:09 -04004842 if (!compat_info)
4843 return -EINVAL;
4844
Vivien Didelotfad09c72016-06-21 12:28:20 -04004845 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004846 if (!chip) {
4847 err = -ENOMEM;
4848 goto out;
4849 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004850
Vivien Didelotfad09c72016-06-21 12:28:20 -04004851 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004852
Vivien Didelotfad09c72016-06-21 12:28:20 -04004853 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004854 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004855 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004856
Andrew Lunnb4308f02016-11-21 23:26:55 +01004857 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004858 if (IS_ERR(chip->reset)) {
4859 err = PTR_ERR(chip->reset);
4860 goto out;
4861 }
Baruch Siach7b75e492019-06-27 21:17:39 +03004862 if (chip->reset)
4863 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01004864
Vivien Didelotfad09c72016-06-21 12:28:20 -04004865 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004866 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004867 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004868
Vivien Didelote57e5e72016-08-15 17:19:00 -04004869 mv88e6xxx_phy_init(chip);
4870
Andrew Lunn00baabe2018-05-19 22:31:35 +02004871 if (chip->info->ops->get_eeprom) {
4872 if (np)
4873 of_property_read_u32(np, "eeprom-length",
4874 &chip->eeprom_len);
4875 else
4876 chip->eeprom_len = pdata->eeprom_len;
4877 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004878
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004879 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004880 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004881 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02004882 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004883 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004884
Andrew Lunna27415d2019-05-01 00:10:50 +02004885 if (np) {
4886 chip->irq = of_irq_get(np, 0);
4887 if (chip->irq == -EPROBE_DEFER) {
4888 err = chip->irq;
4889 goto out;
4890 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004891 }
4892
Andrew Lunna27415d2019-05-01 00:10:50 +02004893 if (pdata)
4894 chip->irq = pdata->irq;
4895
Andrew Lunn294d7112018-02-22 22:58:32 +01004896 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004897 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004898 * controllers
4899 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004900 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004901 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004902 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004903 else
4904 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00004905 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004906
Andrew Lunn294d7112018-02-22 22:58:32 +01004907 if (err)
4908 goto out;
4909
4910 if (chip->info->g2_irqs > 0) {
4911 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004912 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004913 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004914 }
4915
Andrew Lunn294d7112018-02-22 22:58:32 +01004916 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4917 if (err)
4918 goto out_g2_irq;
4919
4920 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4921 if (err)
4922 goto out_g1_atu_prob_irq;
4923
Andrew Lunna3c53be52017-01-24 14:53:50 +01004924 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004925 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004926 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004927
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004928 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004929 if (err)
4930 goto out_mdio;
4931
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004932 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004933
4934out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004935 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004936out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004937 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004938out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004939 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004940out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004941 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004942 mv88e6xxx_g2_irq_free(chip);
4943out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004944 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004945 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004946 else
4947 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004948out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004949 if (pdata)
4950 dev_put(pdata->netdev);
4951
Andrew Lunndc30c352016-10-16 19:56:49 +02004952 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004953}
4954
4955static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4956{
4957 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004958 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004959
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004960 if (chip->info->ptp_support) {
4961 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004962 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004963 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004964
Andrew Lunn930188c2016-08-22 16:01:03 +02004965 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004966 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004967 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004968
Andrew Lunn76f38f12018-03-17 20:21:09 +01004969 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4970 mv88e6xxx_g1_atu_prob_irq_free(chip);
4971
4972 if (chip->info->g2_irqs > 0)
4973 mv88e6xxx_g2_irq_free(chip);
4974
Andrew Lunn76f38f12018-03-17 20:21:09 +01004975 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004976 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004977 else
4978 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004979}
4980
4981static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004982 {
4983 .compatible = "marvell,mv88e6085",
4984 .data = &mv88e6xxx_table[MV88E6085],
4985 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004986 {
4987 .compatible = "marvell,mv88e6190",
4988 .data = &mv88e6xxx_table[MV88E6190],
4989 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004990 {
4991 .compatible = "marvell,mv88e6250",
4992 .data = &mv88e6xxx_table[MV88E6250],
4993 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004994 { /* sentinel */ },
4995};
4996
4997MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4998
4999static struct mdio_driver mv88e6xxx_driver = {
5000 .probe = mv88e6xxx_probe,
5001 .remove = mv88e6xxx_remove,
5002 .mdiodrv.driver = {
5003 .name = "mv88e6085",
5004 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005005 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005006 },
5007};
5008
Andrew Lunn7324d502019-04-27 19:19:10 +02005009mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005010
5011MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5012MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5013MODULE_LICENSE("GPL");