blob: 24486f96dd395d6abd853a1814609df09704fe79 [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{
363 mv88e6xxx_g1_irq_free(chip);
364
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,
428 IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
429 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{
470 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
471 kthread_destroy_worker(chip->kworker);
472}
473
Vivien Didelotec561272016-09-02 14:45:33 -0400474int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400475{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200476 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400477
Andrew Lunn6441e6692016-08-19 00:01:55 +0200478 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400479 u16 val;
480 int err;
481
482 err = mv88e6xxx_read(chip, addr, reg, &val);
483 if (err)
484 return err;
485
486 if (!(val & mask))
487 return 0;
488
489 usleep_range(1000, 2000);
490 }
491
Andrew Lunn30853552016-08-19 00:01:57 +0200492 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400493 return -ETIMEDOUT;
494}
495
Vivien Didelotf22ab642016-07-18 20:45:31 -0400496/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400497int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400498{
499 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200500 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400501
502 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200503 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
504 if (err)
505 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400506
507 /* Set the Update bit to trigger a write operation */
508 val = BIT(15) | update;
509
510 return mv88e6xxx_write(chip, addr, reg, val);
511}
512
Vivien Didelotd78343d2016-11-04 03:23:36 +0100513static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
514 int link, int speed, int duplex,
515 phy_interface_t mode)
516{
517 int err;
518
519 if (!chip->info->ops->port_set_link)
520 return 0;
521
522 /* Port's MAC control must not be changed unless the link is down */
523 err = chip->info->ops->port_set_link(chip, port, 0);
524 if (err)
525 return err;
526
527 if (chip->info->ops->port_set_speed) {
528 err = chip->info->ops->port_set_speed(chip, port, speed);
529 if (err && err != -EOPNOTSUPP)
530 goto restore_link;
531 }
532
533 if (chip->info->ops->port_set_duplex) {
534 err = chip->info->ops->port_set_duplex(chip, port, duplex);
535 if (err && err != -EOPNOTSUPP)
536 goto restore_link;
537 }
538
539 if (chip->info->ops->port_set_rgmii_delay) {
540 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
541 if (err && err != -EOPNOTSUPP)
542 goto restore_link;
543 }
544
Andrew Lunnf39908d2017-02-04 20:02:50 +0100545 if (chip->info->ops->port_set_cmode) {
546 err = chip->info->ops->port_set_cmode(chip, port, mode);
547 if (err && err != -EOPNOTSUPP)
548 goto restore_link;
549 }
550
Vivien Didelotd78343d2016-11-04 03:23:36 +0100551 err = 0;
552restore_link:
553 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400554 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100555
556 return err;
557}
558
Andrew Lunndea87022015-08-31 15:56:47 +0200559/* We expect the switch to perform auto negotiation if there is a real
560 * phy. However, in the case of a fixed link phy, we force the port
561 * settings from the fixed link settings.
562 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400563static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
564 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200565{
Vivien Didelot04bed142016-08-31 18:06:13 -0400566 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200567 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200568
569 if (!phy_is_pseudo_fixed_link(phydev))
570 return;
571
Vivien Didelotfad09c72016-06-21 12:28:20 -0400572 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100573 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
574 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400575 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100576
577 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400578 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200579}
580
Andrew Lunna605a0f2016-11-21 23:26:58 +0100581static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000582{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100583 if (!chip->info->ops->stats_snapshot)
584 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000585
Andrew Lunna605a0f2016-11-21 23:26:58 +0100586 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000587}
588
Andrew Lunne413e7e2015-04-02 04:06:38 +0200589static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100590 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
591 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
592 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
593 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
594 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
595 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
596 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
597 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
598 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
599 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
600 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
601 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
602 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
603 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
604 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
605 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
606 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
607 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
608 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
609 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
610 { "single", 4, 0x14, STATS_TYPE_BANK0, },
611 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
612 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
613 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
614 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
615 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
616 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
617 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
618 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
619 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
620 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
621 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
622 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
623 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
624 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
625 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
626 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
627 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
628 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
629 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
630 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
631 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
632 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
633 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
634 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
635 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
636 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
637 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
638 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
639 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
640 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
641 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
642 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
643 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
644 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
645 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
646 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
647 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
648 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200649};
650
Vivien Didelotfad09c72016-06-21 12:28:20 -0400651static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100652 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100653 int port, u16 bank1_select,
654 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200655{
Andrew Lunn80c46272015-06-20 18:42:30 +0200656 u32 low;
657 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100658 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200659 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200660 u64 value;
661
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100662 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100663 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200664 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
665 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200666 return UINT64_MAX;
667
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200668 low = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200669 if (s->sizeof_stat == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200670 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
671 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200672 return UINT64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200673 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200674 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100675 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100676 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100677 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100678 /* fall through */
679 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100680 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100681 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunn80c46272015-06-20 18:42:30 +0200682 if (s->sizeof_stat == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100683 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500684 break;
685 default:
686 return UINT64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200687 }
688 value = (((u64)high) << 16) | low;
689 return value;
690}
691
Andrew Lunndfafe442016-11-21 23:27:02 +0100692static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
693 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100694{
695 struct mv88e6xxx_hw_stat *stat;
696 int i, j;
697
698 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
699 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100700 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100701 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
702 ETH_GSTRING_LEN);
703 j++;
704 }
705 }
706}
707
Andrew Lunndfafe442016-11-21 23:27:02 +0100708static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
709 uint8_t *data)
710{
711 mv88e6xxx_stats_get_strings(chip, data,
712 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
713}
714
715static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
716 uint8_t *data)
717{
718 mv88e6xxx_stats_get_strings(chip, data,
719 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
720}
721
722static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
723 uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100724{
Vivien Didelot04bed142016-08-31 18:06:13 -0400725 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunndfafe442016-11-21 23:27:02 +0100726
727 if (chip->info->ops->stats_get_strings)
728 chip->info->ops->stats_get_strings(chip, data);
729}
730
731static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
732 int types)
733{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100734 struct mv88e6xxx_hw_stat *stat;
735 int i, j;
736
737 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
738 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100739 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100740 j++;
741 }
742 return j;
743}
744
Andrew Lunndfafe442016-11-21 23:27:02 +0100745static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
746{
747 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
748 STATS_TYPE_PORT);
749}
750
751static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
752{
753 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
754 STATS_TYPE_BANK1);
755}
756
757static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
758{
759 struct mv88e6xxx_chip *chip = ds->priv;
760
761 if (chip->info->ops->stats_get_sset_count)
762 return chip->info->ops->stats_get_sset_count(chip);
763
764 return 0;
765}
766
Andrew Lunn052f9472016-11-21 23:27:03 +0100767static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100768 uint64_t *data, int types,
769 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100770{
771 struct mv88e6xxx_hw_stat *stat;
772 int i, j;
773
774 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
775 stat = &mv88e6xxx_hw_stats[i];
776 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100777 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100778 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
779 bank1_select,
780 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100781 mutex_unlock(&chip->reg_lock);
782
Andrew Lunn052f9472016-11-21 23:27:03 +0100783 j++;
784 }
785 }
786}
787
788static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
789 uint64_t *data)
790{
791 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100792 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400793 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100794}
795
796static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
797 uint64_t *data)
798{
799 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100800 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400801 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
802 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100803}
804
805static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
806 uint64_t *data)
807{
808 return mv88e6xxx_stats_get_stats(chip, port, data,
809 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400810 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
811 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100812}
813
814static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
815 uint64_t *data)
816{
817 if (chip->info->ops->stats_get_stats)
818 chip->info->ops->stats_get_stats(chip, port, data);
819}
820
Vivien Didelotf81ec902016-05-09 13:22:58 -0400821static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
822 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000823{
Vivien Didelot04bed142016-08-31 18:06:13 -0400824 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000825 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000826
Vivien Didelotfad09c72016-06-21 12:28:20 -0400827 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000828
Andrew Lunna605a0f2016-11-21 23:26:58 +0100829 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +0100830 mutex_unlock(&chip->reg_lock);
831
832 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000833 return;
Andrew Lunn052f9472016-11-21 23:27:03 +0100834
835 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000836
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000837}
Ben Hutchings98e67302011-11-25 14:36:19 +0000838
Andrew Lunnde2273872016-11-21 23:27:01 +0100839static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
840{
841 if (chip->info->ops->stats_set_histogram)
842 return chip->info->ops->stats_set_histogram(chip);
843
844 return 0;
845}
846
Vivien Didelotf81ec902016-05-09 13:22:58 -0400847static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700848{
849 return 32 * sizeof(u16);
850}
851
Vivien Didelotf81ec902016-05-09 13:22:58 -0400852static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
853 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700854{
Vivien Didelot04bed142016-08-31 18:06:13 -0400855 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200856 int err;
857 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700858 u16 *p = _p;
859 int i;
860
861 regs->version = 0;
862
863 memset(p, 0xff, 32 * sizeof(u16));
864
Vivien Didelotfad09c72016-06-21 12:28:20 -0400865 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400866
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700867 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700868
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200869 err = mv88e6xxx_port_read(chip, port, i, &reg);
870 if (!err)
871 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700872 }
Vivien Didelot23062512016-05-09 13:22:45 -0400873
Vivien Didelotfad09c72016-06-21 12:28:20 -0400874 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700875}
876
Vivien Didelot08f50062017-08-01 16:32:41 -0400877static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
878 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800879{
Vivien Didelot5480db62017-08-01 16:32:40 -0400880 /* Nothing to do on the port's MAC */
881 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800882}
883
Vivien Didelot08f50062017-08-01 16:32:41 -0400884static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
885 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800886{
Vivien Didelot5480db62017-08-01 16:32:40 -0400887 /* Nothing to do on the port's MAC */
888 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800889}
890
Vivien Didelote5887a22017-03-30 17:37:11 -0400891static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700892{
Vivien Didelote5887a22017-03-30 17:37:11 -0400893 struct dsa_switch *ds = NULL;
894 struct net_device *br;
895 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500896 int i;
897
Vivien Didelote5887a22017-03-30 17:37:11 -0400898 if (dev < DSA_MAX_SWITCHES)
899 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500900
Vivien Didelote5887a22017-03-30 17:37:11 -0400901 /* Prevent frames from unknown switch or port */
902 if (!ds || port >= ds->num_ports)
903 return 0;
904
905 /* Frames from DSA links and CPU ports can egress any local port */
906 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
907 return mv88e6xxx_port_mask(chip);
908
909 br = ds->ports[port].bridge_dev;
910 pvlan = 0;
911
912 /* Frames from user ports can egress any local DSA links and CPU ports,
913 * as well as any local member of their bridge group.
914 */
915 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
916 if (dsa_is_cpu_port(chip->ds, i) ||
917 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400918 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -0400919 pvlan |= BIT(i);
920
921 return pvlan;
922}
923
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400924static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400925{
926 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500927
928 /* prevent frames from going back out of the port they came in on */
929 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700930
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100931 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700932}
933
Vivien Didelotf81ec902016-05-09 13:22:58 -0400934static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
935 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700936{
Vivien Didelot04bed142016-08-31 18:06:13 -0400937 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400938 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700939
Vivien Didelotfad09c72016-06-21 12:28:20 -0400940 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400941 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400942 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400943
944 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400945 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700946}
947
Vivien Didelot9e907d72017-07-17 13:03:43 -0400948static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
949{
950 if (chip->info->ops->pot_clear)
951 return chip->info->ops->pot_clear(chip);
952
953 return 0;
954}
955
Vivien Didelot51c901a2017-07-17 13:03:41 -0400956static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
957{
958 if (chip->info->ops->mgmt_rsvd2cpu)
959 return chip->info->ops->mgmt_rsvd2cpu(chip);
960
961 return 0;
962}
963
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500964static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
965{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500966 int err;
967
Vivien Didelotdaefc942017-03-11 16:12:54 -0500968 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
969 if (err)
970 return err;
971
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500972 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
973 if (err)
974 return err;
975
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500976 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
977}
978
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400979static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
980{
981 int port;
982 int err;
983
984 if (!chip->info->ops->irl_init_all)
985 return 0;
986
987 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
988 /* Disable ingress rate limiting by resetting all per port
989 * ingress rate limit resources to their initial state.
990 */
991 err = chip->info->ops->irl_init_all(chip, port);
992 if (err)
993 return err;
994 }
995
996 return 0;
997}
998
Vivien Didelot04a69a12017-10-13 14:18:05 -0400999static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1000{
1001 if (chip->info->ops->set_switch_mac) {
1002 u8 addr[ETH_ALEN];
1003
1004 eth_random_addr(addr);
1005
1006 return chip->info->ops->set_switch_mac(chip, addr);
1007 }
1008
1009 return 0;
1010}
1011
Vivien Didelot17a15942017-03-30 17:37:09 -04001012static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1013{
1014 u16 pvlan = 0;
1015
1016 if (!mv88e6xxx_has_pvt(chip))
1017 return -EOPNOTSUPP;
1018
1019 /* Skip the local source device, which uses in-chip port VLAN */
1020 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001021 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001022
1023 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1024}
1025
Vivien Didelot81228992017-03-30 17:37:08 -04001026static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1027{
Vivien Didelot17a15942017-03-30 17:37:09 -04001028 int dev, port;
1029 int err;
1030
Vivien Didelot81228992017-03-30 17:37:08 -04001031 if (!mv88e6xxx_has_pvt(chip))
1032 return 0;
1033
1034 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1035 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1036 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001037 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1038 if (err)
1039 return err;
1040
1041 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1042 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1043 err = mv88e6xxx_pvt_map(chip, dev, port);
1044 if (err)
1045 return err;
1046 }
1047 }
1048
1049 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001050}
1051
Vivien Didelot749efcb2016-09-22 16:49:24 -04001052static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1053{
1054 struct mv88e6xxx_chip *chip = ds->priv;
1055 int err;
1056
1057 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001058 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001059 mutex_unlock(&chip->reg_lock);
1060
1061 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001062 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001063}
1064
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001065static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1066{
1067 if (!chip->info->max_vid)
1068 return 0;
1069
1070 return mv88e6xxx_g1_vtu_flush(chip);
1071}
1072
Vivien Didelotf1394b782017-05-01 14:05:22 -04001073static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1074 struct mv88e6xxx_vtu_entry *entry)
1075{
1076 if (!chip->info->ops->vtu_getnext)
1077 return -EOPNOTSUPP;
1078
1079 return chip->info->ops->vtu_getnext(chip, entry);
1080}
1081
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001082static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1083 struct mv88e6xxx_vtu_entry *entry)
1084{
1085 if (!chip->info->ops->vtu_loadpurge)
1086 return -EOPNOTSUPP;
1087
1088 return chip->info->ops->vtu_loadpurge(chip, entry);
1089}
1090
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001091static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001092{
1093 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001094 struct mv88e6xxx_vtu_entry vlan = {
1095 .vid = chip->info->max_vid,
1096 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001097 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001098
1099 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1100
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001101 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001102 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001103 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001104 if (err)
1105 return err;
1106
1107 set_bit(*fid, fid_bitmap);
1108 }
1109
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001110 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001111 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001112 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001113 if (err)
1114 return err;
1115
1116 if (!vlan.valid)
1117 break;
1118
1119 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001120 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001121
1122 /* The reset value 0x000 is used to indicate that multiple address
1123 * databases are not needed. Return the next positive available.
1124 */
1125 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001126 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001127 return -ENOSPC;
1128
1129 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001130 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001131}
1132
Vivien Didelot567aa592017-05-01 14:05:25 -04001133static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1134 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001135{
1136 int err;
1137
1138 if (!vid)
1139 return -EINVAL;
1140
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001141 entry->vid = vid - 1;
1142 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001143
Vivien Didelotf1394b782017-05-01 14:05:22 -04001144 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001145 if (err)
1146 return err;
1147
Vivien Didelot567aa592017-05-01 14:05:25 -04001148 if (entry->vid == vid && entry->valid)
1149 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001150
Vivien Didelot567aa592017-05-01 14:05:25 -04001151 if (new) {
1152 int i;
1153
1154 /* Initialize a fresh VLAN entry */
1155 memset(entry, 0, sizeof(*entry));
1156 entry->valid = true;
1157 entry->vid = vid;
1158
Vivien Didelot553a7682017-06-07 18:12:16 -04001159 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001160 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001161 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001162 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001163
1164 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001165 }
1166
Vivien Didelot567aa592017-05-01 14:05:25 -04001167 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1168 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001169}
1170
Vivien Didelotda9c3592016-02-12 12:09:40 -05001171static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1172 u16 vid_begin, u16 vid_end)
1173{
Vivien Didelot04bed142016-08-31 18:06:13 -04001174 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001175 struct mv88e6xxx_vtu_entry vlan = {
1176 .vid = vid_begin - 1,
1177 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001178 int i, err;
1179
Andrew Lunndb06ae412017-09-25 23:32:20 +02001180 /* DSA and CPU ports have to be members of multiple vlans */
1181 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1182 return 0;
1183
Vivien Didelotda9c3592016-02-12 12:09:40 -05001184 if (!vid_begin)
1185 return -EOPNOTSUPP;
1186
Vivien Didelotfad09c72016-06-21 12:28:20 -04001187 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001188
Vivien Didelotda9c3592016-02-12 12:09:40 -05001189 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001190 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001191 if (err)
1192 goto unlock;
1193
1194 if (!vlan.valid)
1195 break;
1196
1197 if (vlan.vid > vid_end)
1198 break;
1199
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001200 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001201 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1202 continue;
1203
Andrew Lunncd886462017-11-09 22:29:53 +01001204 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001205 continue;
1206
Vivien Didelotbd00e052017-05-01 14:05:11 -04001207 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001208 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001209 continue;
1210
Vivien Didelotc8652c82017-10-16 11:12:19 -04001211 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001212 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001213 break; /* same bridge, check next VLAN */
1214
Vivien Didelotc8652c82017-10-16 11:12:19 -04001215 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001216 continue;
1217
Andrew Lunn743fcc22017-11-09 22:29:54 +01001218 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1219 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001220 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001221 err = -EOPNOTSUPP;
1222 goto unlock;
1223 }
1224 } while (vlan.vid < vid_end);
1225
1226unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001227 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001228
1229 return err;
1230}
1231
Vivien Didelotf81ec902016-05-09 13:22:58 -04001232static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1233 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001234{
Vivien Didelot04bed142016-08-31 18:06:13 -04001235 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001236 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1237 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001238 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001239
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001240 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001241 return -EOPNOTSUPP;
1242
Vivien Didelotfad09c72016-06-21 12:28:20 -04001243 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001244 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001245 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001246
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001247 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001248}
1249
Vivien Didelot57d32312016-06-20 13:13:58 -04001250static int
1251mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001252 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001253{
Vivien Didelot04bed142016-08-31 18:06:13 -04001254 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001255 int err;
1256
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001257 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001258 return -EOPNOTSUPP;
1259
Vivien Didelotda9c3592016-02-12 12:09:40 -05001260 /* If the requested port doesn't belong to the same bridge as the VLAN
1261 * members, do not support it (yet) and fallback to software VLAN.
1262 */
1263 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1264 vlan->vid_end);
1265 if (err)
1266 return err;
1267
Vivien Didelot76e398a2015-11-01 12:33:55 -05001268 /* We don't need any dynamic resource from the kernel (yet),
1269 * so skip the prepare phase.
1270 */
1271 return 0;
1272}
1273
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001274static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1275 const unsigned char *addr, u16 vid,
1276 u8 state)
1277{
1278 struct mv88e6xxx_vtu_entry vlan;
1279 struct mv88e6xxx_atu_entry entry;
1280 int err;
1281
1282 /* Null VLAN ID corresponds to the port private database */
1283 if (vid == 0)
1284 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1285 else
1286 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1287 if (err)
1288 return err;
1289
1290 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1291 ether_addr_copy(entry.mac, addr);
1292 eth_addr_dec(entry.mac);
1293
1294 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1295 if (err)
1296 return err;
1297
1298 /* Initialize a fresh ATU entry if it isn't found */
1299 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1300 !ether_addr_equal(entry.mac, addr)) {
1301 memset(&entry, 0, sizeof(entry));
1302 ether_addr_copy(entry.mac, addr);
1303 }
1304
1305 /* Purge the ATU entry only if no port is using it anymore */
1306 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1307 entry.portvec &= ~BIT(port);
1308 if (!entry.portvec)
1309 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1310 } else {
1311 entry.portvec |= BIT(port);
1312 entry.state = state;
1313 }
1314
1315 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1316}
1317
Andrew Lunn87fa8862017-11-09 22:29:56 +01001318static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1319 u16 vid)
1320{
1321 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1322 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1323
1324 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1325}
1326
1327static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1328{
1329 int port;
1330 int err;
1331
1332 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1333 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1334 if (err)
1335 return err;
1336 }
1337
1338 return 0;
1339}
1340
Vivien Didelotfad09c72016-06-21 12:28:20 -04001341static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001342 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001343{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001344 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001345 int err;
1346
Vivien Didelot567aa592017-05-01 14:05:25 -04001347 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001348 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001349 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001350
Vivien Didelotc91498e2017-06-07 18:12:13 -04001351 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001352
Andrew Lunn87fa8862017-11-09 22:29:56 +01001353 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1354 if (err)
1355 return err;
1356
1357 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001358}
1359
Vivien Didelotf81ec902016-05-09 13:22:58 -04001360static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001361 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001362{
Vivien Didelot04bed142016-08-31 18:06:13 -04001363 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001364 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1365 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001366 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001367 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001368
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001369 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001370 return;
1371
Vivien Didelotc91498e2017-06-07 18:12:13 -04001372 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001373 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001374 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001375 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001376 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001377 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001378
Vivien Didelotfad09c72016-06-21 12:28:20 -04001379 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001380
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001381 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001382 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001383 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1384 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001385
Vivien Didelot77064f32016-11-04 03:23:30 +01001386 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001387 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1388 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001389
Vivien Didelotfad09c72016-06-21 12:28:20 -04001390 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001391}
1392
Vivien Didelotfad09c72016-06-21 12:28:20 -04001393static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001394 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001395{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001396 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001397 int i, err;
1398
Vivien Didelot567aa592017-05-01 14:05:25 -04001399 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001400 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001401 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001402
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001403 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001404 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001405 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001406
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001407 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001408
1409 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001410 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001411 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001412 if (vlan.member[i] !=
1413 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001414 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001415 break;
1416 }
1417 }
1418
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001419 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001420 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001421 return err;
1422
Vivien Didelote606ca32017-03-11 16:12:55 -05001423 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001424}
1425
Vivien Didelotf81ec902016-05-09 13:22:58 -04001426static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1427 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001428{
Vivien Didelot04bed142016-08-31 18:06:13 -04001429 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001430 u16 pvid, vid;
1431 int err = 0;
1432
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001433 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001434 return -EOPNOTSUPP;
1435
Vivien Didelotfad09c72016-06-21 12:28:20 -04001436 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001437
Vivien Didelot77064f32016-11-04 03:23:30 +01001438 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001439 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001440 goto unlock;
1441
Vivien Didelot76e398a2015-11-01 12:33:55 -05001442 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001443 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001444 if (err)
1445 goto unlock;
1446
1447 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001448 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001449 if (err)
1450 goto unlock;
1451 }
1452 }
1453
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001454unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001455 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001456
1457 return err;
1458}
1459
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001460static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1461 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001462{
Vivien Didelot04bed142016-08-31 18:06:13 -04001463 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001464 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001465
Vivien Didelotfad09c72016-06-21 12:28:20 -04001466 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001467 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1468 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001469 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001470
1471 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001472}
1473
Vivien Didelotf81ec902016-05-09 13:22:58 -04001474static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001475 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001476{
Vivien Didelot04bed142016-08-31 18:06:13 -04001477 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001478 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001479
Vivien Didelotfad09c72016-06-21 12:28:20 -04001480 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001481 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001482 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001483 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001484
Vivien Didelot83dabd12016-08-31 11:50:04 -04001485 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001486}
1487
Vivien Didelot83dabd12016-08-31 11:50:04 -04001488static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1489 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001490 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001491{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001492 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001493 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001494 int err;
1495
Vivien Didelot27c0e602017-06-15 12:14:01 -04001496 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001497 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001498
1499 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001500 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001501 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001502 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001503 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001504 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001505
Vivien Didelot27c0e602017-06-15 12:14:01 -04001506 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001507 break;
1508
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001509 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001510 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001511
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001512 if (!is_unicast_ether_addr(addr.mac))
1513 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001514
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001515 is_static = (addr.state ==
1516 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1517 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001518 if (err)
1519 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001520 } while (!is_broadcast_ether_addr(addr.mac));
1521
1522 return err;
1523}
1524
Vivien Didelot83dabd12016-08-31 11:50:04 -04001525static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001526 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001527{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001528 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001529 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001530 };
1531 u16 fid;
1532 int err;
1533
1534 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001535 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001536 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001537 mutex_unlock(&chip->reg_lock);
1538
Vivien Didelot83dabd12016-08-31 11:50:04 -04001539 if (err)
1540 return err;
1541
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001542 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001543 if (err)
1544 return err;
1545
1546 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001547 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001548 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001549 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001550 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001551 if (err)
1552 return err;
1553
1554 if (!vlan.valid)
1555 break;
1556
1557 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001558 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001559 if (err)
1560 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001561 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001562
1563 return err;
1564}
1565
Vivien Didelotf81ec902016-05-09 13:22:58 -04001566static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001567 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001568{
Vivien Didelot04bed142016-08-31 18:06:13 -04001569 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001570
Andrew Lunna61e5402018-02-15 14:38:35 +01001571 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001572}
1573
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001574static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1575 struct net_device *br)
1576{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001577 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001578 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001579 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001580 int err;
1581
1582 /* Remap the Port VLAN of each local bridge group member */
1583 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1584 if (chip->ds->ports[port].bridge_dev == br) {
1585 err = mv88e6xxx_port_vlan_map(chip, port);
1586 if (err)
1587 return err;
1588 }
1589 }
1590
Vivien Didelote96a6e02017-03-30 17:37:13 -04001591 if (!mv88e6xxx_has_pvt(chip))
1592 return 0;
1593
1594 /* Remap the Port VLAN of each cross-chip bridge group member */
1595 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1596 ds = chip->ds->dst->ds[dev];
1597 if (!ds)
1598 break;
1599
1600 for (port = 0; port < ds->num_ports; ++port) {
1601 if (ds->ports[port].bridge_dev == br) {
1602 err = mv88e6xxx_pvt_map(chip, dev, port);
1603 if (err)
1604 return err;
1605 }
1606 }
1607 }
1608
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001609 return 0;
1610}
1611
Vivien Didelotf81ec902016-05-09 13:22:58 -04001612static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001613 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001614{
Vivien Didelot04bed142016-08-31 18:06:13 -04001615 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001616 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001617
Vivien Didelotfad09c72016-06-21 12:28:20 -04001618 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001619 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001620 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001621
Vivien Didelot466dfa02016-02-26 13:16:05 -05001622 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001623}
1624
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001625static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1626 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001627{
Vivien Didelot04bed142016-08-31 18:06:13 -04001628 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001629
Vivien Didelotfad09c72016-06-21 12:28:20 -04001630 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001631 if (mv88e6xxx_bridge_map(chip, br) ||
1632 mv88e6xxx_port_vlan_map(chip, port))
1633 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001634 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001635}
1636
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001637static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1638 int port, struct net_device *br)
1639{
1640 struct mv88e6xxx_chip *chip = ds->priv;
1641 int err;
1642
1643 if (!mv88e6xxx_has_pvt(chip))
1644 return 0;
1645
1646 mutex_lock(&chip->reg_lock);
1647 err = mv88e6xxx_pvt_map(chip, dev, port);
1648 mutex_unlock(&chip->reg_lock);
1649
1650 return err;
1651}
1652
1653static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1654 int port, struct net_device *br)
1655{
1656 struct mv88e6xxx_chip *chip = ds->priv;
1657
1658 if (!mv88e6xxx_has_pvt(chip))
1659 return;
1660
1661 mutex_lock(&chip->reg_lock);
1662 if (mv88e6xxx_pvt_map(chip, dev, port))
1663 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1664 mutex_unlock(&chip->reg_lock);
1665}
1666
Vivien Didelot17e708b2016-12-05 17:30:27 -05001667static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1668{
1669 if (chip->info->ops->reset)
1670 return chip->info->ops->reset(chip);
1671
1672 return 0;
1673}
1674
Vivien Didelot309eca62016-12-05 17:30:26 -05001675static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1676{
1677 struct gpio_desc *gpiod = chip->reset;
1678
1679 /* If there is a GPIO connected to the reset pin, toggle it */
1680 if (gpiod) {
1681 gpiod_set_value_cansleep(gpiod, 1);
1682 usleep_range(10000, 20000);
1683 gpiod_set_value_cansleep(gpiod, 0);
1684 usleep_range(10000, 20000);
1685 }
1686}
1687
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001688static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1689{
1690 int i, err;
1691
1692 /* Set all ports to the Disabled state */
1693 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001694 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001695 if (err)
1696 return err;
1697 }
1698
1699 /* Wait for transmit queues to drain,
1700 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1701 */
1702 usleep_range(2000, 4000);
1703
1704 return 0;
1705}
1706
Vivien Didelotfad09c72016-06-21 12:28:20 -04001707static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001708{
Vivien Didelota935c052016-09-29 12:21:53 -04001709 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001710
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001711 err = mv88e6xxx_disable_ports(chip);
1712 if (err)
1713 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001714
Vivien Didelot309eca62016-12-05 17:30:26 -05001715 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001716
Vivien Didelot17e708b2016-12-05 17:30:27 -05001717 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001718}
1719
Vivien Didelot43145572017-03-11 16:12:59 -05001720static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001721 enum mv88e6xxx_frame_mode frame,
1722 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001723{
1724 int err;
1725
Vivien Didelot43145572017-03-11 16:12:59 -05001726 if (!chip->info->ops->port_set_frame_mode)
1727 return -EOPNOTSUPP;
1728
1729 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001730 if (err)
1731 return err;
1732
Vivien Didelot43145572017-03-11 16:12:59 -05001733 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1734 if (err)
1735 return err;
1736
1737 if (chip->info->ops->port_set_ether_type)
1738 return chip->info->ops->port_set_ether_type(chip, port, etype);
1739
1740 return 0;
1741}
1742
1743static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1744{
1745 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001746 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001747 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001748}
1749
1750static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1751{
1752 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001753 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001754 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001755}
1756
1757static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1758{
1759 return mv88e6xxx_set_port_mode(chip, port,
1760 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001761 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1762 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001763}
1764
1765static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1766{
1767 if (dsa_is_dsa_port(chip->ds, port))
1768 return mv88e6xxx_set_port_mode_dsa(chip, port);
1769
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001770 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001771 return mv88e6xxx_set_port_mode_normal(chip, port);
1772
1773 /* Setup CPU port mode depending on its supported tag format */
1774 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1775 return mv88e6xxx_set_port_mode_dsa(chip, port);
1776
1777 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1778 return mv88e6xxx_set_port_mode_edsa(chip, port);
1779
1780 return -EINVAL;
1781}
1782
Vivien Didelotea698f42017-03-11 16:12:50 -05001783static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1784{
1785 bool message = dsa_is_dsa_port(chip->ds, port);
1786
1787 return mv88e6xxx_port_set_message_port(chip, port, message);
1788}
1789
Vivien Didelot601aeed2017-03-11 16:13:00 -05001790static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1791{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001792 struct dsa_switch *ds = chip->ds;
1793 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001794
1795 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001796 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001797 if (chip->info->ops->port_set_egress_floods)
1798 return chip->info->ops->port_set_egress_floods(chip, port,
1799 flood, flood);
1800
1801 return 0;
1802}
1803
Andrew Lunn6d917822017-05-26 01:03:21 +02001804static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1805 bool on)
1806{
Vivien Didelot523a8902017-05-26 18:02:42 -04001807 if (chip->info->ops->serdes_power)
1808 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001809
Vivien Didelot523a8902017-05-26 18:02:42 -04001810 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001811}
1812
Vivien Didelotfa371c82017-12-05 15:34:10 -05001813static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1814{
1815 struct dsa_switch *ds = chip->ds;
1816 int upstream_port;
1817 int err;
1818
Vivien Didelot07073c72017-12-05 15:34:13 -05001819 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001820 if (chip->info->ops->port_set_upstream_port) {
1821 err = chip->info->ops->port_set_upstream_port(chip, port,
1822 upstream_port);
1823 if (err)
1824 return err;
1825 }
1826
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001827 if (port == upstream_port) {
1828 if (chip->info->ops->set_cpu_port) {
1829 err = chip->info->ops->set_cpu_port(chip,
1830 upstream_port);
1831 if (err)
1832 return err;
1833 }
1834
1835 if (chip->info->ops->set_egress_port) {
1836 err = chip->info->ops->set_egress_port(chip,
1837 upstream_port);
1838 if (err)
1839 return err;
1840 }
1841 }
1842
Vivien Didelotfa371c82017-12-05 15:34:10 -05001843 return 0;
1844}
1845
Vivien Didelotfad09c72016-06-21 12:28:20 -04001846static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001847{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001848 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001849 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001850 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001851
Vivien Didelotd78343d2016-11-04 03:23:36 +01001852 /* MAC Forcing register: don't force link, speed, duplex or flow control
1853 * state to any particular values on physical ports, but force the CPU
1854 * port and all DSA ports to their maximum bandwidth and full duplex.
1855 */
1856 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1857 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1858 SPEED_MAX, DUPLEX_FULL,
1859 PHY_INTERFACE_MODE_NA);
1860 else
1861 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1862 SPEED_UNFORCED, DUPLEX_UNFORCED,
1863 PHY_INTERFACE_MODE_NA);
1864 if (err)
1865 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001866
1867 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1868 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1869 * tunneling, determine priority by looking at 802.1p and IP
1870 * priority fields (IP prio has precedence), and set STP state
1871 * to Forwarding.
1872 *
1873 * If this is the CPU link, use DSA or EDSA tagging depending
1874 * on which tagging mode was configured.
1875 *
1876 * If this is a link to another switch, use DSA tagging mode.
1877 *
1878 * If this is the upstream port for this switch, enable
1879 * forwarding of unknown unicasts and multicasts.
1880 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001881 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1882 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1883 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1884 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001885 if (err)
1886 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001887
Vivien Didelot601aeed2017-03-11 16:13:00 -05001888 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001889 if (err)
1890 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001891
Vivien Didelot601aeed2017-03-11 16:13:00 -05001892 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001893 if (err)
1894 return err;
1895
Andrew Lunn04aca992017-05-26 01:03:24 +02001896 /* Enable the SERDES interface for DSA and CPU ports. Normal
1897 * ports SERDES are enabled when the port is enabled, thus
1898 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001899 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001900 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1901 err = mv88e6xxx_serdes_power(chip, port, true);
1902 if (err)
1903 return err;
1904 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001905
Vivien Didelot8efdda42015-08-13 12:52:23 -04001906 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001907 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001908 * untagged frames on this port, do a destination address lookup on all
1909 * received packets as usual, disable ARP mirroring and don't send a
1910 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001911 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001912 err = mv88e6xxx_port_set_map_da(chip, port);
1913 if (err)
1914 return err;
1915
Vivien Didelotfa371c82017-12-05 15:34:10 -05001916 err = mv88e6xxx_setup_upstream_port(chip, port);
1917 if (err)
1918 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001919
Andrew Lunna23b2962017-02-04 20:15:28 +01001920 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001921 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001922 if (err)
1923 return err;
1924
Vivien Didelotcd782652017-06-08 18:34:13 -04001925 if (chip->info->ops->port_set_jumbo_size) {
1926 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001927 if (err)
1928 return err;
1929 }
1930
Andrew Lunn54d792f2015-05-06 01:09:47 +02001931 /* Port Association Vector: when learning source addresses
1932 * of packets, add the address to the address database using
1933 * a port bitmap that has only the bit for this port set and
1934 * the other bits clear.
1935 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001936 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001937 /* Disable learning for CPU port */
1938 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001939 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001940
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001941 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1942 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001943 if (err)
1944 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001945
1946 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001947 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1948 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001949 if (err)
1950 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001951
Vivien Didelot08984322017-06-08 18:34:12 -04001952 if (chip->info->ops->port_pause_limit) {
1953 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001954 if (err)
1955 return err;
1956 }
1957
Vivien Didelotc8c94892017-03-11 16:13:01 -05001958 if (chip->info->ops->port_disable_learn_limit) {
1959 err = chip->info->ops->port_disable_learn_limit(chip, port);
1960 if (err)
1961 return err;
1962 }
1963
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001964 if (chip->info->ops->port_disable_pri_override) {
1965 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001966 if (err)
1967 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001968 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001969
Andrew Lunnef0a7312016-12-03 04:35:16 +01001970 if (chip->info->ops->port_tag_remap) {
1971 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001972 if (err)
1973 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001974 }
1975
Andrew Lunnef70b112016-12-03 04:45:18 +01001976 if (chip->info->ops->port_egress_rate_limiting) {
1977 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001978 if (err)
1979 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001980 }
1981
Vivien Didelotea698f42017-03-11 16:12:50 -05001982 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001983 if (err)
1984 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001985
Vivien Didelot207afda2016-04-14 14:42:09 -04001986 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001987 * database, and allow bidirectional communication between the
1988 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001989 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001990 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001991 if (err)
1992 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001993
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001994 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001995 if (err)
1996 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001997
1998 /* Default VLAN ID and priority: don't set a default VLAN
1999 * ID, and set the default packet priority to zero.
2000 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002001 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002002}
2003
Andrew Lunn04aca992017-05-26 01:03:24 +02002004static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2005 struct phy_device *phydev)
2006{
2007 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002008 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002009
2010 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002011 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002012 mutex_unlock(&chip->reg_lock);
2013
2014 return err;
2015}
2016
2017static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2018 struct phy_device *phydev)
2019{
2020 struct mv88e6xxx_chip *chip = ds->priv;
2021
2022 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002023 if (mv88e6xxx_serdes_power(chip, port, false))
2024 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002025 mutex_unlock(&chip->reg_lock);
2026}
2027
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002028static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2029 unsigned int ageing_time)
2030{
Vivien Didelot04bed142016-08-31 18:06:13 -04002031 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002032 int err;
2033
2034 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002035 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002036 mutex_unlock(&chip->reg_lock);
2037
2038 return err;
2039}
2040
Vivien Didelot97299342016-07-18 20:45:30 -04002041static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002042{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002043 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04002044 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002045
Vivien Didelot50484ff2016-05-09 13:22:54 -04002046 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002047 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
2048 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04002049 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002050 if (err)
2051 return err;
2052
Vivien Didelot08a01262016-05-09 13:22:50 -04002053 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002054 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002055 if (err)
2056 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002057 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002058 if (err)
2059 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002060 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002061 if (err)
2062 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002063 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002064 if (err)
2065 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002066 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002067 if (err)
2068 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002069 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002070 if (err)
2071 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002072 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002073 if (err)
2074 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002075 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002076 if (err)
2077 return err;
2078
2079 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002080 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002081 if (err)
2082 return err;
2083
Andrew Lunnde2273872016-11-21 23:27:01 +01002084 /* Initialize the statistics unit */
2085 err = mv88e6xxx_stats_set_histogram(chip);
2086 if (err)
2087 return err;
2088
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002089 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002090}
2091
Vivien Didelotf81ec902016-05-09 13:22:58 -04002092static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002093{
Vivien Didelot04bed142016-08-31 18:06:13 -04002094 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002095 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002096 int i;
2097
Vivien Didelotfad09c72016-06-21 12:28:20 -04002098 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002099 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002100
Vivien Didelotfad09c72016-06-21 12:28:20 -04002101 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002102
Vivien Didelot97299342016-07-18 20:45:30 -04002103 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002104 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002105 if (dsa_is_unused_port(ds, i))
2106 continue;
2107
Vivien Didelot97299342016-07-18 20:45:30 -04002108 err = mv88e6xxx_setup_port(chip, i);
2109 if (err)
2110 goto unlock;
2111 }
2112
2113 /* Setup Switch Global 1 Registers */
2114 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002115 if (err)
2116 goto unlock;
2117
Vivien Didelot97299342016-07-18 20:45:30 -04002118 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002119 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002120 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002121 if (err)
2122 goto unlock;
2123 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002124
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002125 err = mv88e6xxx_irl_setup(chip);
2126 if (err)
2127 goto unlock;
2128
Vivien Didelot04a69a12017-10-13 14:18:05 -04002129 err = mv88e6xxx_mac_setup(chip);
2130 if (err)
2131 goto unlock;
2132
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002133 err = mv88e6xxx_phy_setup(chip);
2134 if (err)
2135 goto unlock;
2136
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002137 err = mv88e6xxx_vtu_setup(chip);
2138 if (err)
2139 goto unlock;
2140
Vivien Didelot81228992017-03-30 17:37:08 -04002141 err = mv88e6xxx_pvt_setup(chip);
2142 if (err)
2143 goto unlock;
2144
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002145 err = mv88e6xxx_atu_setup(chip);
2146 if (err)
2147 goto unlock;
2148
Andrew Lunn87fa8862017-11-09 22:29:56 +01002149 err = mv88e6xxx_broadcast_setup(chip, 0);
2150 if (err)
2151 goto unlock;
2152
Vivien Didelot9e907d72017-07-17 13:03:43 -04002153 err = mv88e6xxx_pot_setup(chip);
2154 if (err)
2155 goto unlock;
2156
Vivien Didelot51c901a2017-07-17 13:03:41 -04002157 err = mv88e6xxx_rsvd2cpu_setup(chip);
2158 if (err)
2159 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002160
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002161 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002162 if (chip->info->ptp_support) {
2163 err = mv88e6xxx_ptp_setup(chip);
2164 if (err)
2165 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002166
2167 err = mv88e6xxx_hwtstamp_setup(chip);
2168 if (err)
2169 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002170 }
2171
Vivien Didelot6b17e862015-08-13 12:52:18 -04002172unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002173 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002174
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002175 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002176}
2177
Vivien Didelote57e5e72016-08-15 17:19:00 -04002178static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002179{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002180 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2181 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002182 u16 val;
2183 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002184
Andrew Lunnee26a222017-01-24 14:53:48 +01002185 if (!chip->info->ops->phy_read)
2186 return -EOPNOTSUPP;
2187
Vivien Didelotfad09c72016-06-21 12:28:20 -04002188 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002189 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002190 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002191
Andrew Lunnda9f3302017-02-01 03:40:05 +01002192 if (reg == MII_PHYSID2) {
2193 /* Some internal PHYS don't have a model number. Use
2194 * the mv88e6390 family model number instead.
2195 */
2196 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002197 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002198 }
2199
Vivien Didelote57e5e72016-08-15 17:19:00 -04002200 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002201}
2202
Vivien Didelote57e5e72016-08-15 17:19:00 -04002203static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002204{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002205 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2206 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002207 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002208
Andrew Lunnee26a222017-01-24 14:53:48 +01002209 if (!chip->info->ops->phy_write)
2210 return -EOPNOTSUPP;
2211
Vivien Didelotfad09c72016-06-21 12:28:20 -04002212 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002213 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002214 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002215
2216 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002217}
2218
Vivien Didelotfad09c72016-06-21 12:28:20 -04002219static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002220 struct device_node *np,
2221 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002222{
2223 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002224 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002225 struct mii_bus *bus;
2226 int err;
2227
Andrew Lunn2510bab2018-02-22 01:51:49 +01002228 if (external) {
2229 mutex_lock(&chip->reg_lock);
2230 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2231 mutex_unlock(&chip->reg_lock);
2232
2233 if (err)
2234 return err;
2235 }
2236
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002237 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002238 if (!bus)
2239 return -ENOMEM;
2240
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002241 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002242 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002243 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002244 INIT_LIST_HEAD(&mdio_bus->list);
2245 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002246
Andrew Lunnb516d452016-06-04 21:17:06 +02002247 if (np) {
2248 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002249 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002250 } else {
2251 bus->name = "mv88e6xxx SMI";
2252 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2253 }
2254
2255 bus->read = mv88e6xxx_mdio_read;
2256 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002257 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002258
Andrew Lunna3c53be52017-01-24 14:53:50 +01002259 if (np)
2260 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002261 else
2262 err = mdiobus_register(bus);
2263 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002264 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002265 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002266 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002267
2268 if (external)
2269 list_add_tail(&mdio_bus->list, &chip->mdios);
2270 else
2271 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002272
2273 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002274}
2275
Andrew Lunna3c53be52017-01-24 14:53:50 +01002276static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2277 { .compatible = "marvell,mv88e6xxx-mdio-external",
2278 .data = (void *)true },
2279 { },
2280};
2281
Andrew Lunn3126aee2017-12-07 01:05:57 +01002282static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2283
2284{
2285 struct mv88e6xxx_mdio_bus *mdio_bus;
2286 struct mii_bus *bus;
2287
2288 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2289 bus = mdio_bus->bus;
2290
2291 mdiobus_unregister(bus);
2292 }
2293}
2294
Andrew Lunna3c53be52017-01-24 14:53:50 +01002295static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2296 struct device_node *np)
2297{
2298 const struct of_device_id *match;
2299 struct device_node *child;
2300 int err;
2301
2302 /* Always register one mdio bus for the internal/default mdio
2303 * bus. This maybe represented in the device tree, but is
2304 * optional.
2305 */
2306 child = of_get_child_by_name(np, "mdio");
2307 err = mv88e6xxx_mdio_register(chip, child, false);
2308 if (err)
2309 return err;
2310
2311 /* Walk the device tree, and see if there are any other nodes
2312 * which say they are compatible with the external mdio
2313 * bus.
2314 */
2315 for_each_available_child_of_node(np, child) {
2316 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2317 if (match) {
2318 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002319 if (err) {
2320 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002321 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002322 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002323 }
2324 }
2325
2326 return 0;
2327}
2328
Vivien Didelot855b1932016-07-20 18:18:35 -04002329static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2330{
Vivien Didelot04bed142016-08-31 18:06:13 -04002331 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002332
2333 return chip->eeprom_len;
2334}
2335
Vivien Didelot855b1932016-07-20 18:18:35 -04002336static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2337 struct ethtool_eeprom *eeprom, u8 *data)
2338{
Vivien Didelot04bed142016-08-31 18:06:13 -04002339 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002340 int err;
2341
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002342 if (!chip->info->ops->get_eeprom)
2343 return -EOPNOTSUPP;
2344
Vivien Didelot855b1932016-07-20 18:18:35 -04002345 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002346 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002347 mutex_unlock(&chip->reg_lock);
2348
2349 if (err)
2350 return err;
2351
2352 eeprom->magic = 0xc3ec4951;
2353
2354 return 0;
2355}
2356
Vivien Didelot855b1932016-07-20 18:18:35 -04002357static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2358 struct ethtool_eeprom *eeprom, u8 *data)
2359{
Vivien Didelot04bed142016-08-31 18:06:13 -04002360 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002361 int err;
2362
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002363 if (!chip->info->ops->set_eeprom)
2364 return -EOPNOTSUPP;
2365
Vivien Didelot855b1932016-07-20 18:18:35 -04002366 if (eeprom->magic != 0xc3ec4951)
2367 return -EINVAL;
2368
2369 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002370 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002371 mutex_unlock(&chip->reg_lock);
2372
2373 return err;
2374}
2375
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002376static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002377 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002378 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002379 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002380 .phy_read = mv88e6185_phy_ppu_read,
2381 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002382 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002383 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002384 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002385 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002386 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002387 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002388 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002389 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002390 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002391 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002392 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002393 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002394 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002395 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2396 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002397 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002398 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2399 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002400 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002401 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002402 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002403 .ppu_enable = mv88e6185_g1_ppu_enable,
2404 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002405 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002406 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002407 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002408};
2409
2410static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002411 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002412 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002413 .phy_read = mv88e6185_phy_ppu_read,
2414 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002415 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002416 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002417 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002418 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002419 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002420 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002421 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002422 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002423 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2424 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002425 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002426 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002427 .ppu_enable = mv88e6185_g1_ppu_enable,
2428 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002429 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002430 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002431 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002432};
2433
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002434static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002435 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002436 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002437 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2438 .phy_read = mv88e6xxx_g2_smi_phy_read,
2439 .phy_write = mv88e6xxx_g2_smi_phy_write,
2440 .port_set_link = mv88e6xxx_port_set_link,
2441 .port_set_duplex = mv88e6xxx_port_set_duplex,
2442 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002443 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002444 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002445 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002446 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002447 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002448 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002449 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002450 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002451 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002452 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002453 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002454 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2455 .stats_get_strings = mv88e6095_stats_get_strings,
2456 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002457 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2458 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002459 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002460 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002461 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002462 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002463 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002464 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002465};
2466
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002467static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002468 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002469 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002470 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002471 .phy_read = mv88e6xxx_g2_smi_phy_read,
2472 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002473 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002474 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002475 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002476 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002477 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002478 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002479 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002480 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002481 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002482 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2483 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002484 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002485 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2486 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002487 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002488 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002489 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002490 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002491 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002492 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002493};
2494
2495static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002496 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002497 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002498 .phy_read = mv88e6185_phy_ppu_read,
2499 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002500 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002501 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002502 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002503 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002504 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002505 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002506 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002507 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002508 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002509 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002510 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002511 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002512 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002513 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2514 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002515 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002516 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2517 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002518 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002519 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002520 .ppu_enable = mv88e6185_g1_ppu_enable,
2521 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002522 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002523 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002524 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002525};
2526
Vivien Didelot990e27b2017-03-28 13:50:32 -04002527static const struct mv88e6xxx_ops mv88e6141_ops = {
2528 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002529 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002530 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2531 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2532 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2533 .phy_read = mv88e6xxx_g2_smi_phy_read,
2534 .phy_write = mv88e6xxx_g2_smi_phy_write,
2535 .port_set_link = mv88e6xxx_port_set_link,
2536 .port_set_duplex = mv88e6xxx_port_set_duplex,
2537 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2538 .port_set_speed = mv88e6390_port_set_speed,
2539 .port_tag_remap = mv88e6095_port_tag_remap,
2540 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2541 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2542 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002543 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002544 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002545 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002546 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2547 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2548 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002549 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002550 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2551 .stats_get_strings = mv88e6320_stats_get_strings,
2552 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002553 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2554 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002555 .watchdog_ops = &mv88e6390_watchdog_ops,
2556 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002557 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002558 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002559 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002560 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002561 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002562};
2563
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002564static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002565 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002566 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002567 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002568 .phy_read = mv88e6xxx_g2_smi_phy_read,
2569 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002570 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002571 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002572 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002573 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002574 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002575 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002576 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002577 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002578 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002579 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002580 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002581 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002582 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002583 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002584 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2585 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002586 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002587 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2588 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002589 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002590 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002591 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002592 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002593 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002594 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002595};
2596
2597static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002598 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002599 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002600 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002601 .phy_read = mv88e6165_phy_read,
2602 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002603 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002604 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002605 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002606 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002607 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002608 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002609 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002610 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2611 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002612 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002613 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2614 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002615 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002616 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002617 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002618 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002619 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002620 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002621};
2622
2623static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002624 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002625 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002626 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002627 .phy_read = mv88e6xxx_g2_smi_phy_read,
2628 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002629 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002630 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002631 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002632 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002633 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002634 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002635 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002636 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002637 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002638 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002639 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002640 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002641 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002642 .stats_snapshot = mv88e6320_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 = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002651 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002652 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002653 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002654 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002655};
2656
2657static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002658 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002659 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002660 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2661 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002662 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002663 .phy_read = mv88e6xxx_g2_smi_phy_read,
2664 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002665 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002666 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002667 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002668 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002669 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002670 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002671 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002672 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002673 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002674 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002675 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002676 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002677 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002678 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002679 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002680 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2681 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002682 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002683 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2684 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002685 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002686 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002687 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002688 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002689 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002690 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002691 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002692 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002693};
2694
2695static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002696 /* MV88E6XXX_FAMILY_6351 */
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,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002699 .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,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002703 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002704 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002705 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002706 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002707 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002708 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002709 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002710 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002711 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002712 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002713 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002714 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002715 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002716 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2717 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002718 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002719 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2720 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002721 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002722 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002723 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002724 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002725 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002726 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002727};
2728
2729static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002730 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002731 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002732 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2733 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002734 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002735 .phy_read = mv88e6xxx_g2_smi_phy_read,
2736 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002737 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002738 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002739 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002740 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002741 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002742 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002743 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002744 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002745 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002746 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002747 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002748 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002749 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002750 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002751 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002752 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2753 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002754 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002755 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2756 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002757 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002758 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002759 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002760 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002761 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002762 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002763 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002764 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002765};
2766
2767static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002768 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002769 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002770 .phy_read = mv88e6185_phy_ppu_read,
2771 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002772 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002773 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002774 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002775 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002776 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002777 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002778 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002779 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002780 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002781 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2782 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002783 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002784 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2785 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002786 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002787 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002788 .ppu_enable = mv88e6185_g1_ppu_enable,
2789 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002790 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002791 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002792 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002793};
2794
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002795static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002796 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002797 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002798 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2799 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002800 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2801 .phy_read = mv88e6xxx_g2_smi_phy_read,
2802 .phy_write = mv88e6xxx_g2_smi_phy_write,
2803 .port_set_link = mv88e6xxx_port_set_link,
2804 .port_set_duplex = mv88e6xxx_port_set_duplex,
2805 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2806 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002807 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002808 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002809 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002810 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002811 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002812 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002813 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002814 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002815 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002816 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2817 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002818 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002819 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2820 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002821 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002822 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002823 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002824 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002825 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2826 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002827 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002828 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002829};
2830
2831static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002832 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002833 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002834 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2835 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002836 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2837 .phy_read = mv88e6xxx_g2_smi_phy_read,
2838 .phy_write = mv88e6xxx_g2_smi_phy_write,
2839 .port_set_link = mv88e6xxx_port_set_link,
2840 .port_set_duplex = mv88e6xxx_port_set_duplex,
2841 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2842 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002843 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002844 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002845 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002847 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002848 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002849 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002850 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002851 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002852 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2853 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002854 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002855 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2856 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002857 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002858 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002859 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002860 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002861 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2862 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002863 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002864 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002865};
2866
2867static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002868 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002869 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002870 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2871 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002872 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2873 .phy_read = mv88e6xxx_g2_smi_phy_read,
2874 .phy_write = mv88e6xxx_g2_smi_phy_write,
2875 .port_set_link = mv88e6xxx_port_set_link,
2876 .port_set_duplex = mv88e6xxx_port_set_duplex,
2877 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2878 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002879 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002880 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002881 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002882 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002883 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002884 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002885 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002886 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002887 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002888 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2889 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002890 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002891 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2892 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002893 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002894 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002895 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002896 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002897 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2898 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002899 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002900};
2901
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002902static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002903 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002904 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002905 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2906 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002907 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002908 .phy_read = mv88e6xxx_g2_smi_phy_read,
2909 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002910 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002911 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002912 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002913 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002914 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002915 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002916 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002917 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002918 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002919 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002920 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002921 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002922 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002923 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002924 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002925 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2926 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002927 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002928 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2929 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002930 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002931 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002932 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002933 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002934 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002935 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002936 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002937 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002938 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002939};
2940
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002941static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002942 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002943 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002944 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2945 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002946 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2947 .phy_read = mv88e6xxx_g2_smi_phy_read,
2948 .phy_write = mv88e6xxx_g2_smi_phy_write,
2949 .port_set_link = mv88e6xxx_port_set_link,
2950 .port_set_duplex = mv88e6xxx_port_set_duplex,
2951 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2952 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002953 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002954 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002955 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002956 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002957 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002958 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002959 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002960 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002961 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002962 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002963 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2964 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002965 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002966 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2967 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002968 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002969 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002970 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002971 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002972 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2973 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002974 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002975 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002976 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002977};
2978
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002979static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002980 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002981 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002982 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2983 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002984 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002985 .phy_read = mv88e6xxx_g2_smi_phy_read,
2986 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002987 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002988 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002989 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002990 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002991 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002992 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002993 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002994 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002995 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002996 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002997 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002998 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002999 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003000 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003001 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3002 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003003 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003004 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3005 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003006 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003007 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003008 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003009 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003010 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003011 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003012 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003013};
3014
3015static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003016 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003017 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003018 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3019 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003020 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003021 .phy_read = mv88e6xxx_g2_smi_phy_read,
3022 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003023 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003024 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003025 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003026 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003027 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003028 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003029 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003030 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003031 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003032 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003033 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003034 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003035 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003036 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003037 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3038 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003039 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003040 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3041 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003042 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003043 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003044 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003045 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003046 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003047};
3048
Vivien Didelot16e329a2017-03-28 13:50:33 -04003049static const struct mv88e6xxx_ops mv88e6341_ops = {
3050 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003051 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003052 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3053 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3054 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3055 .phy_read = mv88e6xxx_g2_smi_phy_read,
3056 .phy_write = mv88e6xxx_g2_smi_phy_write,
3057 .port_set_link = mv88e6xxx_port_set_link,
3058 .port_set_duplex = mv88e6xxx_port_set_duplex,
3059 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3060 .port_set_speed = mv88e6390_port_set_speed,
3061 .port_tag_remap = mv88e6095_port_tag_remap,
3062 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3063 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3064 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003065 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003066 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003067 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003068 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3069 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3070 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003071 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003072 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3073 .stats_get_strings = mv88e6320_stats_get_strings,
3074 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003075 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3076 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003077 .watchdog_ops = &mv88e6390_watchdog_ops,
3078 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003079 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003080 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003081 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003082 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003083 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003084 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003085};
3086
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003087static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003088 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003089 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003090 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003091 .phy_read = mv88e6xxx_g2_smi_phy_read,
3092 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003093 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003094 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003095 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003096 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003097 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003098 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003099 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003100 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003101 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003102 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003103 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003104 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003105 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003106 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003107 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003108 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3109 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003110 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003111 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3112 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003113 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003114 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003115 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003116 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003117 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003118 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003119};
3120
3121static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003122 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003123 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003124 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003125 .phy_read = mv88e6xxx_g2_smi_phy_read,
3126 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003127 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003128 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003129 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003130 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003131 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003132 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003133 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003134 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003135 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003136 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003137 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003138 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003139 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003140 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003141 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003142 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3143 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003144 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003145 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3146 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003147 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003148 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003149 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003150 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003151 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003152 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003153 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003154};
3155
3156static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003157 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003158 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003159 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3160 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003161 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003162 .phy_read = mv88e6xxx_g2_smi_phy_read,
3163 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003164 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003165 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003166 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003167 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003168 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003169 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003170 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003171 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003172 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003173 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003174 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003175 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003176 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003177 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003178 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003179 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3180 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003181 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003182 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3183 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003184 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003185 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003186 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003187 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003188 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003189 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003190 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003191 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003192 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003193};
3194
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003195static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003196 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003197 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003198 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3199 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003200 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3201 .phy_read = mv88e6xxx_g2_smi_phy_read,
3202 .phy_write = mv88e6xxx_g2_smi_phy_write,
3203 .port_set_link = mv88e6xxx_port_set_link,
3204 .port_set_duplex = mv88e6xxx_port_set_duplex,
3205 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3206 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003207 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003208 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003209 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003210 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003211 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003212 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003213 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003214 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003215 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003216 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003217 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003218 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003219 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3220 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003221 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003222 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3223 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003224 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003225 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003226 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003227 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003228 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3229 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003230 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003231 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003232 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003233};
3234
3235static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003236 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003237 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003238 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3239 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003240 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3241 .phy_read = mv88e6xxx_g2_smi_phy_read,
3242 .phy_write = mv88e6xxx_g2_smi_phy_write,
3243 .port_set_link = mv88e6xxx_port_set_link,
3244 .port_set_duplex = mv88e6xxx_port_set_duplex,
3245 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3246 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003247 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003248 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003249 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003250 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003251 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003252 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003253 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003254 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003255 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003256 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003257 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003258 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003259 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3260 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003261 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003262 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3263 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003264 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003265 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003266 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003267 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003268 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3269 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003270 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003271 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003272 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003273};
3274
Vivien Didelotf81ec902016-05-09 13:22:58 -04003275static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3276 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003277 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003278 .family = MV88E6XXX_FAMILY_6097,
3279 .name = "Marvell 88E6085",
3280 .num_databases = 4096,
3281 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003282 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003283 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003284 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003285 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003286 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003287 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003288 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003289 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003290 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003291 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003292 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003293 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003294 },
3295
3296 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003297 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003298 .family = MV88E6XXX_FAMILY_6095,
3299 .name = "Marvell 88E6095/88E6095F",
3300 .num_databases = 256,
3301 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003302 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003303 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003304 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003305 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003306 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003307 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003308 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003309 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003310 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003311 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003312 },
3313
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003314 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003315 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003316 .family = MV88E6XXX_FAMILY_6097,
3317 .name = "Marvell 88E6097/88E6097F",
3318 .num_databases = 4096,
3319 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003320 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003321 .port_base_addr = 0x10,
3322 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003323 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003324 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003325 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003326 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003327 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003328 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003329 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003330 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003331 .ops = &mv88e6097_ops,
3332 },
3333
Vivien Didelotf81ec902016-05-09 13:22:58 -04003334 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003335 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003336 .family = MV88E6XXX_FAMILY_6165,
3337 .name = "Marvell 88E6123",
3338 .num_databases = 4096,
3339 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003340 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003341 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003342 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003343 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003344 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003345 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003346 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003347 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003348 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003349 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003350 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003351 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003352 },
3353
3354 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003355 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003356 .family = MV88E6XXX_FAMILY_6185,
3357 .name = "Marvell 88E6131",
3358 .num_databases = 256,
3359 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003360 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003361 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003362 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003363 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003364 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003365 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003366 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003367 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003368 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003369 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003370 },
3371
Vivien Didelot990e27b2017-03-28 13:50:32 -04003372 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003373 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003374 .family = MV88E6XXX_FAMILY_6341,
3375 .name = "Marvell 88E6341",
3376 .num_databases = 4096,
3377 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003378 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003379 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003380 .port_base_addr = 0x10,
3381 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003382 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003383 .age_time_coeff = 3750,
3384 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003385 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003386 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003387 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003388 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003389 .ops = &mv88e6141_ops,
3390 },
3391
Vivien Didelotf81ec902016-05-09 13:22:58 -04003392 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003393 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003394 .family = MV88E6XXX_FAMILY_6165,
3395 .name = "Marvell 88E6161",
3396 .num_databases = 4096,
3397 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003398 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003399 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003400 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003401 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003402 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003403 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003404 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003405 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003406 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003407 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003408 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003409 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003410 },
3411
3412 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003413 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003414 .family = MV88E6XXX_FAMILY_6165,
3415 .name = "Marvell 88E6165",
3416 .num_databases = 4096,
3417 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003418 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003419 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003420 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003421 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003422 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003423 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003424 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003425 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003426 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003427 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003428 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003429 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003430 },
3431
3432 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003433 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003434 .family = MV88E6XXX_FAMILY_6351,
3435 .name = "Marvell 88E6171",
3436 .num_databases = 4096,
3437 .num_ports = 7,
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 = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003444 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003445 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003446 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003447 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003448 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003450 },
3451
3452 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003453 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003454 .family = MV88E6XXX_FAMILY_6352,
3455 .name = "Marvell 88E6172",
3456 .num_databases = 4096,
3457 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003458 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003459 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003460 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003461 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003462 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003463 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003464 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003465 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003466 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003467 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003468 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003469 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003470 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003471 },
3472
3473 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003474 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003475 .family = MV88E6XXX_FAMILY_6351,
3476 .name = "Marvell 88E6175",
3477 .num_databases = 4096,
3478 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003479 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003480 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003481 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003482 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003483 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003484 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003485 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003486 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003487 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003488 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003489 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003490 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003491 },
3492
3493 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003494 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003495 .family = MV88E6XXX_FAMILY_6352,
3496 .name = "Marvell 88E6176",
3497 .num_databases = 4096,
3498 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003499 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003500 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003501 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003502 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003503 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003504 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003505 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003506 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003507 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003508 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003509 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003510 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003511 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003512 },
3513
3514 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003515 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003516 .family = MV88E6XXX_FAMILY_6185,
3517 .name = "Marvell 88E6185",
3518 .num_databases = 256,
3519 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003520 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003521 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003522 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003523 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003524 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003525 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003526 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003527 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003528 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003529 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003530 },
3531
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003532 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003533 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003534 .family = MV88E6XXX_FAMILY_6390,
3535 .name = "Marvell 88E6190",
3536 .num_databases = 4096,
3537 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003538 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003539 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003540 .port_base_addr = 0x0,
3541 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003542 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003543 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003544 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003545 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003546 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003547 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003548 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003549 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003550 .ops = &mv88e6190_ops,
3551 },
3552
3553 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003554 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003555 .family = MV88E6XXX_FAMILY_6390,
3556 .name = "Marvell 88E6190X",
3557 .num_databases = 4096,
3558 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003559 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003560 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003561 .port_base_addr = 0x0,
3562 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003563 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003564 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003565 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003566 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003567 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003568 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003569 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003570 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003571 .ops = &mv88e6190x_ops,
3572 },
3573
3574 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003575 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003576 .family = MV88E6XXX_FAMILY_6390,
3577 .name = "Marvell 88E6191",
3578 .num_databases = 4096,
3579 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003580 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003581 .port_base_addr = 0x0,
3582 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003583 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003584 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003585 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003586 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003587 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003588 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003589 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003590 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003591 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003592 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003593 },
3594
Vivien Didelotf81ec902016-05-09 13:22:58 -04003595 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003596 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003597 .family = MV88E6XXX_FAMILY_6352,
3598 .name = "Marvell 88E6240",
3599 .num_databases = 4096,
3600 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003601 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003602 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003603 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003604 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003605 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003606 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003607 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003608 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003609 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003610 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003611 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003612 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003613 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003614 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003615 },
3616
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003617 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003618 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003619 .family = MV88E6XXX_FAMILY_6390,
3620 .name = "Marvell 88E6290",
3621 .num_databases = 4096,
3622 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003623 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003624 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003625 .port_base_addr = 0x0,
3626 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003627 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003628 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003629 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003630 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003631 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003632 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003633 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003634 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003635 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003636 .ops = &mv88e6290_ops,
3637 },
3638
Vivien Didelotf81ec902016-05-09 13:22:58 -04003639 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003640 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 .family = MV88E6XXX_FAMILY_6320,
3642 .name = "Marvell 88E6320",
3643 .num_databases = 4096,
3644 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003645 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003646 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003647 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003648 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003649 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003650 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003651 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003652 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003653 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003654 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003655 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003656 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003657 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003658 },
3659
3660 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003661 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003662 .family = MV88E6XXX_FAMILY_6320,
3663 .name = "Marvell 88E6321",
3664 .num_databases = 4096,
3665 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003666 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003667 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003668 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003669 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003670 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003671 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003672 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003673 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003674 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003675 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003676 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003677 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003678 },
3679
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003680 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003681 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003682 .family = MV88E6XXX_FAMILY_6341,
3683 .name = "Marvell 88E6341",
3684 .num_databases = 4096,
3685 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003686 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003687 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003688 .port_base_addr = 0x10,
3689 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003690 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003691 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003692 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003693 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003694 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003695 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003696 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003697 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003698 .ops = &mv88e6341_ops,
3699 },
3700
Vivien Didelotf81ec902016-05-09 13:22:58 -04003701 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003702 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003703 .family = MV88E6XXX_FAMILY_6351,
3704 .name = "Marvell 88E6350",
3705 .num_databases = 4096,
3706 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003707 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003708 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003709 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003710 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003711 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003712 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003713 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003714 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003715 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003716 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003717 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003718 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003719 },
3720
3721 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003722 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003723 .family = MV88E6XXX_FAMILY_6351,
3724 .name = "Marvell 88E6351",
3725 .num_databases = 4096,
3726 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003727 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003728 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003729 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003730 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003731 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003732 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003733 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003734 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003735 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003736 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003737 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003738 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003739 },
3740
3741 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003742 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003743 .family = MV88E6XXX_FAMILY_6352,
3744 .name = "Marvell 88E6352",
3745 .num_databases = 4096,
3746 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003747 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003748 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003749 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003750 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003751 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003752 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003753 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003754 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003755 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003756 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003757 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003758 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003759 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003760 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003761 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003762 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003763 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003764 .family = MV88E6XXX_FAMILY_6390,
3765 .name = "Marvell 88E6390",
3766 .num_databases = 4096,
3767 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003768 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003769 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003770 .port_base_addr = 0x0,
3771 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003772 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003773 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003774 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003775 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003776 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003777 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003778 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003779 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003780 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003781 .ops = &mv88e6390_ops,
3782 },
3783 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003784 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003785 .family = MV88E6XXX_FAMILY_6390,
3786 .name = "Marvell 88E6390X",
3787 .num_databases = 4096,
3788 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003789 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003790 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003791 .port_base_addr = 0x0,
3792 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003793 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003794 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003795 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003796 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003797 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003798 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003799 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003800 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003801 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003802 .ops = &mv88e6390x_ops,
3803 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003804};
3805
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003806static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003807{
Vivien Didelota439c062016-04-17 13:23:58 -04003808 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003809
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003810 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3811 if (mv88e6xxx_table[i].prod_num == prod_num)
3812 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003813
Vivien Didelotb9b37712015-10-30 19:39:48 -04003814 return NULL;
3815}
3816
Vivien Didelotfad09c72016-06-21 12:28:20 -04003817static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003818{
3819 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003820 unsigned int prod_num, rev;
3821 u16 id;
3822 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003823
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003824 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003825 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003826 mutex_unlock(&chip->reg_lock);
3827 if (err)
3828 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003829
Vivien Didelot107fcc12017-06-12 12:37:36 -04003830 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3831 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003832
3833 info = mv88e6xxx_lookup_info(prod_num);
3834 if (!info)
3835 return -ENODEV;
3836
Vivien Didelotcaac8542016-06-20 13:14:09 -04003837 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003838 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003839
Vivien Didelotca070c12016-09-02 14:45:34 -04003840 err = mv88e6xxx_g2_require(chip);
3841 if (err)
3842 return err;
3843
Vivien Didelotfad09c72016-06-21 12:28:20 -04003844 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3845 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003846
3847 return 0;
3848}
3849
Vivien Didelotfad09c72016-06-21 12:28:20 -04003850static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003851{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003852 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003853
Vivien Didelotfad09c72016-06-21 12:28:20 -04003854 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3855 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003856 return NULL;
3857
Vivien Didelotfad09c72016-06-21 12:28:20 -04003858 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003859
Vivien Didelotfad09c72016-06-21 12:28:20 -04003860 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003861 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003862
Vivien Didelotfad09c72016-06-21 12:28:20 -04003863 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003864}
3865
Vivien Didelotfad09c72016-06-21 12:28:20 -04003866static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003867 struct mii_bus *bus, int sw_addr)
3868{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003869 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003870 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003871 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003872 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003873 else
3874 return -EINVAL;
3875
Vivien Didelotfad09c72016-06-21 12:28:20 -04003876 chip->bus = bus;
3877 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003878
3879 return 0;
3880}
3881
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08003882static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
3883 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02003884{
Vivien Didelot04bed142016-08-31 18:06:13 -04003885 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003886
Andrew Lunn443d5a12016-12-03 04:35:18 +01003887 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003888}
3889
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003890#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003891static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3892 struct device *host_dev, int sw_addr,
3893 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003894{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003895 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003896 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003897 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003898
Vivien Didelota439c062016-04-17 13:23:58 -04003899 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003900 if (!bus)
3901 return NULL;
3902
Vivien Didelotfad09c72016-06-21 12:28:20 -04003903 chip = mv88e6xxx_alloc_chip(dsa_dev);
3904 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003905 return NULL;
3906
Vivien Didelotcaac8542016-06-20 13:14:09 -04003907 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003908 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003909
Vivien Didelotfad09c72016-06-21 12:28:20 -04003910 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003911 if (err)
3912 goto free;
3913
Vivien Didelotfad09c72016-06-21 12:28:20 -04003914 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003915 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003916 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003917
Andrew Lunndc30c352016-10-16 19:56:49 +02003918 mutex_lock(&chip->reg_lock);
3919 err = mv88e6xxx_switch_reset(chip);
3920 mutex_unlock(&chip->reg_lock);
3921 if (err)
3922 goto free;
3923
Vivien Didelote57e5e72016-08-15 17:19:00 -04003924 mv88e6xxx_phy_init(chip);
3925
Andrew Lunna3c53be52017-01-24 14:53:50 +01003926 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003927 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003928 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003929
Vivien Didelotfad09c72016-06-21 12:28:20 -04003930 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003931
Vivien Didelotfad09c72016-06-21 12:28:20 -04003932 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003933free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003934 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003935
3936 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003937}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003938#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02003939
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003940static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003941 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003942{
3943 /* We don't need any dynamic resource from the kernel (yet),
3944 * so skip the prepare phase.
3945 */
3946
3947 return 0;
3948}
3949
3950static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003951 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003952{
Vivien Didelot04bed142016-08-31 18:06:13 -04003953 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003954
3955 mutex_lock(&chip->reg_lock);
3956 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003957 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003958 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3959 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003960 mutex_unlock(&chip->reg_lock);
3961}
3962
3963static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3964 const struct switchdev_obj_port_mdb *mdb)
3965{
Vivien Didelot04bed142016-08-31 18:06:13 -04003966 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003967 int err;
3968
3969 mutex_lock(&chip->reg_lock);
3970 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003971 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003972 mutex_unlock(&chip->reg_lock);
3973
3974 return err;
3975}
3976
Florian Fainellia82f67a2017-01-08 14:52:08 -08003977static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003978#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003979 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003980#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02003981 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003982 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003983 .adjust_link = mv88e6xxx_adjust_link,
3984 .get_strings = mv88e6xxx_get_strings,
3985 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3986 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003987 .port_enable = mv88e6xxx_port_enable,
3988 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003989 .get_mac_eee = mv88e6xxx_get_mac_eee,
3990 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003991 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003992 .get_eeprom = mv88e6xxx_get_eeprom,
3993 .set_eeprom = mv88e6xxx_set_eeprom,
3994 .get_regs_len = mv88e6xxx_get_regs_len,
3995 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003996 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003997 .port_bridge_join = mv88e6xxx_port_bridge_join,
3998 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3999 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004000 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004001 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4002 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4003 .port_vlan_add = mv88e6xxx_port_vlan_add,
4004 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004005 .port_fdb_add = mv88e6xxx_port_fdb_add,
4006 .port_fdb_del = mv88e6xxx_port_fdb_del,
4007 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004008 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4009 .port_mdb_add = mv88e6xxx_port_mdb_add,
4010 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004011 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4012 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004013 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4014 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4015 .port_txtstamp = mv88e6xxx_port_txtstamp,
4016 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4017 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004018};
4019
Florian Fainelliab3d4082017-01-08 14:52:07 -08004020static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4021 .ops = &mv88e6xxx_switch_ops,
4022};
4023
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004024static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004025{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004026 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004027 struct dsa_switch *ds;
4028
Vivien Didelot73b12042017-03-30 17:37:10 -04004029 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004030 if (!ds)
4031 return -ENOMEM;
4032
Vivien Didelotfad09c72016-06-21 12:28:20 -04004033 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004034 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004035 ds->ageing_time_min = chip->info->age_time_coeff;
4036 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004037
4038 dev_set_drvdata(dev, ds);
4039
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004040 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004041}
4042
Vivien Didelotfad09c72016-06-21 12:28:20 -04004043static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004044{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004045 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004046}
4047
Vivien Didelot57d32312016-06-20 13:13:58 -04004048static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004049{
4050 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004051 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004052 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004053 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004054 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004055 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004056
Vivien Didelotcaac8542016-06-20 13:14:09 -04004057 compat_info = of_device_get_match_data(dev);
4058 if (!compat_info)
4059 return -EINVAL;
4060
Vivien Didelotfad09c72016-06-21 12:28:20 -04004061 chip = mv88e6xxx_alloc_chip(dev);
4062 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004063 return -ENOMEM;
4064
Vivien Didelotfad09c72016-06-21 12:28:20 -04004065 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004066
Vivien Didelotfad09c72016-06-21 12:28:20 -04004067 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004068 if (err)
4069 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004070
Andrew Lunnb4308f02016-11-21 23:26:55 +01004071 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4072 if (IS_ERR(chip->reset))
4073 return PTR_ERR(chip->reset);
4074
Vivien Didelotfad09c72016-06-21 12:28:20 -04004075 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004076 if (err)
4077 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004078
Vivien Didelote57e5e72016-08-15 17:19:00 -04004079 mv88e6xxx_phy_init(chip);
4080
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004081 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004082 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004083 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004084
Andrew Lunndc30c352016-10-16 19:56:49 +02004085 mutex_lock(&chip->reg_lock);
4086 err = mv88e6xxx_switch_reset(chip);
4087 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004088 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004089 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004090
Andrew Lunndc30c352016-10-16 19:56:49 +02004091 chip->irq = of_irq_get(np, 0);
4092 if (chip->irq == -EPROBE_DEFER) {
4093 err = chip->irq;
4094 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004095 }
4096
Andrew Lunn294d7112018-02-22 22:58:32 +01004097 /* Has to be performed before the MDIO bus is created, because
4098 * the PHYs will link there interrupts to these interrupt
4099 * controllers
4100 */
4101 mutex_lock(&chip->reg_lock);
4102 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004103 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004104 else
4105 err = mv88e6xxx_irq_poll_setup(chip);
4106 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004107
Andrew Lunn294d7112018-02-22 22:58:32 +01004108 if (err)
4109 goto out;
4110
4111 if (chip->info->g2_irqs > 0) {
4112 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004113 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004114 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004115 }
4116
Andrew Lunn294d7112018-02-22 22:58:32 +01004117 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4118 if (err)
4119 goto out_g2_irq;
4120
4121 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4122 if (err)
4123 goto out_g1_atu_prob_irq;
4124
Andrew Lunna3c53be52017-01-24 14:53:50 +01004125 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004126 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004127 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004128
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004129 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004130 if (err)
4131 goto out_mdio;
4132
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004133 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004134
4135out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004136 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004137out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004138 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004139out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004140 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004141out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004142 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004143 mv88e6xxx_g2_irq_free(chip);
4144out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004145 mutex_lock(&chip->reg_lock);
4146 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004147 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004148 else
4149 mv88e6xxx_irq_poll_free(chip);
4150 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004151out:
4152 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004153}
4154
4155static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4156{
4157 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004158 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004159
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004160 if (chip->info->ptp_support) {
4161 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004162 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004163 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004164
Andrew Lunn930188c2016-08-22 16:01:03 +02004165 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004166 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004167 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004168
Andrew Lunn467126442016-11-20 20:14:15 +01004169 if (chip->irq > 0) {
Andrew Lunn62eb1162018-01-14 02:32:45 +01004170 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004171 mv88e6xxx_g1_atu_prob_irq_free(chip);
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004172 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004173 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004174 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004175 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004176 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004177 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004178}
4179
4180static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004181 {
4182 .compatible = "marvell,mv88e6085",
4183 .data = &mv88e6xxx_table[MV88E6085],
4184 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004185 {
4186 .compatible = "marvell,mv88e6190",
4187 .data = &mv88e6xxx_table[MV88E6190],
4188 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004189 { /* sentinel */ },
4190};
4191
4192MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4193
4194static struct mdio_driver mv88e6xxx_driver = {
4195 .probe = mv88e6xxx_probe,
4196 .remove = mv88e6xxx_remove,
4197 .mdiodrv.driver = {
4198 .name = "mv88e6085",
4199 .of_match_table = mv88e6xxx_of_match,
4200 },
4201};
4202
Ben Hutchings98e67302011-11-25 14:36:19 +00004203static int __init mv88e6xxx_init(void)
4204{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004205 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004206 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004207}
4208module_init(mv88e6xxx_init);
4209
4210static void __exit mv88e6xxx_cleanup(void)
4211{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004212 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004213 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004214}
4215module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004216
4217MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4218MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4219MODULE_LICENSE("GPL");