blob: 9b61d5b65b0f3886c554a07fa6fc62c37b33143f [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000031#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010032#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000033#include <linux/phy.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000034#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040035
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040036#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040037#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040038#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010039#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020040#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010041#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010042#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020043#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000044
Vivien Didelotfad09c72016-06-21 12:28:20 -040045static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040046{
Vivien Didelotfad09c72016-06-21 12:28:20 -040047 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
48 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049 dump_stack();
50 }
51}
52
Vivien Didelot914b32f2016-06-20 13:14:11 -040053/* The switch ADDR[4:1] configuration pins define the chip SMI device address
54 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
55 *
56 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
57 * is the only device connected to the SMI master. In this mode it responds to
58 * all 32 possible SMI addresses, and thus maps directly the internal devices.
59 *
60 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
61 * multiple devices to share the SMI interface. In this mode it responds to only
62 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000063 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040064
Vivien Didelotfad09c72016-06-21 12:28:20 -040065static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040066 int addr, int reg, u16 *val)
67{
Vivien Didelotfad09c72016-06-21 12:28:20 -040068 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069 return -EOPNOTSUPP;
70
Vivien Didelotfad09c72016-06-21 12:28:20 -040071 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040072}
73
Vivien Didelotfad09c72016-06-21 12:28:20 -040074static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 int addr, int reg, u16 val)
76{
Vivien Didelotfad09c72016-06-21 12:28:20 -040077 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040078 return -EOPNOTSUPP;
79
Vivien Didelotfad09c72016-06-21 12:28:20 -040080 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040081}
82
Vivien Didelotfad09c72016-06-21 12:28:20 -040083static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040084 int addr, int reg, u16 *val)
85{
86 int ret;
87
Vivien Didelotfad09c72016-06-21 12:28:20 -040088 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040089 if (ret < 0)
90 return ret;
91
92 *val = ret & 0xffff;
93
94 return 0;
95}
96
Vivien Didelotfad09c72016-06-21 12:28:20 -040097static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040098 int addr, int reg, u16 val)
99{
100 int ret;
101
Vivien Didelotfad09c72016-06-21 12:28:20 -0400102 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400103 if (ret < 0)
104 return ret;
105
106 return 0;
107}
108
Vivien Didelotc08026a2016-09-29 12:21:59 -0400109static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400110 .read = mv88e6xxx_smi_single_chip_read,
111 .write = mv88e6xxx_smi_single_chip_write,
112};
113
Vivien Didelotfad09c72016-06-21 12:28:20 -0400114static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000115{
116 int ret;
117 int i;
118
119 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400120 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000121 if (ret < 0)
122 return ret;
123
Andrew Lunncca8b132015-04-02 04:06:39 +0200124 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000125 return 0;
126 }
127
128 return -ETIMEDOUT;
129}
130
Vivien Didelotfad09c72016-06-21 12:28:20 -0400131static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400132 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000133{
134 int ret;
135
Barry Grussling3675c8d2013-01-08 16:05:53 +0000136 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400137 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000138 if (ret < 0)
139 return ret;
140
Barry Grussling3675c8d2013-01-08 16:05:53 +0000141 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400142 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200143 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000144 if (ret < 0)
145 return ret;
146
Barry Grussling3675c8d2013-01-08 16:05:53 +0000147 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400148 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000149 if (ret < 0)
150 return ret;
151
Barry Grussling3675c8d2013-01-08 16:05:53 +0000152 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400153 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000154 if (ret < 0)
155 return ret;
156
Vivien Didelot914b32f2016-06-20 13:14:11 -0400157 *val = ret & 0xffff;
158
159 return 0;
160}
161
Vivien Didelotfad09c72016-06-21 12:28:20 -0400162static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400163 int addr, int reg, u16 val)
164{
165 int ret;
166
167 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400168 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400169 if (ret < 0)
170 return ret;
171
172 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400173 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400174 if (ret < 0)
175 return ret;
176
177 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400178 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400179 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
180 if (ret < 0)
181 return ret;
182
183 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400184 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400185 if (ret < 0)
186 return ret;
187
188 return 0;
189}
190
Vivien Didelotc08026a2016-09-29 12:21:59 -0400191static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400192 .read = mv88e6xxx_smi_multi_chip_read,
193 .write = mv88e6xxx_smi_multi_chip_write,
194};
195
Vivien Didelotec561272016-09-02 14:45:33 -0400196int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400197{
198 int err;
199
Vivien Didelotfad09c72016-06-21 12:28:20 -0400200 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203 if (err)
204 return err;
205
Vivien Didelotfad09c72016-06-21 12:28:20 -0400206 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400207 addr, reg, *val);
208
209 return 0;
210}
211
Vivien Didelotec561272016-09-02 14:45:33 -0400212int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400213{
214 int err;
215
Vivien Didelotfad09c72016-06-21 12:28:20 -0400216 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219 if (err)
220 return err;
221
Vivien Didelotfad09c72016-06-21 12:28:20 -0400222 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400223 addr, reg, val);
224
225 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000226}
227
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200228struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100229{
230 struct mv88e6xxx_mdio_bus *mdio_bus;
231
232 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
233 list);
234 if (!mdio_bus)
235 return NULL;
236
237 return mdio_bus->bus;
238}
239
Andrew Lunndc30c352016-10-16 19:56:49 +0200240static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
241{
242 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
243 unsigned int n = d->hwirq;
244
245 chip->g1_irq.masked |= (1 << n);
246}
247
248static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
249{
250 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
251 unsigned int n = d->hwirq;
252
253 chip->g1_irq.masked &= ~(1 << n);
254}
255
Andrew Lunn294d7112018-02-22 22:58:32 +0100256static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200257{
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 unsigned int nhandled = 0;
259 unsigned int sub_irq;
260 unsigned int n;
261 u16 reg;
262 int err;
263
264 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400265 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200266 mutex_unlock(&chip->reg_lock);
267
268 if (err)
269 goto out;
270
271 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
272 if (reg & (1 << n)) {
273 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
274 handle_nested_irq(sub_irq);
275 ++nhandled;
276 }
277 }
278out:
279 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
280}
281
Andrew Lunn294d7112018-02-22 22:58:32 +0100282static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
283{
284 struct mv88e6xxx_chip *chip = dev_id;
285
286 return mv88e6xxx_g1_irq_thread_work(chip);
287}
288
Andrew Lunndc30c352016-10-16 19:56:49 +0200289static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
290{
291 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
292
293 mutex_lock(&chip->reg_lock);
294}
295
296static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
297{
298 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
299 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
300 u16 reg;
301 int err;
302
Vivien Didelotd77f4322017-06-15 12:14:03 -0400303 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200304 if (err)
305 goto out;
306
307 reg &= ~mask;
308 reg |= (~chip->g1_irq.masked & mask);
309
Vivien Didelotd77f4322017-06-15 12:14:03 -0400310 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 if (err)
312 goto out;
313
314out:
315 mutex_unlock(&chip->reg_lock);
316}
317
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530318static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200319 .name = "mv88e6xxx-g1",
320 .irq_mask = mv88e6xxx_g1_irq_mask,
321 .irq_unmask = mv88e6xxx_g1_irq_unmask,
322 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
323 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
324};
325
326static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
327 unsigned int irq,
328 irq_hw_number_t hwirq)
329{
330 struct mv88e6xxx_chip *chip = d->host_data;
331
332 irq_set_chip_data(irq, d->host_data);
333 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
334 irq_set_noprobe(irq);
335
336 return 0;
337}
338
339static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
340 .map = mv88e6xxx_g1_irq_domain_map,
341 .xlate = irq_domain_xlate_twocell,
342};
343
Andrew Lunn294d7112018-02-22 22:58:32 +0100344static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200345{
346 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100347 u16 mask;
348
Vivien Didelotd77f4322017-06-15 12:14:03 -0400349 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100350 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400351 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100352
Andreas Färber5edef2f2016-11-27 23:26:28 +0100353 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100354 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200355 irq_dispose_mapping(virq);
356 }
357
Andrew Lunna3db3d32016-11-20 20:14:14 +0100358 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200359}
360
Andrew Lunn294d7112018-02-22 22:58:32 +0100361static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
362{
Andrew Lunnb19e5c12018-03-08 21:21:36 +0100363 mv88e6xxx_g1_irq_free_common(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100364
365 free_irq(chip->irq, chip);
366}
367
368static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200369{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100370 int err, irq, virq;
371 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200372
373 chip->g1_irq.nirqs = chip->info->g1_irqs;
374 chip->g1_irq.domain = irq_domain_add_simple(
375 NULL, chip->g1_irq.nirqs, 0,
376 &mv88e6xxx_g1_irq_domain_ops, chip);
377 if (!chip->g1_irq.domain)
378 return -ENOMEM;
379
380 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
381 irq_create_mapping(chip->g1_irq.domain, irq);
382
383 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
384 chip->g1_irq.masked = ~0;
385
Vivien Didelotd77f4322017-06-15 12:14:03 -0400386 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200387 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100388 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200389
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100390 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200391
Vivien Didelotd77f4322017-06-15 12:14:03 -0400392 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200393 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100394 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200395
396 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400397 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200398 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200400
Andrew Lunndc30c352016-10-16 19:56:49 +0200401 return 0;
402
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100403out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100404 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400405 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100406
407out_mapping:
408 for (irq = 0; irq < 16; irq++) {
409 virq = irq_find_mapping(chip->g1_irq.domain, irq);
410 irq_dispose_mapping(virq);
411 }
412
413 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200414
415 return err;
416}
417
Andrew Lunn294d7112018-02-22 22:58:32 +0100418static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
419{
420 int err;
421
422 err = mv88e6xxx_g1_irq_setup_common(chip);
423 if (err)
424 return err;
425
426 err = request_threaded_irq(chip->irq, NULL,
427 mv88e6xxx_g1_irq_thread_fn,
Andrew Lunn422a9fd62018-03-25 23:43:14 +0200428 IRQF_ONESHOT,
Andrew Lunn294d7112018-02-22 22:58:32 +0100429 dev_name(chip->dev), chip);
430 if (err)
431 mv88e6xxx_g1_irq_free_common(chip);
432
433 return err;
434}
435
436static void mv88e6xxx_irq_poll(struct kthread_work *work)
437{
438 struct mv88e6xxx_chip *chip = container_of(work,
439 struct mv88e6xxx_chip,
440 irq_poll_work.work);
441 mv88e6xxx_g1_irq_thread_work(chip);
442
443 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
444 msecs_to_jiffies(100));
445}
446
447static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
448{
449 int err;
450
451 err = mv88e6xxx_g1_irq_setup_common(chip);
452 if (err)
453 return err;
454
455 kthread_init_delayed_work(&chip->irq_poll_work,
456 mv88e6xxx_irq_poll);
457
458 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
459 if (IS_ERR(chip->kworker))
460 return PTR_ERR(chip->kworker);
461
462 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
463 msecs_to_jiffies(100));
464
465 return 0;
466}
467
468static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
469{
Andrew Lunn71f74ae2018-03-25 23:43:15 +0200470 mv88e6xxx_g1_irq_free_common(chip);
471
Andrew Lunn294d7112018-02-22 22:58:32 +0100472 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
473 kthread_destroy_worker(chip->kworker);
474}
475
Vivien Didelotec561272016-09-02 14:45:33 -0400476int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400477{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200478 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400479
Andrew Lunn6441e6692016-08-19 00:01:55 +0200480 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400481 u16 val;
482 int err;
483
484 err = mv88e6xxx_read(chip, addr, reg, &val);
485 if (err)
486 return err;
487
488 if (!(val & mask))
489 return 0;
490
491 usleep_range(1000, 2000);
492 }
493
Andrew Lunn30853552016-08-19 00:01:57 +0200494 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400495 return -ETIMEDOUT;
496}
497
Vivien Didelotf22ab642016-07-18 20:45:31 -0400498/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400499int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400500{
501 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200502 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400503
504 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200505 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
506 if (err)
507 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400508
509 /* Set the Update bit to trigger a write operation */
510 val = BIT(15) | update;
511
512 return mv88e6xxx_write(chip, addr, reg, val);
513}
514
Vivien Didelotd78343d2016-11-04 03:23:36 +0100515static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
516 int link, int speed, int duplex,
517 phy_interface_t mode)
518{
519 int err;
520
521 if (!chip->info->ops->port_set_link)
522 return 0;
523
524 /* Port's MAC control must not be changed unless the link is down */
525 err = chip->info->ops->port_set_link(chip, port, 0);
526 if (err)
527 return err;
528
529 if (chip->info->ops->port_set_speed) {
530 err = chip->info->ops->port_set_speed(chip, port, speed);
531 if (err && err != -EOPNOTSUPP)
532 goto restore_link;
533 }
534
535 if (chip->info->ops->port_set_duplex) {
536 err = chip->info->ops->port_set_duplex(chip, port, duplex);
537 if (err && err != -EOPNOTSUPP)
538 goto restore_link;
539 }
540
541 if (chip->info->ops->port_set_rgmii_delay) {
542 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
543 if (err && err != -EOPNOTSUPP)
544 goto restore_link;
545 }
546
Andrew Lunnf39908d2017-02-04 20:02:50 +0100547 if (chip->info->ops->port_set_cmode) {
548 err = chip->info->ops->port_set_cmode(chip, port, mode);
549 if (err && err != -EOPNOTSUPP)
550 goto restore_link;
551 }
552
Vivien Didelotd78343d2016-11-04 03:23:36 +0100553 err = 0;
554restore_link:
555 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400556 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100557
558 return err;
559}
560
Andrew Lunndea87022015-08-31 15:56:47 +0200561/* We expect the switch to perform auto negotiation if there is a real
562 * phy. However, in the case of a fixed link phy, we force the port
563 * settings from the fixed link settings.
564 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400565static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
566 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200567{
Vivien Didelot04bed142016-08-31 18:06:13 -0400568 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200569 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200570
571 if (!phy_is_pseudo_fixed_link(phydev))
572 return;
573
Vivien Didelotfad09c72016-06-21 12:28:20 -0400574 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100575 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
576 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400577 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100578
579 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400580 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200581}
582
Andrew Lunna605a0f2016-11-21 23:26:58 +0100583static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000584{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100585 if (!chip->info->ops->stats_snapshot)
586 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000587
Andrew Lunna605a0f2016-11-21 23:26:58 +0100588 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000589}
590
Andrew Lunne413e7e2015-04-02 04:06:38 +0200591static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100592 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
593 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
594 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
595 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
596 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
597 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
598 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
599 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
600 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
601 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
602 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
603 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
604 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
605 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
606 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
607 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
608 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
609 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
610 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
611 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
612 { "single", 4, 0x14, STATS_TYPE_BANK0, },
613 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
614 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
615 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
616 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
617 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
618 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
619 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
620 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
621 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
622 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
623 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
624 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
625 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
626 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
627 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
628 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
629 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
630 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
631 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
632 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
633 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
634 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
635 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
636 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
637 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
638 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
639 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
640 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
641 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
642 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
643 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
644 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
645 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
646 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
647 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
648 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
649 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
650 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200651};
652
Vivien Didelotfad09c72016-06-21 12:28:20 -0400653static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100654 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100655 int port, u16 bank1_select,
656 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200657{
Andrew Lunn80c46272015-06-20 18:42:30 +0200658 u32 low;
659 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100660 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200661 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200662 u64 value;
663
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100664 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100665 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200666 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
667 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800668 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200669
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200670 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100671 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200672 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
673 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800674 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200675 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200676 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100677 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100678 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100679 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100680 /* fall through */
681 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100682 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100683 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100684 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100685 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500686 break;
687 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800688 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200689 }
690 value = (((u64)high) << 16) | low;
691 return value;
692}
693
Andrew Lunn436fe172018-03-01 02:02:29 +0100694static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
695 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100696{
697 struct mv88e6xxx_hw_stat *stat;
698 int i, j;
699
700 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
701 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100702 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100703 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
704 ETH_GSTRING_LEN);
705 j++;
706 }
707 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100708
709 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100710}
711
Andrew Lunn436fe172018-03-01 02:02:29 +0100712static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
713 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100714{
Andrew Lunn436fe172018-03-01 02:02:29 +0100715 return mv88e6xxx_stats_get_strings(chip, data,
716 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100717}
718
Andrew Lunn436fe172018-03-01 02:02:29 +0100719static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
720 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100721{
Andrew Lunn436fe172018-03-01 02:02:29 +0100722 return mv88e6xxx_stats_get_strings(chip, data,
723 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100724}
725
Andrew Lunn65f60e42018-03-28 23:50:28 +0200726static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
727 "atu_member_violation",
728 "atu_miss_violation",
729 "atu_full_violation",
730 "vtu_member_violation",
731 "vtu_miss_violation",
732};
733
734static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
735{
736 unsigned int i;
737
738 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
739 strlcpy(data + i * ETH_GSTRING_LEN,
740 mv88e6xxx_atu_vtu_stats_strings[i],
741 ETH_GSTRING_LEN);
742}
743
Andrew Lunndfafe442016-11-21 23:27:02 +0100744static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700745 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100746{
Vivien Didelot04bed142016-08-31 18:06:13 -0400747 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100748 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100749
Florian Fainelli89f09042018-04-25 12:12:50 -0700750 if (stringset != ETH_SS_STATS)
751 return;
752
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100753 mutex_lock(&chip->reg_lock);
754
Andrew Lunndfafe442016-11-21 23:27:02 +0100755 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100756 count = chip->info->ops->stats_get_strings(chip, data);
757
758 if (chip->info->ops->serdes_get_strings) {
759 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200760 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100761 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100762
Andrew Lunn65f60e42018-03-28 23:50:28 +0200763 data += count * ETH_GSTRING_LEN;
764 mv88e6xxx_atu_vtu_get_strings(data);
765
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100766 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100767}
768
769static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
770 int types)
771{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100772 struct mv88e6xxx_hw_stat *stat;
773 int i, j;
774
775 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
776 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100777 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100778 j++;
779 }
780 return j;
781}
782
Andrew Lunndfafe442016-11-21 23:27:02 +0100783static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
784{
785 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
786 STATS_TYPE_PORT);
787}
788
789static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
790{
791 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
792 STATS_TYPE_BANK1);
793}
794
Florian Fainelli89f09042018-04-25 12:12:50 -0700795static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100796{
797 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100798 int serdes_count = 0;
799 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100800
Florian Fainelli89f09042018-04-25 12:12:50 -0700801 if (sset != ETH_SS_STATS)
802 return 0;
803
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100804 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100805 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100806 count = chip->info->ops->stats_get_sset_count(chip);
807 if (count < 0)
808 goto out;
809
810 if (chip->info->ops->serdes_get_sset_count)
811 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
812 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100814 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200815 goto out;
816 }
817 count += serdes_count;
818 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
819
Andrew Lunn436fe172018-03-01 02:02:29 +0100820out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100821 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100822
Andrew Lunn436fe172018-03-01 02:02:29 +0100823 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100824}
825
Andrew Lunn436fe172018-03-01 02:02:29 +0100826static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
827 uint64_t *data, int types,
828 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100829{
830 struct mv88e6xxx_hw_stat *stat;
831 int i, j;
832
833 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
834 stat = &mv88e6xxx_hw_stats[i];
835 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100836 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100837 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
838 bank1_select,
839 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100840 mutex_unlock(&chip->reg_lock);
841
Andrew Lunn052f9472016-11-21 23:27:03 +0100842 j++;
843 }
844 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100845 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100846}
847
Andrew Lunn436fe172018-03-01 02:02:29 +0100848static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
849 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100850{
851 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100852 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400853 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100854}
855
Andrew Lunn436fe172018-03-01 02:02:29 +0100856static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
857 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100858{
859 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100860 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400861 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
862 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100863}
864
Andrew Lunn436fe172018-03-01 02:02:29 +0100865static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
866 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100867{
868 return mv88e6xxx_stats_get_stats(chip, port, data,
869 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400870 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
871 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100872}
873
Andrew Lunn65f60e42018-03-28 23:50:28 +0200874static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
875 uint64_t *data)
876{
877 *data++ = chip->ports[port].atu_member_violation;
878 *data++ = chip->ports[port].atu_miss_violation;
879 *data++ = chip->ports[port].atu_full_violation;
880 *data++ = chip->ports[port].vtu_member_violation;
881 *data++ = chip->ports[port].vtu_miss_violation;
882}
883
Andrew Lunn052f9472016-11-21 23:27:03 +0100884static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
885 uint64_t *data)
886{
Andrew Lunn436fe172018-03-01 02:02:29 +0100887 int count = 0;
888
Andrew Lunn052f9472016-11-21 23:27:03 +0100889 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 count = chip->info->ops->stats_get_stats(chip, port, data);
891
Andrew Lunn65f60e42018-03-28 23:50:28 +0200892 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +0100893 if (chip->info->ops->serdes_get_stats) {
894 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200895 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200897 data += count;
898 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
899 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +0100900}
901
Vivien Didelotf81ec902016-05-09 13:22:58 -0400902static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
903 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000904{
Vivien Didelot04bed142016-08-31 18:06:13 -0400905 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000906 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000907
Vivien Didelotfad09c72016-06-21 12:28:20 -0400908 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000909
Andrew Lunna605a0f2016-11-21 23:26:58 +0100910 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +0100911 mutex_unlock(&chip->reg_lock);
912
913 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000914 return;
Andrew Lunn052f9472016-11-21 23:27:03 +0100915
916 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000917
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000918}
Ben Hutchings98e67302011-11-25 14:36:19 +0000919
Andrew Lunnde2273872016-11-21 23:27:01 +0100920static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
921{
922 if (chip->info->ops->stats_set_histogram)
923 return chip->info->ops->stats_set_histogram(chip);
924
925 return 0;
926}
927
Vivien Didelotf81ec902016-05-09 13:22:58 -0400928static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700929{
930 return 32 * sizeof(u16);
931}
932
Vivien Didelotf81ec902016-05-09 13:22:58 -0400933static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
934 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700935{
Vivien Didelot04bed142016-08-31 18:06:13 -0400936 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200937 int err;
938 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700939 u16 *p = _p;
940 int i;
941
942 regs->version = 0;
943
944 memset(p, 0xff, 32 * sizeof(u16));
945
Vivien Didelotfad09c72016-06-21 12:28:20 -0400946 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400947
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700948 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700949
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200950 err = mv88e6xxx_port_read(chip, port, i, &reg);
951 if (!err)
952 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700953 }
Vivien Didelot23062512016-05-09 13:22:45 -0400954
Vivien Didelotfad09c72016-06-21 12:28:20 -0400955 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700956}
957
Vivien Didelot08f50062017-08-01 16:32:41 -0400958static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
959 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800960{
Vivien Didelot5480db62017-08-01 16:32:40 -0400961 /* Nothing to do on the port's MAC */
962 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800963}
964
Vivien Didelot08f50062017-08-01 16:32:41 -0400965static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
966 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800967{
Vivien Didelot5480db62017-08-01 16:32:40 -0400968 /* Nothing to do on the port's MAC */
969 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800970}
971
Vivien Didelote5887a22017-03-30 17:37:11 -0400972static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700973{
Vivien Didelote5887a22017-03-30 17:37:11 -0400974 struct dsa_switch *ds = NULL;
975 struct net_device *br;
976 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500977 int i;
978
Vivien Didelote5887a22017-03-30 17:37:11 -0400979 if (dev < DSA_MAX_SWITCHES)
980 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500981
Vivien Didelote5887a22017-03-30 17:37:11 -0400982 /* Prevent frames from unknown switch or port */
983 if (!ds || port >= ds->num_ports)
984 return 0;
985
986 /* Frames from DSA links and CPU ports can egress any local port */
987 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
988 return mv88e6xxx_port_mask(chip);
989
990 br = ds->ports[port].bridge_dev;
991 pvlan = 0;
992
993 /* Frames from user ports can egress any local DSA links and CPU ports,
994 * as well as any local member of their bridge group.
995 */
996 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
997 if (dsa_is_cpu_port(chip->ds, i) ||
998 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400999 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001000 pvlan |= BIT(i);
1001
1002 return pvlan;
1003}
1004
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001005static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001006{
1007 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001008
1009 /* prevent frames from going back out of the port they came in on */
1010 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001011
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001012 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001013}
1014
Vivien Didelotf81ec902016-05-09 13:22:58 -04001015static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1016 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001017{
Vivien Didelot04bed142016-08-31 18:06:13 -04001018 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001019 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001020
Vivien Didelotfad09c72016-06-21 12:28:20 -04001021 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001022 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001023 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001024
1025 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001026 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001027}
1028
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001029static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1030{
1031 int target, port;
1032 int err;
1033
1034 if (!chip->info->global2_addr)
1035 return 0;
1036
1037 /* Initialize the routing port to the 32 possible target devices */
1038 for (target = 0; target < 32; target++) {
1039 port = 0x1f;
1040 if (target < DSA_MAX_SWITCHES)
1041 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1042 port = chip->ds->rtable[target];
1043
1044 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1045 if (err)
1046 return err;
1047 }
1048
Vivien Didelot02317e62018-05-09 11:38:49 -04001049 if (chip->info->ops->set_cascade_port) {
1050 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1051 err = chip->info->ops->set_cascade_port(chip, port);
1052 if (err)
1053 return err;
1054 }
1055
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001056 return 0;
1057}
1058
Vivien Didelotb28f8722018-04-26 21:56:44 -04001059static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1060{
1061 /* Clear all trunk masks and mapping */
1062 if (chip->info->global2_addr)
1063 return mv88e6xxx_g2_trunk_clear(chip);
1064
1065 return 0;
1066}
1067
Vivien Didelot9e907d72017-07-17 13:03:43 -04001068static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1069{
1070 if (chip->info->ops->pot_clear)
1071 return chip->info->ops->pot_clear(chip);
1072
1073 return 0;
1074}
1075
Vivien Didelot51c901a2017-07-17 13:03:41 -04001076static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1077{
1078 if (chip->info->ops->mgmt_rsvd2cpu)
1079 return chip->info->ops->mgmt_rsvd2cpu(chip);
1080
1081 return 0;
1082}
1083
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001084static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1085{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001086 int err;
1087
Vivien Didelotdaefc942017-03-11 16:12:54 -05001088 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1089 if (err)
1090 return err;
1091
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001092 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1093 if (err)
1094 return err;
1095
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001096 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1097}
1098
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001099static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1100{
1101 int port;
1102 int err;
1103
1104 if (!chip->info->ops->irl_init_all)
1105 return 0;
1106
1107 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1108 /* Disable ingress rate limiting by resetting all per port
1109 * ingress rate limit resources to their initial state.
1110 */
1111 err = chip->info->ops->irl_init_all(chip, port);
1112 if (err)
1113 return err;
1114 }
1115
1116 return 0;
1117}
1118
Vivien Didelot04a69a12017-10-13 14:18:05 -04001119static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1120{
1121 if (chip->info->ops->set_switch_mac) {
1122 u8 addr[ETH_ALEN];
1123
1124 eth_random_addr(addr);
1125
1126 return chip->info->ops->set_switch_mac(chip, addr);
1127 }
1128
1129 return 0;
1130}
1131
Vivien Didelot17a15942017-03-30 17:37:09 -04001132static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1133{
1134 u16 pvlan = 0;
1135
1136 if (!mv88e6xxx_has_pvt(chip))
1137 return -EOPNOTSUPP;
1138
1139 /* Skip the local source device, which uses in-chip port VLAN */
1140 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001141 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001142
1143 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1144}
1145
Vivien Didelot81228992017-03-30 17:37:08 -04001146static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1147{
Vivien Didelot17a15942017-03-30 17:37:09 -04001148 int dev, port;
1149 int err;
1150
Vivien Didelot81228992017-03-30 17:37:08 -04001151 if (!mv88e6xxx_has_pvt(chip))
1152 return 0;
1153
1154 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1155 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1156 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001157 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1158 if (err)
1159 return err;
1160
1161 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1162 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1163 err = mv88e6xxx_pvt_map(chip, dev, port);
1164 if (err)
1165 return err;
1166 }
1167 }
1168
1169 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001170}
1171
Vivien Didelot749efcb2016-09-22 16:49:24 -04001172static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1173{
1174 struct mv88e6xxx_chip *chip = ds->priv;
1175 int err;
1176
1177 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001178 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001179 mutex_unlock(&chip->reg_lock);
1180
1181 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001182 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001183}
1184
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001185static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1186{
1187 if (!chip->info->max_vid)
1188 return 0;
1189
1190 return mv88e6xxx_g1_vtu_flush(chip);
1191}
1192
Vivien Didelotf1394b782017-05-01 14:05:22 -04001193static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1194 struct mv88e6xxx_vtu_entry *entry)
1195{
1196 if (!chip->info->ops->vtu_getnext)
1197 return -EOPNOTSUPP;
1198
1199 return chip->info->ops->vtu_getnext(chip, entry);
1200}
1201
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001202static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1203 struct mv88e6xxx_vtu_entry *entry)
1204{
1205 if (!chip->info->ops->vtu_loadpurge)
1206 return -EOPNOTSUPP;
1207
1208 return chip->info->ops->vtu_loadpurge(chip, entry);
1209}
1210
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001211static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001212{
1213 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001214 struct mv88e6xxx_vtu_entry vlan = {
1215 .vid = chip->info->max_vid,
1216 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001217 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001218
1219 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1220
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001221 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001222 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001223 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001224 if (err)
1225 return err;
1226
1227 set_bit(*fid, fid_bitmap);
1228 }
1229
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001230 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001231 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001232 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001233 if (err)
1234 return err;
1235
1236 if (!vlan.valid)
1237 break;
1238
1239 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001240 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001241
1242 /* The reset value 0x000 is used to indicate that multiple address
1243 * databases are not needed. Return the next positive available.
1244 */
1245 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001246 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001247 return -ENOSPC;
1248
1249 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001250 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001251}
1252
Vivien Didelot567aa592017-05-01 14:05:25 -04001253static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1254 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001255{
1256 int err;
1257
1258 if (!vid)
1259 return -EINVAL;
1260
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001261 entry->vid = vid - 1;
1262 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001263
Vivien Didelotf1394b782017-05-01 14:05:22 -04001264 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001265 if (err)
1266 return err;
1267
Vivien Didelot567aa592017-05-01 14:05:25 -04001268 if (entry->vid == vid && entry->valid)
1269 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001270
Vivien Didelot567aa592017-05-01 14:05:25 -04001271 if (new) {
1272 int i;
1273
1274 /* Initialize a fresh VLAN entry */
1275 memset(entry, 0, sizeof(*entry));
1276 entry->valid = true;
1277 entry->vid = vid;
1278
Vivien Didelot553a7682017-06-07 18:12:16 -04001279 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001280 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001281 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001282 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001283
1284 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001285 }
1286
Vivien Didelot567aa592017-05-01 14:05:25 -04001287 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1288 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001289}
1290
Vivien Didelotda9c3592016-02-12 12:09:40 -05001291static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1292 u16 vid_begin, u16 vid_end)
1293{
Vivien Didelot04bed142016-08-31 18:06:13 -04001294 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001295 struct mv88e6xxx_vtu_entry vlan = {
1296 .vid = vid_begin - 1,
1297 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001298 int i, err;
1299
Andrew Lunndb06ae412017-09-25 23:32:20 +02001300 /* DSA and CPU ports have to be members of multiple vlans */
1301 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1302 return 0;
1303
Vivien Didelotda9c3592016-02-12 12:09:40 -05001304 if (!vid_begin)
1305 return -EOPNOTSUPP;
1306
Vivien Didelotfad09c72016-06-21 12:28:20 -04001307 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001308
Vivien Didelotda9c3592016-02-12 12:09:40 -05001309 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001310 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001311 if (err)
1312 goto unlock;
1313
1314 if (!vlan.valid)
1315 break;
1316
1317 if (vlan.vid > vid_end)
1318 break;
1319
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001320 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001321 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1322 continue;
1323
Andrew Lunncd886462017-11-09 22:29:53 +01001324 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001325 continue;
1326
Vivien Didelotbd00e052017-05-01 14:05:11 -04001327 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001328 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001329 continue;
1330
Vivien Didelotc8652c82017-10-16 11:12:19 -04001331 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001332 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001333 break; /* same bridge, check next VLAN */
1334
Vivien Didelotc8652c82017-10-16 11:12:19 -04001335 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001336 continue;
1337
Andrew Lunn743fcc22017-11-09 22:29:54 +01001338 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1339 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001340 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001341 err = -EOPNOTSUPP;
1342 goto unlock;
1343 }
1344 } while (vlan.vid < vid_end);
1345
1346unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001347 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001348
1349 return err;
1350}
1351
Vivien Didelotf81ec902016-05-09 13:22:58 -04001352static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1353 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001354{
Vivien Didelot04bed142016-08-31 18:06:13 -04001355 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001356 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1357 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001358 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001359
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001360 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001361 return -EOPNOTSUPP;
1362
Vivien Didelotfad09c72016-06-21 12:28:20 -04001363 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001364 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001365 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001366
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001367 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001368}
1369
Vivien Didelot57d32312016-06-20 13:13:58 -04001370static int
1371mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001372 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001373{
Vivien Didelot04bed142016-08-31 18:06:13 -04001374 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001375 int err;
1376
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001377 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001378 return -EOPNOTSUPP;
1379
Vivien Didelotda9c3592016-02-12 12:09:40 -05001380 /* If the requested port doesn't belong to the same bridge as the VLAN
1381 * members, do not support it (yet) and fallback to software VLAN.
1382 */
1383 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1384 vlan->vid_end);
1385 if (err)
1386 return err;
1387
Vivien Didelot76e398a2015-11-01 12:33:55 -05001388 /* We don't need any dynamic resource from the kernel (yet),
1389 * so skip the prepare phase.
1390 */
1391 return 0;
1392}
1393
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001394static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1395 const unsigned char *addr, u16 vid,
1396 u8 state)
1397{
1398 struct mv88e6xxx_vtu_entry vlan;
1399 struct mv88e6xxx_atu_entry entry;
1400 int err;
1401
1402 /* Null VLAN ID corresponds to the port private database */
1403 if (vid == 0)
1404 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1405 else
1406 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1407 if (err)
1408 return err;
1409
1410 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1411 ether_addr_copy(entry.mac, addr);
1412 eth_addr_dec(entry.mac);
1413
1414 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1415 if (err)
1416 return err;
1417
1418 /* Initialize a fresh ATU entry if it isn't found */
1419 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1420 !ether_addr_equal(entry.mac, addr)) {
1421 memset(&entry, 0, sizeof(entry));
1422 ether_addr_copy(entry.mac, addr);
1423 }
1424
1425 /* Purge the ATU entry only if no port is using it anymore */
1426 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1427 entry.portvec &= ~BIT(port);
1428 if (!entry.portvec)
1429 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1430 } else {
1431 entry.portvec |= BIT(port);
1432 entry.state = state;
1433 }
1434
1435 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1436}
1437
Andrew Lunn87fa8862017-11-09 22:29:56 +01001438static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1439 u16 vid)
1440{
1441 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1442 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1443
1444 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1445}
1446
1447static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1448{
1449 int port;
1450 int err;
1451
1452 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1453 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1454 if (err)
1455 return err;
1456 }
1457
1458 return 0;
1459}
1460
Vivien Didelotfad09c72016-06-21 12:28:20 -04001461static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001462 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001463{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001464 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001465 int err;
1466
Vivien Didelot567aa592017-05-01 14:05:25 -04001467 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001468 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001469 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001470
Vivien Didelotc91498e2017-06-07 18:12:13 -04001471 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001472
Andrew Lunn87fa8862017-11-09 22:29:56 +01001473 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1474 if (err)
1475 return err;
1476
1477 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001478}
1479
Vivien Didelotf81ec902016-05-09 13:22:58 -04001480static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001481 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001482{
Vivien Didelot04bed142016-08-31 18:06:13 -04001483 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001484 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1485 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001486 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001487 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001488
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001489 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001490 return;
1491
Vivien Didelotc91498e2017-06-07 18:12:13 -04001492 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001493 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001494 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001495 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001496 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001497 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001498
Vivien Didelotfad09c72016-06-21 12:28:20 -04001499 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001500
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001501 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001502 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001503 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1504 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001505
Vivien Didelot77064f32016-11-04 03:23:30 +01001506 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001507 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1508 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001509
Vivien Didelotfad09c72016-06-21 12:28:20 -04001510 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001511}
1512
Vivien Didelotfad09c72016-06-21 12:28:20 -04001513static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001514 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001515{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001516 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001517 int i, err;
1518
Vivien Didelot567aa592017-05-01 14:05:25 -04001519 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001520 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001521 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001522
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001523 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001524 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001525 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001526
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001527 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001528
1529 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001530 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001531 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001532 if (vlan.member[i] !=
1533 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001534 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001535 break;
1536 }
1537 }
1538
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001539 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001540 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001541 return err;
1542
Vivien Didelote606ca32017-03-11 16:12:55 -05001543 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001544}
1545
Vivien Didelotf81ec902016-05-09 13:22:58 -04001546static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1547 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001548{
Vivien Didelot04bed142016-08-31 18:06:13 -04001549 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001550 u16 pvid, vid;
1551 int err = 0;
1552
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001553 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001554 return -EOPNOTSUPP;
1555
Vivien Didelotfad09c72016-06-21 12:28:20 -04001556 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001557
Vivien Didelot77064f32016-11-04 03:23:30 +01001558 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001559 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001560 goto unlock;
1561
Vivien Didelot76e398a2015-11-01 12:33:55 -05001562 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001563 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001564 if (err)
1565 goto unlock;
1566
1567 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001568 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001569 if (err)
1570 goto unlock;
1571 }
1572 }
1573
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001574unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001575 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001576
1577 return err;
1578}
1579
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001580static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1581 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001582{
Vivien Didelot04bed142016-08-31 18:06:13 -04001583 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001584 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001585
Vivien Didelotfad09c72016-06-21 12:28:20 -04001586 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001587 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1588 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001589 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001590
1591 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001592}
1593
Vivien Didelotf81ec902016-05-09 13:22:58 -04001594static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001595 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001596{
Vivien Didelot04bed142016-08-31 18:06:13 -04001597 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001598 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001599
Vivien Didelotfad09c72016-06-21 12:28:20 -04001600 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001601 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001602 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001603 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001604
Vivien Didelot83dabd12016-08-31 11:50:04 -04001605 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001606}
1607
Vivien Didelot83dabd12016-08-31 11:50:04 -04001608static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1609 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001610 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001611{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001612 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001613 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001614 int err;
1615
Vivien Didelot27c0e602017-06-15 12:14:01 -04001616 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001617 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001618
1619 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001620 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001621 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001622 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001623 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001624 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001625
Vivien Didelot27c0e602017-06-15 12:14:01 -04001626 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001627 break;
1628
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001629 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001630 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001631
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001632 if (!is_unicast_ether_addr(addr.mac))
1633 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001634
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001635 is_static = (addr.state ==
1636 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1637 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001638 if (err)
1639 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001640 } while (!is_broadcast_ether_addr(addr.mac));
1641
1642 return err;
1643}
1644
Vivien Didelot83dabd12016-08-31 11:50:04 -04001645static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001646 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001647{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001648 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001649 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001650 };
1651 u16 fid;
1652 int err;
1653
1654 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001655 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001656 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001657 mutex_unlock(&chip->reg_lock);
1658
Vivien Didelot83dabd12016-08-31 11:50:04 -04001659 if (err)
1660 return err;
1661
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001662 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001663 if (err)
1664 return err;
1665
1666 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001667 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001668 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001669 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001670 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001671 if (err)
1672 return err;
1673
1674 if (!vlan.valid)
1675 break;
1676
1677 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001678 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001679 if (err)
1680 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001681 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001682
1683 return err;
1684}
1685
Vivien Didelotf81ec902016-05-09 13:22:58 -04001686static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001687 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001688{
Vivien Didelot04bed142016-08-31 18:06:13 -04001689 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001690
Andrew Lunna61e5402018-02-15 14:38:35 +01001691 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001692}
1693
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001694static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1695 struct net_device *br)
1696{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001697 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001698 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001699 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001700 int err;
1701
1702 /* Remap the Port VLAN of each local bridge group member */
1703 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1704 if (chip->ds->ports[port].bridge_dev == br) {
1705 err = mv88e6xxx_port_vlan_map(chip, port);
1706 if (err)
1707 return err;
1708 }
1709 }
1710
Vivien Didelote96a6e02017-03-30 17:37:13 -04001711 if (!mv88e6xxx_has_pvt(chip))
1712 return 0;
1713
1714 /* Remap the Port VLAN of each cross-chip bridge group member */
1715 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1716 ds = chip->ds->dst->ds[dev];
1717 if (!ds)
1718 break;
1719
1720 for (port = 0; port < ds->num_ports; ++port) {
1721 if (ds->ports[port].bridge_dev == br) {
1722 err = mv88e6xxx_pvt_map(chip, dev, port);
1723 if (err)
1724 return err;
1725 }
1726 }
1727 }
1728
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001729 return 0;
1730}
1731
Vivien Didelotf81ec902016-05-09 13:22:58 -04001732static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001733 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001734{
Vivien Didelot04bed142016-08-31 18:06:13 -04001735 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001736 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001737
Vivien Didelotfad09c72016-06-21 12:28:20 -04001738 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001739 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001740 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001741
Vivien Didelot466dfa02016-02-26 13:16:05 -05001742 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001743}
1744
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001745static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1746 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001747{
Vivien Didelot04bed142016-08-31 18:06:13 -04001748 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001749
Vivien Didelotfad09c72016-06-21 12:28:20 -04001750 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001751 if (mv88e6xxx_bridge_map(chip, br) ||
1752 mv88e6xxx_port_vlan_map(chip, port))
1753 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001754 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001755}
1756
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001757static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1758 int port, struct net_device *br)
1759{
1760 struct mv88e6xxx_chip *chip = ds->priv;
1761 int err;
1762
1763 if (!mv88e6xxx_has_pvt(chip))
1764 return 0;
1765
1766 mutex_lock(&chip->reg_lock);
1767 err = mv88e6xxx_pvt_map(chip, dev, port);
1768 mutex_unlock(&chip->reg_lock);
1769
1770 return err;
1771}
1772
1773static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1774 int port, struct net_device *br)
1775{
1776 struct mv88e6xxx_chip *chip = ds->priv;
1777
1778 if (!mv88e6xxx_has_pvt(chip))
1779 return;
1780
1781 mutex_lock(&chip->reg_lock);
1782 if (mv88e6xxx_pvt_map(chip, dev, port))
1783 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1784 mutex_unlock(&chip->reg_lock);
1785}
1786
Vivien Didelot17e708b2016-12-05 17:30:27 -05001787static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1788{
1789 if (chip->info->ops->reset)
1790 return chip->info->ops->reset(chip);
1791
1792 return 0;
1793}
1794
Vivien Didelot309eca62016-12-05 17:30:26 -05001795static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1796{
1797 struct gpio_desc *gpiod = chip->reset;
1798
1799 /* If there is a GPIO connected to the reset pin, toggle it */
1800 if (gpiod) {
1801 gpiod_set_value_cansleep(gpiod, 1);
1802 usleep_range(10000, 20000);
1803 gpiod_set_value_cansleep(gpiod, 0);
1804 usleep_range(10000, 20000);
1805 }
1806}
1807
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001808static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1809{
1810 int i, err;
1811
1812 /* Set all ports to the Disabled state */
1813 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001814 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001815 if (err)
1816 return err;
1817 }
1818
1819 /* Wait for transmit queues to drain,
1820 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1821 */
1822 usleep_range(2000, 4000);
1823
1824 return 0;
1825}
1826
Vivien Didelotfad09c72016-06-21 12:28:20 -04001827static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001828{
Vivien Didelota935c052016-09-29 12:21:53 -04001829 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001830
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001831 err = mv88e6xxx_disable_ports(chip);
1832 if (err)
1833 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001834
Vivien Didelot309eca62016-12-05 17:30:26 -05001835 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001836
Vivien Didelot17e708b2016-12-05 17:30:27 -05001837 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001838}
1839
Vivien Didelot43145572017-03-11 16:12:59 -05001840static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001841 enum mv88e6xxx_frame_mode frame,
1842 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001843{
1844 int err;
1845
Vivien Didelot43145572017-03-11 16:12:59 -05001846 if (!chip->info->ops->port_set_frame_mode)
1847 return -EOPNOTSUPP;
1848
1849 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001850 if (err)
1851 return err;
1852
Vivien Didelot43145572017-03-11 16:12:59 -05001853 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1854 if (err)
1855 return err;
1856
1857 if (chip->info->ops->port_set_ether_type)
1858 return chip->info->ops->port_set_ether_type(chip, port, etype);
1859
1860 return 0;
1861}
1862
1863static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1864{
1865 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001866 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001867 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001868}
1869
1870static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1871{
1872 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001873 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001874 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001875}
1876
1877static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1878{
1879 return mv88e6xxx_set_port_mode(chip, port,
1880 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001881 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1882 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001883}
1884
1885static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1886{
1887 if (dsa_is_dsa_port(chip->ds, port))
1888 return mv88e6xxx_set_port_mode_dsa(chip, port);
1889
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001890 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001891 return mv88e6xxx_set_port_mode_normal(chip, port);
1892
1893 /* Setup CPU port mode depending on its supported tag format */
1894 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1895 return mv88e6xxx_set_port_mode_dsa(chip, port);
1896
1897 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1898 return mv88e6xxx_set_port_mode_edsa(chip, port);
1899
1900 return -EINVAL;
1901}
1902
Vivien Didelotea698f42017-03-11 16:12:50 -05001903static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1904{
1905 bool message = dsa_is_dsa_port(chip->ds, port);
1906
1907 return mv88e6xxx_port_set_message_port(chip, port, message);
1908}
1909
Vivien Didelot601aeed2017-03-11 16:13:00 -05001910static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1911{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001912 struct dsa_switch *ds = chip->ds;
1913 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001914
1915 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001916 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001917 if (chip->info->ops->port_set_egress_floods)
1918 return chip->info->ops->port_set_egress_floods(chip, port,
1919 flood, flood);
1920
1921 return 0;
1922}
1923
Andrew Lunn6d917822017-05-26 01:03:21 +02001924static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1925 bool on)
1926{
Vivien Didelot523a8902017-05-26 18:02:42 -04001927 if (chip->info->ops->serdes_power)
1928 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001929
Vivien Didelot523a8902017-05-26 18:02:42 -04001930 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001931}
1932
Vivien Didelotfa371c82017-12-05 15:34:10 -05001933static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1934{
1935 struct dsa_switch *ds = chip->ds;
1936 int upstream_port;
1937 int err;
1938
Vivien Didelot07073c72017-12-05 15:34:13 -05001939 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001940 if (chip->info->ops->port_set_upstream_port) {
1941 err = chip->info->ops->port_set_upstream_port(chip, port,
1942 upstream_port);
1943 if (err)
1944 return err;
1945 }
1946
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001947 if (port == upstream_port) {
1948 if (chip->info->ops->set_cpu_port) {
1949 err = chip->info->ops->set_cpu_port(chip,
1950 upstream_port);
1951 if (err)
1952 return err;
1953 }
1954
1955 if (chip->info->ops->set_egress_port) {
1956 err = chip->info->ops->set_egress_port(chip,
1957 upstream_port);
1958 if (err)
1959 return err;
1960 }
1961 }
1962
Vivien Didelotfa371c82017-12-05 15:34:10 -05001963 return 0;
1964}
1965
Vivien Didelotfad09c72016-06-21 12:28:20 -04001966static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001967{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001968 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001969 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001970 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001971
Vivien Didelotd78343d2016-11-04 03:23:36 +01001972 /* MAC Forcing register: don't force link, speed, duplex or flow control
1973 * state to any particular values on physical ports, but force the CPU
1974 * port and all DSA ports to their maximum bandwidth and full duplex.
1975 */
1976 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1977 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1978 SPEED_MAX, DUPLEX_FULL,
1979 PHY_INTERFACE_MODE_NA);
1980 else
1981 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1982 SPEED_UNFORCED, DUPLEX_UNFORCED,
1983 PHY_INTERFACE_MODE_NA);
1984 if (err)
1985 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001986
1987 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1988 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1989 * tunneling, determine priority by looking at 802.1p and IP
1990 * priority fields (IP prio has precedence), and set STP state
1991 * to Forwarding.
1992 *
1993 * If this is the CPU link, use DSA or EDSA tagging depending
1994 * on which tagging mode was configured.
1995 *
1996 * If this is a link to another switch, use DSA tagging mode.
1997 *
1998 * If this is the upstream port for this switch, enable
1999 * forwarding of unknown unicasts and multicasts.
2000 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002001 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2002 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2003 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2004 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002005 if (err)
2006 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002007
Vivien Didelot601aeed2017-03-11 16:13:00 -05002008 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002009 if (err)
2010 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002011
Vivien Didelot601aeed2017-03-11 16:13:00 -05002012 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002013 if (err)
2014 return err;
2015
Andrew Lunn04aca992017-05-26 01:03:24 +02002016 /* Enable the SERDES interface for DSA and CPU ports. Normal
2017 * ports SERDES are enabled when the port is enabled, thus
2018 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002019 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002020 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2021 err = mv88e6xxx_serdes_power(chip, port, true);
2022 if (err)
2023 return err;
2024 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002025
Vivien Didelot8efdda42015-08-13 12:52:23 -04002026 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002027 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002028 * untagged frames on this port, do a destination address lookup on all
2029 * received packets as usual, disable ARP mirroring and don't send a
2030 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002031 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002032 err = mv88e6xxx_port_set_map_da(chip, port);
2033 if (err)
2034 return err;
2035
Vivien Didelotfa371c82017-12-05 15:34:10 -05002036 err = mv88e6xxx_setup_upstream_port(chip, port);
2037 if (err)
2038 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002039
Andrew Lunna23b2962017-02-04 20:15:28 +01002040 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002041 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002042 if (err)
2043 return err;
2044
Vivien Didelotcd782652017-06-08 18:34:13 -04002045 if (chip->info->ops->port_set_jumbo_size) {
2046 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002047 if (err)
2048 return err;
2049 }
2050
Andrew Lunn54d792f2015-05-06 01:09:47 +02002051 /* Port Association Vector: when learning source addresses
2052 * of packets, add the address to the address database using
2053 * a port bitmap that has only the bit for this port set and
2054 * the other bits clear.
2055 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002056 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002057 /* Disable learning for CPU port */
2058 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002059 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002060
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002061 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2062 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002063 if (err)
2064 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002065
2066 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002067 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2068 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002069 if (err)
2070 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002071
Vivien Didelot08984322017-06-08 18:34:12 -04002072 if (chip->info->ops->port_pause_limit) {
2073 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002074 if (err)
2075 return err;
2076 }
2077
Vivien Didelotc8c94892017-03-11 16:13:01 -05002078 if (chip->info->ops->port_disable_learn_limit) {
2079 err = chip->info->ops->port_disable_learn_limit(chip, port);
2080 if (err)
2081 return err;
2082 }
2083
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002084 if (chip->info->ops->port_disable_pri_override) {
2085 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002086 if (err)
2087 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002088 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002089
Andrew Lunnef0a7312016-12-03 04:35:16 +01002090 if (chip->info->ops->port_tag_remap) {
2091 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002092 if (err)
2093 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002094 }
2095
Andrew Lunnef70b112016-12-03 04:45:18 +01002096 if (chip->info->ops->port_egress_rate_limiting) {
2097 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002098 if (err)
2099 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002100 }
2101
Vivien Didelotea698f42017-03-11 16:12:50 -05002102 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002103 if (err)
2104 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002105
Vivien Didelot207afda2016-04-14 14:42:09 -04002106 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002107 * database, and allow bidirectional communication between the
2108 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002109 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002110 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002111 if (err)
2112 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002113
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002114 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002115 if (err)
2116 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002117
2118 /* Default VLAN ID and priority: don't set a default VLAN
2119 * ID, and set the default packet priority to zero.
2120 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002121 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002122}
2123
Andrew Lunn04aca992017-05-26 01:03:24 +02002124static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2125 struct phy_device *phydev)
2126{
2127 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002128 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002129
2130 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002131 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002132 mutex_unlock(&chip->reg_lock);
2133
2134 return err;
2135}
2136
2137static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2138 struct phy_device *phydev)
2139{
2140 struct mv88e6xxx_chip *chip = ds->priv;
2141
2142 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002143 if (mv88e6xxx_serdes_power(chip, port, false))
2144 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002145 mutex_unlock(&chip->reg_lock);
2146}
2147
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002148static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2149 unsigned int ageing_time)
2150{
Vivien Didelot04bed142016-08-31 18:06:13 -04002151 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002152 int err;
2153
2154 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002155 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002156 mutex_unlock(&chip->reg_lock);
2157
2158 return err;
2159}
2160
Vivien Didelot97299342016-07-18 20:45:30 -04002161static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002162{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002163 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04002164 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002165
Vivien Didelot50484ff2016-05-09 13:22:54 -04002166 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002167 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
Vivien Didelota935c052016-09-29 12:21:53 -04002168 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002169 if (err)
2170 return err;
2171
Vivien Didelot08a01262016-05-09 13:22:50 -04002172 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002173 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002174 if (err)
2175 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002176 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002177 if (err)
2178 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002179 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002180 if (err)
2181 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002182 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002183 if (err)
2184 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002185 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002186 if (err)
2187 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002188 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002189 if (err)
2190 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002191 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002192 if (err)
2193 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002194 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002195 if (err)
2196 return err;
2197
2198 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002199 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002200 if (err)
2201 return err;
2202
Andrew Lunnde2273872016-11-21 23:27:01 +01002203 /* Initialize the statistics unit */
2204 err = mv88e6xxx_stats_set_histogram(chip);
2205 if (err)
2206 return err;
2207
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002208 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002209}
2210
Vivien Didelotf81ec902016-05-09 13:22:58 -04002211static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002212{
Vivien Didelot04bed142016-08-31 18:06:13 -04002213 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002214 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002215 int i;
2216
Vivien Didelotfad09c72016-06-21 12:28:20 -04002217 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002218 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002219
Vivien Didelotfad09c72016-06-21 12:28:20 -04002220 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002221
Vivien Didelot97299342016-07-18 20:45:30 -04002222 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002223 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002224 if (dsa_is_unused_port(ds, i))
2225 continue;
2226
Vivien Didelot97299342016-07-18 20:45:30 -04002227 err = mv88e6xxx_setup_port(chip, i);
2228 if (err)
2229 goto unlock;
2230 }
2231
2232 /* Setup Switch Global 1 Registers */
2233 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002234 if (err)
2235 goto unlock;
2236
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002237 err = mv88e6xxx_irl_setup(chip);
2238 if (err)
2239 goto unlock;
2240
Vivien Didelot04a69a12017-10-13 14:18:05 -04002241 err = mv88e6xxx_mac_setup(chip);
2242 if (err)
2243 goto unlock;
2244
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002245 err = mv88e6xxx_phy_setup(chip);
2246 if (err)
2247 goto unlock;
2248
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002249 err = mv88e6xxx_vtu_setup(chip);
2250 if (err)
2251 goto unlock;
2252
Vivien Didelot81228992017-03-30 17:37:08 -04002253 err = mv88e6xxx_pvt_setup(chip);
2254 if (err)
2255 goto unlock;
2256
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002257 err = mv88e6xxx_atu_setup(chip);
2258 if (err)
2259 goto unlock;
2260
Andrew Lunn87fa8862017-11-09 22:29:56 +01002261 err = mv88e6xxx_broadcast_setup(chip, 0);
2262 if (err)
2263 goto unlock;
2264
Vivien Didelot9e907d72017-07-17 13:03:43 -04002265 err = mv88e6xxx_pot_setup(chip);
2266 if (err)
2267 goto unlock;
2268
Vivien Didelot51c901a2017-07-17 13:03:41 -04002269 err = mv88e6xxx_rsvd2cpu_setup(chip);
2270 if (err)
2271 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002272
Vivien Didelotb28f8722018-04-26 21:56:44 -04002273 err = mv88e6xxx_trunk_setup(chip);
2274 if (err)
2275 goto unlock;
2276
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002277 err = mv88e6xxx_devmap_setup(chip);
2278 if (err)
2279 goto unlock;
2280
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002281 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002282 if (chip->info->ptp_support) {
2283 err = mv88e6xxx_ptp_setup(chip);
2284 if (err)
2285 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002286
2287 err = mv88e6xxx_hwtstamp_setup(chip);
2288 if (err)
2289 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002290 }
2291
Vivien Didelot6b17e862015-08-13 12:52:18 -04002292unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002293 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002294
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002295 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002296}
2297
Vivien Didelote57e5e72016-08-15 17:19:00 -04002298static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002299{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002300 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2301 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002302 u16 val;
2303 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002304
Andrew Lunnee26a222017-01-24 14:53:48 +01002305 if (!chip->info->ops->phy_read)
2306 return -EOPNOTSUPP;
2307
Vivien Didelotfad09c72016-06-21 12:28:20 -04002308 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002309 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002310 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002311
Andrew Lunnda9f3302017-02-01 03:40:05 +01002312 if (reg == MII_PHYSID2) {
2313 /* Some internal PHYS don't have a model number. Use
2314 * the mv88e6390 family model number instead.
2315 */
2316 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002317 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002318 }
2319
Vivien Didelote57e5e72016-08-15 17:19:00 -04002320 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002321}
2322
Vivien Didelote57e5e72016-08-15 17:19:00 -04002323static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002324{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002325 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2326 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002327 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002328
Andrew Lunnee26a222017-01-24 14:53:48 +01002329 if (!chip->info->ops->phy_write)
2330 return -EOPNOTSUPP;
2331
Vivien Didelotfad09c72016-06-21 12:28:20 -04002332 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002333 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002334 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002335
2336 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002337}
2338
Vivien Didelotfad09c72016-06-21 12:28:20 -04002339static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002340 struct device_node *np,
2341 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002342{
2343 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002344 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002345 struct mii_bus *bus;
2346 int err;
2347
Andrew Lunn2510bab2018-02-22 01:51:49 +01002348 if (external) {
2349 mutex_lock(&chip->reg_lock);
2350 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2351 mutex_unlock(&chip->reg_lock);
2352
2353 if (err)
2354 return err;
2355 }
2356
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002357 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002358 if (!bus)
2359 return -ENOMEM;
2360
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002361 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002362 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002363 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002364 INIT_LIST_HEAD(&mdio_bus->list);
2365 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002366
Andrew Lunnb516d452016-06-04 21:17:06 +02002367 if (np) {
2368 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002369 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002370 } else {
2371 bus->name = "mv88e6xxx SMI";
2372 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2373 }
2374
2375 bus->read = mv88e6xxx_mdio_read;
2376 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002377 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002378
Andrew Lunn6f882842018-03-17 20:32:05 +01002379 if (!external) {
2380 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2381 if (err)
2382 return err;
2383 }
2384
Andrew Lunna3c53be52017-01-24 14:53:50 +01002385 if (np)
2386 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002387 else
2388 err = mdiobus_register(bus);
2389 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002390 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002391 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002392 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002393 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002394
2395 if (external)
2396 list_add_tail(&mdio_bus->list, &chip->mdios);
2397 else
2398 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002399
2400 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002401}
2402
Andrew Lunna3c53be52017-01-24 14:53:50 +01002403static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2404 { .compatible = "marvell,mv88e6xxx-mdio-external",
2405 .data = (void *)true },
2406 { },
2407};
2408
Andrew Lunn3126aee2017-12-07 01:05:57 +01002409static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2410
2411{
2412 struct mv88e6xxx_mdio_bus *mdio_bus;
2413 struct mii_bus *bus;
2414
2415 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2416 bus = mdio_bus->bus;
2417
Andrew Lunn6f882842018-03-17 20:32:05 +01002418 if (!mdio_bus->external)
2419 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2420
Andrew Lunn3126aee2017-12-07 01:05:57 +01002421 mdiobus_unregister(bus);
2422 }
2423}
2424
Andrew Lunna3c53be52017-01-24 14:53:50 +01002425static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2426 struct device_node *np)
2427{
2428 const struct of_device_id *match;
2429 struct device_node *child;
2430 int err;
2431
2432 /* Always register one mdio bus for the internal/default mdio
2433 * bus. This maybe represented in the device tree, but is
2434 * optional.
2435 */
2436 child = of_get_child_by_name(np, "mdio");
2437 err = mv88e6xxx_mdio_register(chip, child, false);
2438 if (err)
2439 return err;
2440
2441 /* Walk the device tree, and see if there are any other nodes
2442 * which say they are compatible with the external mdio
2443 * bus.
2444 */
2445 for_each_available_child_of_node(np, child) {
2446 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2447 if (match) {
2448 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002449 if (err) {
2450 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002451 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002452 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002453 }
2454 }
2455
2456 return 0;
2457}
2458
Vivien Didelot855b1932016-07-20 18:18:35 -04002459static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2460{
Vivien Didelot04bed142016-08-31 18:06:13 -04002461 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002462
2463 return chip->eeprom_len;
2464}
2465
Vivien Didelot855b1932016-07-20 18:18:35 -04002466static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2467 struct ethtool_eeprom *eeprom, u8 *data)
2468{
Vivien Didelot04bed142016-08-31 18:06:13 -04002469 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002470 int err;
2471
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002472 if (!chip->info->ops->get_eeprom)
2473 return -EOPNOTSUPP;
2474
Vivien Didelot855b1932016-07-20 18:18:35 -04002475 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002476 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002477 mutex_unlock(&chip->reg_lock);
2478
2479 if (err)
2480 return err;
2481
2482 eeprom->magic = 0xc3ec4951;
2483
2484 return 0;
2485}
2486
Vivien Didelot855b1932016-07-20 18:18:35 -04002487static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2488 struct ethtool_eeprom *eeprom, u8 *data)
2489{
Vivien Didelot04bed142016-08-31 18:06:13 -04002490 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002491 int err;
2492
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002493 if (!chip->info->ops->set_eeprom)
2494 return -EOPNOTSUPP;
2495
Vivien Didelot855b1932016-07-20 18:18:35 -04002496 if (eeprom->magic != 0xc3ec4951)
2497 return -EINVAL;
2498
2499 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002500 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002501 mutex_unlock(&chip->reg_lock);
2502
2503 return err;
2504}
2505
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002506static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002507 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002508 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002509 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002510 .phy_read = mv88e6185_phy_ppu_read,
2511 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002512 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002513 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002514 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002515 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002516 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002517 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002518 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002519 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002520 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002521 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002522 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002523 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002524 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002525 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2526 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002527 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002528 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2529 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002530 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002531 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002532 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002533 .ppu_enable = mv88e6185_g1_ppu_enable,
2534 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002535 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002536 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002537 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002538 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002539};
2540
2541static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002542 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002543 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002544 .phy_read = mv88e6185_phy_ppu_read,
2545 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002546 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002547 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002548 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002549 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002550 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002551 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002552 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002553 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002554 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2555 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002556 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002557 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002558 .ppu_enable = mv88e6185_g1_ppu_enable,
2559 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002560 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002561 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002562 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002563};
2564
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002565static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002566 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002567 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002568 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2569 .phy_read = mv88e6xxx_g2_smi_phy_read,
2570 .phy_write = mv88e6xxx_g2_smi_phy_write,
2571 .port_set_link = mv88e6xxx_port_set_link,
2572 .port_set_duplex = mv88e6xxx_port_set_duplex,
2573 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002574 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002575 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002576 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002577 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002578 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002579 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002580 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002581 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002582 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002583 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002584 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002585 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2586 .stats_get_strings = mv88e6095_stats_get_strings,
2587 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002588 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2589 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002590 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002591 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002592 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002593 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002594 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002595 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002596};
2597
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002598static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002599 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002600 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002601 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002602 .phy_read = mv88e6xxx_g2_smi_phy_read,
2603 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002604 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002605 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002606 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002607 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002608 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002609 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002610 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002611 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002612 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002613 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2614 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002615 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002616 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2617 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002618 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002619 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002620 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002621 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002622 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002623 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002624};
2625
2626static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002627 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002628 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002629 .phy_read = mv88e6185_phy_ppu_read,
2630 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002631 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002632 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002633 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002634 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002635 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002636 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002637 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002638 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002639 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002640 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002641 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002642 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002643 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002644 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2645 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002646 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002647 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2648 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002649 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002650 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002651 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002652 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002653 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002654 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002655 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002656 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002657};
2658
Vivien Didelot990e27b2017-03-28 13:50:32 -04002659static const struct mv88e6xxx_ops mv88e6141_ops = {
2660 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002661 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002662 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2663 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2664 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2665 .phy_read = mv88e6xxx_g2_smi_phy_read,
2666 .phy_write = mv88e6xxx_g2_smi_phy_write,
2667 .port_set_link = mv88e6xxx_port_set_link,
2668 .port_set_duplex = mv88e6xxx_port_set_duplex,
2669 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2670 .port_set_speed = mv88e6390_port_set_speed,
2671 .port_tag_remap = mv88e6095_port_tag_remap,
2672 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2673 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2674 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002675 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002676 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002677 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002678 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2679 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2680 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002681 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002682 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2683 .stats_get_strings = mv88e6320_stats_get_strings,
2684 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002685 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2686 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002687 .watchdog_ops = &mv88e6390_watchdog_ops,
2688 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002689 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002690 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002691 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002692 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002693 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002694};
2695
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002696static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002697 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002698 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002699 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002700 .phy_read = mv88e6xxx_g2_smi_phy_read,
2701 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002702 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002703 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002704 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002705 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002706 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002707 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002708 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002709 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002710 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002711 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002712 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002713 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002714 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002715 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002716 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2717 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002718 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002719 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2720 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002721 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002722 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002723 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002724 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002725 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002726 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002727};
2728
2729static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002730 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002731 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002732 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002733 .phy_read = mv88e6165_phy_read,
2734 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002735 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002736 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002737 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002738 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002739 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002740 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002741 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002742 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2743 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002744 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002745 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2746 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002747 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002748 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002749 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002750 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002751 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002752 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002753};
2754
2755static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002756 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002757 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002758 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002759 .phy_read = mv88e6xxx_g2_smi_phy_read,
2760 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002761 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002762 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002763 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002764 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002765 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002766 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002767 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002768 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002769 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002770 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002771 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002772 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002773 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002774 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002775 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002776 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2777 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002778 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002779 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2780 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002781 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002782 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002783 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002784 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002785 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002786 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002787};
2788
2789static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002790 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002791 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002792 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2793 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002794 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002795 .phy_read = mv88e6xxx_g2_smi_phy_read,
2796 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002797 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002798 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002799 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002800 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002801 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002802 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002803 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002804 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002805 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002806 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002807 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002808 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002809 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002810 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002811 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002812 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2813 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002814 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002815 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2816 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002817 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002818 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002819 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002820 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002821 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002822 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002823 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002824 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002825};
2826
2827static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002828 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002829 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002830 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002831 .phy_read = mv88e6xxx_g2_smi_phy_read,
2832 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002833 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002834 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002835 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002836 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002837 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002838 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002839 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002840 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002841 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002842 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002843 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002844 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002845 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002846 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002847 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002848 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2849 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002850 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002851 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2852 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002853 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002854 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002855 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002856 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002857 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002858 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002859 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002860};
2861
2862static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002863 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002864 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002865 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2866 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002867 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002868 .phy_read = mv88e6xxx_g2_smi_phy_read,
2869 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002870 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002871 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002872 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002873 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002874 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002875 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002876 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002877 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002878 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002879 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002880 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002881 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002882 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002883 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002884 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002885 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2886 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002887 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002888 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2889 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002890 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002891 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002892 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002893 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002894 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002895 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002896 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002897 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002898};
2899
2900static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002901 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002902 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002903 .phy_read = mv88e6185_phy_ppu_read,
2904 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002905 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002906 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002907 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002908 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002909 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002910 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002911 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002912 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002913 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002914 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2915 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002916 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002917 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2918 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002919 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002920 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04002921 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002922 .ppu_enable = mv88e6185_g1_ppu_enable,
2923 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002924 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002925 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002926 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002927};
2928
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002929static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002930 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002931 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002932 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2933 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002934 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2935 .phy_read = mv88e6xxx_g2_smi_phy_read,
2936 .phy_write = mv88e6xxx_g2_smi_phy_write,
2937 .port_set_link = mv88e6xxx_port_set_link,
2938 .port_set_duplex = mv88e6xxx_port_set_duplex,
2939 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2940 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002941 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002942 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002943 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002944 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002945 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002946 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002947 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002948 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002949 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002950 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2951 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002952 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002953 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2954 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002955 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002956 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002957 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002958 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002959 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2960 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002961 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002962 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002963};
2964
2965static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002966 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002967 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002968 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2969 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002970 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2971 .phy_read = mv88e6xxx_g2_smi_phy_read,
2972 .phy_write = mv88e6xxx_g2_smi_phy_write,
2973 .port_set_link = mv88e6xxx_port_set_link,
2974 .port_set_duplex = mv88e6xxx_port_set_duplex,
2975 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2976 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002977 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002978 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002979 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002980 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002981 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002982 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002983 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002984 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002985 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002986 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2987 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002988 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002989 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2990 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002991 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002992 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002993 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002994 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002995 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2996 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002997 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002998 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002999};
3000
3001static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003002 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003003 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003004 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3005 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003006 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3007 .phy_read = mv88e6xxx_g2_smi_phy_read,
3008 .phy_write = mv88e6xxx_g2_smi_phy_write,
3009 .port_set_link = mv88e6xxx_port_set_link,
3010 .port_set_duplex = mv88e6xxx_port_set_duplex,
3011 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3012 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003013 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003014 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003015 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003016 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003017 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003018 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003019 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003020 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003021 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003022 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3023 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003024 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003025 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3026 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003027 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003028 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003029 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003030 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003031 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3032 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003033 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003034};
3035
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003036static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003037 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003038 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003039 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3040 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003041 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003042 .phy_read = mv88e6xxx_g2_smi_phy_read,
3043 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003044 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003045 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003046 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003047 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003048 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003049 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003050 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003051 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003052 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003053 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003054 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003055 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003056 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003057 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003058 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003059 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3060 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003061 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003062 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3063 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003064 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003065 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003066 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003067 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003068 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003069 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003070 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003071 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003072 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003073};
3074
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003075static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003076 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003077 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003078 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3079 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003080 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3081 .phy_read = mv88e6xxx_g2_smi_phy_read,
3082 .phy_write = mv88e6xxx_g2_smi_phy_write,
3083 .port_set_link = mv88e6xxx_port_set_link,
3084 .port_set_duplex = mv88e6xxx_port_set_duplex,
3085 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3086 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003087 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003088 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003089 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003090 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003091 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003092 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003093 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003094 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003095 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003096 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003097 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3098 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003099 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003100 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3101 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003102 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003103 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003104 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003105 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003106 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3107 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003108 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003109 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003110 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003111};
3112
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003113static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003114 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003115 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003116 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3117 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003118 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003119 .phy_read = mv88e6xxx_g2_smi_phy_read,
3120 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003121 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003122 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003123 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003124 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003125 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003126 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003127 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003128 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003129 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003130 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003131 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003132 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003133 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003134 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003135 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3136 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003137 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003138 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3139 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003140 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003141 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003142 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003143 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003144 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003145 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003146 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003147};
3148
3149static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003150 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003151 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003152 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3153 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003154 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003155 .phy_read = mv88e6xxx_g2_smi_phy_read,
3156 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003157 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003158 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003159 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003160 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003161 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003162 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003163 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003164 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003165 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003166 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003167 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003168 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003169 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003170 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003171 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3172 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003173 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003174 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3175 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003176 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003177 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003178 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003179 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003180 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003181};
3182
Vivien Didelot16e329a2017-03-28 13:50:33 -04003183static const struct mv88e6xxx_ops mv88e6341_ops = {
3184 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003185 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003186 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3187 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3188 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3189 .phy_read = mv88e6xxx_g2_smi_phy_read,
3190 .phy_write = mv88e6xxx_g2_smi_phy_write,
3191 .port_set_link = mv88e6xxx_port_set_link,
3192 .port_set_duplex = mv88e6xxx_port_set_duplex,
3193 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3194 .port_set_speed = mv88e6390_port_set_speed,
3195 .port_tag_remap = mv88e6095_port_tag_remap,
3196 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3197 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3198 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003199 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003200 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003201 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003202 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3203 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3204 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003205 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003206 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3207 .stats_get_strings = mv88e6320_stats_get_strings,
3208 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003209 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3210 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003211 .watchdog_ops = &mv88e6390_watchdog_ops,
3212 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003213 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003214 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003215 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003216 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003217 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003218 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003219};
3220
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003221static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003222 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003223 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003224 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003225 .phy_read = mv88e6xxx_g2_smi_phy_read,
3226 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003227 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003228 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003229 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003230 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003231 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003232 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003233 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003234 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003235 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003236 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003237 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003238 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003239 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003240 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003241 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003242 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3243 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003244 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003245 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3246 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003247 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003248 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003249 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003250 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003251 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003252 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003253};
3254
3255static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003256 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003257 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003258 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003259 .phy_read = mv88e6xxx_g2_smi_phy_read,
3260 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003261 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003262 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003263 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003264 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003265 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003266 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003267 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003268 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003269 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003270 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003271 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003272 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003273 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003274 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003275 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003276 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3277 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003278 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003279 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3280 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003281 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003282 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003283 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003284 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003285 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003286 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003287 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003288};
3289
3290static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003291 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003292 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003293 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3294 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003295 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003296 .phy_read = mv88e6xxx_g2_smi_phy_read,
3297 .phy_write = mv88e6xxx_g2_smi_phy_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 Didelota0a0f622016-11-04 03:23:34 +01003300 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003301 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003302 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003303 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003304 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003305 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003306 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003307 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003308 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003309 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003310 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003311 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003312 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003313 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3314 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003315 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003316 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3317 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003318 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003319 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003320 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003321 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003322 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003323 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003324 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003325 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003326 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003327 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3328 .serdes_get_strings = mv88e6352_serdes_get_strings,
3329 .serdes_get_stats = mv88e6352_serdes_get_stats,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003330};
3331
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003332static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003333 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003334 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003335 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3336 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003337 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3338 .phy_read = mv88e6xxx_g2_smi_phy_read,
3339 .phy_write = mv88e6xxx_g2_smi_phy_write,
3340 .port_set_link = mv88e6xxx_port_set_link,
3341 .port_set_duplex = mv88e6xxx_port_set_duplex,
3342 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3343 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003344 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003345 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003346 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003347 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003348 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003349 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003350 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003351 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003352 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003353 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003354 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003355 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003356 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3357 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003358 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003359 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3360 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003361 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003362 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003363 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003364 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003365 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3366 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003367 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003368 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003369 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003370};
3371
3372static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003373 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003374 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003375 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3376 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003377 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3378 .phy_read = mv88e6xxx_g2_smi_phy_read,
3379 .phy_write = mv88e6xxx_g2_smi_phy_write,
3380 .port_set_link = mv88e6xxx_port_set_link,
3381 .port_set_duplex = mv88e6xxx_port_set_duplex,
3382 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3383 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003384 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003385 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003386 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003387 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003388 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003389 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003390 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003391 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003392 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003393 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003394 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003395 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003396 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3397 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003398 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003399 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3400 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003401 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003402 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003403 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003404 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003405 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3406 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003407 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003408 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003409 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003410};
3411
Vivien Didelotf81ec902016-05-09 13:22:58 -04003412static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3413 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003414 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003415 .family = MV88E6XXX_FAMILY_6097,
3416 .name = "Marvell 88E6085",
3417 .num_databases = 4096,
3418 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003419 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003420 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003421 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003422 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003423 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003424 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003425 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003426 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003427 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003428 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003429 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003430 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003431 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003432 },
3433
3434 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003435 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003436 .family = MV88E6XXX_FAMILY_6095,
3437 .name = "Marvell 88E6095/88E6095F",
3438 .num_databases = 256,
3439 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003440 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003441 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003442 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003443 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003444 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003445 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003446 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003447 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003448 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003449 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003450 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003451 },
3452
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003453 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003454 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003455 .family = MV88E6XXX_FAMILY_6097,
3456 .name = "Marvell 88E6097/88E6097F",
3457 .num_databases = 4096,
3458 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003459 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003460 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003461 .port_base_addr = 0x10,
3462 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003463 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003464 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003465 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003466 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003467 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003468 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003469 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003470 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003471 .ops = &mv88e6097_ops,
3472 },
3473
Vivien Didelotf81ec902016-05-09 13:22:58 -04003474 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003475 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003476 .family = MV88E6XXX_FAMILY_6165,
3477 .name = "Marvell 88E6123",
3478 .num_databases = 4096,
3479 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003480 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003481 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003482 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003483 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003484 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003485 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003486 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003487 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003488 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003489 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003490 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003491 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003492 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003493 },
3494
3495 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003496 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003497 .family = MV88E6XXX_FAMILY_6185,
3498 .name = "Marvell 88E6131",
3499 .num_databases = 256,
3500 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003501 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003502 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003503 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003504 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003505 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003506 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003507 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003508 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003509 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003510 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003511 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003512 },
3513
Vivien Didelot990e27b2017-03-28 13:50:32 -04003514 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003515 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003516 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003517 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003518 .num_databases = 4096,
3519 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003520 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003521 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003522 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003523 .port_base_addr = 0x10,
3524 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003525 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003526 .age_time_coeff = 3750,
3527 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003528 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003529 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003530 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003531 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003532 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003533 .ops = &mv88e6141_ops,
3534 },
3535
Vivien Didelotf81ec902016-05-09 13:22:58 -04003536 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003537 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003538 .family = MV88E6XXX_FAMILY_6165,
3539 .name = "Marvell 88E6161",
3540 .num_databases = 4096,
3541 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003542 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003543 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003544 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003545 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003546 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003547 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003548 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003549 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003550 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003551 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003552 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003553 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003554 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003555 },
3556
3557 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003558 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003559 .family = MV88E6XXX_FAMILY_6165,
3560 .name = "Marvell 88E6165",
3561 .num_databases = 4096,
3562 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003563 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003564 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003565 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003566 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003567 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003568 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003569 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003570 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003571 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003572 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003573 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003574 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003575 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003576 },
3577
3578 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003579 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003580 .family = MV88E6XXX_FAMILY_6351,
3581 .name = "Marvell 88E6171",
3582 .num_databases = 4096,
3583 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003584 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003585 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003586 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003587 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003588 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003589 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003590 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003591 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003592 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003593 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003594 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003595 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003596 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003597 },
3598
3599 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003600 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003601 .family = MV88E6XXX_FAMILY_6352,
3602 .name = "Marvell 88E6172",
3603 .num_databases = 4096,
3604 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003605 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003606 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003607 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003608 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003609 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003610 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003611 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003612 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003613 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003614 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003615 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003616 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003617 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003619 },
3620
3621 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003622 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003623 .family = MV88E6XXX_FAMILY_6351,
3624 .name = "Marvell 88E6175",
3625 .num_databases = 4096,
3626 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003627 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003628 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003629 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003630 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003631 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003632 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003633 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003634 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003635 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003636 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003637 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003638 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003639 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003640 },
3641
3642 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003643 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003644 .family = MV88E6XXX_FAMILY_6352,
3645 .name = "Marvell 88E6176",
3646 .num_databases = 4096,
3647 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003648 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003649 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003650 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003651 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003652 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003653 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003654 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003655 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003656 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003657 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003658 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003659 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003660 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003661 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003662 },
3663
3664 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003665 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003666 .family = MV88E6XXX_FAMILY_6185,
3667 .name = "Marvell 88E6185",
3668 .num_databases = 256,
3669 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003670 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003671 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003672 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003673 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003674 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003675 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003676 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003677 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003678 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003679 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003680 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003681 },
3682
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003683 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003684 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003685 .family = MV88E6XXX_FAMILY_6390,
3686 .name = "Marvell 88E6190",
3687 .num_databases = 4096,
3688 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003689 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003690 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003691 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003692 .port_base_addr = 0x0,
3693 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003694 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003695 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003696 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003697 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003698 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003699 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003700 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003701 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003702 .ops = &mv88e6190_ops,
3703 },
3704
3705 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003706 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003707 .family = MV88E6XXX_FAMILY_6390,
3708 .name = "Marvell 88E6190X",
3709 .num_databases = 4096,
3710 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003711 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003712 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003713 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003714 .port_base_addr = 0x0,
3715 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003716 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003717 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003718 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003719 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003720 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003721 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003722 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003723 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003724 .ops = &mv88e6190x_ops,
3725 },
3726
3727 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003728 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003729 .family = MV88E6XXX_FAMILY_6390,
3730 .name = "Marvell 88E6191",
3731 .num_databases = 4096,
3732 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003733 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04003734 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003735 .port_base_addr = 0x0,
3736 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003737 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003738 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003739 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003740 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003741 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003742 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003743 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003744 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003745 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003746 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003747 },
3748
Vivien Didelotf81ec902016-05-09 13:22:58 -04003749 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003750 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003751 .family = MV88E6XXX_FAMILY_6352,
3752 .name = "Marvell 88E6240",
3753 .num_databases = 4096,
3754 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003755 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003756 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003757 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003758 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003759 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003760 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003761 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003762 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003763 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003764 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003765 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003766 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003767 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003768 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003769 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003770 },
3771
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003772 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003773 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003774 .family = MV88E6XXX_FAMILY_6390,
3775 .name = "Marvell 88E6290",
3776 .num_databases = 4096,
3777 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003778 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003779 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003780 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003781 .port_base_addr = 0x0,
3782 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003783 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003784 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003785 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003786 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003787 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003788 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003789 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003790 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003791 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003792 .ops = &mv88e6290_ops,
3793 },
3794
Vivien Didelotf81ec902016-05-09 13:22:58 -04003795 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003796 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003797 .family = MV88E6XXX_FAMILY_6320,
3798 .name = "Marvell 88E6320",
3799 .num_databases = 4096,
3800 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003801 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003802 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003803 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003804 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003805 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003806 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003807 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003808 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003809 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003810 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003811 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003812 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003813 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003814 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003815 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003816 },
3817
3818 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003819 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003820 .family = MV88E6XXX_FAMILY_6320,
3821 .name = "Marvell 88E6321",
3822 .num_databases = 4096,
3823 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003824 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003825 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003826 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003827 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003828 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003829 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003830 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003831 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003832 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003833 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003834 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003835 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003836 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003837 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003838 },
3839
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003840 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003841 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003842 .family = MV88E6XXX_FAMILY_6341,
3843 .name = "Marvell 88E6341",
3844 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01003845 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003846 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003847 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003848 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003849 .port_base_addr = 0x10,
3850 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003851 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003852 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003853 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003854 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003855 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003856 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003857 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003858 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003859 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003860 .ops = &mv88e6341_ops,
3861 },
3862
Vivien Didelotf81ec902016-05-09 13:22:58 -04003863 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003864 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003865 .family = MV88E6XXX_FAMILY_6351,
3866 .name = "Marvell 88E6350",
3867 .num_databases = 4096,
3868 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003869 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003870 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003871 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003872 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003873 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003874 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003875 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003876 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003877 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003878 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003879 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003880 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003881 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003882 },
3883
3884 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003885 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003886 .family = MV88E6XXX_FAMILY_6351,
3887 .name = "Marvell 88E6351",
3888 .num_databases = 4096,
3889 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003890 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003891 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003892 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003893 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003894 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003895 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003896 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003897 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003898 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003899 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003900 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003901 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003902 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003903 },
3904
3905 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003906 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003907 .family = MV88E6XXX_FAMILY_6352,
3908 .name = "Marvell 88E6352",
3909 .num_databases = 4096,
3910 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003911 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003912 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003913 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003914 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003915 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003916 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003917 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003918 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003919 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003920 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003921 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003922 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003923 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003924 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003925 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003926 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003927 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003928 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003929 .family = MV88E6XXX_FAMILY_6390,
3930 .name = "Marvell 88E6390",
3931 .num_databases = 4096,
3932 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003933 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003934 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003935 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003936 .port_base_addr = 0x0,
3937 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003938 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003939 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003940 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003941 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003942 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003943 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003944 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003945 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003946 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003947 .ops = &mv88e6390_ops,
3948 },
3949 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003950 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003951 .family = MV88E6XXX_FAMILY_6390,
3952 .name = "Marvell 88E6390X",
3953 .num_databases = 4096,
3954 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003955 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003956 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003957 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003958 .port_base_addr = 0x0,
3959 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003960 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003961 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003962 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003963 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003964 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003965 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003966 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003967 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003968 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003969 .ops = &mv88e6390x_ops,
3970 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003971};
3972
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003973static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003974{
Vivien Didelota439c062016-04-17 13:23:58 -04003975 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003976
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003977 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3978 if (mv88e6xxx_table[i].prod_num == prod_num)
3979 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003980
Vivien Didelotb9b37712015-10-30 19:39:48 -04003981 return NULL;
3982}
3983
Vivien Didelotfad09c72016-06-21 12:28:20 -04003984static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003985{
3986 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003987 unsigned int prod_num, rev;
3988 u16 id;
3989 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003990
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003991 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003992 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003993 mutex_unlock(&chip->reg_lock);
3994 if (err)
3995 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003996
Vivien Didelot107fcc12017-06-12 12:37:36 -04003997 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3998 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003999
4000 info = mv88e6xxx_lookup_info(prod_num);
4001 if (!info)
4002 return -ENODEV;
4003
Vivien Didelotcaac8542016-06-20 13:14:09 -04004004 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004005 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004006
Vivien Didelotca070c12016-09-02 14:45:34 -04004007 err = mv88e6xxx_g2_require(chip);
4008 if (err)
4009 return err;
4010
Vivien Didelotfad09c72016-06-21 12:28:20 -04004011 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4012 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004013
4014 return 0;
4015}
4016
Vivien Didelotfad09c72016-06-21 12:28:20 -04004017static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004018{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004019 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004020
Vivien Didelotfad09c72016-06-21 12:28:20 -04004021 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4022 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004023 return NULL;
4024
Vivien Didelotfad09c72016-06-21 12:28:20 -04004025 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004026
Vivien Didelotfad09c72016-06-21 12:28:20 -04004027 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004028 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004029
Vivien Didelotfad09c72016-06-21 12:28:20 -04004030 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004031}
4032
Vivien Didelotfad09c72016-06-21 12:28:20 -04004033static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004034 struct mii_bus *bus, int sw_addr)
4035{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004036 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004037 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004038 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004039 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004040 else
4041 return -EINVAL;
4042
Vivien Didelotfad09c72016-06-21 12:28:20 -04004043 chip->bus = bus;
4044 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004045
4046 return 0;
4047}
4048
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004049static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4050 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004051{
Vivien Didelot04bed142016-08-31 18:06:13 -04004052 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004053
Andrew Lunn443d5a12016-12-03 04:35:18 +01004054 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004055}
4056
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004057#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004058static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4059 struct device *host_dev, int sw_addr,
4060 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004061{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004062 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004063 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004064 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004065
Vivien Didelota439c062016-04-17 13:23:58 -04004066 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004067 if (!bus)
4068 return NULL;
4069
Vivien Didelotfad09c72016-06-21 12:28:20 -04004070 chip = mv88e6xxx_alloc_chip(dsa_dev);
4071 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004072 return NULL;
4073
Vivien Didelotcaac8542016-06-20 13:14:09 -04004074 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004075 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004076
Vivien Didelotfad09c72016-06-21 12:28:20 -04004077 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004078 if (err)
4079 goto free;
4080
Vivien Didelotfad09c72016-06-21 12:28:20 -04004081 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004082 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004083 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004084
Andrew Lunndc30c352016-10-16 19:56:49 +02004085 mutex_lock(&chip->reg_lock);
4086 err = mv88e6xxx_switch_reset(chip);
4087 mutex_unlock(&chip->reg_lock);
4088 if (err)
4089 goto free;
4090
Vivien Didelote57e5e72016-08-15 17:19:00 -04004091 mv88e6xxx_phy_init(chip);
4092
Andrew Lunna3c53be52017-01-24 14:53:50 +01004093 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004094 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004095 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004096
Vivien Didelotfad09c72016-06-21 12:28:20 -04004097 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004098
Vivien Didelotfad09c72016-06-21 12:28:20 -04004099 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004100free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004101 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004102
4103 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004104}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004105#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004106
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004107static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004108 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004109{
4110 /* We don't need any dynamic resource from the kernel (yet),
4111 * so skip the prepare phase.
4112 */
4113
4114 return 0;
4115}
4116
4117static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004118 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004119{
Vivien Didelot04bed142016-08-31 18:06:13 -04004120 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004121
4122 mutex_lock(&chip->reg_lock);
4123 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004124 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004125 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4126 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004127 mutex_unlock(&chip->reg_lock);
4128}
4129
4130static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4131 const struct switchdev_obj_port_mdb *mdb)
4132{
Vivien Didelot04bed142016-08-31 18:06:13 -04004133 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004134 int err;
4135
4136 mutex_lock(&chip->reg_lock);
4137 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004138 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004139 mutex_unlock(&chip->reg_lock);
4140
4141 return err;
4142}
4143
Florian Fainellia82f67a2017-01-08 14:52:08 -08004144static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004145#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004146 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004147#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004148 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004149 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004150 .adjust_link = mv88e6xxx_adjust_link,
4151 .get_strings = mv88e6xxx_get_strings,
4152 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4153 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004154 .port_enable = mv88e6xxx_port_enable,
4155 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004156 .get_mac_eee = mv88e6xxx_get_mac_eee,
4157 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004158 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004159 .get_eeprom = mv88e6xxx_get_eeprom,
4160 .set_eeprom = mv88e6xxx_set_eeprom,
4161 .get_regs_len = mv88e6xxx_get_regs_len,
4162 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004163 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004164 .port_bridge_join = mv88e6xxx_port_bridge_join,
4165 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4166 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004167 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004168 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4169 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4170 .port_vlan_add = mv88e6xxx_port_vlan_add,
4171 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004172 .port_fdb_add = mv88e6xxx_port_fdb_add,
4173 .port_fdb_del = mv88e6xxx_port_fdb_del,
4174 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004175 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4176 .port_mdb_add = mv88e6xxx_port_mdb_add,
4177 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004178 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4179 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004180 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4181 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4182 .port_txtstamp = mv88e6xxx_port_txtstamp,
4183 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4184 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004185};
4186
Florian Fainelliab3d4082017-01-08 14:52:07 -08004187static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4188 .ops = &mv88e6xxx_switch_ops,
4189};
4190
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004191static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004192{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004193 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004194 struct dsa_switch *ds;
4195
Vivien Didelot73b12042017-03-30 17:37:10 -04004196 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004197 if (!ds)
4198 return -ENOMEM;
4199
Vivien Didelotfad09c72016-06-21 12:28:20 -04004200 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004201 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004202 ds->ageing_time_min = chip->info->age_time_coeff;
4203 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004204
4205 dev_set_drvdata(dev, ds);
4206
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004207 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004208}
4209
Vivien Didelotfad09c72016-06-21 12:28:20 -04004210static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004211{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004212 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004213}
4214
Vivien Didelot57d32312016-06-20 13:13:58 -04004215static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004216{
4217 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004218 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004219 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004220 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004221 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004222 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004223
Vivien Didelotcaac8542016-06-20 13:14:09 -04004224 compat_info = of_device_get_match_data(dev);
4225 if (!compat_info)
4226 return -EINVAL;
4227
Vivien Didelotfad09c72016-06-21 12:28:20 -04004228 chip = mv88e6xxx_alloc_chip(dev);
4229 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004230 return -ENOMEM;
4231
Vivien Didelotfad09c72016-06-21 12:28:20 -04004232 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004233
Vivien Didelotfad09c72016-06-21 12:28:20 -04004234 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004235 if (err)
4236 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004237
Andrew Lunnb4308f02016-11-21 23:26:55 +01004238 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4239 if (IS_ERR(chip->reset))
4240 return PTR_ERR(chip->reset);
4241
Vivien Didelotfad09c72016-06-21 12:28:20 -04004242 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004243 if (err)
4244 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004245
Vivien Didelote57e5e72016-08-15 17:19:00 -04004246 mv88e6xxx_phy_init(chip);
4247
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004248 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004249 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004250 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004251
Andrew Lunndc30c352016-10-16 19:56:49 +02004252 mutex_lock(&chip->reg_lock);
4253 err = mv88e6xxx_switch_reset(chip);
4254 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004255 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004256 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004257
Andrew Lunndc30c352016-10-16 19:56:49 +02004258 chip->irq = of_irq_get(np, 0);
4259 if (chip->irq == -EPROBE_DEFER) {
4260 err = chip->irq;
4261 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004262 }
4263
Andrew Lunn294d7112018-02-22 22:58:32 +01004264 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004265 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004266 * controllers
4267 */
4268 mutex_lock(&chip->reg_lock);
4269 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004270 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004271 else
4272 err = mv88e6xxx_irq_poll_setup(chip);
4273 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004274
Andrew Lunn294d7112018-02-22 22:58:32 +01004275 if (err)
4276 goto out;
4277
4278 if (chip->info->g2_irqs > 0) {
4279 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004280 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004281 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004282 }
4283
Andrew Lunn294d7112018-02-22 22:58:32 +01004284 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4285 if (err)
4286 goto out_g2_irq;
4287
4288 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4289 if (err)
4290 goto out_g1_atu_prob_irq;
4291
Andrew Lunna3c53be52017-01-24 14:53:50 +01004292 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004293 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004294 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004295
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004296 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004297 if (err)
4298 goto out_mdio;
4299
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004300 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004301
4302out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004303 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004304out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004305 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004306out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004307 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004308out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004309 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004310 mv88e6xxx_g2_irq_free(chip);
4311out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004312 mutex_lock(&chip->reg_lock);
4313 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004314 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004315 else
4316 mv88e6xxx_irq_poll_free(chip);
4317 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004318out:
4319 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004320}
4321
4322static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4323{
4324 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004325 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004326
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004327 if (chip->info->ptp_support) {
4328 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004329 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004330 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004331
Andrew Lunn930188c2016-08-22 16:01:03 +02004332 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004333 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004334 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004335
Andrew Lunn76f38f12018-03-17 20:21:09 +01004336 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4337 mv88e6xxx_g1_atu_prob_irq_free(chip);
4338
4339 if (chip->info->g2_irqs > 0)
4340 mv88e6xxx_g2_irq_free(chip);
4341
4342 mutex_lock(&chip->reg_lock);
4343 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004344 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004345 else
4346 mv88e6xxx_irq_poll_free(chip);
4347 mutex_unlock(&chip->reg_lock);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004348}
4349
4350static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004351 {
4352 .compatible = "marvell,mv88e6085",
4353 .data = &mv88e6xxx_table[MV88E6085],
4354 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004355 {
4356 .compatible = "marvell,mv88e6190",
4357 .data = &mv88e6xxx_table[MV88E6190],
4358 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004359 { /* sentinel */ },
4360};
4361
4362MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4363
4364static struct mdio_driver mv88e6xxx_driver = {
4365 .probe = mv88e6xxx_probe,
4366 .remove = mv88e6xxx_remove,
4367 .mdiodrv.driver = {
4368 .name = "mv88e6085",
4369 .of_match_table = mv88e6xxx_of_match,
4370 },
4371};
4372
Ben Hutchings98e67302011-11-25 14:36:19 +00004373static int __init mv88e6xxx_init(void)
4374{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004375 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004376 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004377}
4378module_init(mv88e6xxx_init);
4379
4380static void __exit mv88e6xxx_cleanup(void)
4381{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004382 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004383 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004384}
4385module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004386
4387MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4388MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4389MODULE_LICENSE("GPL");