blob: 0dbe6c8b9dc09897a5cf963e1679bd9259030fee [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000343 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100344 err = request_threaded_irq(chip->irq, NULL,
345 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200346 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 dev_name(chip->dev), chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000348 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100349 if (err)
350 mv88e6xxx_g1_irq_free_common(chip);
351
352 return err;
353}
354
355static void mv88e6xxx_irq_poll(struct kthread_work *work)
356{
357 struct mv88e6xxx_chip *chip = container_of(work,
358 struct mv88e6xxx_chip,
359 irq_poll_work.work);
360 mv88e6xxx_g1_irq_thread_work(chip);
361
362 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
363 msecs_to_jiffies(100));
364}
365
366static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
367{
368 int err;
369
370 err = mv88e6xxx_g1_irq_setup_common(chip);
371 if (err)
372 return err;
373
374 kthread_init_delayed_work(&chip->irq_poll_work,
375 mv88e6xxx_irq_poll);
376
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800377 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100378 if (IS_ERR(chip->kworker))
379 return PTR_ERR(chip->kworker);
380
381 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
382 msecs_to_jiffies(100));
383
384 return 0;
385}
386
387static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
388{
389 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
390 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200391
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000392 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200393 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000394 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100395}
396
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100397int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
398 int speed, int duplex, int pause,
399 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100400{
Andrew Lunna26deec2019-04-18 03:11:39 +0200401 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100402 int err;
403
404 if (!chip->info->ops->port_set_link)
405 return 0;
406
Andrew Lunna26deec2019-04-18 03:11:39 +0200407 if (!chip->info->ops->port_link_state)
408 return 0;
409
410 err = chip->info->ops->port_link_state(chip, port, &state);
411 if (err)
412 return err;
413
414 /* Has anything actually changed? We don't expect the
415 * interface mode to change without one of the other
416 * parameters also changing
417 */
418 if (state.link == link &&
419 state.speed == speed &&
Marek Behún927441a2019-08-14 16:40:24 +0200420 state.duplex == duplex &&
421 (state.interface == mode ||
422 state.interface == PHY_INTERFACE_MODE_NA))
Andrew Lunna26deec2019-04-18 03:11:39 +0200423 return 0;
424
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200426 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100427 if (err)
428 return err;
429
430 if (chip->info->ops->port_set_speed) {
431 err = chip->info->ops->port_set_speed(chip, port, speed);
432 if (err && err != -EOPNOTSUPP)
433 goto restore_link;
434 }
435
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100436 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
437 mode = chip->info->ops->port_max_speed_mode(port);
438
Andrew Lunn54186b92018-08-09 15:38:37 +0200439 if (chip->info->ops->port_set_pause) {
440 err = chip->info->ops->port_set_pause(chip, port, pause);
441 if (err)
442 goto restore_link;
443 }
444
Vivien Didelotd78343d2016-11-04 03:23:36 +0100445 if (chip->info->ops->port_set_duplex) {
446 err = chip->info->ops->port_set_duplex(chip, port, duplex);
447 if (err && err != -EOPNOTSUPP)
448 goto restore_link;
449 }
450
451 if (chip->info->ops->port_set_rgmii_delay) {
452 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
453 if (err && err != -EOPNOTSUPP)
454 goto restore_link;
455 }
456
Andrew Lunnf39908d2017-02-04 20:02:50 +0100457 if (chip->info->ops->port_set_cmode) {
458 err = chip->info->ops->port_set_cmode(chip, port, mode);
459 if (err && err != -EOPNOTSUPP)
460 goto restore_link;
461 }
462
Vivien Didelotd78343d2016-11-04 03:23:36 +0100463 err = 0;
464restore_link:
465 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400466 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100467
468 return err;
469}
470
Marek Vasutd700ec42018-09-12 00:15:24 +0200471static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
472{
473 struct mv88e6xxx_chip *chip = ds->priv;
474
475 return port < chip->info->num_internal_phys;
476}
477
Russell King6c422e32018-08-09 15:38:39 +0200478static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
479 unsigned long *mask,
480 struct phylink_link_state *state)
481{
482 if (!phy_interface_mode_is_8023z(state->interface)) {
483 /* 10M and 100M are only supported in non-802.3z mode */
484 phylink_set(mask, 10baseT_Half);
485 phylink_set(mask, 10baseT_Full);
486 phylink_set(mask, 100baseT_Half);
487 phylink_set(mask, 100baseT_Full);
488 }
489}
490
491static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
492 unsigned long *mask,
493 struct phylink_link_state *state)
494{
495 /* FIXME: if the port is in 1000Base-X mode, then it only supports
496 * 1000M FD speeds. In this case, CMODE will indicate 5.
497 */
498 phylink_set(mask, 1000baseT_Full);
499 phylink_set(mask, 1000baseX_Full);
500
501 mv88e6065_phylink_validate(chip, port, mask, state);
502}
503
Marek Behúne3af71a2019-02-25 12:39:55 +0100504static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
505 unsigned long *mask,
506 struct phylink_link_state *state)
507{
508 if (port >= 5)
509 phylink_set(mask, 2500baseX_Full);
510
511 /* No ethtool bits for 200Mbps */
512 phylink_set(mask, 1000baseT_Full);
513 phylink_set(mask, 1000baseX_Full);
514
515 mv88e6065_phylink_validate(chip, port, mask, state);
516}
517
Russell King6c422e32018-08-09 15:38:39 +0200518static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
519 unsigned long *mask,
520 struct phylink_link_state *state)
521{
522 /* No ethtool bits for 200Mbps */
523 phylink_set(mask, 1000baseT_Full);
524 phylink_set(mask, 1000baseX_Full);
525
526 mv88e6065_phylink_validate(chip, port, mask, state);
527}
528
529static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
530 unsigned long *mask,
531 struct phylink_link_state *state)
532{
Andrew Lunnec260162019-02-08 22:25:44 +0100533 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200534 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100535 phylink_set(mask, 2500baseT_Full);
536 }
Russell King6c422e32018-08-09 15:38:39 +0200537
538 /* No ethtool bits for 200Mbps */
539 phylink_set(mask, 1000baseT_Full);
540 phylink_set(mask, 1000baseX_Full);
541
542 mv88e6065_phylink_validate(chip, port, mask, state);
543}
544
545static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
546 unsigned long *mask,
547 struct phylink_link_state *state)
548{
549 if (port >= 9) {
550 phylink_set(mask, 10000baseT_Full);
551 phylink_set(mask, 10000baseKR_Full);
552 }
553
554 mv88e6390_phylink_validate(chip, port, mask, state);
555}
556
Russell Kingc9a23562018-05-10 13:17:35 -0700557static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
558 unsigned long *supported,
559 struct phylink_link_state *state)
560{
Russell King6c422e32018-08-09 15:38:39 +0200561 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
562 struct mv88e6xxx_chip *chip = ds->priv;
563
564 /* Allow all the expected bits */
565 phylink_set(mask, Autoneg);
566 phylink_set(mask, Pause);
567 phylink_set_port_modes(mask);
568
569 if (chip->info->ops->phylink_validate)
570 chip->info->ops->phylink_validate(chip, port, mask, state);
571
572 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
573 bitmap_and(state->advertising, state->advertising, mask,
574 __ETHTOOL_LINK_MODE_MASK_NBITS);
575
576 /* We can only operate at 2500BaseX or 1000BaseX. If requested
577 * to advertise both, only report advertising at 2500BaseX.
578 */
579 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700580}
581
582static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
583 struct phylink_link_state *state)
584{
585 struct mv88e6xxx_chip *chip = ds->priv;
586 int err;
587
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000588 mv88e6xxx_reg_lock(chip);
Russell King6c422e32018-08-09 15:38:39 +0200589 if (chip->info->ops->port_link_state)
590 err = chip->info->ops->port_link_state(chip, port, state);
591 else
592 err = -EOPNOTSUPP;
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000593 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700594
595 return err;
596}
597
598static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
599 unsigned int mode,
600 const struct phylink_link_state *state)
601{
602 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200603 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700604
Marek Vasutd700ec42018-09-12 00:15:24 +0200605 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700606 return;
607
608 if (mode == MLO_AN_FIXED) {
609 link = LINK_FORCED_UP;
610 speed = state->speed;
611 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200612 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
613 link = state->link;
614 speed = state->speed;
615 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700616 } else {
617 speed = SPEED_UNFORCED;
618 duplex = DUPLEX_UNFORCED;
619 link = LINK_UNFORCED;
620 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200621 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700622
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000623 mv88e6xxx_reg_lock(chip);
Andrew Lunn54186b92018-08-09 15:38:37 +0200624 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700625 state->interface);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000626 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700627
628 if (err && err != -EOPNOTSUPP)
629 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
630}
631
632static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
633{
634 struct mv88e6xxx_chip *chip = ds->priv;
635 int err;
636
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000637 mv88e6xxx_reg_lock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700638 err = chip->info->ops->port_set_link(chip, port, link);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000639 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700640
641 if (err)
642 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
643}
644
645static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
646 unsigned int mode,
647 phy_interface_t interface)
648{
649 if (mode == MLO_AN_FIXED)
650 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
651}
652
653static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
654 unsigned int mode, phy_interface_t interface,
655 struct phy_device *phydev)
656{
657 if (mode == MLO_AN_FIXED)
658 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
659}
660
Andrew Lunna605a0f2016-11-21 23:26:58 +0100661static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000662{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100663 if (!chip->info->ops->stats_snapshot)
664 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000667}
668
Andrew Lunne413e7e2015-04-02 04:06:38 +0200669static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100670 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
671 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
672 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
673 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
674 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
675 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
676 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
677 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
678 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
679 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
680 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
681 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
682 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
683 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
684 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
685 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
686 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
687 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
688 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
689 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
690 { "single", 4, 0x14, STATS_TYPE_BANK0, },
691 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
692 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
693 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
694 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
695 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
696 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
697 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
698 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
699 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
700 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
701 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
702 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
703 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
704 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
705 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
706 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
707 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
708 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
709 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
710 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
711 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
712 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
713 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
714 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
715 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
716 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
717 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
718 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
719 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
720 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
721 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
722 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
723 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
724 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
725 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
726 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
727 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
728 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200729};
730
Vivien Didelotfad09c72016-06-21 12:28:20 -0400731static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100732 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100733 int port, u16 bank1_select,
734 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200735{
Andrew Lunn80c46272015-06-20 18:42:30 +0200736 u32 low;
737 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100738 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200739 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200740 u64 value;
741
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100742 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100743 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200744 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
745 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800746 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200747
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200748 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100749 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200750 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
751 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800752 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000753 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200754 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100755 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100756 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100757 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100758 /* fall through */
759 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100761 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100762 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100763 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500764 break;
765 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800766 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200767 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100768 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200769 return value;
770}
771
Andrew Lunn436fe172018-03-01 02:02:29 +0100772static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
773 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100774{
775 struct mv88e6xxx_hw_stat *stat;
776 int i, j;
777
778 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
779 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100780 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100781 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
782 ETH_GSTRING_LEN);
783 j++;
784 }
785 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100786
787 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100788}
789
Andrew Lunn436fe172018-03-01 02:02:29 +0100790static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
791 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100792{
Andrew Lunn436fe172018-03-01 02:02:29 +0100793 return mv88e6xxx_stats_get_strings(chip, data,
794 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100795}
796
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000797static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
798 uint8_t *data)
799{
800 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
801}
802
Andrew Lunn436fe172018-03-01 02:02:29 +0100803static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
804 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100805{
Andrew Lunn436fe172018-03-01 02:02:29 +0100806 return mv88e6xxx_stats_get_strings(chip, data,
807 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100808}
809
Andrew Lunn65f60e42018-03-28 23:50:28 +0200810static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
811 "atu_member_violation",
812 "atu_miss_violation",
813 "atu_full_violation",
814 "vtu_member_violation",
815 "vtu_miss_violation",
816};
817
818static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
819{
820 unsigned int i;
821
822 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
823 strlcpy(data + i * ETH_GSTRING_LEN,
824 mv88e6xxx_atu_vtu_stats_strings[i],
825 ETH_GSTRING_LEN);
826}
827
Andrew Lunndfafe442016-11-21 23:27:02 +0100828static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700829 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100830{
Vivien Didelot04bed142016-08-31 18:06:13 -0400831 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100832 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100833
Florian Fainelli89f09042018-04-25 12:12:50 -0700834 if (stringset != ETH_SS_STATS)
835 return;
836
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000837 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100838
Andrew Lunndfafe442016-11-21 23:27:02 +0100839 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100840 count = chip->info->ops->stats_get_strings(chip, data);
841
842 if (chip->info->ops->serdes_get_strings) {
843 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200844 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100845 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100846
Andrew Lunn65f60e42018-03-28 23:50:28 +0200847 data += count * ETH_GSTRING_LEN;
848 mv88e6xxx_atu_vtu_get_strings(data);
849
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000850 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100851}
852
853static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
854 int types)
855{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100856 struct mv88e6xxx_hw_stat *stat;
857 int i, j;
858
859 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
860 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100861 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100862 j++;
863 }
864 return j;
865}
866
Andrew Lunndfafe442016-11-21 23:27:02 +0100867static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
868{
869 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
870 STATS_TYPE_PORT);
871}
872
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000873static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
874{
875 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
876}
877
Andrew Lunndfafe442016-11-21 23:27:02 +0100878static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
879{
880 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
881 STATS_TYPE_BANK1);
882}
883
Florian Fainelli89f09042018-04-25 12:12:50 -0700884static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100885{
886 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100887 int serdes_count = 0;
888 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100889
Florian Fainelli89f09042018-04-25 12:12:50 -0700890 if (sset != ETH_SS_STATS)
891 return 0;
892
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000893 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100894 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100895 count = chip->info->ops->stats_get_sset_count(chip);
896 if (count < 0)
897 goto out;
898
899 if (chip->info->ops->serdes_get_sset_count)
900 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
901 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200902 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100903 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200904 goto out;
905 }
906 count += serdes_count;
907 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
908
Andrew Lunn436fe172018-03-01 02:02:29 +0100909out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000910 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100913}
914
Andrew Lunn436fe172018-03-01 02:02:29 +0100915static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
916 uint64_t *data, int types,
917 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100918{
919 struct mv88e6xxx_hw_stat *stat;
920 int i, j;
921
922 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
923 stat = &mv88e6xxx_hw_stats[i];
924 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000925 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100926 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
927 bank1_select,
928 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000929 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +0100930
Andrew Lunn052f9472016-11-21 23:27:03 +0100931 j++;
932 }
933 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100934 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100935}
936
Andrew Lunn436fe172018-03-01 02:02:29 +0100937static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
938 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100939{
940 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100941 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400942 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100943}
944
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000945static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
946 uint64_t *data)
947{
948 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
949 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
950}
951
Andrew Lunn436fe172018-03-01 02:02:29 +0100952static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
953 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100954{
955 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100956 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400957 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
958 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100959}
960
Andrew Lunn436fe172018-03-01 02:02:29 +0100961static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
962 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100963{
964 return mv88e6xxx_stats_get_stats(chip, port, data,
965 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400966 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
967 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100968}
969
Andrew Lunn65f60e42018-03-28 23:50:28 +0200970static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
971 uint64_t *data)
972{
973 *data++ = chip->ports[port].atu_member_violation;
974 *data++ = chip->ports[port].atu_miss_violation;
975 *data++ = chip->ports[port].atu_full_violation;
976 *data++ = chip->ports[port].vtu_member_violation;
977 *data++ = chip->ports[port].vtu_miss_violation;
978}
979
Andrew Lunn052f9472016-11-21 23:27:03 +0100980static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
981 uint64_t *data)
982{
Andrew Lunn436fe172018-03-01 02:02:29 +0100983 int count = 0;
984
Andrew Lunn052f9472016-11-21 23:27:03 +0100985 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100986 count = chip->info->ops->stats_get_stats(chip, port, data);
987
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000988 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 if (chip->info->ops->serdes_get_stats) {
990 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200991 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100992 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200993 data += count;
994 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000995 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +0100996}
997
Vivien Didelotf81ec902016-05-09 13:22:58 -0400998static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
999 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001000{
Vivien Didelot04bed142016-08-31 18:06:13 -04001001 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001002 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001003
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001004 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001005
Andrew Lunna605a0f2016-11-21 23:26:58 +01001006 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001007 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001008
1009 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001010 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001011
1012 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001013
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001014}
Ben Hutchings98e67302011-11-25 14:36:19 +00001015
Vivien Didelotf81ec902016-05-09 13:22:58 -04001016static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001017{
1018 return 32 * sizeof(u16);
1019}
1020
Vivien Didelotf81ec902016-05-09 13:22:58 -04001021static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1022 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001023{
Vivien Didelot04bed142016-08-31 18:06:13 -04001024 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001025 int err;
1026 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001027 u16 *p = _p;
1028 int i;
1029
Vivien Didelota5f39322018-12-17 16:05:21 -05001030 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001031
1032 memset(p, 0xff, 32 * sizeof(u16));
1033
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001034 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001035
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001036 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001037
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001038 err = mv88e6xxx_port_read(chip, port, i, &reg);
1039 if (!err)
1040 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001041 }
Vivien Didelot23062512016-05-09 13:22:45 -04001042
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001043 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001044}
1045
Vivien Didelot08f50062017-08-01 16:32:41 -04001046static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1047 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001048{
Vivien Didelot5480db62017-08-01 16:32:40 -04001049 /* Nothing to do on the port's MAC */
1050 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001051}
1052
Vivien Didelot08f50062017-08-01 16:32:41 -04001053static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1054 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001055{
Vivien Didelot5480db62017-08-01 16:32:40 -04001056 /* Nothing to do on the port's MAC */
1057 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001058}
1059
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001060/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001061static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001062{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001063 struct dsa_switch *ds = chip->ds;
1064 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001065 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001066 struct dsa_port *dp;
1067 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001068 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001069
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001070 list_for_each_entry(dp, &dst->ports, list) {
1071 if (dp->ds->index == dev && dp->index == port) {
1072 found = true;
1073 break;
1074 }
1075 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001076
Vivien Didelote5887a22017-03-30 17:37:11 -04001077 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001078 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001079 return 0;
1080
1081 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001082 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001083 return mv88e6xxx_port_mask(chip);
1084
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001085 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001086 pvlan = 0;
1087
1088 /* Frames from user ports can egress any local DSA links and CPU ports,
1089 * as well as any local member of their bridge group.
1090 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001091 list_for_each_entry(dp, &dst->ports, list)
1092 if (dp->ds == ds &&
1093 (dp->type == DSA_PORT_TYPE_CPU ||
1094 dp->type == DSA_PORT_TYPE_DSA ||
1095 (br && dp->bridge_dev == br)))
1096 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001097
1098 return pvlan;
1099}
1100
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001101static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001102{
1103 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001104
1105 /* prevent frames from going back out of the port they came in on */
1106 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001107
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001108 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001109}
1110
Vivien Didelotf81ec902016-05-09 13:22:58 -04001111static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1112 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001113{
Vivien Didelot04bed142016-08-31 18:06:13 -04001114 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001115 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001116
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001117 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001118 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001119 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001120
1121 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001122 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001123}
1124
Vivien Didelot93e18d62018-05-11 17:16:35 -04001125static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1126{
1127 int err;
1128
1129 if (chip->info->ops->ieee_pri_map) {
1130 err = chip->info->ops->ieee_pri_map(chip);
1131 if (err)
1132 return err;
1133 }
1134
1135 if (chip->info->ops->ip_pri_map) {
1136 err = chip->info->ops->ip_pri_map(chip);
1137 if (err)
1138 return err;
1139 }
1140
1141 return 0;
1142}
1143
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001144static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1145{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001146 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001147 int target, port;
1148 int err;
1149
1150 if (!chip->info->global2_addr)
1151 return 0;
1152
1153 /* Initialize the routing port to the 32 possible target devices */
1154 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001155 port = dsa_routing_port(ds, target);
1156 if (port == ds->num_ports)
1157 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001158
1159 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1160 if (err)
1161 return err;
1162 }
1163
Vivien Didelot02317e62018-05-09 11:38:49 -04001164 if (chip->info->ops->set_cascade_port) {
1165 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1166 err = chip->info->ops->set_cascade_port(chip, port);
1167 if (err)
1168 return err;
1169 }
1170
Vivien Didelot23c98912018-05-09 11:38:50 -04001171 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1172 if (err)
1173 return err;
1174
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001175 return 0;
1176}
1177
Vivien Didelotb28f8722018-04-26 21:56:44 -04001178static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1179{
1180 /* Clear all trunk masks and mapping */
1181 if (chip->info->global2_addr)
1182 return mv88e6xxx_g2_trunk_clear(chip);
1183
1184 return 0;
1185}
1186
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001187static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1188{
1189 if (chip->info->ops->rmu_disable)
1190 return chip->info->ops->rmu_disable(chip);
1191
1192 return 0;
1193}
1194
Vivien Didelot9e907d72017-07-17 13:03:43 -04001195static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1196{
1197 if (chip->info->ops->pot_clear)
1198 return chip->info->ops->pot_clear(chip);
1199
1200 return 0;
1201}
1202
Vivien Didelot51c901a2017-07-17 13:03:41 -04001203static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1204{
1205 if (chip->info->ops->mgmt_rsvd2cpu)
1206 return chip->info->ops->mgmt_rsvd2cpu(chip);
1207
1208 return 0;
1209}
1210
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001211static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1212{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001213 int err;
1214
Vivien Didelotdaefc942017-03-11 16:12:54 -05001215 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1216 if (err)
1217 return err;
1218
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001219 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1220 if (err)
1221 return err;
1222
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001223 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1224}
1225
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001226static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1227{
1228 int port;
1229 int err;
1230
1231 if (!chip->info->ops->irl_init_all)
1232 return 0;
1233
1234 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1235 /* Disable ingress rate limiting by resetting all per port
1236 * ingress rate limit resources to their initial state.
1237 */
1238 err = chip->info->ops->irl_init_all(chip, port);
1239 if (err)
1240 return err;
1241 }
1242
1243 return 0;
1244}
1245
Vivien Didelot04a69a12017-10-13 14:18:05 -04001246static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1247{
1248 if (chip->info->ops->set_switch_mac) {
1249 u8 addr[ETH_ALEN];
1250
1251 eth_random_addr(addr);
1252
1253 return chip->info->ops->set_switch_mac(chip, addr);
1254 }
1255
1256 return 0;
1257}
1258
Vivien Didelot17a15942017-03-30 17:37:09 -04001259static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1260{
1261 u16 pvlan = 0;
1262
1263 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001264 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001265
1266 /* Skip the local source device, which uses in-chip port VLAN */
1267 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001268 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001269
1270 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1271}
1272
Vivien Didelot81228992017-03-30 17:37:08 -04001273static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1274{
Vivien Didelot17a15942017-03-30 17:37:09 -04001275 int dev, port;
1276 int err;
1277
Vivien Didelot81228992017-03-30 17:37:08 -04001278 if (!mv88e6xxx_has_pvt(chip))
1279 return 0;
1280
1281 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1282 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1283 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001284 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1285 if (err)
1286 return err;
1287
1288 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1289 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1290 err = mv88e6xxx_pvt_map(chip, dev, port);
1291 if (err)
1292 return err;
1293 }
1294 }
1295
1296 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001297}
1298
Vivien Didelot749efcb2016-09-22 16:49:24 -04001299static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1300{
1301 struct mv88e6xxx_chip *chip = ds->priv;
1302 int err;
1303
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001304 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001305 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001306 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001307
1308 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001309 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001310}
1311
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001312static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1313{
1314 if (!chip->info->max_vid)
1315 return 0;
1316
1317 return mv88e6xxx_g1_vtu_flush(chip);
1318}
1319
Vivien Didelotf1394b782017-05-01 14:05:22 -04001320static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1321 struct mv88e6xxx_vtu_entry *entry)
1322{
1323 if (!chip->info->ops->vtu_getnext)
1324 return -EOPNOTSUPP;
1325
1326 return chip->info->ops->vtu_getnext(chip, entry);
1327}
1328
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001329static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1330 struct mv88e6xxx_vtu_entry *entry)
1331{
1332 if (!chip->info->ops->vtu_loadpurge)
1333 return -EOPNOTSUPP;
1334
1335 return chip->info->ops->vtu_loadpurge(chip, entry);
1336}
1337
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001338static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001339{
1340 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001341 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001342 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001343
1344 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1345
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001346 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001347 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001348 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001349 if (err)
1350 return err;
1351
1352 set_bit(*fid, fid_bitmap);
1353 }
1354
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001355 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001356 vlan.vid = chip->info->max_vid;
1357 vlan.valid = false;
1358
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001359 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001360 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001361 if (err)
1362 return err;
1363
1364 if (!vlan.valid)
1365 break;
1366
1367 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001368 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001369
1370 /* The reset value 0x000 is used to indicate that multiple address
1371 * databases are not needed. Return the next positive available.
1372 */
1373 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001374 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001375 return -ENOSPC;
1376
1377 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001378 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001379}
1380
Andrew Lunn23e8b472019-10-25 01:03:52 +02001381static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1382{
1383 if (chip->info->ops->atu_get_hash)
1384 return chip->info->ops->atu_get_hash(chip, hash);
1385
1386 return -EOPNOTSUPP;
1387}
1388
1389static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1390{
1391 if (chip->info->ops->atu_set_hash)
1392 return chip->info->ops->atu_set_hash(chip, hash);
1393
1394 return -EOPNOTSUPP;
1395}
1396
Vivien Didelotda9c3592016-02-12 12:09:40 -05001397static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1398 u16 vid_begin, u16 vid_end)
1399{
Vivien Didelot04bed142016-08-31 18:06:13 -04001400 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001401 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001402 int i, err;
1403
Andrew Lunndb06ae412017-09-25 23:32:20 +02001404 /* DSA and CPU ports have to be members of multiple vlans */
1405 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1406 return 0;
1407
Vivien Didelotda9c3592016-02-12 12:09:40 -05001408 if (!vid_begin)
1409 return -EOPNOTSUPP;
1410
Vivien Didelot425d2d32019-08-01 14:36:34 -04001411 vlan.vid = vid_begin - 1;
1412 vlan.valid = false;
1413
Vivien Didelotda9c3592016-02-12 12:09:40 -05001414 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001415 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001416 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001417 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001418
1419 if (!vlan.valid)
1420 break;
1421
1422 if (vlan.vid > vid_end)
1423 break;
1424
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001425 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001426 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1427 continue;
1428
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001429 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001430 continue;
1431
Vivien Didelotbd00e052017-05-01 14:05:11 -04001432 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001433 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001434 continue;
1435
Vivien Didelotc8652c82017-10-16 11:12:19 -04001436 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001437 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001438 break; /* same bridge, check next VLAN */
1439
Vivien Didelotc8652c82017-10-16 11:12:19 -04001440 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001441 continue;
1442
Andrew Lunn743fcc22017-11-09 22:29:54 +01001443 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1444 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001445 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001446 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001447 }
1448 } while (vlan.vid < vid_end);
1449
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001450 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001451}
1452
Vivien Didelotf81ec902016-05-09 13:22:58 -04001453static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1454 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001455{
Vivien Didelot04bed142016-08-31 18:06:13 -04001456 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001457 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1458 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001459 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001460
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001461 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001462 return -EOPNOTSUPP;
1463
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001464 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001465 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001466 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001467
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001468 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001469}
1470
Vivien Didelot57d32312016-06-20 13:13:58 -04001471static int
1472mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001473 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001474{
Vivien Didelot04bed142016-08-31 18:06:13 -04001475 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001476 int err;
1477
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001478 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001479 return -EOPNOTSUPP;
1480
Vivien Didelotda9c3592016-02-12 12:09:40 -05001481 /* If the requested port doesn't belong to the same bridge as the VLAN
1482 * members, do not support it (yet) and fallback to software VLAN.
1483 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001484 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001485 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1486 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001487 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001488
Vivien Didelot76e398a2015-11-01 12:33:55 -05001489 /* We don't need any dynamic resource from the kernel (yet),
1490 * so skip the prepare phase.
1491 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001492 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001493}
1494
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001495static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1496 const unsigned char *addr, u16 vid,
1497 u8 state)
1498{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001499 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001500 struct mv88e6xxx_vtu_entry vlan;
1501 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001502 int err;
1503
1504 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001505 if (vid == 0) {
1506 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1507 if (err)
1508 return err;
1509 } else {
1510 vlan.vid = vid - 1;
1511 vlan.valid = false;
1512
1513 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1514 if (err)
1515 return err;
1516
1517 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1518 if (vlan.vid != vid || !vlan.valid)
1519 return -EOPNOTSUPP;
1520
1521 fid = vlan.fid;
1522 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001523
Vivien Didelotd8291a92019-09-07 16:00:47 -04001524 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001525 ether_addr_copy(entry.mac, addr);
1526 eth_addr_dec(entry.mac);
1527
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001528 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001529 if (err)
1530 return err;
1531
1532 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001533 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001534 memset(&entry, 0, sizeof(entry));
1535 ether_addr_copy(entry.mac, addr);
1536 }
1537
1538 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001539 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001540 entry.portvec &= ~BIT(port);
1541 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001542 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001543 } else {
1544 entry.portvec |= BIT(port);
1545 entry.state = state;
1546 }
1547
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001548 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001549}
1550
Vivien Didelotda7dc872019-09-07 16:00:49 -04001551static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1552 const struct mv88e6xxx_policy *policy)
1553{
1554 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1555 enum mv88e6xxx_policy_action action = policy->action;
1556 const u8 *addr = policy->addr;
1557 u16 vid = policy->vid;
1558 u8 state;
1559 int err;
1560 int id;
1561
1562 if (!chip->info->ops->port_set_policy)
1563 return -EOPNOTSUPP;
1564
1565 switch (mapping) {
1566 case MV88E6XXX_POLICY_MAPPING_DA:
1567 case MV88E6XXX_POLICY_MAPPING_SA:
1568 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1569 state = 0; /* Dissociate the port and address */
1570 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1571 is_multicast_ether_addr(addr))
1572 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1573 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1574 is_unicast_ether_addr(addr))
1575 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1576 else
1577 return -EOPNOTSUPP;
1578
1579 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1580 state);
1581 if (err)
1582 return err;
1583 break;
1584 default:
1585 return -EOPNOTSUPP;
1586 }
1587
1588 /* Skip the port's policy clearing if the mapping is still in use */
1589 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1590 idr_for_each_entry(&chip->policies, policy, id)
1591 if (policy->port == port &&
1592 policy->mapping == mapping &&
1593 policy->action != action)
1594 return 0;
1595
1596 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1597}
1598
1599static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1600 struct ethtool_rx_flow_spec *fs)
1601{
1602 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1603 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1604 enum mv88e6xxx_policy_mapping mapping;
1605 enum mv88e6xxx_policy_action action;
1606 struct mv88e6xxx_policy *policy;
1607 u16 vid = 0;
1608 u8 *addr;
1609 int err;
1610 int id;
1611
1612 if (fs->location != RX_CLS_LOC_ANY)
1613 return -EINVAL;
1614
1615 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1616 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1617 else
1618 return -EOPNOTSUPP;
1619
1620 switch (fs->flow_type & ~FLOW_EXT) {
1621 case ETHER_FLOW:
1622 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1623 is_zero_ether_addr(mac_mask->h_source)) {
1624 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1625 addr = mac_entry->h_dest;
1626 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1627 !is_zero_ether_addr(mac_mask->h_source)) {
1628 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1629 addr = mac_entry->h_source;
1630 } else {
1631 /* Cannot support DA and SA mapping in the same rule */
1632 return -EOPNOTSUPP;
1633 }
1634 break;
1635 default:
1636 return -EOPNOTSUPP;
1637 }
1638
1639 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1640 if (fs->m_ext.vlan_tci != 0xffff)
1641 return -EOPNOTSUPP;
1642 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1643 }
1644
1645 idr_for_each_entry(&chip->policies, policy, id) {
1646 if (policy->port == port && policy->mapping == mapping &&
1647 policy->action == action && policy->vid == vid &&
1648 ether_addr_equal(policy->addr, addr))
1649 return -EEXIST;
1650 }
1651
1652 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1653 if (!policy)
1654 return -ENOMEM;
1655
1656 fs->location = 0;
1657 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1658 GFP_KERNEL);
1659 if (err) {
1660 devm_kfree(chip->dev, policy);
1661 return err;
1662 }
1663
1664 memcpy(&policy->fs, fs, sizeof(*fs));
1665 ether_addr_copy(policy->addr, addr);
1666 policy->mapping = mapping;
1667 policy->action = action;
1668 policy->port = port;
1669 policy->vid = vid;
1670
1671 err = mv88e6xxx_policy_apply(chip, port, policy);
1672 if (err) {
1673 idr_remove(&chip->policies, fs->location);
1674 devm_kfree(chip->dev, policy);
1675 return err;
1676 }
1677
1678 return 0;
1679}
1680
1681static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1682 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1683{
1684 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1685 struct mv88e6xxx_chip *chip = ds->priv;
1686 struct mv88e6xxx_policy *policy;
1687 int err;
1688 int id;
1689
1690 mv88e6xxx_reg_lock(chip);
1691
1692 switch (rxnfc->cmd) {
1693 case ETHTOOL_GRXCLSRLCNT:
1694 rxnfc->data = 0;
1695 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1696 rxnfc->rule_cnt = 0;
1697 idr_for_each_entry(&chip->policies, policy, id)
1698 if (policy->port == port)
1699 rxnfc->rule_cnt++;
1700 err = 0;
1701 break;
1702 case ETHTOOL_GRXCLSRULE:
1703 err = -ENOENT;
1704 policy = idr_find(&chip->policies, fs->location);
1705 if (policy) {
1706 memcpy(fs, &policy->fs, sizeof(*fs));
1707 err = 0;
1708 }
1709 break;
1710 case ETHTOOL_GRXCLSRLALL:
1711 rxnfc->data = 0;
1712 rxnfc->rule_cnt = 0;
1713 idr_for_each_entry(&chip->policies, policy, id)
1714 if (policy->port == port)
1715 rule_locs[rxnfc->rule_cnt++] = id;
1716 err = 0;
1717 break;
1718 default:
1719 err = -EOPNOTSUPP;
1720 break;
1721 }
1722
1723 mv88e6xxx_reg_unlock(chip);
1724
1725 return err;
1726}
1727
1728static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1729 struct ethtool_rxnfc *rxnfc)
1730{
1731 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1732 struct mv88e6xxx_chip *chip = ds->priv;
1733 struct mv88e6xxx_policy *policy;
1734 int err;
1735
1736 mv88e6xxx_reg_lock(chip);
1737
1738 switch (rxnfc->cmd) {
1739 case ETHTOOL_SRXCLSRLINS:
1740 err = mv88e6xxx_policy_insert(chip, port, fs);
1741 break;
1742 case ETHTOOL_SRXCLSRLDEL:
1743 err = -ENOENT;
1744 policy = idr_remove(&chip->policies, fs->location);
1745 if (policy) {
1746 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1747 err = mv88e6xxx_policy_apply(chip, port, policy);
1748 devm_kfree(chip->dev, policy);
1749 }
1750 break;
1751 default:
1752 err = -EOPNOTSUPP;
1753 break;
1754 }
1755
1756 mv88e6xxx_reg_unlock(chip);
1757
1758 return err;
1759}
1760
Andrew Lunn87fa8862017-11-09 22:29:56 +01001761static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1762 u16 vid)
1763{
1764 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1765 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1766
1767 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1768}
1769
1770static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1771{
1772 int port;
1773 int err;
1774
1775 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1776 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1777 if (err)
1778 return err;
1779 }
1780
1781 return 0;
1782}
1783
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001784static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001785 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001786{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001787 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001788 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001789 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001790
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001791 if (!vid)
1792 return -EOPNOTSUPP;
1793
1794 vlan.vid = vid - 1;
1795 vlan.valid = false;
1796
1797 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001798 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001800
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001801 if (vlan.vid != vid || !vlan.valid) {
1802 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001803
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001804 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1805 if (err)
1806 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001807
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001808 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1809 if (i == port)
1810 vlan.member[i] = member;
1811 else
1812 vlan.member[i] = non_member;
1813
1814 vlan.vid = vid;
1815 vlan.valid = true;
1816
1817 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1818 if (err)
1819 return err;
1820
1821 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1822 if (err)
1823 return err;
1824 } else if (vlan.member[port] != member) {
1825 vlan.member[port] = member;
1826
1827 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1828 if (err)
1829 return err;
1830 } else {
1831 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1832 port, vid);
1833 }
1834
1835 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001836}
1837
Vivien Didelotf81ec902016-05-09 13:22:58 -04001838static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001839 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001840{
Vivien Didelot04bed142016-08-31 18:06:13 -04001841 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001842 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1843 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001844 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001845 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001846
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001847 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001848 return;
1849
Vivien Didelotc91498e2017-06-07 18:12:13 -04001850 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001851 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001852 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001853 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001854 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001855 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001856
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001857 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001858
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001859 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001860 if (mv88e6xxx_port_vlan_join(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001861 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1862 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001863
Vivien Didelot77064f32016-11-04 03:23:30 +01001864 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001865 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1866 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001867
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001868 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001869}
1870
Vivien Didelot521098922019-08-01 14:36:36 -04001871static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1872 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001873{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001874 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001875 int i, err;
1876
Vivien Didelot521098922019-08-01 14:36:36 -04001877 if (!vid)
1878 return -EOPNOTSUPP;
1879
1880 vlan.vid = vid - 1;
1881 vlan.valid = false;
1882
1883 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001884 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001885 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001886
Vivien Didelot521098922019-08-01 14:36:36 -04001887 /* If the VLAN doesn't exist in hardware or the port isn't a member,
1888 * tell switchdev that this VLAN is likely handled in software.
1889 */
1890 if (vlan.vid != vid || !vlan.valid ||
1891 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001892 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001893
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001894 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001895
1896 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001897 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001898 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001899 if (vlan.member[i] !=
1900 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001901 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001902 break;
1903 }
1904 }
1905
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001906 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001907 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001908 return err;
1909
Vivien Didelote606ca32017-03-11 16:12:55 -05001910 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001911}
1912
Vivien Didelotf81ec902016-05-09 13:22:58 -04001913static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1914 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001915{
Vivien Didelot04bed142016-08-31 18:06:13 -04001916 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001917 u16 pvid, vid;
1918 int err = 0;
1919
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001920 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001921 return -EOPNOTSUPP;
1922
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001923 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001924
Vivien Didelot77064f32016-11-04 03:23:30 +01001925 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001926 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001927 goto unlock;
1928
Vivien Didelot76e398a2015-11-01 12:33:55 -05001929 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04001930 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001931 if (err)
1932 goto unlock;
1933
1934 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001935 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001936 if (err)
1937 goto unlock;
1938 }
1939 }
1940
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001941unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001942 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001943
1944 return err;
1945}
1946
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001947static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1948 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001949{
Vivien Didelot04bed142016-08-31 18:06:13 -04001950 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001951 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001952
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001953 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001954 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1955 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001956 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001957
1958 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001959}
1960
Vivien Didelotf81ec902016-05-09 13:22:58 -04001961static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001962 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001963{
Vivien Didelot04bed142016-08-31 18:06:13 -04001964 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001965 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001966
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001967 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04001968 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001969 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07001970
Vivien Didelot83dabd12016-08-31 11:50:04 -04001971 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001972}
1973
Vivien Didelot83dabd12016-08-31 11:50:04 -04001974static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1975 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001976 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001977{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001978 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001979 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001980 int err;
1981
Vivien Didelotd8291a92019-09-07 16:00:47 -04001982 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001983 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001984
1985 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001986 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001987 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001988 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001989
Vivien Didelotd8291a92019-09-07 16:00:47 -04001990 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001991 break;
1992
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001993 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001994 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001995
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001996 if (!is_unicast_ether_addr(addr.mac))
1997 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001998
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001999 is_static = (addr.state ==
2000 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2001 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002002 if (err)
2003 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002004 } while (!is_broadcast_ether_addr(addr.mac));
2005
2006 return err;
2007}
2008
Vivien Didelot83dabd12016-08-31 11:50:04 -04002009static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002010 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002011{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002012 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002013 u16 fid;
2014 int err;
2015
2016 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002017 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002018 if (err)
2019 return err;
2020
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002021 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002022 if (err)
2023 return err;
2024
2025 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002026 vlan.vid = chip->info->max_vid;
2027 vlan.valid = false;
2028
Vivien Didelot83dabd12016-08-31 11:50:04 -04002029 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002030 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002031 if (err)
2032 return err;
2033
2034 if (!vlan.valid)
2035 break;
2036
2037 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002038 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002039 if (err)
2040 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002041 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002042
2043 return err;
2044}
2045
Vivien Didelotf81ec902016-05-09 13:22:58 -04002046static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002047 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002048{
Vivien Didelot04bed142016-08-31 18:06:13 -04002049 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002050 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002051
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002052 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002053 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002054 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002055
2056 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002057}
2058
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002059static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2060 struct net_device *br)
2061{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002062 struct dsa_switch *ds = chip->ds;
2063 struct dsa_switch_tree *dst = ds->dst;
2064 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002065 int err;
2066
Vivien Didelotef2025e2019-10-21 16:51:27 -04002067 list_for_each_entry(dp, &dst->ports, list) {
2068 if (dp->bridge_dev == br) {
2069 if (dp->ds == ds) {
2070 /* This is a local bridge group member,
2071 * remap its Port VLAN Map.
2072 */
2073 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2074 if (err)
2075 return err;
2076 } else {
2077 /* This is an external bridge group member,
2078 * remap its cross-chip Port VLAN Table entry.
2079 */
2080 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2081 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002082 if (err)
2083 return err;
2084 }
2085 }
2086 }
2087
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002088 return 0;
2089}
2090
Vivien Didelotf81ec902016-05-09 13:22:58 -04002091static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002092 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002093{
Vivien Didelot04bed142016-08-31 18:06:13 -04002094 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002095 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002096
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002097 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002098 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002099 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002100
Vivien Didelot466dfa02016-02-26 13:16:05 -05002101 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002102}
2103
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002104static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2105 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002106{
Vivien Didelot04bed142016-08-31 18:06:13 -04002107 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002109 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002110 if (mv88e6xxx_bridge_map(chip, br) ||
2111 mv88e6xxx_port_vlan_map(chip, port))
2112 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002113 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002114}
2115
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002116static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2117 int port, struct net_device *br)
2118{
2119 struct mv88e6xxx_chip *chip = ds->priv;
2120 int err;
2121
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002122 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002123 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002124 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002125
2126 return err;
2127}
2128
2129static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2130 int port, struct net_device *br)
2131{
2132 struct mv88e6xxx_chip *chip = ds->priv;
2133
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002134 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002135 if (mv88e6xxx_pvt_map(chip, dev, port))
2136 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002137 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002138}
2139
Vivien Didelot17e708b2016-12-05 17:30:27 -05002140static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2141{
2142 if (chip->info->ops->reset)
2143 return chip->info->ops->reset(chip);
2144
2145 return 0;
2146}
2147
Vivien Didelot309eca62016-12-05 17:30:26 -05002148static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2149{
2150 struct gpio_desc *gpiod = chip->reset;
2151
2152 /* If there is a GPIO connected to the reset pin, toggle it */
2153 if (gpiod) {
2154 gpiod_set_value_cansleep(gpiod, 1);
2155 usleep_range(10000, 20000);
2156 gpiod_set_value_cansleep(gpiod, 0);
2157 usleep_range(10000, 20000);
2158 }
2159}
2160
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002161static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2162{
2163 int i, err;
2164
2165 /* Set all ports to the Disabled state */
2166 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002167 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002168 if (err)
2169 return err;
2170 }
2171
2172 /* Wait for transmit queues to drain,
2173 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2174 */
2175 usleep_range(2000, 4000);
2176
2177 return 0;
2178}
2179
Vivien Didelotfad09c72016-06-21 12:28:20 -04002180static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002181{
Vivien Didelota935c052016-09-29 12:21:53 -04002182 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002183
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002184 err = mv88e6xxx_disable_ports(chip);
2185 if (err)
2186 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002187
Vivien Didelot309eca62016-12-05 17:30:26 -05002188 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002189
Vivien Didelot17e708b2016-12-05 17:30:27 -05002190 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002191}
2192
Vivien Didelot43145572017-03-11 16:12:59 -05002193static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002194 enum mv88e6xxx_frame_mode frame,
2195 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002196{
2197 int err;
2198
Vivien Didelot43145572017-03-11 16:12:59 -05002199 if (!chip->info->ops->port_set_frame_mode)
2200 return -EOPNOTSUPP;
2201
2202 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002203 if (err)
2204 return err;
2205
Vivien Didelot43145572017-03-11 16:12:59 -05002206 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2207 if (err)
2208 return err;
2209
2210 if (chip->info->ops->port_set_ether_type)
2211 return chip->info->ops->port_set_ether_type(chip, port, etype);
2212
2213 return 0;
2214}
2215
2216static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2217{
2218 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002219 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002220 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002221}
2222
2223static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2224{
2225 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002226 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002227 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002228}
2229
2230static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2231{
2232 return mv88e6xxx_set_port_mode(chip, port,
2233 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002234 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2235 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002236}
2237
2238static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2239{
2240 if (dsa_is_dsa_port(chip->ds, port))
2241 return mv88e6xxx_set_port_mode_dsa(chip, port);
2242
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002243 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002244 return mv88e6xxx_set_port_mode_normal(chip, port);
2245
2246 /* Setup CPU port mode depending on its supported tag format */
2247 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2248 return mv88e6xxx_set_port_mode_dsa(chip, port);
2249
2250 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2251 return mv88e6xxx_set_port_mode_edsa(chip, port);
2252
2253 return -EINVAL;
2254}
2255
Vivien Didelotea698f42017-03-11 16:12:50 -05002256static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2257{
2258 bool message = dsa_is_dsa_port(chip->ds, port);
2259
2260 return mv88e6xxx_port_set_message_port(chip, port, message);
2261}
2262
Vivien Didelot601aeed2017-03-11 16:13:00 -05002263static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2264{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002265 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002266 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002267
David S. Miller407308f2019-06-15 13:35:29 -07002268 /* Upstream ports flood frames with unknown unicast or multicast DA */
2269 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2270 if (chip->info->ops->port_set_egress_floods)
2271 return chip->info->ops->port_set_egress_floods(chip, port,
2272 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002273
David S. Miller407308f2019-06-15 13:35:29 -07002274 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002275}
2276
Vivien Didelot45de77f2019-08-31 16:18:36 -04002277static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2278{
2279 struct mv88e6xxx_port *mvp = dev_id;
2280 struct mv88e6xxx_chip *chip = mvp->chip;
2281 irqreturn_t ret = IRQ_NONE;
2282 int port = mvp->port;
2283 u8 lane;
2284
2285 mv88e6xxx_reg_lock(chip);
2286 lane = mv88e6xxx_serdes_get_lane(chip, port);
2287 if (lane)
2288 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2289 mv88e6xxx_reg_unlock(chip);
2290
2291 return ret;
2292}
2293
2294static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2295 u8 lane)
2296{
2297 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2298 unsigned int irq;
2299 int err;
2300
2301 /* Nothing to request if this SERDES port has no IRQ */
2302 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2303 if (!irq)
2304 return 0;
2305
2306 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2307 mv88e6xxx_reg_unlock(chip);
2308 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
2309 IRQF_ONESHOT, "mv88e6xxx-serdes", dev_id);
2310 mv88e6xxx_reg_lock(chip);
2311 if (err)
2312 return err;
2313
2314 dev_id->serdes_irq = irq;
2315
2316 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2317}
2318
2319static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2320 u8 lane)
2321{
2322 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2323 unsigned int irq = dev_id->serdes_irq;
2324 int err;
2325
2326 /* Nothing to free if no IRQ has been requested */
2327 if (!irq)
2328 return 0;
2329
2330 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2331
2332 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2333 mv88e6xxx_reg_unlock(chip);
2334 free_irq(irq, dev_id);
2335 mv88e6xxx_reg_lock(chip);
2336
2337 dev_id->serdes_irq = 0;
2338
2339 return err;
2340}
2341
Andrew Lunn6d917822017-05-26 01:03:21 +02002342static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2343 bool on)
2344{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002345 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002346 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002347
Vivien Didelotdc272f62019-08-31 16:18:33 -04002348 lane = mv88e6xxx_serdes_get_lane(chip, port);
2349 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002350 return 0;
2351
2352 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002353 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002354 if (err)
2355 return err;
2356
Vivien Didelot45de77f2019-08-31 16:18:36 -04002357 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002358 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002359 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2360 if (err)
2361 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002362
Vivien Didelotdc272f62019-08-31 16:18:33 -04002363 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002364 }
2365
2366 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002367}
2368
Vivien Didelotfa371c82017-12-05 15:34:10 -05002369static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2370{
2371 struct dsa_switch *ds = chip->ds;
2372 int upstream_port;
2373 int err;
2374
Vivien Didelot07073c72017-12-05 15:34:13 -05002375 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002376 if (chip->info->ops->port_set_upstream_port) {
2377 err = chip->info->ops->port_set_upstream_port(chip, port,
2378 upstream_port);
2379 if (err)
2380 return err;
2381 }
2382
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002383 if (port == upstream_port) {
2384 if (chip->info->ops->set_cpu_port) {
2385 err = chip->info->ops->set_cpu_port(chip,
2386 upstream_port);
2387 if (err)
2388 return err;
2389 }
2390
2391 if (chip->info->ops->set_egress_port) {
2392 err = chip->info->ops->set_egress_port(chip,
2393 upstream_port);
2394 if (err)
2395 return err;
2396 }
2397 }
2398
Vivien Didelotfa371c82017-12-05 15:34:10 -05002399 return 0;
2400}
2401
Vivien Didelotfad09c72016-06-21 12:28:20 -04002402static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002403{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002404 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002405 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002406 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002407
Andrew Lunn7b898462018-08-09 15:38:47 +02002408 chip->ports[port].chip = chip;
2409 chip->ports[port].port = port;
2410
Vivien Didelotd78343d2016-11-04 03:23:36 +01002411 /* MAC Forcing register: don't force link, speed, duplex or flow control
2412 * state to any particular values on physical ports, but force the CPU
2413 * port and all DSA ports to their maximum bandwidth and full duplex.
2414 */
2415 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2416 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2417 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002418 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002419 PHY_INTERFACE_MODE_NA);
2420 else
2421 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2422 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002423 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002424 PHY_INTERFACE_MODE_NA);
2425 if (err)
2426 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002427
2428 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2429 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2430 * tunneling, determine priority by looking at 802.1p and IP
2431 * priority fields (IP prio has precedence), and set STP state
2432 * to Forwarding.
2433 *
2434 * If this is the CPU link, use DSA or EDSA tagging depending
2435 * on which tagging mode was configured.
2436 *
2437 * If this is a link to another switch, use DSA tagging mode.
2438 *
2439 * If this is the upstream port for this switch, enable
2440 * forwarding of unknown unicasts and multicasts.
2441 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002442 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2443 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2444 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2445 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002446 if (err)
2447 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002448
Vivien Didelot601aeed2017-03-11 16:13:00 -05002449 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002450 if (err)
2451 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002452
Vivien Didelot601aeed2017-03-11 16:13:00 -05002453 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002454 if (err)
2455 return err;
2456
Vivien Didelot8efdda42015-08-13 12:52:23 -04002457 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002458 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002459 * untagged frames on this port, do a destination address lookup on all
2460 * received packets as usual, disable ARP mirroring and don't send a
2461 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002462 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002463 err = mv88e6xxx_port_set_map_da(chip, port);
2464 if (err)
2465 return err;
2466
Vivien Didelotfa371c82017-12-05 15:34:10 -05002467 err = mv88e6xxx_setup_upstream_port(chip, port);
2468 if (err)
2469 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002470
Andrew Lunna23b2962017-02-04 20:15:28 +01002471 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002472 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002473 if (err)
2474 return err;
2475
Vivien Didelotcd782652017-06-08 18:34:13 -04002476 if (chip->info->ops->port_set_jumbo_size) {
2477 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002478 if (err)
2479 return err;
2480 }
2481
Andrew Lunn54d792f2015-05-06 01:09:47 +02002482 /* Port Association Vector: when learning source addresses
2483 * of packets, add the address to the address database using
2484 * a port bitmap that has only the bit for this port set and
2485 * the other bits clear.
2486 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002487 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002488 /* Disable learning for CPU port */
2489 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002490 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002491
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002492 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2493 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002494 if (err)
2495 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002496
2497 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002498 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2499 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002500 if (err)
2501 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002502
Vivien Didelot08984322017-06-08 18:34:12 -04002503 if (chip->info->ops->port_pause_limit) {
2504 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002505 if (err)
2506 return err;
2507 }
2508
Vivien Didelotc8c94892017-03-11 16:13:01 -05002509 if (chip->info->ops->port_disable_learn_limit) {
2510 err = chip->info->ops->port_disable_learn_limit(chip, port);
2511 if (err)
2512 return err;
2513 }
2514
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002515 if (chip->info->ops->port_disable_pri_override) {
2516 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002517 if (err)
2518 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002519 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002520
Andrew Lunnef0a7312016-12-03 04:35:16 +01002521 if (chip->info->ops->port_tag_remap) {
2522 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002523 if (err)
2524 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002525 }
2526
Andrew Lunnef70b112016-12-03 04:45:18 +01002527 if (chip->info->ops->port_egress_rate_limiting) {
2528 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002529 if (err)
2530 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002531 }
2532
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002533 if (chip->info->ops->port_setup_message_port) {
2534 err = chip->info->ops->port_setup_message_port(chip, port);
2535 if (err)
2536 return err;
2537 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002538
Vivien Didelot207afda2016-04-14 14:42:09 -04002539 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002540 * database, and allow bidirectional communication between the
2541 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002542 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002543 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002544 if (err)
2545 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002546
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002547 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002548 if (err)
2549 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002550
2551 /* Default VLAN ID and priority: don't set a default VLAN
2552 * ID, and set the default packet priority to zero.
2553 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002554 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002555}
2556
Andrew Lunn04aca992017-05-26 01:03:24 +02002557static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2558 struct phy_device *phydev)
2559{
2560 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002561 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002562
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002563 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002564 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002565 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002566
2567 return err;
2568}
2569
Andrew Lunn75104db2019-02-24 20:44:43 +01002570static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002571{
2572 struct mv88e6xxx_chip *chip = ds->priv;
2573
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002574 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002575 if (mv88e6xxx_serdes_power(chip, port, false))
2576 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002577 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002578}
2579
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002580static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2581 unsigned int ageing_time)
2582{
Vivien Didelot04bed142016-08-31 18:06:13 -04002583 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002584 int err;
2585
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002586 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002587 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002588 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002589
2590 return err;
2591}
2592
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002593static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002594{
2595 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002596
Andrew Lunnde2273872016-11-21 23:27:01 +01002597 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002598 if (chip->info->ops->stats_set_histogram) {
2599 err = chip->info->ops->stats_set_histogram(chip);
2600 if (err)
2601 return err;
2602 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002603
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002604 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002605}
2606
Andrew Lunnea890982019-01-09 00:24:03 +01002607/* Check if the errata has already been applied. */
2608static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2609{
2610 int port;
2611 int err;
2612 u16 val;
2613
2614 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002615 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002616 if (err) {
2617 dev_err(chip->dev,
2618 "Error reading hidden register: %d\n", err);
2619 return false;
2620 }
2621 if (val != 0x01c0)
2622 return false;
2623 }
2624
2625 return true;
2626}
2627
2628/* The 6390 copper ports have an errata which require poking magic
2629 * values into undocumented hidden registers and then performing a
2630 * software reset.
2631 */
2632static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2633{
2634 int port;
2635 int err;
2636
2637 if (mv88e6390_setup_errata_applied(chip))
2638 return 0;
2639
2640 /* Set the ports into blocking mode */
2641 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2642 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2643 if (err)
2644 return err;
2645 }
2646
2647 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002648 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002649 if (err)
2650 return err;
2651 }
2652
2653 return mv88e6xxx_software_reset(chip);
2654}
2655
Andrew Lunn23e8b472019-10-25 01:03:52 +02002656enum mv88e6xxx_devlink_param_id {
2657 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2658 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2659};
2660
2661static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2662 struct devlink_param_gset_ctx *ctx)
2663{
2664 struct mv88e6xxx_chip *chip = ds->priv;
2665 int err;
2666
2667 mv88e6xxx_reg_lock(chip);
2668
2669 switch (id) {
2670 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2671 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2672 break;
2673 default:
2674 err = -EOPNOTSUPP;
2675 break;
2676 }
2677
2678 mv88e6xxx_reg_unlock(chip);
2679
2680 return err;
2681}
2682
2683static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2684 struct devlink_param_gset_ctx *ctx)
2685{
2686 struct mv88e6xxx_chip *chip = ds->priv;
2687 int err;
2688
2689 mv88e6xxx_reg_lock(chip);
2690
2691 switch (id) {
2692 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2693 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2694 break;
2695 default:
2696 err = -EOPNOTSUPP;
2697 break;
2698 }
2699
2700 mv88e6xxx_reg_unlock(chip);
2701
2702 return err;
2703}
2704
2705static const struct devlink_param mv88e6xxx_devlink_params[] = {
2706 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2707 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2708 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2709};
2710
2711static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2712{
2713 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2714 ARRAY_SIZE(mv88e6xxx_devlink_params));
2715}
2716
2717static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2718{
2719 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2720 ARRAY_SIZE(mv88e6xxx_devlink_params));
2721}
2722
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002723enum mv88e6xxx_devlink_resource_id {
2724 MV88E6XXX_RESOURCE_ID_ATU,
2725 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2726 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2727 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2728 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2729};
2730
2731static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2732 u16 bin)
2733{
2734 u16 occupancy = 0;
2735 int err;
2736
2737 mv88e6xxx_reg_lock(chip);
2738
2739 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2740 bin);
2741 if (err) {
2742 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2743 goto unlock;
2744 }
2745
2746 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2747 if (err) {
2748 dev_err(chip->dev, "failed to perform ATU get next\n");
2749 goto unlock;
2750 }
2751
2752 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2753 if (err) {
2754 dev_err(chip->dev, "failed to get ATU stats\n");
2755 goto unlock;
2756 }
2757
2758unlock:
2759 mv88e6xxx_reg_unlock(chip);
2760
2761 return occupancy;
2762}
2763
2764static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2765{
2766 struct mv88e6xxx_chip *chip = priv;
2767
2768 return mv88e6xxx_devlink_atu_bin_get(chip,
2769 MV88E6XXX_G2_ATU_STATS_BIN_0);
2770}
2771
2772static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2773{
2774 struct mv88e6xxx_chip *chip = priv;
2775
2776 return mv88e6xxx_devlink_atu_bin_get(chip,
2777 MV88E6XXX_G2_ATU_STATS_BIN_1);
2778}
2779
2780static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2781{
2782 struct mv88e6xxx_chip *chip = priv;
2783
2784 return mv88e6xxx_devlink_atu_bin_get(chip,
2785 MV88E6XXX_G2_ATU_STATS_BIN_2);
2786}
2787
2788static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2789{
2790 struct mv88e6xxx_chip *chip = priv;
2791
2792 return mv88e6xxx_devlink_atu_bin_get(chip,
2793 MV88E6XXX_G2_ATU_STATS_BIN_3);
2794}
2795
2796static u64 mv88e6xxx_devlink_atu_get(void *priv)
2797{
2798 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2799 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2800 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2801 mv88e6xxx_devlink_atu_bin_3_get(priv);
2802}
2803
2804static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2805{
2806 struct devlink_resource_size_params size_params;
2807 struct mv88e6xxx_chip *chip = ds->priv;
2808 int err;
2809
2810 devlink_resource_size_params_init(&size_params,
2811 mv88e6xxx_num_macs(chip),
2812 mv88e6xxx_num_macs(chip),
2813 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2814
2815 err = dsa_devlink_resource_register(ds, "ATU",
2816 mv88e6xxx_num_macs(chip),
2817 MV88E6XXX_RESOURCE_ID_ATU,
2818 DEVLINK_RESOURCE_ID_PARENT_TOP,
2819 &size_params);
2820 if (err)
2821 goto out;
2822
2823 devlink_resource_size_params_init(&size_params,
2824 mv88e6xxx_num_macs(chip) / 4,
2825 mv88e6xxx_num_macs(chip) / 4,
2826 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2827
2828 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2829 mv88e6xxx_num_macs(chip) / 4,
2830 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2831 MV88E6XXX_RESOURCE_ID_ATU,
2832 &size_params);
2833 if (err)
2834 goto out;
2835
2836 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2837 mv88e6xxx_num_macs(chip) / 4,
2838 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2839 MV88E6XXX_RESOURCE_ID_ATU,
2840 &size_params);
2841 if (err)
2842 goto out;
2843
2844 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2845 mv88e6xxx_num_macs(chip) / 4,
2846 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2847 MV88E6XXX_RESOURCE_ID_ATU,
2848 &size_params);
2849 if (err)
2850 goto out;
2851
2852 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2853 mv88e6xxx_num_macs(chip) / 4,
2854 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2855 MV88E6XXX_RESOURCE_ID_ATU,
2856 &size_params);
2857 if (err)
2858 goto out;
2859
2860 dsa_devlink_resource_occ_get_register(ds,
2861 MV88E6XXX_RESOURCE_ID_ATU,
2862 mv88e6xxx_devlink_atu_get,
2863 chip);
2864
2865 dsa_devlink_resource_occ_get_register(ds,
2866 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2867 mv88e6xxx_devlink_atu_bin_0_get,
2868 chip);
2869
2870 dsa_devlink_resource_occ_get_register(ds,
2871 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2872 mv88e6xxx_devlink_atu_bin_1_get,
2873 chip);
2874
2875 dsa_devlink_resource_occ_get_register(ds,
2876 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2877 mv88e6xxx_devlink_atu_bin_2_get,
2878 chip);
2879
2880 dsa_devlink_resource_occ_get_register(ds,
2881 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2882 mv88e6xxx_devlink_atu_bin_3_get,
2883 chip);
2884
2885 return 0;
2886
2887out:
2888 dsa_devlink_resources_unregister(ds);
2889 return err;
2890}
2891
Andrew Lunn23e8b472019-10-25 01:03:52 +02002892static void mv88e6xxx_teardown(struct dsa_switch *ds)
2893{
2894 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002895 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002896}
2897
Vivien Didelotf81ec902016-05-09 13:22:58 -04002898static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002899{
Vivien Didelot04bed142016-08-31 18:06:13 -04002900 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002901 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002902 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002903 int i;
2904
Vivien Didelotfad09c72016-06-21 12:28:20 -04002905 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002906 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002907
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002908 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002909
Andrew Lunnea890982019-01-09 00:24:03 +01002910 if (chip->info->ops->setup_errata) {
2911 err = chip->info->ops->setup_errata(chip);
2912 if (err)
2913 goto unlock;
2914 }
2915
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002916 /* Cache the cmode of each port. */
2917 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2918 if (chip->info->ops->port_get_cmode) {
2919 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2920 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002921 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002922
2923 chip->ports[i].cmode = cmode;
2924 }
2925 }
2926
Vivien Didelot97299342016-07-18 20:45:30 -04002927 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002928 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002929 if (dsa_is_unused_port(ds, i))
2930 continue;
2931
Hubert Feursteinc8574862019-07-31 10:23:48 +02002932 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002933 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002934 dev_err(chip->dev, "port %d is invalid\n", i);
2935 err = -EINVAL;
2936 goto unlock;
2937 }
2938
Vivien Didelot97299342016-07-18 20:45:30 -04002939 err = mv88e6xxx_setup_port(chip, i);
2940 if (err)
2941 goto unlock;
2942 }
2943
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002944 err = mv88e6xxx_irl_setup(chip);
2945 if (err)
2946 goto unlock;
2947
Vivien Didelot04a69a12017-10-13 14:18:05 -04002948 err = mv88e6xxx_mac_setup(chip);
2949 if (err)
2950 goto unlock;
2951
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002952 err = mv88e6xxx_phy_setup(chip);
2953 if (err)
2954 goto unlock;
2955
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002956 err = mv88e6xxx_vtu_setup(chip);
2957 if (err)
2958 goto unlock;
2959
Vivien Didelot81228992017-03-30 17:37:08 -04002960 err = mv88e6xxx_pvt_setup(chip);
2961 if (err)
2962 goto unlock;
2963
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002964 err = mv88e6xxx_atu_setup(chip);
2965 if (err)
2966 goto unlock;
2967
Andrew Lunn87fa8862017-11-09 22:29:56 +01002968 err = mv88e6xxx_broadcast_setup(chip, 0);
2969 if (err)
2970 goto unlock;
2971
Vivien Didelot9e907d72017-07-17 13:03:43 -04002972 err = mv88e6xxx_pot_setup(chip);
2973 if (err)
2974 goto unlock;
2975
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002976 err = mv88e6xxx_rmu_setup(chip);
2977 if (err)
2978 goto unlock;
2979
Vivien Didelot51c901a2017-07-17 13:03:41 -04002980 err = mv88e6xxx_rsvd2cpu_setup(chip);
2981 if (err)
2982 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002983
Vivien Didelotb28f8722018-04-26 21:56:44 -04002984 err = mv88e6xxx_trunk_setup(chip);
2985 if (err)
2986 goto unlock;
2987
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002988 err = mv88e6xxx_devmap_setup(chip);
2989 if (err)
2990 goto unlock;
2991
Vivien Didelot93e18d62018-05-11 17:16:35 -04002992 err = mv88e6xxx_pri_setup(chip);
2993 if (err)
2994 goto unlock;
2995
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002996 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002997 if (chip->info->ptp_support) {
2998 err = mv88e6xxx_ptp_setup(chip);
2999 if (err)
3000 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003001
3002 err = mv88e6xxx_hwtstamp_setup(chip);
3003 if (err)
3004 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003005 }
3006
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003007 err = mv88e6xxx_stats_setup(chip);
3008 if (err)
3009 goto unlock;
3010
Vivien Didelot6b17e862015-08-13 12:52:18 -04003011unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003012 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003013
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003014 if (err)
3015 return err;
3016
3017 /* Have to be called without holding the register lock, since
3018 * they take the devlink lock, and we later take the locks in
3019 * the reverse order when getting/setting parameters or
3020 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003021 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003022 err = mv88e6xxx_setup_devlink_resources(ds);
3023 if (err)
3024 return err;
3025
3026 err = mv88e6xxx_setup_devlink_params(ds);
3027 if (err)
3028 dsa_devlink_resources_unregister(ds);
3029
3030 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003031}
3032
Vivien Didelote57e5e72016-08-15 17:19:00 -04003033static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003034{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003035 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3036 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003037 u16 val;
3038 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003039
Andrew Lunnee26a222017-01-24 14:53:48 +01003040 if (!chip->info->ops->phy_read)
3041 return -EOPNOTSUPP;
3042
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003043 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003044 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003045 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003046
Andrew Lunnda9f3302017-02-01 03:40:05 +01003047 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003048 /* Some internal PHYs don't have a model number. */
3049 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3050 /* Then there is the 6165 family. It gets is
3051 * PHYs correct. But it can also have two
3052 * SERDES interfaces in the PHY address
3053 * space. And these don't have a model
3054 * number. But they are not PHYs, so we don't
3055 * want to give them something a PHY driver
3056 * will recognise.
3057 *
3058 * Use the mv88e6390 family model number
3059 * instead, for anything which really could be
3060 * a PHY,
3061 */
3062 if (!(val & 0x3f0))
3063 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003064 }
3065
Vivien Didelote57e5e72016-08-15 17:19:00 -04003066 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003067}
3068
Vivien Didelote57e5e72016-08-15 17:19:00 -04003069static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003070{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003071 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3072 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003073 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003074
Andrew Lunnee26a222017-01-24 14:53:48 +01003075 if (!chip->info->ops->phy_write)
3076 return -EOPNOTSUPP;
3077
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003078 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003079 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003080 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003081
3082 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003083}
3084
Vivien Didelotfad09c72016-06-21 12:28:20 -04003085static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003086 struct device_node *np,
3087 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003088{
3089 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003090 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003091 struct mii_bus *bus;
3092 int err;
3093
Andrew Lunn2510bab2018-02-22 01:51:49 +01003094 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003095 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003096 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003097 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003098
3099 if (err)
3100 return err;
3101 }
3102
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003103 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003104 if (!bus)
3105 return -ENOMEM;
3106
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003107 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003108 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003109 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003110 INIT_LIST_HEAD(&mdio_bus->list);
3111 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003112
Andrew Lunnb516d452016-06-04 21:17:06 +02003113 if (np) {
3114 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003115 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003116 } else {
3117 bus->name = "mv88e6xxx SMI";
3118 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3119 }
3120
3121 bus->read = mv88e6xxx_mdio_read;
3122 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003123 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003124
Andrew Lunn6f882842018-03-17 20:32:05 +01003125 if (!external) {
3126 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3127 if (err)
3128 return err;
3129 }
3130
Florian Fainelli00e798c2018-05-15 16:56:19 -07003131 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003132 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003133 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003134 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003135 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003136 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003137
3138 if (external)
3139 list_add_tail(&mdio_bus->list, &chip->mdios);
3140 else
3141 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003142
3143 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003144}
3145
Andrew Lunna3c53be52017-01-24 14:53:50 +01003146static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3147 { .compatible = "marvell,mv88e6xxx-mdio-external",
3148 .data = (void *)true },
3149 { },
3150};
3151
Andrew Lunn3126aee2017-12-07 01:05:57 +01003152static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3153
3154{
3155 struct mv88e6xxx_mdio_bus *mdio_bus;
3156 struct mii_bus *bus;
3157
3158 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3159 bus = mdio_bus->bus;
3160
Andrew Lunn6f882842018-03-17 20:32:05 +01003161 if (!mdio_bus->external)
3162 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3163
Andrew Lunn3126aee2017-12-07 01:05:57 +01003164 mdiobus_unregister(bus);
3165 }
3166}
3167
Andrew Lunna3c53be52017-01-24 14:53:50 +01003168static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3169 struct device_node *np)
3170{
3171 const struct of_device_id *match;
3172 struct device_node *child;
3173 int err;
3174
3175 /* Always register one mdio bus for the internal/default mdio
3176 * bus. This maybe represented in the device tree, but is
3177 * optional.
3178 */
3179 child = of_get_child_by_name(np, "mdio");
3180 err = mv88e6xxx_mdio_register(chip, child, false);
3181 if (err)
3182 return err;
3183
3184 /* Walk the device tree, and see if there are any other nodes
3185 * which say they are compatible with the external mdio
3186 * bus.
3187 */
3188 for_each_available_child_of_node(np, child) {
3189 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3190 if (match) {
3191 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003192 if (err) {
3193 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303194 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003195 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003196 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003197 }
3198 }
3199
3200 return 0;
3201}
3202
Vivien Didelot855b1932016-07-20 18:18:35 -04003203static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3204{
Vivien Didelot04bed142016-08-31 18:06:13 -04003205 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003206
3207 return chip->eeprom_len;
3208}
3209
Vivien Didelot855b1932016-07-20 18:18:35 -04003210static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3211 struct ethtool_eeprom *eeprom, u8 *data)
3212{
Vivien Didelot04bed142016-08-31 18:06:13 -04003213 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003214 int err;
3215
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003216 if (!chip->info->ops->get_eeprom)
3217 return -EOPNOTSUPP;
3218
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003219 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003220 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003221 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003222
3223 if (err)
3224 return err;
3225
3226 eeprom->magic = 0xc3ec4951;
3227
3228 return 0;
3229}
3230
Vivien Didelot855b1932016-07-20 18:18:35 -04003231static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3232 struct ethtool_eeprom *eeprom, u8 *data)
3233{
Vivien Didelot04bed142016-08-31 18:06:13 -04003234 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003235 int err;
3236
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003237 if (!chip->info->ops->set_eeprom)
3238 return -EOPNOTSUPP;
3239
Vivien Didelot855b1932016-07-20 18:18:35 -04003240 if (eeprom->magic != 0xc3ec4951)
3241 return -EINVAL;
3242
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003243 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003244 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003245 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003246
3247 return err;
3248}
3249
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003250static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003251 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003252 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3253 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003254 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003255 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003256 .phy_read = mv88e6185_phy_ppu_read,
3257 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003258 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003259 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003260 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003261 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003262 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003263 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003264 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003265 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003266 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003267 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003268 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003269 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003270 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003271 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003272 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003273 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003274 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3275 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003276 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003277 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3278 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003279 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003280 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003281 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003282 .ppu_enable = mv88e6185_g1_ppu_enable,
3283 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003284 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003285 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003286 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003287 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003288 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003289};
3290
3291static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003292 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003293 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3294 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003295 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003296 .phy_read = mv88e6185_phy_ppu_read,
3297 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003298 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003299 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003300 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003301 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003302 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003303 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02003304 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003305 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003306 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003307 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003308 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003309 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3310 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003311 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003312 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003313 .ppu_enable = mv88e6185_g1_ppu_enable,
3314 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003315 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003316 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003317 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003318 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003319};
3320
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003321static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003322 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003323 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3324 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003325 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003326 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3327 .phy_read = mv88e6xxx_g2_smi_phy_read,
3328 .phy_write = mv88e6xxx_g2_smi_phy_write,
3329 .port_set_link = mv88e6xxx_port_set_link,
3330 .port_set_duplex = mv88e6xxx_port_set_duplex,
3331 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003332 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003333 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003334 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003335 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003336 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003337 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003338 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003339 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003340 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003341 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003342 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003343 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003344 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003345 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003346 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3347 .stats_get_strings = mv88e6095_stats_get_strings,
3348 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003349 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3350 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003351 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003352 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003353 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003354 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003355 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003356 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003357 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003358 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003359};
3360
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003361static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003362 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003363 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3364 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003365 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003366 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003367 .phy_read = mv88e6xxx_g2_smi_phy_read,
3368 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003369 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003370 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003371 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003372 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003373 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003374 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003375 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003376 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003377 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003378 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003379 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003380 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003381 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3382 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003383 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003384 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3385 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003386 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003387 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003388 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003389 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003390 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3391 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003392 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003393 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003394 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003395};
3396
3397static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003398 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003399 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3400 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003401 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003402 .phy_read = mv88e6185_phy_ppu_read,
3403 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003404 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003405 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003406 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003407 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003408 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003409 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003410 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003411 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003412 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003413 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003414 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003415 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003416 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003417 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003418 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003419 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003420 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003421 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3422 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003423 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003424 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3425 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003426 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003427 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003428 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003429 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003430 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003431 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003432 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003433 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003434 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003435};
3436
Vivien Didelot990e27b2017-03-28 13:50:32 -04003437static const struct mv88e6xxx_ops mv88e6141_ops = {
3438 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003439 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3440 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003441 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003442 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3443 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3444 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3445 .phy_read = mv88e6xxx_g2_smi_phy_read,
3446 .phy_write = mv88e6xxx_g2_smi_phy_write,
3447 .port_set_link = mv88e6xxx_port_set_link,
3448 .port_set_duplex = mv88e6xxx_port_set_duplex,
3449 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003450 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003451 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003452 .port_tag_remap = mv88e6095_port_tag_remap,
3453 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3454 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3455 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003456 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003457 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003458 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003459 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3460 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003461 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003462 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003463 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003464 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003465 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003466 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003467 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3468 .stats_get_strings = mv88e6320_stats_get_strings,
3469 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003470 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3471 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003472 .watchdog_ops = &mv88e6390_watchdog_ops,
3473 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003474 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003475 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003476 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003477 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003478 .serdes_power = mv88e6390_serdes_power,
3479 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003480 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003481 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003482 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003483 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003484 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003485};
3486
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003487static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003488 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003489 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3490 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003491 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003492 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003493 .phy_read = mv88e6xxx_g2_smi_phy_read,
3494 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003495 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003496 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003497 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003498 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003499 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003500 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003501 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003502 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003503 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003504 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003505 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003506 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003507 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003508 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003509 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003510 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003511 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003512 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3513 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003514 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003515 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3516 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003517 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003518 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003519 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003520 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003521 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3522 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003523 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003524 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003525 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003526 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003527 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003528};
3529
3530static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003531 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003532 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3533 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003534 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003535 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003536 .phy_read = mv88e6165_phy_read,
3537 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003538 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003539 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003540 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003541 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003542 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003543 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003544 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003545 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003546 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003547 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003548 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3549 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003550 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003551 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3552 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003553 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003554 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003555 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003556 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003557 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3558 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003559 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003560 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003561 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003562 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003563 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003564};
3565
3566static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003567 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003568 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3569 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003570 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003571 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003572 .phy_read = mv88e6xxx_g2_smi_phy_read,
3573 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003574 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003575 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003576 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003577 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003578 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003579 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003580 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003581 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003582 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003583 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003584 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003585 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003586 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003587 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003588 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003589 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003590 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003591 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003592 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3593 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003594 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003595 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3596 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003597 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003598 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003599 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003600 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003601 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3602 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003603 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003604 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003605 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003606};
3607
3608static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003609 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003610 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3611 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003612 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003613 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3614 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003615 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003616 .phy_read = mv88e6xxx_g2_smi_phy_read,
3617 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003618 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003619 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003620 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003621 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003622 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003623 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003624 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003625 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003626 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003627 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003628 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003629 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003630 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003631 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003632 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003633 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003634 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003635 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003636 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003637 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3638 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003639 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003640 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3641 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003642 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003643 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003644 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003645 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003646 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003647 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3648 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003649 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003650 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003651 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003652 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003653 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003654 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003655};
3656
3657static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003658 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003659 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3660 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003661 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003662 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003663 .phy_read = mv88e6xxx_g2_smi_phy_read,
3664 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003665 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003666 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003667 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003668 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003669 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003670 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003671 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003672 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003673 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003674 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003675 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003676 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003677 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003678 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003679 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003680 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003681 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003682 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003683 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3684 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003685 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003686 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3687 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003688 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003689 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003690 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003691 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003692 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3693 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003694 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003695 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003696 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003697};
3698
3699static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003700 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003701 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3702 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003703 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003704 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3705 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003706 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003707 .phy_read = mv88e6xxx_g2_smi_phy_read,
3708 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003709 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003710 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003711 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003712 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003713 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003714 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003715 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003716 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003717 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003718 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003719 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003720 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003721 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003722 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003723 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003724 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003725 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003726 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003727 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003728 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3729 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003730 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003731 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3732 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003733 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003734 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003735 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003736 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003737 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003738 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3739 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003740 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003741 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003742 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003743 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003744 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003745 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003746 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003747 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003748 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003749};
3750
3751static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003752 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003753 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3754 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003755 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003756 .phy_read = mv88e6185_phy_ppu_read,
3757 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003758 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003759 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003760 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003761 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003762 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003763 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003764 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003765 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003766 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003767 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003768 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003769 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003770 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003771 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3772 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003773 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003774 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3775 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003776 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003777 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003778 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003779 .ppu_enable = mv88e6185_g1_ppu_enable,
3780 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003781 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003782 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003783 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003784 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003785};
3786
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003787static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003788 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003789 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003790 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003791 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3792 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003793 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3794 .phy_read = mv88e6xxx_g2_smi_phy_read,
3795 .phy_write = mv88e6xxx_g2_smi_phy_write,
3796 .port_set_link = mv88e6xxx_port_set_link,
3797 .port_set_duplex = mv88e6xxx_port_set_duplex,
3798 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3799 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003800 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003801 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003802 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003803 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003804 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003805 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003806 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003807 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003808 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003809 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003810 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003811 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003812 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003813 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003814 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003815 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3816 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003817 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003818 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3819 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003820 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003821 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003822 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003823 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003824 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003825 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3826 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003827 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3828 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003829 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003830 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003831 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003832 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003833 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003834 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003835 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003836};
3837
3838static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003839 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003840 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003841 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003842 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3843 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003844 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3845 .phy_read = mv88e6xxx_g2_smi_phy_read,
3846 .phy_write = mv88e6xxx_g2_smi_phy_write,
3847 .port_set_link = mv88e6xxx_port_set_link,
3848 .port_set_duplex = mv88e6xxx_port_set_duplex,
3849 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3850 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003851 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003852 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003853 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003854 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003855 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003856 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003857 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003858 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003859 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003860 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003861 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003862 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003863 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003864 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003865 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003866 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3867 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003868 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003869 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3870 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003871 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003872 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003873 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003874 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003875 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003876 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3877 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003878 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3879 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003880 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003881 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003882 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003883 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003884 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003885 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003886 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003887};
3888
3889static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003890 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003891 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003892 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003893 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3894 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003895 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3896 .phy_read = mv88e6xxx_g2_smi_phy_read,
3897 .phy_write = mv88e6xxx_g2_smi_phy_write,
3898 .port_set_link = mv88e6xxx_port_set_link,
3899 .port_set_duplex = mv88e6xxx_port_set_duplex,
3900 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3901 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003902 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003903 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003904 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003905 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003906 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003907 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003908 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003909 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003910 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003911 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003912 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003913 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003914 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003915 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003916 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3917 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003918 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003919 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3920 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003921 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003922 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003923 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003924 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003925 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003926 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3927 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003928 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3929 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003930 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003931 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003932 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003933 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003934 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003935 .avb_ops = &mv88e6390_avb_ops,
3936 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003937 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003938};
3939
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003940static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003941 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003942 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3943 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003944 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003945 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3946 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003947 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003948 .phy_read = mv88e6xxx_g2_smi_phy_read,
3949 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003950 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003951 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003952 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003953 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003954 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003955 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003956 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003957 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003958 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003959 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003960 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003961 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003962 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003963 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003964 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003965 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003966 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003967 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003968 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003969 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3970 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003971 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003972 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3973 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003974 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003975 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003976 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003977 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003978 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003979 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3980 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003981 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003982 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003983 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02003984 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003985 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003986 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003987 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003988 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003989 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003990 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003991 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003992};
3993
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003994static const struct mv88e6xxx_ops mv88e6250_ops = {
3995 /* MV88E6XXX_FAMILY_6250 */
3996 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3997 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3998 .irl_init_all = mv88e6352_g2_irl_init_all,
3999 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4000 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4001 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4002 .phy_read = mv88e6xxx_g2_smi_phy_read,
4003 .phy_write = mv88e6xxx_g2_smi_phy_write,
4004 .port_set_link = mv88e6xxx_port_set_link,
4005 .port_set_duplex = mv88e6xxx_port_set_duplex,
4006 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4007 .port_set_speed = mv88e6250_port_set_speed,
4008 .port_tag_remap = mv88e6095_port_tag_remap,
4009 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4010 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4011 .port_set_ether_type = mv88e6351_port_set_ether_type,
4012 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4013 .port_pause_limit = mv88e6097_port_pause_limit,
4014 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4015 .port_link_state = mv88e6250_port_link_state,
4016 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4017 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4018 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4019 .stats_get_strings = mv88e6250_stats_get_strings,
4020 .stats_get_stats = mv88e6250_stats_get_stats,
4021 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4022 .set_egress_port = mv88e6095_g1_set_egress_port,
4023 .watchdog_ops = &mv88e6250_watchdog_ops,
4024 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4025 .pot_clear = mv88e6xxx_g2_pot_clear,
4026 .reset = mv88e6250_g1_reset,
4027 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4028 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004029 .avb_ops = &mv88e6352_avb_ops,
4030 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004031 .phylink_validate = mv88e6065_phylink_validate,
4032};
4033
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004034static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004035 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004036 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004037 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004038 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4039 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004040 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4041 .phy_read = mv88e6xxx_g2_smi_phy_read,
4042 .phy_write = mv88e6xxx_g2_smi_phy_write,
4043 .port_set_link = mv88e6xxx_port_set_link,
4044 .port_set_duplex = mv88e6xxx_port_set_duplex,
4045 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4046 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004047 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004048 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004049 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004050 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004051 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004052 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004053 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004054 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004055 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004056 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004057 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004058 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004059 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004060 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004061 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004062 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4063 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004064 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004065 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4066 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004067 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004068 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004069 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004070 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004071 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004072 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4073 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004074 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4075 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004076 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004077 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004078 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004079 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004080 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004081 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004082 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004083 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004084 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004085};
4086
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004087static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004088 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004089 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4090 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004091 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004092 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4093 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004094 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004095 .phy_read = mv88e6xxx_g2_smi_phy_read,
4096 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004097 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004098 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004099 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004100 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004101 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004102 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004103 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004104 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004105 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004106 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004107 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004108 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004109 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004110 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004111 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004112 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004113 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004114 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4115 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004116 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004117 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4118 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004119 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004120 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004121 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004122 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004123 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004124 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004125 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004126 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004127 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004128 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004129};
4130
4131static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004132 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004133 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4134 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004135 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004136 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4137 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004138 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004139 .phy_read = mv88e6xxx_g2_smi_phy_read,
4140 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004141 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004142 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004143 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004144 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004145 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004146 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004147 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004148 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004149 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004150 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004151 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004152 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004153 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004154 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004155 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004156 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004157 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004158 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4159 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004160 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004161 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4162 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004163 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004164 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004165 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004166 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004167 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004168 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004169 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004170 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004171};
4172
Vivien Didelot16e329a2017-03-28 13:50:33 -04004173static const struct mv88e6xxx_ops mv88e6341_ops = {
4174 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004175 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4176 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004177 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004178 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4179 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4180 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4181 .phy_read = mv88e6xxx_g2_smi_phy_read,
4182 .phy_write = mv88e6xxx_g2_smi_phy_write,
4183 .port_set_link = mv88e6xxx_port_set_link,
4184 .port_set_duplex = mv88e6xxx_port_set_duplex,
4185 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02004186 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004187 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004188 .port_tag_remap = mv88e6095_port_tag_remap,
4189 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4190 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4191 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004192 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004193 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004194 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004195 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4196 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004197 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004198 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004199 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004200 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004201 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004202 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004203 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4204 .stats_get_strings = mv88e6320_stats_get_strings,
4205 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004206 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4207 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004208 .watchdog_ops = &mv88e6390_watchdog_ops,
4209 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004210 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004211 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004212 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004213 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004214 .serdes_power = mv88e6390_serdes_power,
4215 .serdes_get_lane = mv88e6341_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004216 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004217 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004218 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004219 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004220 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004221 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004222 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004223};
4224
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004225static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004226 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004227 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4228 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004229 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004230 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004231 .phy_read = mv88e6xxx_g2_smi_phy_read,
4232 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004233 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004234 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004235 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004236 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004237 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004238 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004239 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004240 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004241 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004242 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004243 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004244 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004245 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004246 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004247 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004248 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004249 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004250 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004251 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4252 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004253 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004254 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4255 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004256 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004257 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004258 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004259 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004260 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4261 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004262 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004263 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004264 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004265};
4266
4267static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004268 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004269 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4270 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004271 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004272 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004273 .phy_read = mv88e6xxx_g2_smi_phy_read,
4274 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004275 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004276 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004277 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004278 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004279 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004280 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004281 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004282 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004283 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004284 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004285 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004286 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004287 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004288 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004289 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004290 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004291 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004292 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004293 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4294 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004295 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004296 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4297 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004298 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004299 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004300 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004301 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004302 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4303 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004304 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004305 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004306 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004307 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004308 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004309};
4310
4311static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004312 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004313 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4314 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004315 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004316 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4317 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004318 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004319 .phy_read = mv88e6xxx_g2_smi_phy_read,
4320 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004321 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01004322 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004323 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01004324 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004325 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004326 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004327 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004328 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004329 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004330 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004331 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004332 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004333 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004334 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004335 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004336 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004337 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004338 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004339 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004340 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4341 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004342 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004343 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4344 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004345 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004346 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004347 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004348 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004349 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004350 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4351 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004352 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004353 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004354 .serdes_get_lane = mv88e6352_serdes_get_lane,
Andrew Lunn6d917822017-05-26 01:03:21 +02004355 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004356 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004357 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004358 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004359 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004360 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004361 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004362 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4363 .serdes_get_strings = mv88e6352_serdes_get_strings,
4364 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02004365 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004366};
4367
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004368static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004369 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004370 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004371 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004372 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4373 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004374 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4375 .phy_read = mv88e6xxx_g2_smi_phy_read,
4376 .phy_write = mv88e6xxx_g2_smi_phy_write,
4377 .port_set_link = mv88e6xxx_port_set_link,
4378 .port_set_duplex = mv88e6xxx_port_set_duplex,
4379 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4380 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004381 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004382 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004383 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004384 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004385 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004386 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004387 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004388 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004389 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004390 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004391 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004392 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004393 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004394 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004395 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004396 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004397 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004398 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4399 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004400 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004401 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4402 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004403 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004404 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004405 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004406 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004407 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004408 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4409 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004410 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4411 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004412 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004413 .serdes_get_lane = mv88e6390_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004414 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004415 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004416 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004417 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004418 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004419 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004420 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004421};
4422
4423static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004424 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004425 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004426 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004427 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4428 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004429 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4430 .phy_read = mv88e6xxx_g2_smi_phy_read,
4431 .phy_write = mv88e6xxx_g2_smi_phy_write,
4432 .port_set_link = mv88e6xxx_port_set_link,
4433 .port_set_duplex = mv88e6xxx_port_set_duplex,
4434 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4435 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004436 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004437 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004438 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004439 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004440 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004441 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004442 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004443 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004444 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004445 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004446 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02004447 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004448 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004449 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004450 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004451 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004452 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004453 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4454 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004455 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004456 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4457 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004458 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004459 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004460 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004461 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004462 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004463 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4464 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004465 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4466 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004467 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004468 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004469 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004470 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004471 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004472 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004473 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004474 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004475 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004476};
4477
Vivien Didelotf81ec902016-05-09 13:22:58 -04004478static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4479 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004480 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004481 .family = MV88E6XXX_FAMILY_6097,
4482 .name = "Marvell 88E6085",
4483 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004484 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004485 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004486 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004487 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004488 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004489 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004490 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004491 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004492 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004493 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004494 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004495 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004496 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004497 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004498 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004499 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004500 },
4501
4502 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004503 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004504 .family = MV88E6XXX_FAMILY_6095,
4505 .name = "Marvell 88E6095/88E6095F",
4506 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004507 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004508 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004509 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004510 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004511 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004512 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004513 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004514 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004515 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004516 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004517 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004518 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004519 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004520 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004521 },
4522
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004523 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004524 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004525 .family = MV88E6XXX_FAMILY_6097,
4526 .name = "Marvell 88E6097/88E6097F",
4527 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004528 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004529 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004530 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004531 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004532 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004533 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004534 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004535 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004536 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004537 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004538 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004539 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004540 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004541 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004542 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004543 .ops = &mv88e6097_ops,
4544 },
4545
Vivien Didelotf81ec902016-05-09 13:22:58 -04004546 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004547 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004548 .family = MV88E6XXX_FAMILY_6165,
4549 .name = "Marvell 88E6123",
4550 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004551 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004552 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004553 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004554 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004555 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004556 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004557 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004558 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004559 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004560 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004561 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004562 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004563 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004564 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004565 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004566 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004567 },
4568
4569 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004570 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004571 .family = MV88E6XXX_FAMILY_6185,
4572 .name = "Marvell 88E6131",
4573 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004574 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004575 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004576 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004577 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004578 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004579 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004580 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004581 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004582 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004583 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004584 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004585 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004586 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004587 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004588 },
4589
Vivien Didelot990e27b2017-03-28 13:50:32 -04004590 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004591 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004592 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004593 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004594 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004595 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004596 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004597 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004598 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004599 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004600 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004601 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004602 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004603 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004604 .age_time_coeff = 3750,
4605 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004606 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004607 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004608 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004609 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004610 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004611 .ops = &mv88e6141_ops,
4612 },
4613
Vivien Didelotf81ec902016-05-09 13:22:58 -04004614 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004615 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004616 .family = MV88E6XXX_FAMILY_6165,
4617 .name = "Marvell 88E6161",
4618 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004619 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004620 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004621 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004622 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004623 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004624 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004625 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004626 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004627 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004628 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004629 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004630 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004631 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004632 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004633 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004634 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004635 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004636 },
4637
4638 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004639 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004640 .family = MV88E6XXX_FAMILY_6165,
4641 .name = "Marvell 88E6165",
4642 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004643 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004644 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004645 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004646 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004647 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004648 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004649 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004650 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004651 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004652 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004653 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004654 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004655 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004656 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004657 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004658 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004659 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004660 },
4661
4662 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004663 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004664 .family = MV88E6XXX_FAMILY_6351,
4665 .name = "Marvell 88E6171",
4666 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004667 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004668 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004669 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004670 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004671 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004672 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004673 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004674 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004675 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004676 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004677 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004678 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004679 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004680 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004681 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004682 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004683 },
4684
4685 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004686 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004687 .family = MV88E6XXX_FAMILY_6352,
4688 .name = "Marvell 88E6172",
4689 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004690 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004691 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004692 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004693 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004694 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004695 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004696 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004697 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004698 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004699 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004700 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004701 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004702 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004703 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004704 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004705 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004706 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004707 },
4708
4709 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004710 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004711 .family = MV88E6XXX_FAMILY_6351,
4712 .name = "Marvell 88E6175",
4713 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004714 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004715 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004716 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004717 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004718 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004719 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004720 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004721 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004722 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004723 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004724 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004725 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004726 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004727 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004728 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004729 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004730 },
4731
4732 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004733 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004734 .family = MV88E6XXX_FAMILY_6352,
4735 .name = "Marvell 88E6176",
4736 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004737 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004739 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004740 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004741 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004742 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004743 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004744 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004745 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004746 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004747 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004748 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004749 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004750 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004751 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004752 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004753 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 },
4755
4756 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004757 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004758 .family = MV88E6XXX_FAMILY_6185,
4759 .name = "Marvell 88E6185",
4760 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004761 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004762 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004763 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004764 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004765 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004766 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004767 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004768 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004769 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004770 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004771 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004772 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004773 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004774 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 },
4776
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004777 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004778 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004779 .family = MV88E6XXX_FAMILY_6390,
4780 .name = "Marvell 88E6190",
4781 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004782 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004783 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004784 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004785 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004786 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004787 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004788 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004789 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004790 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004791 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004792 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004793 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004794 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004795 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004796 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004797 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004798 .ops = &mv88e6190_ops,
4799 },
4800
4801 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004802 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004803 .family = MV88E6XXX_FAMILY_6390,
4804 .name = "Marvell 88E6190X",
4805 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004806 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004807 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004808 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004809 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004810 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004811 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004812 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004813 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004814 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004815 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004816 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004817 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004818 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004819 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004820 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004821 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004822 .ops = &mv88e6190x_ops,
4823 },
4824
4825 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004826 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004827 .family = MV88E6XXX_FAMILY_6390,
4828 .name = "Marvell 88E6191",
4829 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004830 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004831 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004832 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004833 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004834 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004835 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004836 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004837 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004838 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004839 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004840 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004841 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004842 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004843 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004844 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004845 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004846 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004847 },
4848
Hubert Feurstein49022642019-07-31 10:23:46 +02004849 [MV88E6220] = {
4850 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4851 .family = MV88E6XXX_FAMILY_6250,
4852 .name = "Marvell 88E6220",
4853 .num_databases = 64,
4854
4855 /* Ports 2-4 are not routed to pins
4856 * => usable ports 0, 1, 5, 6
4857 */
4858 .num_ports = 7,
4859 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004860 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004861 .max_vid = 4095,
4862 .port_base_addr = 0x08,
4863 .phy_base_addr = 0x00,
4864 .global1_addr = 0x0f,
4865 .global2_addr = 0x07,
4866 .age_time_coeff = 15000,
4867 .g1_irqs = 9,
4868 .g2_irqs = 10,
4869 .atu_move_port_mask = 0xf,
4870 .dual_chip = true,
4871 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004872 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004873 .ops = &mv88e6250_ops,
4874 },
4875
Vivien Didelotf81ec902016-05-09 13:22:58 -04004876 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004877 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004878 .family = MV88E6XXX_FAMILY_6352,
4879 .name = "Marvell 88E6240",
4880 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004881 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004882 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004883 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004884 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004885 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004886 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004887 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004888 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004889 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004890 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004891 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004892 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004893 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004894 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004895 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004896 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004897 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004898 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004899 },
4900
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004901 [MV88E6250] = {
4902 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4903 .family = MV88E6XXX_FAMILY_6250,
4904 .name = "Marvell 88E6250",
4905 .num_databases = 64,
4906 .num_ports = 7,
4907 .num_internal_phys = 5,
4908 .max_vid = 4095,
4909 .port_base_addr = 0x08,
4910 .phy_base_addr = 0x00,
4911 .global1_addr = 0x0f,
4912 .global2_addr = 0x07,
4913 .age_time_coeff = 15000,
4914 .g1_irqs = 9,
4915 .g2_irqs = 10,
4916 .atu_move_port_mask = 0xf,
4917 .dual_chip = true,
4918 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004919 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004920 .ops = &mv88e6250_ops,
4921 },
4922
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004923 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004924 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004925 .family = MV88E6XXX_FAMILY_6390,
4926 .name = "Marvell 88E6290",
4927 .num_databases = 4096,
4928 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004929 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004930 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004931 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004932 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004933 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004934 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004935 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004936 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004937 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004938 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004939 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004940 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004941 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004942 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004943 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004944 .ops = &mv88e6290_ops,
4945 },
4946
Vivien Didelotf81ec902016-05-09 13:22:58 -04004947 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004948 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004949 .family = MV88E6XXX_FAMILY_6320,
4950 .name = "Marvell 88E6320",
4951 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004952 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004953 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004954 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004955 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004956 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004957 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004958 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004959 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004960 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004961 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004962 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004963 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004964 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004965 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004966 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004967 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004968 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004969 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004970 },
4971
4972 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004973 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004974 .family = MV88E6XXX_FAMILY_6320,
4975 .name = "Marvell 88E6321",
4976 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004977 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004978 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004979 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004980 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004981 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004982 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004983 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004984 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004985 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004986 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004987 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004988 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004989 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004990 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004991 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004992 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004993 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004994 },
4995
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004996 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004997 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004998 .family = MV88E6XXX_FAMILY_6341,
4999 .name = "Marvell 88E6341",
5000 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005001 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005002 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005003 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005004 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005005 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005006 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005007 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005008 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005009 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005010 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005011 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005012 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005013 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005014 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005015 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005016 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005017 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005018 .ops = &mv88e6341_ops,
5019 },
5020
Vivien Didelotf81ec902016-05-09 13:22:58 -04005021 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005022 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005023 .family = MV88E6XXX_FAMILY_6351,
5024 .name = "Marvell 88E6350",
5025 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005026 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005027 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005028 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005029 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005030 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005031 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005032 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005033 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005034 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005035 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005036 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005037 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005038 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005039 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005040 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005041 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005042 },
5043
5044 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005045 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005046 .family = MV88E6XXX_FAMILY_6351,
5047 .name = "Marvell 88E6351",
5048 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005049 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005050 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005051 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005052 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005053 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005054 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005055 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005056 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005057 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005058 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005059 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005060 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005061 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005062 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005063 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005064 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005065 },
5066
5067 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005068 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005069 .family = MV88E6XXX_FAMILY_6352,
5070 .name = "Marvell 88E6352",
5071 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005072 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005073 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005074 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005075 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005076 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005077 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005078 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005079 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005080 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005081 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005082 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005083 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005084 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005085 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005086 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005087 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005088 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005089 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005090 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005091 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005092 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005093 .family = MV88E6XXX_FAMILY_6390,
5094 .name = "Marvell 88E6390",
5095 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005096 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005097 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005098 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005099 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005100 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005101 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005102 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005103 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005104 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005105 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005106 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005107 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005108 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005109 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005110 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005111 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005112 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005113 .ops = &mv88e6390_ops,
5114 },
5115 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005116 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005117 .family = MV88E6XXX_FAMILY_6390,
5118 .name = "Marvell 88E6390X",
5119 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005120 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005121 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005122 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005123 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005124 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005125 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005126 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005127 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005128 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005129 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005130 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005131 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005132 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005133 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005134 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005135 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005136 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005137 .ops = &mv88e6390x_ops,
5138 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005139};
5140
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005141static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005142{
Vivien Didelota439c062016-04-17 13:23:58 -04005143 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005144
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005145 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5146 if (mv88e6xxx_table[i].prod_num == prod_num)
5147 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005148
Vivien Didelotb9b37712015-10-30 19:39:48 -04005149 return NULL;
5150}
5151
Vivien Didelotfad09c72016-06-21 12:28:20 -04005152static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005153{
5154 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005155 unsigned int prod_num, rev;
5156 u16 id;
5157 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005158
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005159 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005160 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005161 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005162 if (err)
5163 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005164
Vivien Didelot107fcc12017-06-12 12:37:36 -04005165 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5166 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005167
5168 info = mv88e6xxx_lookup_info(prod_num);
5169 if (!info)
5170 return -ENODEV;
5171
Vivien Didelotcaac8542016-06-20 13:14:09 -04005172 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005173 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005174
Vivien Didelotca070c12016-09-02 14:45:34 -04005175 err = mv88e6xxx_g2_require(chip);
5176 if (err)
5177 return err;
5178
Vivien Didelotfad09c72016-06-21 12:28:20 -04005179 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5180 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005181
5182 return 0;
5183}
5184
Vivien Didelotfad09c72016-06-21 12:28:20 -04005185static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005186{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005187 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005188
Vivien Didelotfad09c72016-06-21 12:28:20 -04005189 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5190 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005191 return NULL;
5192
Vivien Didelotfad09c72016-06-21 12:28:20 -04005193 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005194
Vivien Didelotfad09c72016-06-21 12:28:20 -04005195 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005196 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005197 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005198
Vivien Didelotfad09c72016-06-21 12:28:20 -04005199 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005200}
5201
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005202static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
5203 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02005204{
Vivien Didelot04bed142016-08-31 18:06:13 -04005205 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005206
Andrew Lunn443d5a12016-12-03 04:35:18 +01005207 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005208}
5209
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005210static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005211 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005212{
5213 /* We don't need any dynamic resource from the kernel (yet),
5214 * so skip the prepare phase.
5215 */
5216
5217 return 0;
5218}
5219
5220static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005221 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005222{
Vivien Didelot04bed142016-08-31 18:06:13 -04005223 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005224
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005225 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005226 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005227 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005228 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5229 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005230 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005231}
5232
5233static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5234 const struct switchdev_obj_port_mdb *mdb)
5235{
Vivien Didelot04bed142016-08-31 18:06:13 -04005236 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005237 int err;
5238
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005239 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005240 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005241 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005242
5243 return err;
5244}
5245
Russell King4f859012019-02-20 15:35:05 -08005246static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5247 bool unicast, bool multicast)
5248{
5249 struct mv88e6xxx_chip *chip = ds->priv;
5250 int err = -EOPNOTSUPP;
5251
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005252 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005253 if (chip->info->ops->port_set_egress_floods)
5254 err = chip->info->ops->port_set_egress_floods(chip, port,
5255 unicast,
5256 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005257 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005258
5259 return err;
5260}
5261
Florian Fainellia82f67a2017-01-08 14:52:08 -08005262static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005263 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005264 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005265 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005266 .phylink_validate = mv88e6xxx_validate,
5267 .phylink_mac_link_state = mv88e6xxx_link_state,
5268 .phylink_mac_config = mv88e6xxx_mac_config,
5269 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5270 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005271 .get_strings = mv88e6xxx_get_strings,
5272 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5273 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005274 .port_enable = mv88e6xxx_port_enable,
5275 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005276 .get_mac_eee = mv88e6xxx_get_mac_eee,
5277 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005278 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005279 .get_eeprom = mv88e6xxx_get_eeprom,
5280 .set_eeprom = mv88e6xxx_set_eeprom,
5281 .get_regs_len = mv88e6xxx_get_regs_len,
5282 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005283 .get_rxnfc = mv88e6xxx_get_rxnfc,
5284 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005285 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005286 .port_bridge_join = mv88e6xxx_port_bridge_join,
5287 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005288 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005289 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005290 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005291 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5292 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5293 .port_vlan_add = mv88e6xxx_port_vlan_add,
5294 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005295 .port_fdb_add = mv88e6xxx_port_fdb_add,
5296 .port_fdb_del = mv88e6xxx_port_fdb_del,
5297 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005298 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5299 .port_mdb_add = mv88e6xxx_port_mdb_add,
5300 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005301 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5302 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005303 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5304 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5305 .port_txtstamp = mv88e6xxx_port_txtstamp,
5306 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5307 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005308 .devlink_param_get = mv88e6xxx_devlink_param_get,
5309 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005310};
5311
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005312static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005313{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005314 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005315 struct dsa_switch *ds;
5316
Vivien Didelot7e99e342019-10-21 16:51:30 -04005317 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005318 if (!ds)
5319 return -ENOMEM;
5320
Vivien Didelot7e99e342019-10-21 16:51:30 -04005321 ds->dev = dev;
5322 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005323 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005324 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005325 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005326 ds->ageing_time_min = chip->info->age_time_coeff;
5327 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005328
5329 dev_set_drvdata(dev, ds);
5330
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005331 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005332}
5333
Vivien Didelotfad09c72016-06-21 12:28:20 -04005334static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005335{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005336 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005337}
5338
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005339static const void *pdata_device_get_match_data(struct device *dev)
5340{
5341 const struct of_device_id *matches = dev->driver->of_match_table;
5342 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5343
5344 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5345 matches++) {
5346 if (!strcmp(pdata->compatible, matches->compatible))
5347 return matches->data;
5348 }
5349 return NULL;
5350}
5351
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005352/* There is no suspend to RAM support at DSA level yet, the switch configuration
5353 * would be lost after a power cycle so prevent it to be suspended.
5354 */
5355static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5356{
5357 return -EOPNOTSUPP;
5358}
5359
5360static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5361{
5362 return 0;
5363}
5364
5365static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5366
Vivien Didelot57d32312016-06-20 13:13:58 -04005367static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005368{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005369 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005370 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005371 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005372 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005373 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005374 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005375 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005376
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005377 if (!np && !pdata)
5378 return -EINVAL;
5379
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005380 if (np)
5381 compat_info = of_device_get_match_data(dev);
5382
5383 if (pdata) {
5384 compat_info = pdata_device_get_match_data(dev);
5385
5386 if (!pdata->netdev)
5387 return -EINVAL;
5388
5389 for (port = 0; port < DSA_MAX_PORTS; port++) {
5390 if (!(pdata->enabled_ports & (1 << port)))
5391 continue;
5392 if (strcmp(pdata->cd.port_names[port], "cpu"))
5393 continue;
5394 pdata->cd.netdev[port] = &pdata->netdev->dev;
5395 break;
5396 }
5397 }
5398
Vivien Didelotcaac8542016-06-20 13:14:09 -04005399 if (!compat_info)
5400 return -EINVAL;
5401
Vivien Didelotfad09c72016-06-21 12:28:20 -04005402 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005403 if (!chip) {
5404 err = -ENOMEM;
5405 goto out;
5406 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005407
Vivien Didelotfad09c72016-06-21 12:28:20 -04005408 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005409
Vivien Didelotfad09c72016-06-21 12:28:20 -04005410 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005411 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005412 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005413
Andrew Lunnb4308f02016-11-21 23:26:55 +01005414 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005415 if (IS_ERR(chip->reset)) {
5416 err = PTR_ERR(chip->reset);
5417 goto out;
5418 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005419 if (chip->reset)
5420 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005421
Vivien Didelotfad09c72016-06-21 12:28:20 -04005422 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005423 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005424 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005425
Vivien Didelote57e5e72016-08-15 17:19:00 -04005426 mv88e6xxx_phy_init(chip);
5427
Andrew Lunn00baabe2018-05-19 22:31:35 +02005428 if (chip->info->ops->get_eeprom) {
5429 if (np)
5430 of_property_read_u32(np, "eeprom-length",
5431 &chip->eeprom_len);
5432 else
5433 chip->eeprom_len = pdata->eeprom_len;
5434 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005435
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005436 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005437 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005438 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005439 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005440 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005441
Andrew Lunna27415d2019-05-01 00:10:50 +02005442 if (np) {
5443 chip->irq = of_irq_get(np, 0);
5444 if (chip->irq == -EPROBE_DEFER) {
5445 err = chip->irq;
5446 goto out;
5447 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005448 }
5449
Andrew Lunna27415d2019-05-01 00:10:50 +02005450 if (pdata)
5451 chip->irq = pdata->irq;
5452
Andrew Lunn294d7112018-02-22 22:58:32 +01005453 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005454 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005455 * controllers
5456 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005457 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005458 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005459 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005460 else
5461 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005462 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005463
Andrew Lunn294d7112018-02-22 22:58:32 +01005464 if (err)
5465 goto out;
5466
5467 if (chip->info->g2_irqs > 0) {
5468 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005469 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005470 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005471 }
5472
Andrew Lunn294d7112018-02-22 22:58:32 +01005473 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5474 if (err)
5475 goto out_g2_irq;
5476
5477 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5478 if (err)
5479 goto out_g1_atu_prob_irq;
5480
Andrew Lunna3c53be52017-01-24 14:53:50 +01005481 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005482 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005483 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005484
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005485 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005486 if (err)
5487 goto out_mdio;
5488
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005489 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005490
5491out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005492 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005493out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005494 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005495out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005496 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005497out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005498 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005499 mv88e6xxx_g2_irq_free(chip);
5500out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005501 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005502 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005503 else
5504 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005505out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005506 if (pdata)
5507 dev_put(pdata->netdev);
5508
Andrew Lunndc30c352016-10-16 19:56:49 +02005509 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005510}
5511
5512static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5513{
5514 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005515 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005516
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005517 if (chip->info->ptp_support) {
5518 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005519 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005520 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005521
Andrew Lunn930188c2016-08-22 16:01:03 +02005522 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005523 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005524 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005525
Andrew Lunn76f38f12018-03-17 20:21:09 +01005526 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5527 mv88e6xxx_g1_atu_prob_irq_free(chip);
5528
5529 if (chip->info->g2_irqs > 0)
5530 mv88e6xxx_g2_irq_free(chip);
5531
Andrew Lunn76f38f12018-03-17 20:21:09 +01005532 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005533 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005534 else
5535 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005536}
5537
5538static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005539 {
5540 .compatible = "marvell,mv88e6085",
5541 .data = &mv88e6xxx_table[MV88E6085],
5542 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005543 {
5544 .compatible = "marvell,mv88e6190",
5545 .data = &mv88e6xxx_table[MV88E6190],
5546 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005547 {
5548 .compatible = "marvell,mv88e6250",
5549 .data = &mv88e6xxx_table[MV88E6250],
5550 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005551 { /* sentinel */ },
5552};
5553
5554MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5555
5556static struct mdio_driver mv88e6xxx_driver = {
5557 .probe = mv88e6xxx_probe,
5558 .remove = mv88e6xxx_remove,
5559 .mdiodrv.driver = {
5560 .name = "mv88e6085",
5561 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005562 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005563 },
5564};
5565
Andrew Lunn7324d502019-04-27 19:19:10 +02005566mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005567
5568MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5569MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5570MODULE_LICENSE("GPL");