blob: d1ca4d6ef9be48f699d1c2659db7a5c250b33122 [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
1049 return 0;
1050}
1051
Vivien Didelotb28f8722018-04-26 21:56:44 -04001052static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1053{
1054 /* Clear all trunk masks and mapping */
1055 if (chip->info->global2_addr)
1056 return mv88e6xxx_g2_trunk_clear(chip);
1057
1058 return 0;
1059}
1060
Vivien Didelot9e907d72017-07-17 13:03:43 -04001061static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1062{
1063 if (chip->info->ops->pot_clear)
1064 return chip->info->ops->pot_clear(chip);
1065
1066 return 0;
1067}
1068
Vivien Didelot51c901a2017-07-17 13:03:41 -04001069static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1070{
1071 if (chip->info->ops->mgmt_rsvd2cpu)
1072 return chip->info->ops->mgmt_rsvd2cpu(chip);
1073
1074 return 0;
1075}
1076
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001077static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1078{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001079 int err;
1080
Vivien Didelotdaefc942017-03-11 16:12:54 -05001081 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1082 if (err)
1083 return err;
1084
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001085 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1086 if (err)
1087 return err;
1088
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001089 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1090}
1091
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001092static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1093{
1094 int port;
1095 int err;
1096
1097 if (!chip->info->ops->irl_init_all)
1098 return 0;
1099
1100 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1101 /* Disable ingress rate limiting by resetting all per port
1102 * ingress rate limit resources to their initial state.
1103 */
1104 err = chip->info->ops->irl_init_all(chip, port);
1105 if (err)
1106 return err;
1107 }
1108
1109 return 0;
1110}
1111
Vivien Didelot04a69a12017-10-13 14:18:05 -04001112static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1113{
1114 if (chip->info->ops->set_switch_mac) {
1115 u8 addr[ETH_ALEN];
1116
1117 eth_random_addr(addr);
1118
1119 return chip->info->ops->set_switch_mac(chip, addr);
1120 }
1121
1122 return 0;
1123}
1124
Vivien Didelot17a15942017-03-30 17:37:09 -04001125static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1126{
1127 u16 pvlan = 0;
1128
1129 if (!mv88e6xxx_has_pvt(chip))
1130 return -EOPNOTSUPP;
1131
1132 /* Skip the local source device, which uses in-chip port VLAN */
1133 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001134 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001135
1136 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1137}
1138
Vivien Didelot81228992017-03-30 17:37:08 -04001139static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1140{
Vivien Didelot17a15942017-03-30 17:37:09 -04001141 int dev, port;
1142 int err;
1143
Vivien Didelot81228992017-03-30 17:37:08 -04001144 if (!mv88e6xxx_has_pvt(chip))
1145 return 0;
1146
1147 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1148 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1149 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001150 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1151 if (err)
1152 return err;
1153
1154 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1155 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1156 err = mv88e6xxx_pvt_map(chip, dev, port);
1157 if (err)
1158 return err;
1159 }
1160 }
1161
1162 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001163}
1164
Vivien Didelot749efcb2016-09-22 16:49:24 -04001165static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1166{
1167 struct mv88e6xxx_chip *chip = ds->priv;
1168 int err;
1169
1170 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001171 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001172 mutex_unlock(&chip->reg_lock);
1173
1174 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001175 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001176}
1177
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001178static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1179{
1180 if (!chip->info->max_vid)
1181 return 0;
1182
1183 return mv88e6xxx_g1_vtu_flush(chip);
1184}
1185
Vivien Didelotf1394b782017-05-01 14:05:22 -04001186static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1187 struct mv88e6xxx_vtu_entry *entry)
1188{
1189 if (!chip->info->ops->vtu_getnext)
1190 return -EOPNOTSUPP;
1191
1192 return chip->info->ops->vtu_getnext(chip, entry);
1193}
1194
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001195static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1196 struct mv88e6xxx_vtu_entry *entry)
1197{
1198 if (!chip->info->ops->vtu_loadpurge)
1199 return -EOPNOTSUPP;
1200
1201 return chip->info->ops->vtu_loadpurge(chip, entry);
1202}
1203
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001204static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001205{
1206 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001207 struct mv88e6xxx_vtu_entry vlan = {
1208 .vid = chip->info->max_vid,
1209 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001210 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001211
1212 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1213
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001214 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001215 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001216 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001217 if (err)
1218 return err;
1219
1220 set_bit(*fid, fid_bitmap);
1221 }
1222
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001223 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001224 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001225 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001226 if (err)
1227 return err;
1228
1229 if (!vlan.valid)
1230 break;
1231
1232 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001233 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001234
1235 /* The reset value 0x000 is used to indicate that multiple address
1236 * databases are not needed. Return the next positive available.
1237 */
1238 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001239 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001240 return -ENOSPC;
1241
1242 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001243 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001244}
1245
Vivien Didelot567aa592017-05-01 14:05:25 -04001246static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1247 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001248{
1249 int err;
1250
1251 if (!vid)
1252 return -EINVAL;
1253
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001254 entry->vid = vid - 1;
1255 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001256
Vivien Didelotf1394b782017-05-01 14:05:22 -04001257 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001258 if (err)
1259 return err;
1260
Vivien Didelot567aa592017-05-01 14:05:25 -04001261 if (entry->vid == vid && entry->valid)
1262 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001263
Vivien Didelot567aa592017-05-01 14:05:25 -04001264 if (new) {
1265 int i;
1266
1267 /* Initialize a fresh VLAN entry */
1268 memset(entry, 0, sizeof(*entry));
1269 entry->valid = true;
1270 entry->vid = vid;
1271
Vivien Didelot553a7682017-06-07 18:12:16 -04001272 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001273 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001274 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001275 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001276
1277 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001278 }
1279
Vivien Didelot567aa592017-05-01 14:05:25 -04001280 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1281 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001282}
1283
Vivien Didelotda9c3592016-02-12 12:09:40 -05001284static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1285 u16 vid_begin, u16 vid_end)
1286{
Vivien Didelot04bed142016-08-31 18:06:13 -04001287 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001288 struct mv88e6xxx_vtu_entry vlan = {
1289 .vid = vid_begin - 1,
1290 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001291 int i, err;
1292
Andrew Lunndb06ae412017-09-25 23:32:20 +02001293 /* DSA and CPU ports have to be members of multiple vlans */
1294 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1295 return 0;
1296
Vivien Didelotda9c3592016-02-12 12:09:40 -05001297 if (!vid_begin)
1298 return -EOPNOTSUPP;
1299
Vivien Didelotfad09c72016-06-21 12:28:20 -04001300 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001301
Vivien Didelotda9c3592016-02-12 12:09:40 -05001302 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001303 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001304 if (err)
1305 goto unlock;
1306
1307 if (!vlan.valid)
1308 break;
1309
1310 if (vlan.vid > vid_end)
1311 break;
1312
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001313 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001314 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1315 continue;
1316
Andrew Lunncd886462017-11-09 22:29:53 +01001317 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001318 continue;
1319
Vivien Didelotbd00e052017-05-01 14:05:11 -04001320 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001321 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001322 continue;
1323
Vivien Didelotc8652c82017-10-16 11:12:19 -04001324 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001325 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001326 break; /* same bridge, check next VLAN */
1327
Vivien Didelotc8652c82017-10-16 11:12:19 -04001328 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001329 continue;
1330
Andrew Lunn743fcc22017-11-09 22:29:54 +01001331 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1332 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001333 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001334 err = -EOPNOTSUPP;
1335 goto unlock;
1336 }
1337 } while (vlan.vid < vid_end);
1338
1339unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001340 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001341
1342 return err;
1343}
1344
Vivien Didelotf81ec902016-05-09 13:22:58 -04001345static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1346 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001347{
Vivien Didelot04bed142016-08-31 18:06:13 -04001348 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001349 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1350 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001351 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001352
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001353 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001354 return -EOPNOTSUPP;
1355
Vivien Didelotfad09c72016-06-21 12:28:20 -04001356 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001357 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001358 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001359
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001360 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001361}
1362
Vivien Didelot57d32312016-06-20 13:13:58 -04001363static int
1364mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001365 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001366{
Vivien Didelot04bed142016-08-31 18:06:13 -04001367 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001368 int err;
1369
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001370 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001371 return -EOPNOTSUPP;
1372
Vivien Didelotda9c3592016-02-12 12:09:40 -05001373 /* If the requested port doesn't belong to the same bridge as the VLAN
1374 * members, do not support it (yet) and fallback to software VLAN.
1375 */
1376 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1377 vlan->vid_end);
1378 if (err)
1379 return err;
1380
Vivien Didelot76e398a2015-11-01 12:33:55 -05001381 /* We don't need any dynamic resource from the kernel (yet),
1382 * so skip the prepare phase.
1383 */
1384 return 0;
1385}
1386
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001387static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1388 const unsigned char *addr, u16 vid,
1389 u8 state)
1390{
1391 struct mv88e6xxx_vtu_entry vlan;
1392 struct mv88e6xxx_atu_entry entry;
1393 int err;
1394
1395 /* Null VLAN ID corresponds to the port private database */
1396 if (vid == 0)
1397 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1398 else
1399 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1400 if (err)
1401 return err;
1402
1403 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1404 ether_addr_copy(entry.mac, addr);
1405 eth_addr_dec(entry.mac);
1406
1407 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1408 if (err)
1409 return err;
1410
1411 /* Initialize a fresh ATU entry if it isn't found */
1412 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1413 !ether_addr_equal(entry.mac, addr)) {
1414 memset(&entry, 0, sizeof(entry));
1415 ether_addr_copy(entry.mac, addr);
1416 }
1417
1418 /* Purge the ATU entry only if no port is using it anymore */
1419 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1420 entry.portvec &= ~BIT(port);
1421 if (!entry.portvec)
1422 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1423 } else {
1424 entry.portvec |= BIT(port);
1425 entry.state = state;
1426 }
1427
1428 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1429}
1430
Andrew Lunn87fa8862017-11-09 22:29:56 +01001431static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1432 u16 vid)
1433{
1434 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1435 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1436
1437 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1438}
1439
1440static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1441{
1442 int port;
1443 int err;
1444
1445 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1446 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1447 if (err)
1448 return err;
1449 }
1450
1451 return 0;
1452}
1453
Vivien Didelotfad09c72016-06-21 12:28:20 -04001454static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001455 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001456{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001457 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001458 int err;
1459
Vivien Didelot567aa592017-05-01 14:05:25 -04001460 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001461 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001462 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001463
Vivien Didelotc91498e2017-06-07 18:12:13 -04001464 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001465
Andrew Lunn87fa8862017-11-09 22:29:56 +01001466 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1467 if (err)
1468 return err;
1469
1470 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001471}
1472
Vivien Didelotf81ec902016-05-09 13:22:58 -04001473static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001474 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001475{
Vivien Didelot04bed142016-08-31 18:06:13 -04001476 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001477 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1478 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001479 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001480 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001481
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001482 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001483 return;
1484
Vivien Didelotc91498e2017-06-07 18:12:13 -04001485 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001486 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001487 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001488 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001489 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001490 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001491
Vivien Didelotfad09c72016-06-21 12:28:20 -04001492 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001493
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001494 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001495 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001496 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1497 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001498
Vivien Didelot77064f32016-11-04 03:23:30 +01001499 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001500 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1501 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001502
Vivien Didelotfad09c72016-06-21 12:28:20 -04001503 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001504}
1505
Vivien Didelotfad09c72016-06-21 12:28:20 -04001506static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001507 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001508{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001509 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001510 int i, err;
1511
Vivien Didelot567aa592017-05-01 14:05:25 -04001512 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001513 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001514 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001515
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001516 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001517 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001518 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001519
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001520 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001521
1522 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001523 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001524 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001525 if (vlan.member[i] !=
1526 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001527 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001528 break;
1529 }
1530 }
1531
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001532 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001533 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001534 return err;
1535
Vivien Didelote606ca32017-03-11 16:12:55 -05001536 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001537}
1538
Vivien Didelotf81ec902016-05-09 13:22:58 -04001539static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1540 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001541{
Vivien Didelot04bed142016-08-31 18:06:13 -04001542 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001543 u16 pvid, vid;
1544 int err = 0;
1545
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001546 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001547 return -EOPNOTSUPP;
1548
Vivien Didelotfad09c72016-06-21 12:28:20 -04001549 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001550
Vivien Didelot77064f32016-11-04 03:23:30 +01001551 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001552 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001553 goto unlock;
1554
Vivien Didelot76e398a2015-11-01 12:33:55 -05001555 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001556 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001557 if (err)
1558 goto unlock;
1559
1560 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001561 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001562 if (err)
1563 goto unlock;
1564 }
1565 }
1566
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001567unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001568 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001569
1570 return err;
1571}
1572
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001573static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1574 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001575{
Vivien Didelot04bed142016-08-31 18:06:13 -04001576 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001577 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001578
Vivien Didelotfad09c72016-06-21 12:28:20 -04001579 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001580 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1581 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001582 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001583
1584 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001585}
1586
Vivien Didelotf81ec902016-05-09 13:22:58 -04001587static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001588 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001589{
Vivien Didelot04bed142016-08-31 18:06:13 -04001590 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001591 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001592
Vivien Didelotfad09c72016-06-21 12:28:20 -04001593 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001594 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001595 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001596 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001597
Vivien Didelot83dabd12016-08-31 11:50:04 -04001598 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001599}
1600
Vivien Didelot83dabd12016-08-31 11:50:04 -04001601static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1602 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001603 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001604{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001605 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001606 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001607 int err;
1608
Vivien Didelot27c0e602017-06-15 12:14:01 -04001609 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001610 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001611
1612 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001613 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001614 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001615 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001616 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001617 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001618
Vivien Didelot27c0e602017-06-15 12:14:01 -04001619 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001620 break;
1621
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001622 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001623 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001624
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001625 if (!is_unicast_ether_addr(addr.mac))
1626 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001627
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001628 is_static = (addr.state ==
1629 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1630 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001631 if (err)
1632 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001633 } while (!is_broadcast_ether_addr(addr.mac));
1634
1635 return err;
1636}
1637
Vivien Didelot83dabd12016-08-31 11:50:04 -04001638static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001639 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001640{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001641 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001642 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001643 };
1644 u16 fid;
1645 int err;
1646
1647 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001648 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001649 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001650 mutex_unlock(&chip->reg_lock);
1651
Vivien Didelot83dabd12016-08-31 11:50:04 -04001652 if (err)
1653 return err;
1654
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001655 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001656 if (err)
1657 return err;
1658
1659 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001660 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001661 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001662 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001663 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001664 if (err)
1665 return err;
1666
1667 if (!vlan.valid)
1668 break;
1669
1670 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001671 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001672 if (err)
1673 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001674 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001675
1676 return err;
1677}
1678
Vivien Didelotf81ec902016-05-09 13:22:58 -04001679static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001680 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001681{
Vivien Didelot04bed142016-08-31 18:06:13 -04001682 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001683
Andrew Lunna61e5402018-02-15 14:38:35 +01001684 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001685}
1686
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001687static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1688 struct net_device *br)
1689{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001690 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001691 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001692 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001693 int err;
1694
1695 /* Remap the Port VLAN of each local bridge group member */
1696 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1697 if (chip->ds->ports[port].bridge_dev == br) {
1698 err = mv88e6xxx_port_vlan_map(chip, port);
1699 if (err)
1700 return err;
1701 }
1702 }
1703
Vivien Didelote96a6e02017-03-30 17:37:13 -04001704 if (!mv88e6xxx_has_pvt(chip))
1705 return 0;
1706
1707 /* Remap the Port VLAN of each cross-chip bridge group member */
1708 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1709 ds = chip->ds->dst->ds[dev];
1710 if (!ds)
1711 break;
1712
1713 for (port = 0; port < ds->num_ports; ++port) {
1714 if (ds->ports[port].bridge_dev == br) {
1715 err = mv88e6xxx_pvt_map(chip, dev, port);
1716 if (err)
1717 return err;
1718 }
1719 }
1720 }
1721
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001722 return 0;
1723}
1724
Vivien Didelotf81ec902016-05-09 13:22:58 -04001725static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001726 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001727{
Vivien Didelot04bed142016-08-31 18:06:13 -04001728 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001729 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001730
Vivien Didelotfad09c72016-06-21 12:28:20 -04001731 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001732 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001733 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001734
Vivien Didelot466dfa02016-02-26 13:16:05 -05001735 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001736}
1737
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001738static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1739 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001740{
Vivien Didelot04bed142016-08-31 18:06:13 -04001741 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001742
Vivien Didelotfad09c72016-06-21 12:28:20 -04001743 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001744 if (mv88e6xxx_bridge_map(chip, br) ||
1745 mv88e6xxx_port_vlan_map(chip, port))
1746 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001747 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001748}
1749
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001750static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1751 int port, struct net_device *br)
1752{
1753 struct mv88e6xxx_chip *chip = ds->priv;
1754 int err;
1755
1756 if (!mv88e6xxx_has_pvt(chip))
1757 return 0;
1758
1759 mutex_lock(&chip->reg_lock);
1760 err = mv88e6xxx_pvt_map(chip, dev, port);
1761 mutex_unlock(&chip->reg_lock);
1762
1763 return err;
1764}
1765
1766static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1767 int port, struct net_device *br)
1768{
1769 struct mv88e6xxx_chip *chip = ds->priv;
1770
1771 if (!mv88e6xxx_has_pvt(chip))
1772 return;
1773
1774 mutex_lock(&chip->reg_lock);
1775 if (mv88e6xxx_pvt_map(chip, dev, port))
1776 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1777 mutex_unlock(&chip->reg_lock);
1778}
1779
Vivien Didelot17e708b2016-12-05 17:30:27 -05001780static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1781{
1782 if (chip->info->ops->reset)
1783 return chip->info->ops->reset(chip);
1784
1785 return 0;
1786}
1787
Vivien Didelot309eca62016-12-05 17:30:26 -05001788static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1789{
1790 struct gpio_desc *gpiod = chip->reset;
1791
1792 /* If there is a GPIO connected to the reset pin, toggle it */
1793 if (gpiod) {
1794 gpiod_set_value_cansleep(gpiod, 1);
1795 usleep_range(10000, 20000);
1796 gpiod_set_value_cansleep(gpiod, 0);
1797 usleep_range(10000, 20000);
1798 }
1799}
1800
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001801static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1802{
1803 int i, err;
1804
1805 /* Set all ports to the Disabled state */
1806 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001807 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001808 if (err)
1809 return err;
1810 }
1811
1812 /* Wait for transmit queues to drain,
1813 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1814 */
1815 usleep_range(2000, 4000);
1816
1817 return 0;
1818}
1819
Vivien Didelotfad09c72016-06-21 12:28:20 -04001820static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001821{
Vivien Didelota935c052016-09-29 12:21:53 -04001822 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001823
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001824 err = mv88e6xxx_disable_ports(chip);
1825 if (err)
1826 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001827
Vivien Didelot309eca62016-12-05 17:30:26 -05001828 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001829
Vivien Didelot17e708b2016-12-05 17:30:27 -05001830 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001831}
1832
Vivien Didelot43145572017-03-11 16:12:59 -05001833static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001834 enum mv88e6xxx_frame_mode frame,
1835 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001836{
1837 int err;
1838
Vivien Didelot43145572017-03-11 16:12:59 -05001839 if (!chip->info->ops->port_set_frame_mode)
1840 return -EOPNOTSUPP;
1841
1842 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001843 if (err)
1844 return err;
1845
Vivien Didelot43145572017-03-11 16:12:59 -05001846 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1847 if (err)
1848 return err;
1849
1850 if (chip->info->ops->port_set_ether_type)
1851 return chip->info->ops->port_set_ether_type(chip, port, etype);
1852
1853 return 0;
1854}
1855
1856static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1857{
1858 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001859 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001860 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001861}
1862
1863static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1864{
1865 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
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_edsa(struct mv88e6xxx_chip *chip, int port)
1871{
1872 return mv88e6xxx_set_port_mode(chip, port,
1873 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001874 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1875 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001876}
1877
1878static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1879{
1880 if (dsa_is_dsa_port(chip->ds, port))
1881 return mv88e6xxx_set_port_mode_dsa(chip, port);
1882
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001883 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001884 return mv88e6xxx_set_port_mode_normal(chip, port);
1885
1886 /* Setup CPU port mode depending on its supported tag format */
1887 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1888 return mv88e6xxx_set_port_mode_dsa(chip, port);
1889
1890 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1891 return mv88e6xxx_set_port_mode_edsa(chip, port);
1892
1893 return -EINVAL;
1894}
1895
Vivien Didelotea698f42017-03-11 16:12:50 -05001896static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1897{
1898 bool message = dsa_is_dsa_port(chip->ds, port);
1899
1900 return mv88e6xxx_port_set_message_port(chip, port, message);
1901}
1902
Vivien Didelot601aeed2017-03-11 16:13:00 -05001903static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1904{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001905 struct dsa_switch *ds = chip->ds;
1906 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001907
1908 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001909 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001910 if (chip->info->ops->port_set_egress_floods)
1911 return chip->info->ops->port_set_egress_floods(chip, port,
1912 flood, flood);
1913
1914 return 0;
1915}
1916
Andrew Lunn6d917822017-05-26 01:03:21 +02001917static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1918 bool on)
1919{
Vivien Didelot523a8902017-05-26 18:02:42 -04001920 if (chip->info->ops->serdes_power)
1921 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001922
Vivien Didelot523a8902017-05-26 18:02:42 -04001923 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001924}
1925
Vivien Didelotfa371c82017-12-05 15:34:10 -05001926static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1927{
1928 struct dsa_switch *ds = chip->ds;
1929 int upstream_port;
1930 int err;
1931
Vivien Didelot07073c72017-12-05 15:34:13 -05001932 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001933 if (chip->info->ops->port_set_upstream_port) {
1934 err = chip->info->ops->port_set_upstream_port(chip, port,
1935 upstream_port);
1936 if (err)
1937 return err;
1938 }
1939
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001940 if (port == upstream_port) {
1941 if (chip->info->ops->set_cpu_port) {
1942 err = chip->info->ops->set_cpu_port(chip,
1943 upstream_port);
1944 if (err)
1945 return err;
1946 }
1947
1948 if (chip->info->ops->set_egress_port) {
1949 err = chip->info->ops->set_egress_port(chip,
1950 upstream_port);
1951 if (err)
1952 return err;
1953 }
1954 }
1955
Vivien Didelotfa371c82017-12-05 15:34:10 -05001956 return 0;
1957}
1958
Vivien Didelotfad09c72016-06-21 12:28:20 -04001959static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001960{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001961 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001962 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001963 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001964
Vivien Didelotd78343d2016-11-04 03:23:36 +01001965 /* MAC Forcing register: don't force link, speed, duplex or flow control
1966 * state to any particular values on physical ports, but force the CPU
1967 * port and all DSA ports to their maximum bandwidth and full duplex.
1968 */
1969 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1970 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1971 SPEED_MAX, DUPLEX_FULL,
1972 PHY_INTERFACE_MODE_NA);
1973 else
1974 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1975 SPEED_UNFORCED, DUPLEX_UNFORCED,
1976 PHY_INTERFACE_MODE_NA);
1977 if (err)
1978 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001979
1980 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1981 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1982 * tunneling, determine priority by looking at 802.1p and IP
1983 * priority fields (IP prio has precedence), and set STP state
1984 * to Forwarding.
1985 *
1986 * If this is the CPU link, use DSA or EDSA tagging depending
1987 * on which tagging mode was configured.
1988 *
1989 * If this is a link to another switch, use DSA tagging mode.
1990 *
1991 * If this is the upstream port for this switch, enable
1992 * forwarding of unknown unicasts and multicasts.
1993 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001994 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1995 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1996 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1997 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001998 if (err)
1999 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002000
Vivien Didelot601aeed2017-03-11 16:13:00 -05002001 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002002 if (err)
2003 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002004
Vivien Didelot601aeed2017-03-11 16:13:00 -05002005 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002006 if (err)
2007 return err;
2008
Andrew Lunn04aca992017-05-26 01:03:24 +02002009 /* Enable the SERDES interface for DSA and CPU ports. Normal
2010 * ports SERDES are enabled when the port is enabled, thus
2011 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002012 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002013 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2014 err = mv88e6xxx_serdes_power(chip, port, true);
2015 if (err)
2016 return err;
2017 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002018
Vivien Didelot8efdda42015-08-13 12:52:23 -04002019 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002020 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002021 * untagged frames on this port, do a destination address lookup on all
2022 * received packets as usual, disable ARP mirroring and don't send a
2023 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002024 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002025 err = mv88e6xxx_port_set_map_da(chip, port);
2026 if (err)
2027 return err;
2028
Vivien Didelotfa371c82017-12-05 15:34:10 -05002029 err = mv88e6xxx_setup_upstream_port(chip, port);
2030 if (err)
2031 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002032
Andrew Lunna23b2962017-02-04 20:15:28 +01002033 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002034 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002035 if (err)
2036 return err;
2037
Vivien Didelotcd782652017-06-08 18:34:13 -04002038 if (chip->info->ops->port_set_jumbo_size) {
2039 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002040 if (err)
2041 return err;
2042 }
2043
Andrew Lunn54d792f2015-05-06 01:09:47 +02002044 /* Port Association Vector: when learning source addresses
2045 * of packets, add the address to the address database using
2046 * a port bitmap that has only the bit for this port set and
2047 * the other bits clear.
2048 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002049 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002050 /* Disable learning for CPU port */
2051 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002052 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002053
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002054 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2055 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002056 if (err)
2057 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002058
2059 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002060 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2061 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002062 if (err)
2063 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002064
Vivien Didelot08984322017-06-08 18:34:12 -04002065 if (chip->info->ops->port_pause_limit) {
2066 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002067 if (err)
2068 return err;
2069 }
2070
Vivien Didelotc8c94892017-03-11 16:13:01 -05002071 if (chip->info->ops->port_disable_learn_limit) {
2072 err = chip->info->ops->port_disable_learn_limit(chip, port);
2073 if (err)
2074 return err;
2075 }
2076
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002077 if (chip->info->ops->port_disable_pri_override) {
2078 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002079 if (err)
2080 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002081 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002082
Andrew Lunnef0a7312016-12-03 04:35:16 +01002083 if (chip->info->ops->port_tag_remap) {
2084 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002085 if (err)
2086 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002087 }
2088
Andrew Lunnef70b112016-12-03 04:45:18 +01002089 if (chip->info->ops->port_egress_rate_limiting) {
2090 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002091 if (err)
2092 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002093 }
2094
Vivien Didelotea698f42017-03-11 16:12:50 -05002095 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002096 if (err)
2097 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002098
Vivien Didelot207afda2016-04-14 14:42:09 -04002099 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002100 * database, and allow bidirectional communication between the
2101 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002102 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002103 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002104 if (err)
2105 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002106
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002107 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002108 if (err)
2109 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002110
2111 /* Default VLAN ID and priority: don't set a default VLAN
2112 * ID, and set the default packet priority to zero.
2113 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002114 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002115}
2116
Andrew Lunn04aca992017-05-26 01:03:24 +02002117static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2118 struct phy_device *phydev)
2119{
2120 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002121 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002122
2123 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002124 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002125 mutex_unlock(&chip->reg_lock);
2126
2127 return err;
2128}
2129
2130static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2131 struct phy_device *phydev)
2132{
2133 struct mv88e6xxx_chip *chip = ds->priv;
2134
2135 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002136 if (mv88e6xxx_serdes_power(chip, port, false))
2137 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002138 mutex_unlock(&chip->reg_lock);
2139}
2140
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002141static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2142 unsigned int ageing_time)
2143{
Vivien Didelot04bed142016-08-31 18:06:13 -04002144 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002145 int err;
2146
2147 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002148 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002149 mutex_unlock(&chip->reg_lock);
2150
2151 return err;
2152}
2153
Vivien Didelot97299342016-07-18 20:45:30 -04002154static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002155{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002156 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04002157 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002158
Vivien Didelot50484ff2016-05-09 13:22:54 -04002159 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002160 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
2161 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04002162 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002163 if (err)
2164 return err;
2165
Vivien Didelot08a01262016-05-09 13:22:50 -04002166 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002167 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002168 if (err)
2169 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002170 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002171 if (err)
2172 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002173 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
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_3, 0x5555);
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_4, 0xaaaa);
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_5, 0xaaaa);
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_6, 0xffff);
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_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002189 if (err)
2190 return err;
2191
2192 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002193 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002194 if (err)
2195 return err;
2196
Andrew Lunnde2273872016-11-21 23:27:01 +01002197 /* Initialize the statistics unit */
2198 err = mv88e6xxx_stats_set_histogram(chip);
2199 if (err)
2200 return err;
2201
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002202 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002203}
2204
Vivien Didelotf81ec902016-05-09 13:22:58 -04002205static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002206{
Vivien Didelot04bed142016-08-31 18:06:13 -04002207 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002208 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002209 int i;
2210
Vivien Didelotfad09c72016-06-21 12:28:20 -04002211 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002212 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002213
Vivien Didelotfad09c72016-06-21 12:28:20 -04002214 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002215
Vivien Didelot97299342016-07-18 20:45:30 -04002216 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002217 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002218 if (dsa_is_unused_port(ds, i))
2219 continue;
2220
Vivien Didelot97299342016-07-18 20:45:30 -04002221 err = mv88e6xxx_setup_port(chip, i);
2222 if (err)
2223 goto unlock;
2224 }
2225
2226 /* Setup Switch Global 1 Registers */
2227 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002228 if (err)
2229 goto unlock;
2230
Vivien Didelot97299342016-07-18 20:45:30 -04002231 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002232 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002233 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002234 if (err)
2235 goto unlock;
2236 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002237
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002238 err = mv88e6xxx_irl_setup(chip);
2239 if (err)
2240 goto unlock;
2241
Vivien Didelot04a69a12017-10-13 14:18:05 -04002242 err = mv88e6xxx_mac_setup(chip);
2243 if (err)
2244 goto unlock;
2245
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002246 err = mv88e6xxx_phy_setup(chip);
2247 if (err)
2248 goto unlock;
2249
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002250 err = mv88e6xxx_vtu_setup(chip);
2251 if (err)
2252 goto unlock;
2253
Vivien Didelot81228992017-03-30 17:37:08 -04002254 err = mv88e6xxx_pvt_setup(chip);
2255 if (err)
2256 goto unlock;
2257
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002258 err = mv88e6xxx_atu_setup(chip);
2259 if (err)
2260 goto unlock;
2261
Andrew Lunn87fa8862017-11-09 22:29:56 +01002262 err = mv88e6xxx_broadcast_setup(chip, 0);
2263 if (err)
2264 goto unlock;
2265
Vivien Didelot9e907d72017-07-17 13:03:43 -04002266 err = mv88e6xxx_pot_setup(chip);
2267 if (err)
2268 goto unlock;
2269
Vivien Didelot51c901a2017-07-17 13:03:41 -04002270 err = mv88e6xxx_rsvd2cpu_setup(chip);
2271 if (err)
2272 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002273
Vivien Didelotb28f8722018-04-26 21:56:44 -04002274 err = mv88e6xxx_trunk_setup(chip);
2275 if (err)
2276 goto unlock;
2277
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002278 err = mv88e6xxx_devmap_setup(chip);
2279 if (err)
2280 goto unlock;
2281
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002282 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002283 if (chip->info->ptp_support) {
2284 err = mv88e6xxx_ptp_setup(chip);
2285 if (err)
2286 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002287
2288 err = mv88e6xxx_hwtstamp_setup(chip);
2289 if (err)
2290 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002291 }
2292
Vivien Didelot6b17e862015-08-13 12:52:18 -04002293unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002294 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002295
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002296 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002297}
2298
Vivien Didelote57e5e72016-08-15 17:19:00 -04002299static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002300{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002301 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2302 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002303 u16 val;
2304 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002305
Andrew Lunnee26a222017-01-24 14:53:48 +01002306 if (!chip->info->ops->phy_read)
2307 return -EOPNOTSUPP;
2308
Vivien Didelotfad09c72016-06-21 12:28:20 -04002309 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002310 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002311 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002312
Andrew Lunnda9f3302017-02-01 03:40:05 +01002313 if (reg == MII_PHYSID2) {
2314 /* Some internal PHYS don't have a model number. Use
2315 * the mv88e6390 family model number instead.
2316 */
2317 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002318 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002319 }
2320
Vivien Didelote57e5e72016-08-15 17:19:00 -04002321 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002322}
2323
Vivien Didelote57e5e72016-08-15 17:19:00 -04002324static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002325{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002326 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2327 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002328 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002329
Andrew Lunnee26a222017-01-24 14:53:48 +01002330 if (!chip->info->ops->phy_write)
2331 return -EOPNOTSUPP;
2332
Vivien Didelotfad09c72016-06-21 12:28:20 -04002333 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002334 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002335 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002336
2337 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002338}
2339
Vivien Didelotfad09c72016-06-21 12:28:20 -04002340static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002341 struct device_node *np,
2342 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002343{
2344 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002345 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002346 struct mii_bus *bus;
2347 int err;
2348
Andrew Lunn2510bab2018-02-22 01:51:49 +01002349 if (external) {
2350 mutex_lock(&chip->reg_lock);
2351 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2352 mutex_unlock(&chip->reg_lock);
2353
2354 if (err)
2355 return err;
2356 }
2357
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002358 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002359 if (!bus)
2360 return -ENOMEM;
2361
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002362 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002363 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002364 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002365 INIT_LIST_HEAD(&mdio_bus->list);
2366 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002367
Andrew Lunnb516d452016-06-04 21:17:06 +02002368 if (np) {
2369 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002370 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002371 } else {
2372 bus->name = "mv88e6xxx SMI";
2373 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2374 }
2375
2376 bus->read = mv88e6xxx_mdio_read;
2377 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002378 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002379
Andrew Lunn6f882842018-03-17 20:32:05 +01002380 if (!external) {
2381 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2382 if (err)
2383 return err;
2384 }
2385
Andrew Lunna3c53be52017-01-24 14:53:50 +01002386 if (np)
2387 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002388 else
2389 err = mdiobus_register(bus);
2390 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002391 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002392 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002393 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002394 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002395
2396 if (external)
2397 list_add_tail(&mdio_bus->list, &chip->mdios);
2398 else
2399 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002400
2401 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002402}
2403
Andrew Lunna3c53be52017-01-24 14:53:50 +01002404static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2405 { .compatible = "marvell,mv88e6xxx-mdio-external",
2406 .data = (void *)true },
2407 { },
2408};
2409
Andrew Lunn3126aee2017-12-07 01:05:57 +01002410static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2411
2412{
2413 struct mv88e6xxx_mdio_bus *mdio_bus;
2414 struct mii_bus *bus;
2415
2416 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2417 bus = mdio_bus->bus;
2418
Andrew Lunn6f882842018-03-17 20:32:05 +01002419 if (!mdio_bus->external)
2420 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2421
Andrew Lunn3126aee2017-12-07 01:05:57 +01002422 mdiobus_unregister(bus);
2423 }
2424}
2425
Andrew Lunna3c53be52017-01-24 14:53:50 +01002426static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2427 struct device_node *np)
2428{
2429 const struct of_device_id *match;
2430 struct device_node *child;
2431 int err;
2432
2433 /* Always register one mdio bus for the internal/default mdio
2434 * bus. This maybe represented in the device tree, but is
2435 * optional.
2436 */
2437 child = of_get_child_by_name(np, "mdio");
2438 err = mv88e6xxx_mdio_register(chip, child, false);
2439 if (err)
2440 return err;
2441
2442 /* Walk the device tree, and see if there are any other nodes
2443 * which say they are compatible with the external mdio
2444 * bus.
2445 */
2446 for_each_available_child_of_node(np, child) {
2447 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2448 if (match) {
2449 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002450 if (err) {
2451 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002452 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002453 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002454 }
2455 }
2456
2457 return 0;
2458}
2459
Vivien Didelot855b1932016-07-20 18:18:35 -04002460static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2461{
Vivien Didelot04bed142016-08-31 18:06:13 -04002462 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002463
2464 return chip->eeprom_len;
2465}
2466
Vivien Didelot855b1932016-07-20 18:18:35 -04002467static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2468 struct ethtool_eeprom *eeprom, u8 *data)
2469{
Vivien Didelot04bed142016-08-31 18:06:13 -04002470 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002471 int err;
2472
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002473 if (!chip->info->ops->get_eeprom)
2474 return -EOPNOTSUPP;
2475
Vivien Didelot855b1932016-07-20 18:18:35 -04002476 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002477 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002478 mutex_unlock(&chip->reg_lock);
2479
2480 if (err)
2481 return err;
2482
2483 eeprom->magic = 0xc3ec4951;
2484
2485 return 0;
2486}
2487
Vivien Didelot855b1932016-07-20 18:18:35 -04002488static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2489 struct ethtool_eeprom *eeprom, u8 *data)
2490{
Vivien Didelot04bed142016-08-31 18:06:13 -04002491 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002492 int err;
2493
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002494 if (!chip->info->ops->set_eeprom)
2495 return -EOPNOTSUPP;
2496
Vivien Didelot855b1932016-07-20 18:18:35 -04002497 if (eeprom->magic != 0xc3ec4951)
2498 return -EINVAL;
2499
2500 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002501 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002502 mutex_unlock(&chip->reg_lock);
2503
2504 return err;
2505}
2506
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002507static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002508 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002509 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002510 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002511 .phy_read = mv88e6185_phy_ppu_read,
2512 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002513 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002514 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002515 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002516 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002517 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002518 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002519 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002520 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002521 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002522 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002523 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002524 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002525 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002526 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2527 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002528 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002529 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2530 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002531 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002532 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002533 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002534 .ppu_enable = mv88e6185_g1_ppu_enable,
2535 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002536 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002537 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002538 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
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,
2652 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002653 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002654 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002655 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002656};
2657
Vivien Didelot990e27b2017-03-28 13:50:32 -04002658static const struct mv88e6xxx_ops mv88e6141_ops = {
2659 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002660 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002661 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2662 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2663 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2664 .phy_read = mv88e6xxx_g2_smi_phy_read,
2665 .phy_write = mv88e6xxx_g2_smi_phy_write,
2666 .port_set_link = mv88e6xxx_port_set_link,
2667 .port_set_duplex = mv88e6xxx_port_set_duplex,
2668 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2669 .port_set_speed = mv88e6390_port_set_speed,
2670 .port_tag_remap = mv88e6095_port_tag_remap,
2671 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2672 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2673 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002674 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002675 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002676 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002677 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2678 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2679 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002680 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002681 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2682 .stats_get_strings = mv88e6320_stats_get_strings,
2683 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002684 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2685 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002686 .watchdog_ops = &mv88e6390_watchdog_ops,
2687 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002688 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002689 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002690 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002691 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002692 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002693};
2694
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002695static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002696 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002697 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002698 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002699 .phy_read = mv88e6xxx_g2_smi_phy_read,
2700 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002701 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002702 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002703 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002704 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002705 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002706 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002707 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002708 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002709 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002710 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002711 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002712 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002713 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002714 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002715 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2716 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002717 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002718 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2719 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002720 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002721 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002722 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002723 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002724 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002725 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002726};
2727
2728static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002729 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002730 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002731 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002732 .phy_read = mv88e6165_phy_read,
2733 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002734 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002735 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002736 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002737 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002738 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002739 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002740 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002741 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2742 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002743 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002744 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2745 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002746 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002747 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002748 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002749 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002750 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002751 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002752};
2753
2754static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002755 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002756 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002757 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002758 .phy_read = mv88e6xxx_g2_smi_phy_read,
2759 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002760 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002761 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002762 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002763 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002764 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002765 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002766 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002767 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002768 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002769 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002770 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002771 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002772 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002773 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002774 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002775 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2776 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002777 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002778 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2779 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002780 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002781 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002782 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002783 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002784 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002785 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002786};
2787
2788static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002789 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002790 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002791 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2792 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002793 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002794 .phy_read = mv88e6xxx_g2_smi_phy_read,
2795 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002796 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002797 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002798 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002799 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002800 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002801 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002802 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002803 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002804 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002805 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002806 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002807 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002808 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002809 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002810 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002811 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2812 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002813 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002814 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2815 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002816 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002817 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002818 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002819 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002820 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002821 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002822 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002823 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002824};
2825
2826static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002827 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002828 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002829 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002830 .phy_read = mv88e6xxx_g2_smi_phy_read,
2831 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002832 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002833 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002834 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002835 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002836 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002837 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002838 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002839 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002840 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002841 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002842 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002843 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002844 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002845 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002846 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002847 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2848 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002849 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002850 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2851 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002852 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002853 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002854 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002855 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002856 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002857 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002858};
2859
2860static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002861 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002862 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002863 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2864 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002865 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002866 .phy_read = mv88e6xxx_g2_smi_phy_read,
2867 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002868 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002869 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002870 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002871 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002872 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002873 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002874 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002875 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002876 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002877 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002878 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002879 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002880 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002881 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002882 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002883 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2884 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002885 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002886 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2887 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002888 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002889 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002890 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002891 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002892 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002893 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002894 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002895 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002896};
2897
2898static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002899 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002900 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002901 .phy_read = mv88e6185_phy_ppu_read,
2902 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002903 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002904 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002905 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002906 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002907 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002908 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002909 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002910 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002911 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002912 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2913 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002914 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002915 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2916 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002917 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002918 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002919 .ppu_enable = mv88e6185_g1_ppu_enable,
2920 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002921 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002922 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002923 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002924};
2925
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002926static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002927 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002928 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002929 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2930 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002931 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2932 .phy_read = mv88e6xxx_g2_smi_phy_read,
2933 .phy_write = mv88e6xxx_g2_smi_phy_write,
2934 .port_set_link = mv88e6xxx_port_set_link,
2935 .port_set_duplex = mv88e6xxx_port_set_duplex,
2936 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2937 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002938 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002939 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002940 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002941 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002942 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002943 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002944 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002945 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002946 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002947 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2948 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002949 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002950 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2951 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002952 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002953 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002954 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002955 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002956 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2957 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002958 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002959 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002960};
2961
2962static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002963 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002964 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002965 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2966 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002967 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2968 .phy_read = mv88e6xxx_g2_smi_phy_read,
2969 .phy_write = mv88e6xxx_g2_smi_phy_write,
2970 .port_set_link = mv88e6xxx_port_set_link,
2971 .port_set_duplex = mv88e6xxx_port_set_duplex,
2972 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2973 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002974 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002975 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002976 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002977 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002978 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002979 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002980 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002981 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002982 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002983 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2984 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002985 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002986 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2987 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002988 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002989 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002990 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002991 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002992 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2993 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002994 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002995 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002996};
2997
2998static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002999 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003000 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003001 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3002 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003003 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3004 .phy_read = mv88e6xxx_g2_smi_phy_read,
3005 .phy_write = mv88e6xxx_g2_smi_phy_write,
3006 .port_set_link = mv88e6xxx_port_set_link,
3007 .port_set_duplex = mv88e6xxx_port_set_duplex,
3008 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3009 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003010 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003011 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003012 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003013 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003014 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003015 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003016 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003017 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003018 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003019 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3020 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003021 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003022 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3023 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003024 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003025 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003026 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003027 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003028 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3029 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003030 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003031};
3032
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003033static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003034 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003035 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003036 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3037 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003038 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003039 .phy_read = mv88e6xxx_g2_smi_phy_read,
3040 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003041 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003042 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003043 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003044 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003045 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003046 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003047 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003048 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003049 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003050 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003051 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003052 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003053 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003054 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003055 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003056 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3057 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003058 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003059 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3060 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003061 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003062 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003063 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003064 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003065 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003066 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003067 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003068 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003069 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003070};
3071
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003072static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003073 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003074 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003075 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3076 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003077 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3078 .phy_read = mv88e6xxx_g2_smi_phy_read,
3079 .phy_write = mv88e6xxx_g2_smi_phy_write,
3080 .port_set_link = mv88e6xxx_port_set_link,
3081 .port_set_duplex = mv88e6xxx_port_set_duplex,
3082 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3083 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003084 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003085 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003086 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003087 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003088 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003089 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003090 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003091 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003092 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003093 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003094 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3095 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003096 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003097 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3098 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003099 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003100 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003101 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003102 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003103 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3104 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003105 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003106 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003107 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003108};
3109
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003110static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003111 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003112 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003113 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3114 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003115 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003116 .phy_read = mv88e6xxx_g2_smi_phy_read,
3117 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003118 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003119 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003120 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003121 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003122 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003123 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003124 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003125 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003126 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003127 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003128 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003129 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003130 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003131 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003132 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3133 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003134 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003135 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3136 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003137 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003138 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003139 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003140 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003141 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003142 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003143 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003144};
3145
3146static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003147 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003148 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003149 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3150 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003151 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003152 .phy_read = mv88e6xxx_g2_smi_phy_read,
3153 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003154 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003155 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003156 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003157 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003158 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003159 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003160 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003161 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003162 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003163 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003164 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003165 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003166 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003167 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003168 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3169 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003170 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003171 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3172 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003173 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003174 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003175 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003176 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003177 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003178};
3179
Vivien Didelot16e329a2017-03-28 13:50:33 -04003180static const struct mv88e6xxx_ops mv88e6341_ops = {
3181 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003182 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003183 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3184 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3185 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3186 .phy_read = mv88e6xxx_g2_smi_phy_read,
3187 .phy_write = mv88e6xxx_g2_smi_phy_write,
3188 .port_set_link = mv88e6xxx_port_set_link,
3189 .port_set_duplex = mv88e6xxx_port_set_duplex,
3190 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3191 .port_set_speed = mv88e6390_port_set_speed,
3192 .port_tag_remap = mv88e6095_port_tag_remap,
3193 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3194 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3195 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003196 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003197 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003198 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003199 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3200 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3201 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003202 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003203 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3204 .stats_get_strings = mv88e6320_stats_get_strings,
3205 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003206 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3207 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003208 .watchdog_ops = &mv88e6390_watchdog_ops,
3209 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003210 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003211 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003212 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003213 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003214 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003215 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003216};
3217
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003218static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003219 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003220 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003222 .phy_read = mv88e6xxx_g2_smi_phy_read,
3223 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003224 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003225 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003226 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003227 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003228 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003230 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003231 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003232 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003233 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003234 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003235 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003236 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003237 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003238 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003239 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3240 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003241 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003242 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3243 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003244 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003245 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003246 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003247 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003248 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003249 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003250};
3251
3252static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003253 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003254 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003255 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003256 .phy_read = mv88e6xxx_g2_smi_phy_read,
3257 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003258 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003259 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003260 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003261 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003262 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003263 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003264 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003265 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003266 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003267 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003268 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003269 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003270 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003271 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003272 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003273 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3274 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003275 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003276 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3277 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003278 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003279 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003280 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003281 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003282 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003283 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003284 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003285};
3286
3287static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003288 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003289 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003290 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3291 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003292 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003293 .phy_read = mv88e6xxx_g2_smi_phy_read,
3294 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003295 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003296 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003297 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003298 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003299 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003300 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003301 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003302 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003303 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003304 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003305 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003306 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003307 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003308 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003309 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003310 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3311 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003312 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003313 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3314 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003315 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003316 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003317 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003318 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003319 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003320 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003321 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003322 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003323 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003324 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3325 .serdes_get_strings = mv88e6352_serdes_get_strings,
3326 .serdes_get_stats = mv88e6352_serdes_get_stats,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003327};
3328
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003329static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003330 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003331 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003332 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3333 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003334 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3335 .phy_read = mv88e6xxx_g2_smi_phy_read,
3336 .phy_write = mv88e6xxx_g2_smi_phy_write,
3337 .port_set_link = mv88e6xxx_port_set_link,
3338 .port_set_duplex = mv88e6xxx_port_set_duplex,
3339 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3340 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003341 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003342 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003343 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003344 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003345 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003346 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003347 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003348 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003349 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003350 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003351 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003352 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003353 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3354 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003355 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003356 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3357 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003358 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003359 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003360 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003361 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003362 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3363 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003364 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003365 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003366 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003367};
3368
3369static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003370 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003371 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003372 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3373 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003374 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3375 .phy_read = mv88e6xxx_g2_smi_phy_read,
3376 .phy_write = mv88e6xxx_g2_smi_phy_write,
3377 .port_set_link = mv88e6xxx_port_set_link,
3378 .port_set_duplex = mv88e6xxx_port_set_duplex,
3379 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3380 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003381 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003382 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003383 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003384 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003385 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003386 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003387 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003388 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003389 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003390 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003391 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003392 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003393 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3394 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003395 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003396 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3397 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003398 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003399 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003400 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003401 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003402 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3403 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003404 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003405 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003406 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003407};
3408
Vivien Didelotf81ec902016-05-09 13:22:58 -04003409static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3410 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003411 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003412 .family = MV88E6XXX_FAMILY_6097,
3413 .name = "Marvell 88E6085",
3414 .num_databases = 4096,
3415 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003416 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003417 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003418 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003419 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003420 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003421 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003422 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003423 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003424 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003425 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003426 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003427 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003428 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003429 },
3430
3431 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003432 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003433 .family = MV88E6XXX_FAMILY_6095,
3434 .name = "Marvell 88E6095/88E6095F",
3435 .num_databases = 256,
3436 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003437 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003438 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003439 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003440 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003441 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003442 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003443 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003444 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003445 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003446 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003447 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003448 },
3449
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003450 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003451 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003452 .family = MV88E6XXX_FAMILY_6097,
3453 .name = "Marvell 88E6097/88E6097F",
3454 .num_databases = 4096,
3455 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003456 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003457 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003458 .port_base_addr = 0x10,
3459 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003460 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003461 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003462 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003463 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003464 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003465 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003466 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003467 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003468 .ops = &mv88e6097_ops,
3469 },
3470
Vivien Didelotf81ec902016-05-09 13:22:58 -04003471 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003472 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003473 .family = MV88E6XXX_FAMILY_6165,
3474 .name = "Marvell 88E6123",
3475 .num_databases = 4096,
3476 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003477 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003478 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003479 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003480 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003481 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003482 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003483 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003484 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003485 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003486 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003487 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003488 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003489 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003490 },
3491
3492 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003493 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003494 .family = MV88E6XXX_FAMILY_6185,
3495 .name = "Marvell 88E6131",
3496 .num_databases = 256,
3497 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003498 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003499 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003500 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003501 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003502 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003503 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003504 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003505 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003506 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003507 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003508 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003509 },
3510
Vivien Didelot990e27b2017-03-28 13:50:32 -04003511 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003512 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003513 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003514 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003515 .num_databases = 4096,
3516 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003517 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003518 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003519 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003520 .port_base_addr = 0x10,
3521 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003522 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003523 .age_time_coeff = 3750,
3524 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003525 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003526 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003527 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003528 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003529 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003530 .ops = &mv88e6141_ops,
3531 },
3532
Vivien Didelotf81ec902016-05-09 13:22:58 -04003533 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003534 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003535 .family = MV88E6XXX_FAMILY_6165,
3536 .name = "Marvell 88E6161",
3537 .num_databases = 4096,
3538 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003539 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003540 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003541 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003542 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003543 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003544 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003545 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003546 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003547 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003548 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003549 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003550 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003551 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003552 },
3553
3554 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003555 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003556 .family = MV88E6XXX_FAMILY_6165,
3557 .name = "Marvell 88E6165",
3558 .num_databases = 4096,
3559 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003560 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003561 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003562 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003563 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003564 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003565 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003566 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003567 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003568 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003569 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003570 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003571 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003572 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003573 },
3574
3575 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003576 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003577 .family = MV88E6XXX_FAMILY_6351,
3578 .name = "Marvell 88E6171",
3579 .num_databases = 4096,
3580 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003581 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003582 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003583 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003584 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003585 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003586 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003587 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003588 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003589 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003590 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003591 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003592 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003593 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003594 },
3595
3596 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003597 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003598 .family = MV88E6XXX_FAMILY_6352,
3599 .name = "Marvell 88E6172",
3600 .num_databases = 4096,
3601 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003602 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003603 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003604 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003605 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003606 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003607 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003608 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003609 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003610 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003611 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003612 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003613 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003614 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003615 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003616 },
3617
3618 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003619 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003620 .family = MV88E6XXX_FAMILY_6351,
3621 .name = "Marvell 88E6175",
3622 .num_databases = 4096,
3623 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003624 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003625 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003626 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003627 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003628 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003629 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003630 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003631 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003632 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003633 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003634 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003635 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003636 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003637 },
3638
3639 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003640 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 .family = MV88E6XXX_FAMILY_6352,
3642 .name = "Marvell 88E6176",
3643 .num_databases = 4096,
3644 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003645 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003646 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003647 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003648 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003649 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003650 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003651 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003652 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003653 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003654 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003655 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003656 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003657 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003658 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003659 },
3660
3661 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003662 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003663 .family = MV88E6XXX_FAMILY_6185,
3664 .name = "Marvell 88E6185",
3665 .num_databases = 256,
3666 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003667 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003668 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003669 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003670 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003671 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003672 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003673 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003674 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003675 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003676 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003677 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003678 },
3679
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003680 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003681 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003682 .family = MV88E6XXX_FAMILY_6390,
3683 .name = "Marvell 88E6190",
3684 .num_databases = 4096,
3685 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003686 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003687 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003688 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003689 .port_base_addr = 0x0,
3690 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003691 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003692 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003693 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003694 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003695 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003696 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003697 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003698 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003699 .ops = &mv88e6190_ops,
3700 },
3701
3702 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003703 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003704 .family = MV88E6XXX_FAMILY_6390,
3705 .name = "Marvell 88E6190X",
3706 .num_databases = 4096,
3707 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003708 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003709 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003710 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003711 .port_base_addr = 0x0,
3712 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003713 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003714 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003715 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003716 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003717 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003718 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003719 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003720 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003721 .ops = &mv88e6190x_ops,
3722 },
3723
3724 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003725 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003726 .family = MV88E6XXX_FAMILY_6390,
3727 .name = "Marvell 88E6191",
3728 .num_databases = 4096,
3729 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003730 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04003731 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003732 .port_base_addr = 0x0,
3733 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003734 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003735 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003736 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003737 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003738 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003739 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003740 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003741 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003742 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003743 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003744 },
3745
Vivien Didelotf81ec902016-05-09 13:22:58 -04003746 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003747 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003748 .family = MV88E6XXX_FAMILY_6352,
3749 .name = "Marvell 88E6240",
3750 .num_databases = 4096,
3751 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003752 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003753 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003754 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003755 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003756 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003757 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003758 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003759 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003760 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003761 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003762 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003763 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003764 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003765 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003766 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003767 },
3768
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003769 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003770 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003771 .family = MV88E6XXX_FAMILY_6390,
3772 .name = "Marvell 88E6290",
3773 .num_databases = 4096,
3774 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003775 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003776 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003777 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003778 .port_base_addr = 0x0,
3779 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003780 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003781 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003782 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003783 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003784 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003785 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003786 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003787 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003788 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003789 .ops = &mv88e6290_ops,
3790 },
3791
Vivien Didelotf81ec902016-05-09 13:22:58 -04003792 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003793 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003794 .family = MV88E6XXX_FAMILY_6320,
3795 .name = "Marvell 88E6320",
3796 .num_databases = 4096,
3797 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003798 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003799 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003800 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003801 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003802 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003803 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003804 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003805 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003806 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003807 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003808 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003809 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003810 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003811 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003812 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003813 },
3814
3815 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003816 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003817 .family = MV88E6XXX_FAMILY_6320,
3818 .name = "Marvell 88E6321",
3819 .num_databases = 4096,
3820 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003821 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003822 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003823 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003824 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003825 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003826 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003827 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003828 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003829 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003830 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003831 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003832 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003833 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003834 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003835 },
3836
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003837 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003838 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003839 .family = MV88E6XXX_FAMILY_6341,
3840 .name = "Marvell 88E6341",
3841 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01003842 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003843 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003844 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003845 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003846 .port_base_addr = 0x10,
3847 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003848 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003849 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003850 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003851 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003852 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003853 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003854 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003855 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003856 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003857 .ops = &mv88e6341_ops,
3858 },
3859
Vivien Didelotf81ec902016-05-09 13:22:58 -04003860 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003861 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003862 .family = MV88E6XXX_FAMILY_6351,
3863 .name = "Marvell 88E6350",
3864 .num_databases = 4096,
3865 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003866 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003867 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003868 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003869 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003870 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003871 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003872 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003873 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003874 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003875 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003876 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003877 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003878 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003879 },
3880
3881 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003882 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003883 .family = MV88E6XXX_FAMILY_6351,
3884 .name = "Marvell 88E6351",
3885 .num_databases = 4096,
3886 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003887 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003888 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003889 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003890 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003891 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003892 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003893 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003894 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003895 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003896 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003897 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003898 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003899 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003900 },
3901
3902 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003903 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003904 .family = MV88E6XXX_FAMILY_6352,
3905 .name = "Marvell 88E6352",
3906 .num_databases = 4096,
3907 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003908 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003909 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003910 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003911 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003912 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003913 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003914 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003915 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003916 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003917 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003918 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003919 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003920 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003921 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003922 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003923 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003924 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003925 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003926 .family = MV88E6XXX_FAMILY_6390,
3927 .name = "Marvell 88E6390",
3928 .num_databases = 4096,
3929 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003930 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003931 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003932 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003933 .port_base_addr = 0x0,
3934 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003935 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003936 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003937 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003938 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003939 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003940 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003941 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003942 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003943 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003944 .ops = &mv88e6390_ops,
3945 },
3946 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003947 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003948 .family = MV88E6XXX_FAMILY_6390,
3949 .name = "Marvell 88E6390X",
3950 .num_databases = 4096,
3951 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003952 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003953 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003954 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003955 .port_base_addr = 0x0,
3956 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003957 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003958 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003959 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003960 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003961 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003962 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003963 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003964 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003965 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003966 .ops = &mv88e6390x_ops,
3967 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003968};
3969
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003970static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003971{
Vivien Didelota439c062016-04-17 13:23:58 -04003972 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003973
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003974 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3975 if (mv88e6xxx_table[i].prod_num == prod_num)
3976 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003977
Vivien Didelotb9b37712015-10-30 19:39:48 -04003978 return NULL;
3979}
3980
Vivien Didelotfad09c72016-06-21 12:28:20 -04003981static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003982{
3983 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003984 unsigned int prod_num, rev;
3985 u16 id;
3986 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003987
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003988 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003989 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003990 mutex_unlock(&chip->reg_lock);
3991 if (err)
3992 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003993
Vivien Didelot107fcc12017-06-12 12:37:36 -04003994 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3995 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003996
3997 info = mv88e6xxx_lookup_info(prod_num);
3998 if (!info)
3999 return -ENODEV;
4000
Vivien Didelotcaac8542016-06-20 13:14:09 -04004001 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004002 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004003
Vivien Didelotca070c12016-09-02 14:45:34 -04004004 err = mv88e6xxx_g2_require(chip);
4005 if (err)
4006 return err;
4007
Vivien Didelotfad09c72016-06-21 12:28:20 -04004008 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4009 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004010
4011 return 0;
4012}
4013
Vivien Didelotfad09c72016-06-21 12:28:20 -04004014static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004015{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004016 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004017
Vivien Didelotfad09c72016-06-21 12:28:20 -04004018 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4019 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004020 return NULL;
4021
Vivien Didelotfad09c72016-06-21 12:28:20 -04004022 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004023
Vivien Didelotfad09c72016-06-21 12:28:20 -04004024 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004025 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004026
Vivien Didelotfad09c72016-06-21 12:28:20 -04004027 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004028}
4029
Vivien Didelotfad09c72016-06-21 12:28:20 -04004030static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004031 struct mii_bus *bus, int sw_addr)
4032{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004033 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004034 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004035 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004036 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004037 else
4038 return -EINVAL;
4039
Vivien Didelotfad09c72016-06-21 12:28:20 -04004040 chip->bus = bus;
4041 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004042
4043 return 0;
4044}
4045
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004046static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4047 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004048{
Vivien Didelot04bed142016-08-31 18:06:13 -04004049 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004050
Andrew Lunn443d5a12016-12-03 04:35:18 +01004051 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004052}
4053
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004054#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004055static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4056 struct device *host_dev, int sw_addr,
4057 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004058{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004059 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004060 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004061 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004062
Vivien Didelota439c062016-04-17 13:23:58 -04004063 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004064 if (!bus)
4065 return NULL;
4066
Vivien Didelotfad09c72016-06-21 12:28:20 -04004067 chip = mv88e6xxx_alloc_chip(dsa_dev);
4068 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004069 return NULL;
4070
Vivien Didelotcaac8542016-06-20 13:14:09 -04004071 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004072 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004073
Vivien Didelotfad09c72016-06-21 12:28:20 -04004074 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004075 if (err)
4076 goto free;
4077
Vivien Didelotfad09c72016-06-21 12:28:20 -04004078 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004079 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004080 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004081
Andrew Lunndc30c352016-10-16 19:56:49 +02004082 mutex_lock(&chip->reg_lock);
4083 err = mv88e6xxx_switch_reset(chip);
4084 mutex_unlock(&chip->reg_lock);
4085 if (err)
4086 goto free;
4087
Vivien Didelote57e5e72016-08-15 17:19:00 -04004088 mv88e6xxx_phy_init(chip);
4089
Andrew Lunna3c53be52017-01-24 14:53:50 +01004090 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004091 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004092 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004093
Vivien Didelotfad09c72016-06-21 12:28:20 -04004094 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004095
Vivien Didelotfad09c72016-06-21 12:28:20 -04004096 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004097free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004098 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004099
4100 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004101}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004102#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004103
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004104static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004105 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004106{
4107 /* We don't need any dynamic resource from the kernel (yet),
4108 * so skip the prepare phase.
4109 */
4110
4111 return 0;
4112}
4113
4114static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004115 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004116{
Vivien Didelot04bed142016-08-31 18:06:13 -04004117 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004118
4119 mutex_lock(&chip->reg_lock);
4120 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004121 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004122 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4123 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004124 mutex_unlock(&chip->reg_lock);
4125}
4126
4127static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4128 const struct switchdev_obj_port_mdb *mdb)
4129{
Vivien Didelot04bed142016-08-31 18:06:13 -04004130 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004131 int err;
4132
4133 mutex_lock(&chip->reg_lock);
4134 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004135 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004136 mutex_unlock(&chip->reg_lock);
4137
4138 return err;
4139}
4140
Florian Fainellia82f67a2017-01-08 14:52:08 -08004141static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004142#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004143 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004144#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004145 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004146 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004147 .adjust_link = mv88e6xxx_adjust_link,
4148 .get_strings = mv88e6xxx_get_strings,
4149 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4150 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004151 .port_enable = mv88e6xxx_port_enable,
4152 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004153 .get_mac_eee = mv88e6xxx_get_mac_eee,
4154 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004155 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004156 .get_eeprom = mv88e6xxx_get_eeprom,
4157 .set_eeprom = mv88e6xxx_set_eeprom,
4158 .get_regs_len = mv88e6xxx_get_regs_len,
4159 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004160 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004161 .port_bridge_join = mv88e6xxx_port_bridge_join,
4162 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4163 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004164 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004165 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4166 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4167 .port_vlan_add = mv88e6xxx_port_vlan_add,
4168 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004169 .port_fdb_add = mv88e6xxx_port_fdb_add,
4170 .port_fdb_del = mv88e6xxx_port_fdb_del,
4171 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004172 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4173 .port_mdb_add = mv88e6xxx_port_mdb_add,
4174 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004175 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4176 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004177 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4178 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4179 .port_txtstamp = mv88e6xxx_port_txtstamp,
4180 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4181 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004182};
4183
Florian Fainelliab3d4082017-01-08 14:52:07 -08004184static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4185 .ops = &mv88e6xxx_switch_ops,
4186};
4187
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004188static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004189{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004190 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004191 struct dsa_switch *ds;
4192
Vivien Didelot73b12042017-03-30 17:37:10 -04004193 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004194 if (!ds)
4195 return -ENOMEM;
4196
Vivien Didelotfad09c72016-06-21 12:28:20 -04004197 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004198 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004199 ds->ageing_time_min = chip->info->age_time_coeff;
4200 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004201
4202 dev_set_drvdata(dev, ds);
4203
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004204 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004205}
4206
Vivien Didelotfad09c72016-06-21 12:28:20 -04004207static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004208{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004209 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004210}
4211
Vivien Didelot57d32312016-06-20 13:13:58 -04004212static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004213{
4214 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004215 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004216 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004217 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004218 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004219 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004220
Vivien Didelotcaac8542016-06-20 13:14:09 -04004221 compat_info = of_device_get_match_data(dev);
4222 if (!compat_info)
4223 return -EINVAL;
4224
Vivien Didelotfad09c72016-06-21 12:28:20 -04004225 chip = mv88e6xxx_alloc_chip(dev);
4226 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004227 return -ENOMEM;
4228
Vivien Didelotfad09c72016-06-21 12:28:20 -04004229 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004230
Vivien Didelotfad09c72016-06-21 12:28:20 -04004231 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004232 if (err)
4233 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004234
Andrew Lunnb4308f02016-11-21 23:26:55 +01004235 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4236 if (IS_ERR(chip->reset))
4237 return PTR_ERR(chip->reset);
4238
Vivien Didelotfad09c72016-06-21 12:28:20 -04004239 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004240 if (err)
4241 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004242
Vivien Didelote57e5e72016-08-15 17:19:00 -04004243 mv88e6xxx_phy_init(chip);
4244
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004245 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004246 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004247 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004248
Andrew Lunndc30c352016-10-16 19:56:49 +02004249 mutex_lock(&chip->reg_lock);
4250 err = mv88e6xxx_switch_reset(chip);
4251 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004252 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004253 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004254
Andrew Lunndc30c352016-10-16 19:56:49 +02004255 chip->irq = of_irq_get(np, 0);
4256 if (chip->irq == -EPROBE_DEFER) {
4257 err = chip->irq;
4258 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004259 }
4260
Andrew Lunn294d7112018-02-22 22:58:32 +01004261 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004262 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004263 * controllers
4264 */
4265 mutex_lock(&chip->reg_lock);
4266 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004267 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004268 else
4269 err = mv88e6xxx_irq_poll_setup(chip);
4270 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004271
Andrew Lunn294d7112018-02-22 22:58:32 +01004272 if (err)
4273 goto out;
4274
4275 if (chip->info->g2_irqs > 0) {
4276 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004277 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004278 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004279 }
4280
Andrew Lunn294d7112018-02-22 22:58:32 +01004281 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4282 if (err)
4283 goto out_g2_irq;
4284
4285 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4286 if (err)
4287 goto out_g1_atu_prob_irq;
4288
Andrew Lunna3c53be52017-01-24 14:53:50 +01004289 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004290 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004291 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004292
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004293 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004294 if (err)
4295 goto out_mdio;
4296
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004297 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004298
4299out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004300 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004301out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004302 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004303out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004304 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004305out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004306 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004307 mv88e6xxx_g2_irq_free(chip);
4308out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004309 mutex_lock(&chip->reg_lock);
4310 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004311 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004312 else
4313 mv88e6xxx_irq_poll_free(chip);
4314 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004315out:
4316 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004317}
4318
4319static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4320{
4321 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004322 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004323
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004324 if (chip->info->ptp_support) {
4325 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004326 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004327 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004328
Andrew Lunn930188c2016-08-22 16:01:03 +02004329 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004330 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004331 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004332
Andrew Lunn76f38f12018-03-17 20:21:09 +01004333 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4334 mv88e6xxx_g1_atu_prob_irq_free(chip);
4335
4336 if (chip->info->g2_irqs > 0)
4337 mv88e6xxx_g2_irq_free(chip);
4338
4339 mutex_lock(&chip->reg_lock);
4340 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004341 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004342 else
4343 mv88e6xxx_irq_poll_free(chip);
4344 mutex_unlock(&chip->reg_lock);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004345}
4346
4347static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004348 {
4349 .compatible = "marvell,mv88e6085",
4350 .data = &mv88e6xxx_table[MV88E6085],
4351 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004352 {
4353 .compatible = "marvell,mv88e6190",
4354 .data = &mv88e6xxx_table[MV88E6190],
4355 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004356 { /* sentinel */ },
4357};
4358
4359MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4360
4361static struct mdio_driver mv88e6xxx_driver = {
4362 .probe = mv88e6xxx_probe,
4363 .remove = mv88e6xxx_remove,
4364 .mdiodrv.driver = {
4365 .name = "mv88e6085",
4366 .of_match_table = mv88e6xxx_of_match,
4367 },
4368};
4369
Ben Hutchings98e67302011-11-25 14:36:19 +00004370static int __init mv88e6xxx_init(void)
4371{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004372 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004373 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004374}
4375module_init(mv88e6xxx_init);
4376
4377static void __exit mv88e6xxx_cleanup(void)
4378{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004379 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004380 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004381}
4382module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004383
4384MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4385MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4386MODULE_LICENSE("GPL");