1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Marvell 88e6xxx Ethernet switch single-chip support
5 * Copyright (c) 2008 Marvell Semiconductor
7 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
9 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
13 #include <linux/bitfield.h>
14 #include <linux/delay.h>
15 #include <linux/dsa/mv88e6xxx.h>
16 #include <linux/etherdevice.h>
17 #include <linux/ethtool.h>
18 #include <linux/if_bridge.h>
19 #include <linux/interrupt.h>
20 #include <linux/irq.h>
21 #include <linux/irqdomain.h>
22 #include <linux/jiffies.h>
23 #include <linux/list.h>
24 #include <linux/mdio.h>
25 #include <linux/module.h>
27 #include <linux/of_irq.h>
28 #include <linux/of_mdio.h>
29 #include <linux/platform_data/mv88e6xxx.h>
30 #include <linux/netdevice.h>
31 #include <linux/gpio/consumer.h>
32 #include <linux/phylink.h>
46 static void assert_reg_lock(struct mv88e6xxx_chip *chip)
48 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
49 dev_err(chip->dev, "Switch registers lock not held!\n");
54 int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
58 assert_reg_lock(chip);
60 err = mv88e6xxx_smi_read(chip, addr, reg, val);
64 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
70 int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
74 assert_reg_lock(chip);
76 err = mv88e6xxx_smi_write(chip, addr, reg, val);
80 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
86 int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
89 const unsigned long timeout = jiffies + msecs_to_jiffies(50);
94 /* There's no bus specific operation to wait for a mask. Even
95 * if the initial poll takes longer than 50ms, always do at
96 * least one more attempt.
98 for (i = 0; time_before(jiffies, timeout) || (i < 2); i++) {
99 err = mv88e6xxx_read(chip, addr, reg, &data);
103 if ((data & mask) == val)
109 usleep_range(1000, 2000);
112 err = mv88e6xxx_read(chip, addr, reg, &data);
116 if ((data & mask) == val)
119 dev_err(chip->dev, "Timeout while waiting for switch\n");
123 int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
126 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
127 val ? BIT(bit) : 0x0000);
130 struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
132 struct mv88e6xxx_mdio_bus *mdio_bus;
134 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
139 return mdio_bus->bus;
142 static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
144 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
145 unsigned int n = d->hwirq;
147 chip->g1_irq.masked |= (1 << n);
150 static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
152 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
153 unsigned int n = d->hwirq;
155 chip->g1_irq.masked &= ~(1 << n);
158 static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
160 unsigned int nhandled = 0;
161 unsigned int sub_irq;
167 mv88e6xxx_reg_lock(chip);
168 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®);
169 mv88e6xxx_reg_unlock(chip);
175 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
176 if (reg & (1 << n)) {
177 sub_irq = irq_find_mapping(chip->g1_irq.domain,
179 handle_nested_irq(sub_irq);
184 mv88e6xxx_reg_lock(chip);
185 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
188 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®);
190 mv88e6xxx_reg_unlock(chip);
193 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
194 } while (reg & ctl1);
197 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
200 static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
202 struct mv88e6xxx_chip *chip = dev_id;
204 return mv88e6xxx_g1_irq_thread_work(chip);
207 static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
209 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
211 mv88e6xxx_reg_lock(chip);
214 static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
216 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
217 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
221 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®);
226 reg |= (~chip->g1_irq.masked & mask);
228 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
233 mv88e6xxx_reg_unlock(chip);
236 static const struct irq_chip mv88e6xxx_g1_irq_chip = {
237 .name = "mv88e6xxx-g1",
238 .irq_mask = mv88e6xxx_g1_irq_mask,
239 .irq_unmask = mv88e6xxx_g1_irq_unmask,
240 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
241 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
244 static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
246 irq_hw_number_t hwirq)
248 struct mv88e6xxx_chip *chip = d->host_data;
250 irq_set_chip_data(irq, d->host_data);
251 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
252 irq_set_noprobe(irq);
257 static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
258 .map = mv88e6xxx_g1_irq_domain_map,
259 .xlate = irq_domain_xlate_twocell,
262 /* To be called with reg_lock held */
263 static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
268 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
269 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
270 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
272 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
273 virq = irq_find_mapping(chip->g1_irq.domain, irq);
274 irq_dispose_mapping(virq);
277 irq_domain_remove(chip->g1_irq.domain);
280 static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
283 * free_irq must be called without reg_lock taken because the irq
284 * handler takes this lock, too.
286 free_irq(chip->irq, chip);
288 mv88e6xxx_reg_lock(chip);
289 mv88e6xxx_g1_irq_free_common(chip);
290 mv88e6xxx_reg_unlock(chip);
293 static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
298 chip->g1_irq.nirqs = chip->info->g1_irqs;
299 chip->g1_irq.domain = irq_domain_add_simple(
300 NULL, chip->g1_irq.nirqs, 0,
301 &mv88e6xxx_g1_irq_domain_ops, chip);
302 if (!chip->g1_irq.domain)
305 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
306 irq_create_mapping(chip->g1_irq.domain, irq);
308 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
309 chip->g1_irq.masked = ~0;
311 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
315 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
317 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
321 /* Reading the interrupt status clears (most of) them */
322 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®);
329 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
330 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
333 for (irq = 0; irq < 16; irq++) {
334 virq = irq_find_mapping(chip->g1_irq.domain, irq);
335 irq_dispose_mapping(virq);
338 irq_domain_remove(chip->g1_irq.domain);
343 static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
345 static struct lock_class_key lock_key;
346 static struct lock_class_key request_key;
349 err = mv88e6xxx_g1_irq_setup_common(chip);
353 /* These lock classes tells lockdep that global 1 irqs are in
354 * a different category than their parent GPIO, so it won't
355 * report false recursion.
357 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
359 snprintf(chip->irq_name, sizeof(chip->irq_name),
360 "mv88e6xxx-%s", dev_name(chip->dev));
362 mv88e6xxx_reg_unlock(chip);
363 err = request_threaded_irq(chip->irq, NULL,
364 mv88e6xxx_g1_irq_thread_fn,
365 IRQF_ONESHOT | IRQF_SHARED,
366 chip->irq_name, chip);
367 mv88e6xxx_reg_lock(chip);
369 mv88e6xxx_g1_irq_free_common(chip);
374 static void mv88e6xxx_irq_poll(struct kthread_work *work)
376 struct mv88e6xxx_chip *chip = container_of(work,
377 struct mv88e6xxx_chip,
379 mv88e6xxx_g1_irq_thread_work(chip);
381 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
382 msecs_to_jiffies(100));
385 static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
389 err = mv88e6xxx_g1_irq_setup_common(chip);
393 kthread_init_delayed_work(&chip->irq_poll_work,
396 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
397 if (IS_ERR(chip->kworker))
398 return PTR_ERR(chip->kworker);
400 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
401 msecs_to_jiffies(100));
406 static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
408 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
409 kthread_destroy_worker(chip->kworker);
411 mv88e6xxx_reg_lock(chip);
412 mv88e6xxx_g1_irq_free_common(chip);
413 mv88e6xxx_reg_unlock(chip);
416 static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
417 int port, phy_interface_t interface)
421 if (chip->info->ops->port_set_rgmii_delay) {
422 err = chip->info->ops->port_set_rgmii_delay(chip, port,
424 if (err && err != -EOPNOTSUPP)
428 if (chip->info->ops->port_set_cmode) {
429 err = chip->info->ops->port_set_cmode(chip, port,
431 if (err && err != -EOPNOTSUPP)
438 static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
439 int link, int speed, int duplex, int pause,
440 phy_interface_t mode)
444 if (!chip->info->ops->port_set_link)
447 /* Port's MAC control must not be changed unless the link is down */
448 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
452 if (chip->info->ops->port_set_speed_duplex) {
453 err = chip->info->ops->port_set_speed_duplex(chip, port,
455 if (err && err != -EOPNOTSUPP)
459 if (chip->info->ops->port_set_pause) {
460 err = chip->info->ops->port_set_pause(chip, port, pause);
465 err = mv88e6xxx_port_config_interface(chip, port, mode);
467 if (chip->info->ops->port_set_link(chip, port, link))
468 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
473 static int mv88e6xxx_phy_is_internal(struct mv88e6xxx_chip *chip, int port)
475 return port >= chip->info->internal_phys_offset &&
476 port < chip->info->num_internal_phys +
477 chip->info->internal_phys_offset;
480 static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
485 /* The 88e6250 family does not have the PHY detect bit. Instead,
486 * report whether the port is internal.
488 if (chip->info->family == MV88E6XXX_FAMILY_6250)
489 return mv88e6xxx_phy_is_internal(chip, port);
491 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®);
494 "p%d: %s: failed to read port status\n",
499 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
502 static const u8 mv88e6185_phy_interface_modes[] = {
503 [MV88E6185_PORT_STS_CMODE_GMII_FD] = PHY_INTERFACE_MODE_GMII,
504 [MV88E6185_PORT_STS_CMODE_MII_100_FD_PS] = PHY_INTERFACE_MODE_MII,
505 [MV88E6185_PORT_STS_CMODE_MII_100] = PHY_INTERFACE_MODE_MII,
506 [MV88E6185_PORT_STS_CMODE_MII_10] = PHY_INTERFACE_MODE_MII,
507 [MV88E6185_PORT_STS_CMODE_SERDES] = PHY_INTERFACE_MODE_1000BASEX,
508 [MV88E6185_PORT_STS_CMODE_1000BASE_X] = PHY_INTERFACE_MODE_1000BASEX,
509 [MV88E6185_PORT_STS_CMODE_PHY] = PHY_INTERFACE_MODE_SGMII,
512 static void mv88e6095_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
513 struct phylink_config *config)
515 u8 cmode = chip->ports[port].cmode;
517 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100;
519 if (mv88e6xxx_phy_is_internal(chip, port)) {
520 __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces);
522 if (cmode < ARRAY_SIZE(mv88e6185_phy_interface_modes) &&
523 mv88e6185_phy_interface_modes[cmode])
524 __set_bit(mv88e6185_phy_interface_modes[cmode],
525 config->supported_interfaces);
527 config->mac_capabilities |= MAC_1000FD;
531 static void mv88e6185_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
532 struct phylink_config *config)
534 u8 cmode = chip->ports[port].cmode;
536 if (cmode < ARRAY_SIZE(mv88e6185_phy_interface_modes) &&
537 mv88e6185_phy_interface_modes[cmode])
538 __set_bit(mv88e6185_phy_interface_modes[cmode],
539 config->supported_interfaces);
541 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
545 static const u8 mv88e6xxx_phy_interface_modes[] = {
546 [MV88E6XXX_PORT_STS_CMODE_MII_PHY] = PHY_INTERFACE_MODE_REVMII,
547 [MV88E6XXX_PORT_STS_CMODE_MII] = PHY_INTERFACE_MODE_MII,
548 [MV88E6XXX_PORT_STS_CMODE_GMII] = PHY_INTERFACE_MODE_GMII,
549 [MV88E6XXX_PORT_STS_CMODE_RMII_PHY] = PHY_INTERFACE_MODE_REVRMII,
550 [MV88E6XXX_PORT_STS_CMODE_RMII] = PHY_INTERFACE_MODE_RMII,
551 [MV88E6XXX_PORT_STS_CMODE_100BASEX] = PHY_INTERFACE_MODE_100BASEX,
552 [MV88E6XXX_PORT_STS_CMODE_1000BASEX] = PHY_INTERFACE_MODE_1000BASEX,
553 [MV88E6XXX_PORT_STS_CMODE_SGMII] = PHY_INTERFACE_MODE_SGMII,
554 /* higher interface modes are not needed here, since ports supporting
555 * them are writable, and so the supported interfaces are filled in the
556 * corresponding .phylink_set_interfaces() implementation below
560 static void mv88e6xxx_translate_cmode(u8 cmode, unsigned long *supported)
562 if (cmode < ARRAY_SIZE(mv88e6xxx_phy_interface_modes) &&
563 mv88e6xxx_phy_interface_modes[cmode])
564 __set_bit(mv88e6xxx_phy_interface_modes[cmode], supported);
565 else if (cmode == MV88E6XXX_PORT_STS_CMODE_RGMII)
566 phy_interface_set_rgmii(supported);
569 static void mv88e6250_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
570 struct phylink_config *config)
572 unsigned long *supported = config->supported_interfaces;
574 /* Translate the default cmode */
575 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
577 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100;
580 static int mv88e6352_get_port4_serdes_cmode(struct mv88e6xxx_chip *chip)
585 err = mv88e6xxx_port_read(chip, 4, MV88E6XXX_PORT_STS, ®);
589 /* If PHY_DETECT is zero, then we are not in auto-media mode */
590 if (!(reg & MV88E6XXX_PORT_STS_PHY_DETECT))
593 val = reg & ~MV88E6XXX_PORT_STS_PHY_DETECT;
594 err = mv88e6xxx_port_write(chip, 4, MV88E6XXX_PORT_STS, val);
598 err = mv88e6xxx_port_read(chip, 4, MV88E6XXX_PORT_STS, &val);
602 /* Restore PHY_DETECT value */
603 err = mv88e6xxx_port_write(chip, 4, MV88E6XXX_PORT_STS, reg);
607 return val & MV88E6XXX_PORT_STS_CMODE_MASK;
610 static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
611 struct phylink_config *config)
613 unsigned long *supported = config->supported_interfaces;
616 /* Translate the default cmode */
617 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
619 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
622 /* Port 4 supports automedia if the serdes is associated with it. */
624 err = mv88e6352_g2_scratch_port_has_serdes(chip, port);
626 dev_err(chip->dev, "p%d: failed to read scratch\n",
631 cmode = mv88e6352_get_port4_serdes_cmode(chip);
633 dev_err(chip->dev, "p%d: failed to read serdes cmode\n",
636 mv88e6xxx_translate_cmode(cmode, supported);
640 static void mv88e6341_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
641 struct phylink_config *config)
643 unsigned long *supported = config->supported_interfaces;
645 /* Translate the default cmode */
646 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
648 /* No ethtool bits for 200Mbps */
649 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
652 /* The C_Mode field is programmable on port 5 */
654 __set_bit(PHY_INTERFACE_MODE_SGMII, supported);
655 __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported);
656 __set_bit(PHY_INTERFACE_MODE_2500BASEX, supported);
658 config->mac_capabilities |= MAC_2500FD;
662 static void mv88e6390_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
663 struct phylink_config *config)
665 unsigned long *supported = config->supported_interfaces;
667 /* Translate the default cmode */
668 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
670 /* No ethtool bits for 200Mbps */
671 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
674 /* The C_Mode field is programmable on ports 9 and 10 */
675 if (port == 9 || port == 10) {
676 __set_bit(PHY_INTERFACE_MODE_SGMII, supported);
677 __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported);
678 __set_bit(PHY_INTERFACE_MODE_2500BASEX, supported);
680 config->mac_capabilities |= MAC_2500FD;
684 static void mv88e6390x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
685 struct phylink_config *config)
687 unsigned long *supported = config->supported_interfaces;
689 mv88e6390_phylink_get_caps(chip, port, config);
691 /* For the 6x90X, ports 2-7 can be in automedia mode.
692 * (Note that 6x90 doesn't support RXAUI nor XAUI).
694 * Port 2 can also support 1000BASE-X in automedia mode if port 9 is
695 * configured for 1000BASE-X, SGMII or 2500BASE-X.
696 * Port 3-4 can also support 1000BASE-X in automedia mode if port 9 is
697 * configured for RXAUI, 1000BASE-X, SGMII or 2500BASE-X.
699 * Port 5 can also support 1000BASE-X in automedia mode if port 10 is
700 * configured for 1000BASE-X, SGMII or 2500BASE-X.
701 * Port 6-7 can also support 1000BASE-X in automedia mode if port 10 is
702 * configured for RXAUI, 1000BASE-X, SGMII or 2500BASE-X.
704 * For now, be permissive (as the old code was) and allow 1000BASE-X
707 if (port >= 2 && port <= 7)
708 __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported);
710 /* The C_Mode field can also be programmed for 10G speeds */
711 if (port == 9 || port == 10) {
712 __set_bit(PHY_INTERFACE_MODE_XAUI, supported);
713 __set_bit(PHY_INTERFACE_MODE_RXAUI, supported);
715 config->mac_capabilities |= MAC_10000FD;
719 static void mv88e6393x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
720 struct phylink_config *config)
722 unsigned long *supported = config->supported_interfaces;
724 chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X;
726 chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6361;
728 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported);
730 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 |
733 /* The C_Mode field can be programmed for ports 0, 9 and 10 */
734 if (port == 0 || port == 9 || port == 10) {
735 __set_bit(PHY_INTERFACE_MODE_SGMII, supported);
736 __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported);
738 /* 6191X supports >1G modes only on port 10 */
739 if (!is_6191x || port == 10) {
740 __set_bit(PHY_INTERFACE_MODE_2500BASEX, supported);
741 config->mac_capabilities |= MAC_2500FD;
743 /* 6361 only supports up to 2500BaseX */
745 __set_bit(PHY_INTERFACE_MODE_5GBASER, supported);
746 __set_bit(PHY_INTERFACE_MODE_10GBASER, supported);
747 __set_bit(PHY_INTERFACE_MODE_USXGMII, supported);
748 config->mac_capabilities |= MAC_5000FD |
755 __set_bit(PHY_INTERFACE_MODE_RMII, supported);
756 __set_bit(PHY_INTERFACE_MODE_RGMII, supported);
757 __set_bit(PHY_INTERFACE_MODE_RGMII_ID, supported);
758 __set_bit(PHY_INTERFACE_MODE_RGMII_RXID, supported);
759 __set_bit(PHY_INTERFACE_MODE_RGMII_TXID, supported);
763 static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,
764 struct phylink_config *config)
766 struct mv88e6xxx_chip *chip = ds->priv;
768 mv88e6xxx_reg_lock(chip);
769 chip->info->ops->phylink_get_caps(chip, port, config);
770 mv88e6xxx_reg_unlock(chip);
772 if (mv88e6xxx_phy_is_internal(chip, port)) {
773 __set_bit(PHY_INTERFACE_MODE_INTERNAL,
774 config->supported_interfaces);
775 /* Internal ports with no phy-mode need GMII for PHYLIB */
776 __set_bit(PHY_INTERFACE_MODE_GMII,
777 config->supported_interfaces);
781 static struct phylink_pcs *mv88e6xxx_mac_select_pcs(struct dsa_switch *ds,
783 phy_interface_t interface)
785 struct mv88e6xxx_chip *chip = ds->priv;
786 struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
788 if (chip->info->ops->pcs_ops)
789 pcs = chip->info->ops->pcs_ops->pcs_select(chip, port,
795 static int mv88e6xxx_mac_prepare(struct dsa_switch *ds, int port,
796 unsigned int mode, phy_interface_t interface)
798 struct mv88e6xxx_chip *chip = ds->priv;
801 /* In inband mode, the link may come up at any time while the link
802 * is not forced down. Force the link down while we reconfigure the
805 if (mode == MLO_AN_INBAND &&
806 chip->ports[port].interface != interface &&
807 chip->info->ops->port_set_link) {
808 mv88e6xxx_reg_lock(chip);
809 err = chip->info->ops->port_set_link(chip, port,
811 mv88e6xxx_reg_unlock(chip);
817 static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
819 const struct phylink_link_state *state)
821 struct mv88e6xxx_chip *chip = ds->priv;
824 mv88e6xxx_reg_lock(chip);
826 if (mode != MLO_AN_PHY || !mv88e6xxx_phy_is_internal(chip, port)) {
827 err = mv88e6xxx_port_config_interface(chip, port,
829 if (err && err != -EOPNOTSUPP)
834 mv88e6xxx_reg_unlock(chip);
836 if (err && err != -EOPNOTSUPP)
837 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
840 static int mv88e6xxx_mac_finish(struct dsa_switch *ds, int port,
841 unsigned int mode, phy_interface_t interface)
843 struct mv88e6xxx_chip *chip = ds->priv;
846 /* Undo the forced down state above after completing configuration
847 * irrespective of its state on entry, which allows the link to come
848 * up in the in-band case where there is no separate SERDES. Also
849 * ensure that the link can come up if the PPU is in use and we are
850 * in PHY mode (we treat the PPU as an effective in-band mechanism.)
852 mv88e6xxx_reg_lock(chip);
854 if (chip->info->ops->port_set_link &&
855 ((mode == MLO_AN_INBAND &&
856 chip->ports[port].interface != interface) ||
857 (mode == MLO_AN_PHY && mv88e6xxx_port_ppu_updates(chip, port))))
858 err = chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
860 mv88e6xxx_reg_unlock(chip);
862 chip->ports[port].interface = interface;
867 static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
869 phy_interface_t interface)
871 struct mv88e6xxx_chip *chip = ds->priv;
872 const struct mv88e6xxx_ops *ops;
875 ops = chip->info->ops;
877 mv88e6xxx_reg_lock(chip);
878 /* Force the link down if we know the port may not be automatically
879 * updated by the switch or if we are using fixed-link mode.
881 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
882 mode == MLO_AN_FIXED) && ops->port_sync_link)
883 err = ops->port_sync_link(chip, port, mode, false);
885 if (!err && ops->port_set_speed_duplex)
886 err = ops->port_set_speed_duplex(chip, port, SPEED_UNFORCED,
888 mv88e6xxx_reg_unlock(chip);
892 "p%d: failed to force MAC link down\n", port);
895 static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
896 unsigned int mode, phy_interface_t interface,
897 struct phy_device *phydev,
898 int speed, int duplex,
899 bool tx_pause, bool rx_pause)
901 struct mv88e6xxx_chip *chip = ds->priv;
902 const struct mv88e6xxx_ops *ops;
905 ops = chip->info->ops;
907 mv88e6xxx_reg_lock(chip);
908 /* Configure and force the link up if we know that the port may not
909 * automatically updated by the switch or if we are using fixed-link
912 if (!mv88e6xxx_port_ppu_updates(chip, port) ||
913 mode == MLO_AN_FIXED) {
914 if (ops->port_set_speed_duplex) {
915 err = ops->port_set_speed_duplex(chip, port,
917 if (err && err != -EOPNOTSUPP)
921 if (ops->port_sync_link)
922 err = ops->port_sync_link(chip, port, mode, true);
925 mv88e6xxx_reg_unlock(chip);
927 if (err && err != -EOPNOTSUPP)
929 "p%d: failed to configure MAC link up\n", port);
932 static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
934 if (!chip->info->ops->stats_snapshot)
937 return chip->info->ops->stats_snapshot(chip, port);
940 static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
941 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
942 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
943 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
944 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
945 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
946 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
947 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
948 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
949 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
950 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
951 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
952 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
953 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
954 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
955 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
956 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
957 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
958 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
959 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
960 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
961 { "single", 4, 0x14, STATS_TYPE_BANK0, },
962 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
963 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
964 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
965 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
966 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
967 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
968 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
969 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
970 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
971 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
972 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
973 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
974 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
975 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
976 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
977 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
978 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
979 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
980 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
981 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
982 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
983 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
984 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
985 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
986 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
987 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
988 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
989 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
990 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
991 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
992 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
993 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
994 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
995 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
996 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
997 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
998 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
999 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
1002 static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
1003 struct mv88e6xxx_hw_stat *s,
1004 int port, u16 bank1_select,
1014 case STATS_TYPE_PORT:
1015 err = mv88e6xxx_port_read(chip, port, s->reg, ®);
1021 err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®);
1024 low |= ((u32)reg) << 16;
1027 case STATS_TYPE_BANK1:
1030 case STATS_TYPE_BANK0:
1031 reg |= s->reg | histogram;
1032 mv88e6xxx_g1_stats_read(chip, reg, &low);
1034 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
1039 value = (((u64)high) << 32) | low;
1043 static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
1044 uint8_t *data, int types)
1046 struct mv88e6xxx_hw_stat *stat;
1049 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1050 stat = &mv88e6xxx_hw_stats[i];
1051 if (stat->type & types) {
1052 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
1061 static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
1064 return mv88e6xxx_stats_get_strings(chip, data,
1065 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
1068 static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
1071 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
1074 static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
1077 return mv88e6xxx_stats_get_strings(chip, data,
1078 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
1081 static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
1082 "atu_member_violation",
1083 "atu_miss_violation",
1084 "atu_full_violation",
1085 "vtu_member_violation",
1086 "vtu_miss_violation",
1089 static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
1093 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
1094 strscpy(data + i * ETH_GSTRING_LEN,
1095 mv88e6xxx_atu_vtu_stats_strings[i],
1099 static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
1100 u32 stringset, uint8_t *data)
1102 struct mv88e6xxx_chip *chip = ds->priv;
1105 if (stringset != ETH_SS_STATS)
1108 mv88e6xxx_reg_lock(chip);
1110 if (chip->info->ops->stats_get_strings)
1111 count = chip->info->ops->stats_get_strings(chip, data);
1113 if (chip->info->ops->serdes_get_strings) {
1114 data += count * ETH_GSTRING_LEN;
1115 count = chip->info->ops->serdes_get_strings(chip, port, data);
1118 data += count * ETH_GSTRING_LEN;
1119 mv88e6xxx_atu_vtu_get_strings(data);
1121 mv88e6xxx_reg_unlock(chip);
1124 static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1127 struct mv88e6xxx_hw_stat *stat;
1130 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1131 stat = &mv88e6xxx_hw_stats[i];
1132 if (stat->type & types)
1138 static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1140 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1144 static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1146 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
1149 static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1151 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1155 static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
1157 struct mv88e6xxx_chip *chip = ds->priv;
1158 int serdes_count = 0;
1161 if (sset != ETH_SS_STATS)
1164 mv88e6xxx_reg_lock(chip);
1165 if (chip->info->ops->stats_get_sset_count)
1166 count = chip->info->ops->stats_get_sset_count(chip);
1170 if (chip->info->ops->serdes_get_sset_count)
1171 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1173 if (serdes_count < 0) {
1174 count = serdes_count;
1177 count += serdes_count;
1178 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1181 mv88e6xxx_reg_unlock(chip);
1186 static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1187 uint64_t *data, int types,
1188 u16 bank1_select, u16 histogram)
1190 struct mv88e6xxx_hw_stat *stat;
1193 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1194 stat = &mv88e6xxx_hw_stats[i];
1195 if (stat->type & types) {
1196 mv88e6xxx_reg_lock(chip);
1197 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1200 mv88e6xxx_reg_unlock(chip);
1208 static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1211 return mv88e6xxx_stats_get_stats(chip, port, data,
1212 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
1213 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1216 static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1219 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1220 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1223 static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1226 return mv88e6xxx_stats_get_stats(chip, port, data,
1227 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
1228 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1229 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1232 static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1235 return mv88e6xxx_stats_get_stats(chip, port, data,
1236 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
1237 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1241 static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1244 *data++ = chip->ports[port].atu_member_violation;
1245 *data++ = chip->ports[port].atu_miss_violation;
1246 *data++ = chip->ports[port].atu_full_violation;
1247 *data++ = chip->ports[port].vtu_member_violation;
1248 *data++ = chip->ports[port].vtu_miss_violation;
1251 static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1256 if (chip->info->ops->stats_get_stats)
1257 count = chip->info->ops->stats_get_stats(chip, port, data);
1259 mv88e6xxx_reg_lock(chip);
1260 if (chip->info->ops->serdes_get_stats) {
1262 count = chip->info->ops->serdes_get_stats(chip, port, data);
1265 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1266 mv88e6xxx_reg_unlock(chip);
1269 static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1272 struct mv88e6xxx_chip *chip = ds->priv;
1275 mv88e6xxx_reg_lock(chip);
1277 ret = mv88e6xxx_stats_snapshot(chip, port);
1278 mv88e6xxx_reg_unlock(chip);
1283 mv88e6xxx_get_stats(chip, port, data);
1287 static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
1289 struct mv88e6xxx_chip *chip = ds->priv;
1292 len = 32 * sizeof(u16);
1293 if (chip->info->ops->serdes_get_regs_len)
1294 len += chip->info->ops->serdes_get_regs_len(chip, port);
1299 static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1300 struct ethtool_regs *regs, void *_p)
1302 struct mv88e6xxx_chip *chip = ds->priv;
1308 regs->version = chip->info->prod_num;
1310 memset(p, 0xff, 32 * sizeof(u16));
1312 mv88e6xxx_reg_lock(chip);
1314 for (i = 0; i < 32; i++) {
1316 err = mv88e6xxx_port_read(chip, port, i, ®);
1321 if (chip->info->ops->serdes_get_regs)
1322 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1324 mv88e6xxx_reg_unlock(chip);
1327 static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1328 struct ethtool_eee *e)
1330 /* Nothing to do on the port's MAC */
1334 static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1335 struct ethtool_eee *e)
1337 /* Nothing to do on the port's MAC */
1341 /* Mask of the local ports allowed to receive frames from a given fabric port */
1342 static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
1344 struct dsa_switch *ds = chip->ds;
1345 struct dsa_switch_tree *dst = ds->dst;
1346 struct dsa_port *dp, *other_dp;
1350 /* dev is a physical switch */
1351 if (dev <= dst->last_switch) {
1352 list_for_each_entry(dp, &dst->ports, list) {
1353 if (dp->ds->index == dev && dp->index == port) {
1354 /* dp might be a DSA link or a user port, so it
1355 * might or might not have a bridge.
1356 * Use the "found" variable for both cases.
1362 /* dev is a virtual bridge */
1364 list_for_each_entry(dp, &dst->ports, list) {
1365 unsigned int bridge_num = dsa_port_bridge_num_get(dp);
1370 if (bridge_num + dst->last_switch != dev)
1378 /* Prevent frames from unknown switch or virtual bridge */
1382 /* Frames from DSA links and CPU ports can egress any local port */
1383 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
1384 return mv88e6xxx_port_mask(chip);
1388 /* Frames from standalone user ports can only egress on the
1391 if (!dsa_port_bridge_dev_get(dp))
1392 return BIT(dsa_switch_upstream_port(ds));
1394 /* Frames from bridged user ports can egress any local DSA
1395 * links and CPU ports, as well as any local member of their
1398 dsa_switch_for_each_port(other_dp, ds)
1399 if (other_dp->type == DSA_PORT_TYPE_CPU ||
1400 other_dp->type == DSA_PORT_TYPE_DSA ||
1401 dsa_port_bridge_same(dp, other_dp))
1402 pvlan |= BIT(other_dp->index);
1407 static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
1409 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
1411 /* prevent frames from going back out of the port they came in on */
1412 output_ports &= ~BIT(port);
1414 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
1417 static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1420 struct mv88e6xxx_chip *chip = ds->priv;
1423 mv88e6xxx_reg_lock(chip);
1424 err = mv88e6xxx_port_set_state(chip, port, state);
1425 mv88e6xxx_reg_unlock(chip);
1428 dev_err(ds->dev, "p%d: failed to update state\n", port);
1431 static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1435 if (chip->info->ops->ieee_pri_map) {
1436 err = chip->info->ops->ieee_pri_map(chip);
1441 if (chip->info->ops->ip_pri_map) {
1442 err = chip->info->ops->ip_pri_map(chip);
1450 static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1452 struct dsa_switch *ds = chip->ds;
1456 if (!chip->info->global2_addr)
1459 /* Initialize the routing port to the 32 possible target devices */
1460 for (target = 0; target < 32; target++) {
1461 port = dsa_routing_port(ds, target);
1462 if (port == ds->num_ports)
1465 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1470 if (chip->info->ops->set_cascade_port) {
1471 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1472 err = chip->info->ops->set_cascade_port(chip, port);
1477 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1484 static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1486 /* Clear all trunk masks and mapping */
1487 if (chip->info->global2_addr)
1488 return mv88e6xxx_g2_trunk_clear(chip);
1493 static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1495 if (chip->info->ops->rmu_disable)
1496 return chip->info->ops->rmu_disable(chip);
1501 static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1503 if (chip->info->ops->pot_clear)
1504 return chip->info->ops->pot_clear(chip);
1509 static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1511 if (chip->info->ops->mgmt_rsvd2cpu)
1512 return chip->info->ops->mgmt_rsvd2cpu(chip);
1517 static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1521 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1525 /* The chips that have a "learn2all" bit in Global1, ATU
1526 * Control are precisely those whose port registers have a
1527 * Message Port bit in Port Control 1 and hence implement
1528 * ->port_setup_message_port.
1530 if (chip->info->ops->port_setup_message_port) {
1531 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1536 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1539 static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1544 if (!chip->info->ops->irl_init_all)
1547 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1548 /* Disable ingress rate limiting by resetting all per port
1549 * ingress rate limit resources to their initial state.
1551 err = chip->info->ops->irl_init_all(chip, port);
1559 static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1561 if (chip->info->ops->set_switch_mac) {
1564 eth_random_addr(addr);
1566 return chip->info->ops->set_switch_mac(chip, addr);
1572 static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1574 struct dsa_switch_tree *dst = chip->ds->dst;
1575 struct dsa_switch *ds;
1576 struct dsa_port *dp;
1579 if (!mv88e6xxx_has_pvt(chip))
1582 /* Skip the local source device, which uses in-chip port VLAN */
1583 if (dev != chip->ds->index) {
1584 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
1586 ds = dsa_switch_find(dst->index, dev);
1587 dp = ds ? dsa_to_port(ds, port) : NULL;
1588 if (dp && dp->lag) {
1589 /* As the PVT is used to limit flooding of
1590 * FORWARD frames, which use the LAG ID as the
1591 * source port, we must translate dev/port to
1592 * the special "LAG device" in the PVT, using
1593 * the LAG ID (one-based) as the port number
1596 dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK;
1597 port = dsa_port_lag_id_get(dp) - 1;
1601 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1604 static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1609 if (!mv88e6xxx_has_pvt(chip))
1612 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1613 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1615 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1619 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1620 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1621 err = mv88e6xxx_pvt_map(chip, dev, port);
1630 static int mv88e6xxx_port_fast_age_fid(struct mv88e6xxx_chip *chip, int port,
1633 if (dsa_to_port(chip->ds, port)->lag)
1634 /* Hardware is incapable of fast-aging a LAG through a
1635 * regular ATU move operation. Until we have something
1636 * more fancy in place this is a no-op.
1640 return mv88e6xxx_g1_atu_remove(chip, fid, port, false);
1643 static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1645 struct mv88e6xxx_chip *chip = ds->priv;
1648 mv88e6xxx_reg_lock(chip);
1649 err = mv88e6xxx_port_fast_age_fid(chip, port, 0);
1650 mv88e6xxx_reg_unlock(chip);
1653 dev_err(chip->ds->dev, "p%d: failed to flush ATU: %d\n",
1657 static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1659 if (!mv88e6xxx_max_vid(chip))
1662 return mv88e6xxx_g1_vtu_flush(chip);
1665 static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1666 struct mv88e6xxx_vtu_entry *entry)
1670 if (!chip->info->ops->vtu_getnext)
1673 entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip);
1674 entry->valid = false;
1676 err = chip->info->ops->vtu_getnext(chip, entry);
1678 if (entry->vid != vid)
1679 entry->valid = false;
1684 int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,
1685 int (*cb)(struct mv88e6xxx_chip *chip,
1686 const struct mv88e6xxx_vtu_entry *entry,
1690 struct mv88e6xxx_vtu_entry entry = {
1691 .vid = mv88e6xxx_max_vid(chip),
1696 if (!chip->info->ops->vtu_getnext)
1700 err = chip->info->ops->vtu_getnext(chip, &entry);
1707 err = cb(chip, &entry, priv);
1710 } while (entry.vid < mv88e6xxx_max_vid(chip));
1715 static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1716 struct mv88e6xxx_vtu_entry *entry)
1718 if (!chip->info->ops->vtu_loadpurge)
1721 return chip->info->ops->vtu_loadpurge(chip, entry);
1724 static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip,
1725 const struct mv88e6xxx_vtu_entry *entry,
1728 unsigned long *fid_bitmap = _fid_bitmap;
1730 set_bit(entry->fid, fid_bitmap);
1734 int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
1736 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1738 /* Every FID has an associated VID, so walking the VTU
1739 * will discover the full set of FIDs in use.
1741 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap);
1744 static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1746 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1749 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1753 *fid = find_first_zero_bit(fid_bitmap, MV88E6XXX_N_FID);
1754 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
1757 /* Clear the database */
1758 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
1761 static int mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
1762 struct mv88e6xxx_stu_entry *entry)
1764 if (!chip->info->ops->stu_loadpurge)
1767 return chip->info->ops->stu_loadpurge(chip, entry);
1770 static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip)
1772 struct mv88e6xxx_stu_entry stu = {
1777 if (!mv88e6xxx_has_stu(chip))
1780 /* Make sure that SID 0 is always valid. This is used by VTU
1781 * entries that do not make use of the STU, e.g. when creating
1782 * a VLAN upper on a port that is also part of a VLAN
1785 return mv88e6xxx_stu_loadpurge(chip, &stu);
1788 static int mv88e6xxx_sid_get(struct mv88e6xxx_chip *chip, u8 *sid)
1790 DECLARE_BITMAP(busy, MV88E6XXX_N_SID) = { 0 };
1791 struct mv88e6xxx_mst *mst;
1795 list_for_each_entry(mst, &chip->msts, node)
1796 __set_bit(mst->stu.sid, busy);
1798 *sid = find_first_zero_bit(busy, MV88E6XXX_N_SID);
1800 return (*sid >= mv88e6xxx_max_sid(chip)) ? -ENOSPC : 0;
1803 static int mv88e6xxx_mst_put(struct mv88e6xxx_chip *chip, u8 sid)
1805 struct mv88e6xxx_mst *mst, *tmp;
1811 list_for_each_entry_safe(mst, tmp, &chip->msts, node) {
1812 if (mst->stu.sid != sid)
1815 if (!refcount_dec_and_test(&mst->refcnt))
1818 mst->stu.valid = false;
1819 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu);
1821 refcount_set(&mst->refcnt, 1);
1825 list_del(&mst->node);
1833 static int mv88e6xxx_mst_get(struct mv88e6xxx_chip *chip, struct net_device *br,
1836 struct mv88e6xxx_mst *mst;
1839 if (!mv88e6xxx_has_stu(chip)) {
1849 list_for_each_entry(mst, &chip->msts, node) {
1850 if (mst->br == br && mst->msti == msti) {
1851 refcount_inc(&mst->refcnt);
1852 *sid = mst->stu.sid;
1857 err = mv88e6xxx_sid_get(chip, sid);
1861 mst = kzalloc(sizeof(*mst), GFP_KERNEL);
1867 INIT_LIST_HEAD(&mst->node);
1868 refcount_set(&mst->refcnt, 1);
1871 mst->stu.valid = true;
1872 mst->stu.sid = *sid;
1874 /* The bridge starts out all ports in the disabled state. But
1875 * a STU state of disabled means to go by the port-global
1876 * state. So we set all user port's initial state to blocking,
1877 * to match the bridge's behavior.
1879 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
1880 mst->stu.state[i] = dsa_is_user_port(chip->ds, i) ?
1881 MV88E6XXX_PORT_CTL0_STATE_BLOCKING :
1882 MV88E6XXX_PORT_CTL0_STATE_DISABLED;
1884 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu);
1888 list_add_tail(&mst->node, &chip->msts);
1897 static int mv88e6xxx_port_mst_state_set(struct dsa_switch *ds, int port,
1898 const struct switchdev_mst_state *st)
1900 struct dsa_port *dp = dsa_to_port(ds, port);
1901 struct mv88e6xxx_chip *chip = ds->priv;
1902 struct mv88e6xxx_mst *mst;
1906 if (!mv88e6xxx_has_stu(chip))
1909 switch (st->state) {
1910 case BR_STATE_DISABLED:
1911 case BR_STATE_BLOCKING:
1912 case BR_STATE_LISTENING:
1913 state = MV88E6XXX_PORT_CTL0_STATE_BLOCKING;
1915 case BR_STATE_LEARNING:
1916 state = MV88E6XXX_PORT_CTL0_STATE_LEARNING;
1918 case BR_STATE_FORWARDING:
1919 state = MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1925 list_for_each_entry(mst, &chip->msts, node) {
1926 if (mst->br == dsa_port_bridge_dev_get(dp) &&
1927 mst->msti == st->msti) {
1928 if (mst->stu.state[port] == state)
1931 mst->stu.state[port] = state;
1932 mv88e6xxx_reg_lock(chip);
1933 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu);
1934 mv88e6xxx_reg_unlock(chip);
1942 static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1945 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
1946 struct mv88e6xxx_chip *chip = ds->priv;
1947 struct mv88e6xxx_vtu_entry vlan;
1950 /* DSA and CPU ports have to be members of multiple vlans */
1951 if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp))
1954 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
1961 dsa_switch_for_each_user_port(other_dp, ds) {
1962 struct net_device *other_br;
1964 if (vlan.member[other_dp->index] ==
1965 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1968 if (dsa_port_bridge_same(dp, other_dp))
1969 break; /* same bridge, check next VLAN */
1971 other_br = dsa_port_bridge_dev_get(other_dp);
1975 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1976 port, vlan.vid, other_dp->index, netdev_name(other_br));
1983 static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
1985 struct dsa_port *dp = dsa_to_port(chip->ds, port);
1986 struct net_device *br = dsa_port_bridge_dev_get(dp);
1987 struct mv88e6xxx_port *p = &chip->ports[port];
1988 u16 pvid = MV88E6XXX_VID_STANDALONE;
1989 bool drop_untagged = false;
1993 if (br_vlan_enabled(br)) {
1994 pvid = p->bridge_pvid.vid;
1995 drop_untagged = !p->bridge_pvid.valid;
1997 pvid = MV88E6XXX_VID_BRIDGED;
2001 err = mv88e6xxx_port_set_pvid(chip, port, pvid);
2005 return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged);
2008 static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
2009 bool vlan_filtering,
2010 struct netlink_ext_ack *extack)
2012 struct mv88e6xxx_chip *chip = ds->priv;
2013 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
2014 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
2017 if (!mv88e6xxx_max_vid(chip))
2020 mv88e6xxx_reg_lock(chip);
2022 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
2026 err = mv88e6xxx_port_commit_pvid(chip, port);
2031 mv88e6xxx_reg_unlock(chip);
2037 mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
2038 const struct switchdev_obj_port_vlan *vlan)
2040 struct mv88e6xxx_chip *chip = ds->priv;
2043 if (!mv88e6xxx_max_vid(chip))
2046 /* If the requested port doesn't belong to the same bridge as the VLAN
2047 * members, do not support it (yet) and fallback to software VLAN.
2049 mv88e6xxx_reg_lock(chip);
2050 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
2051 mv88e6xxx_reg_unlock(chip);
2056 static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
2057 const unsigned char *addr, u16 vid,
2060 struct mv88e6xxx_atu_entry entry;
2061 struct mv88e6xxx_vtu_entry vlan;
2065 /* Ports have two private address databases: one for when the port is
2066 * standalone and one for when the port is under a bridge and the
2067 * 802.1Q mode is disabled. When the port is standalone, DSA wants its
2068 * address database to remain 100% empty, so we never load an ATU entry
2069 * into a standalone port's database. Therefore, translate the null
2070 * VLAN ID into the port's database used for VLAN-unaware bridging.
2073 fid = MV88E6XXX_FID_BRIDGED;
2075 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
2079 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
2087 ether_addr_copy(entry.mac, addr);
2088 eth_addr_dec(entry.mac);
2090 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
2094 /* Initialize a fresh ATU entry if it isn't found */
2095 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
2096 memset(&entry, 0, sizeof(entry));
2097 ether_addr_copy(entry.mac, addr);
2100 /* Purge the ATU entry only if no port is using it anymore */
2102 entry.portvec &= ~BIT(port);
2106 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
2107 entry.portvec = BIT(port);
2109 entry.portvec |= BIT(port);
2111 entry.state = state;
2114 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
2117 static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
2118 const struct mv88e6xxx_policy *policy)
2120 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
2121 enum mv88e6xxx_policy_action action = policy->action;
2122 const u8 *addr = policy->addr;
2123 u16 vid = policy->vid;
2128 if (!chip->info->ops->port_set_policy)
2132 case MV88E6XXX_POLICY_MAPPING_DA:
2133 case MV88E6XXX_POLICY_MAPPING_SA:
2134 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
2135 state = 0; /* Dissociate the port and address */
2136 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
2137 is_multicast_ether_addr(addr))
2138 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
2139 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
2140 is_unicast_ether_addr(addr))
2141 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
2145 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2154 /* Skip the port's policy clearing if the mapping is still in use */
2155 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
2156 idr_for_each_entry(&chip->policies, policy, id)
2157 if (policy->port == port &&
2158 policy->mapping == mapping &&
2159 policy->action != action)
2162 return chip->info->ops->port_set_policy(chip, port, mapping, action);
2165 static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
2166 struct ethtool_rx_flow_spec *fs)
2168 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
2169 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
2170 enum mv88e6xxx_policy_mapping mapping;
2171 enum mv88e6xxx_policy_action action;
2172 struct mv88e6xxx_policy *policy;
2178 if (fs->location != RX_CLS_LOC_ANY)
2181 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
2182 action = MV88E6XXX_POLICY_ACTION_DISCARD;
2186 switch (fs->flow_type & ~FLOW_EXT) {
2188 if (!is_zero_ether_addr(mac_mask->h_dest) &&
2189 is_zero_ether_addr(mac_mask->h_source)) {
2190 mapping = MV88E6XXX_POLICY_MAPPING_DA;
2191 addr = mac_entry->h_dest;
2192 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
2193 !is_zero_ether_addr(mac_mask->h_source)) {
2194 mapping = MV88E6XXX_POLICY_MAPPING_SA;
2195 addr = mac_entry->h_source;
2197 /* Cannot support DA and SA mapping in the same rule */
2205 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
2206 if (fs->m_ext.vlan_tci != htons(0xffff))
2208 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
2211 idr_for_each_entry(&chip->policies, policy, id) {
2212 if (policy->port == port && policy->mapping == mapping &&
2213 policy->action == action && policy->vid == vid &&
2214 ether_addr_equal(policy->addr, addr))
2218 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
2223 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
2226 devm_kfree(chip->dev, policy);
2230 memcpy(&policy->fs, fs, sizeof(*fs));
2231 ether_addr_copy(policy->addr, addr);
2232 policy->mapping = mapping;
2233 policy->action = action;
2234 policy->port = port;
2237 err = mv88e6xxx_policy_apply(chip, port, policy);
2239 idr_remove(&chip->policies, fs->location);
2240 devm_kfree(chip->dev, policy);
2247 static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
2248 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
2250 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2251 struct mv88e6xxx_chip *chip = ds->priv;
2252 struct mv88e6xxx_policy *policy;
2256 mv88e6xxx_reg_lock(chip);
2258 switch (rxnfc->cmd) {
2259 case ETHTOOL_GRXCLSRLCNT:
2261 rxnfc->data |= RX_CLS_LOC_SPECIAL;
2262 rxnfc->rule_cnt = 0;
2263 idr_for_each_entry(&chip->policies, policy, id)
2264 if (policy->port == port)
2268 case ETHTOOL_GRXCLSRULE:
2270 policy = idr_find(&chip->policies, fs->location);
2272 memcpy(fs, &policy->fs, sizeof(*fs));
2276 case ETHTOOL_GRXCLSRLALL:
2278 rxnfc->rule_cnt = 0;
2279 idr_for_each_entry(&chip->policies, policy, id)
2280 if (policy->port == port)
2281 rule_locs[rxnfc->rule_cnt++] = id;
2289 mv88e6xxx_reg_unlock(chip);
2294 static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
2295 struct ethtool_rxnfc *rxnfc)
2297 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2298 struct mv88e6xxx_chip *chip = ds->priv;
2299 struct mv88e6xxx_policy *policy;
2302 mv88e6xxx_reg_lock(chip);
2304 switch (rxnfc->cmd) {
2305 case ETHTOOL_SRXCLSRLINS:
2306 err = mv88e6xxx_policy_insert(chip, port, fs);
2308 case ETHTOOL_SRXCLSRLDEL:
2310 policy = idr_remove(&chip->policies, fs->location);
2312 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
2313 err = mv88e6xxx_policy_apply(chip, port, policy);
2314 devm_kfree(chip->dev, policy);
2322 mv88e6xxx_reg_unlock(chip);
2327 static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
2330 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
2331 u8 broadcast[ETH_ALEN];
2333 eth_broadcast_addr(broadcast);
2335 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
2338 static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
2343 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2344 struct dsa_port *dp = dsa_to_port(chip->ds, port);
2345 struct net_device *brport;
2347 if (dsa_is_unused_port(chip->ds, port))
2350 brport = dsa_port_to_bridge_port(dp);
2351 if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD))
2352 /* Skip bridged user ports where broadcast
2353 * flooding is disabled.
2357 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
2365 struct mv88e6xxx_port_broadcast_sync_ctx {
2371 mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip,
2372 const struct mv88e6xxx_vtu_entry *vlan,
2375 struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx;
2376 u8 broadcast[ETH_ALEN];
2380 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
2382 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED;
2384 eth_broadcast_addr(broadcast);
2386 return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast,
2390 static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port,
2393 struct mv88e6xxx_port_broadcast_sync_ctx ctx = {
2397 struct mv88e6xxx_vtu_entry vid0 = {
2402 /* Update the port's private database... */
2403 err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx);
2407 /* ...and the database for all VLANs. */
2408 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan,
2412 static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
2413 u16 vid, u8 member, bool warn)
2415 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
2416 struct mv88e6xxx_vtu_entry vlan;
2419 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
2424 memset(&vlan, 0, sizeof(vlan));
2426 if (vid == MV88E6XXX_VID_STANDALONE)
2429 err = mv88e6xxx_atu_new(chip, &vlan.fid);
2433 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
2435 vlan.member[i] = member;
2437 vlan.member[i] = non_member;
2442 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2446 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
2449 } else if (vlan.member[port] != member) {
2450 vlan.member[port] = member;
2452 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2456 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
2463 static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
2464 const struct switchdev_obj_port_vlan *vlan,
2465 struct netlink_ext_ack *extack)
2467 struct mv88e6xxx_chip *chip = ds->priv;
2468 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
2469 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
2470 struct mv88e6xxx_port *p = &chip->ports[port];
2478 err = mv88e6xxx_port_vlan_prepare(ds, port, vlan);
2482 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
2483 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
2485 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
2487 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
2489 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
2490 * and then the CPU port. Do not warn for duplicates for the CPU port.
2492 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2494 mv88e6xxx_reg_lock(chip);
2496 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn);
2498 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2499 vlan->vid, untagged ? 'u' : 't');
2504 p->bridge_pvid.vid = vlan->vid;
2505 p->bridge_pvid.valid = true;
2507 err = mv88e6xxx_port_commit_pvid(chip, port);
2510 } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) {
2511 /* The old pvid was reinstalled as a non-pvid VLAN */
2512 p->bridge_pvid.valid = false;
2514 err = mv88e6xxx_port_commit_pvid(chip, port);
2520 mv88e6xxx_reg_unlock(chip);
2525 static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2528 struct mv88e6xxx_vtu_entry vlan;
2534 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
2538 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2539 * tell switchdev that this VLAN is likely handled in software.
2542 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
2545 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
2547 /* keep the VLAN unless all ports are excluded */
2549 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
2550 if (vlan.member[i] !=
2551 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
2557 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2562 err = mv88e6xxx_mst_put(chip, vlan.sid);
2567 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
2570 static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2571 const struct switchdev_obj_port_vlan *vlan)
2573 struct mv88e6xxx_chip *chip = ds->priv;
2574 struct mv88e6xxx_port *p = &chip->ports[port];
2578 if (!mv88e6xxx_max_vid(chip))
2581 /* The ATU removal procedure needs the FID to be mapped in the VTU,
2582 * but FDB deletion runs concurrently with VLAN deletion. Flush the DSA
2583 * switchdev workqueue to ensure that all FDB entries are deleted
2584 * before we remove the VLAN.
2586 dsa_flush_workqueue();
2588 mv88e6xxx_reg_lock(chip);
2590 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
2594 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2598 if (vlan->vid == pvid) {
2599 p->bridge_pvid.valid = false;
2601 err = mv88e6xxx_port_commit_pvid(chip, port);
2607 mv88e6xxx_reg_unlock(chip);
2612 static int mv88e6xxx_port_vlan_fast_age(struct dsa_switch *ds, int port, u16 vid)
2614 struct mv88e6xxx_chip *chip = ds->priv;
2615 struct mv88e6xxx_vtu_entry vlan;
2618 mv88e6xxx_reg_lock(chip);
2620 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
2624 err = mv88e6xxx_port_fast_age_fid(chip, port, vlan.fid);
2627 mv88e6xxx_reg_unlock(chip);
2632 static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds,
2633 struct dsa_bridge bridge,
2634 const struct switchdev_vlan_msti *msti)
2636 struct mv88e6xxx_chip *chip = ds->priv;
2637 struct mv88e6xxx_vtu_entry vlan;
2638 u8 old_sid, new_sid;
2641 if (!mv88e6xxx_has_stu(chip))
2644 mv88e6xxx_reg_lock(chip);
2646 err = mv88e6xxx_vtu_get(chip, msti->vid, &vlan);
2657 err = mv88e6xxx_mst_get(chip, bridge.dev, msti->msti, &new_sid);
2661 if (new_sid != old_sid) {
2664 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2666 mv88e6xxx_mst_put(chip, new_sid);
2671 err = mv88e6xxx_mst_put(chip, old_sid);
2674 mv88e6xxx_reg_unlock(chip);
2678 static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2679 const unsigned char *addr, u16 vid,
2682 struct mv88e6xxx_chip *chip = ds->priv;
2685 mv88e6xxx_reg_lock(chip);
2686 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2687 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2688 mv88e6xxx_reg_unlock(chip);
2693 static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
2694 const unsigned char *addr, u16 vid,
2697 struct mv88e6xxx_chip *chip = ds->priv;
2700 mv88e6xxx_reg_lock(chip);
2701 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
2702 mv88e6xxx_reg_unlock(chip);
2707 static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2708 u16 fid, u16 vid, int port,
2709 dsa_fdb_dump_cb_t *cb, void *data)
2711 struct mv88e6xxx_atu_entry addr;
2716 eth_broadcast_addr(addr.mac);
2719 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
2726 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
2729 if (!is_unicast_ether_addr(addr.mac))
2732 is_static = (addr.state ==
2733 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2734 err = cb(addr.mac, vid, is_static, data);
2737 } while (!is_broadcast_ether_addr(addr.mac));
2742 struct mv88e6xxx_port_db_dump_vlan_ctx {
2744 dsa_fdb_dump_cb_t *cb;
2748 static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip,
2749 const struct mv88e6xxx_vtu_entry *entry,
2752 struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data;
2754 return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid,
2755 ctx->port, ctx->cb, ctx->data);
2758 static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
2759 dsa_fdb_dump_cb_t *cb, void *data)
2761 struct mv88e6xxx_port_db_dump_vlan_ctx ctx = {
2769 /* Dump port's default Filtering Information Database (VLAN ID 0) */
2770 err = mv88e6xxx_port_get_fid(chip, port, &fid);
2774 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
2778 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx);
2781 static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
2782 dsa_fdb_dump_cb_t *cb, void *data)
2784 struct mv88e6xxx_chip *chip = ds->priv;
2787 mv88e6xxx_reg_lock(chip);
2788 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
2789 mv88e6xxx_reg_unlock(chip);
2794 static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2795 struct dsa_bridge bridge)
2797 struct dsa_switch *ds = chip->ds;
2798 struct dsa_switch_tree *dst = ds->dst;
2799 struct dsa_port *dp;
2802 list_for_each_entry(dp, &dst->ports, list) {
2803 if (dsa_port_offloads_bridge(dp, &bridge)) {
2805 /* This is a local bridge group member,
2806 * remap its Port VLAN Map.
2808 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2812 /* This is an external bridge group member,
2813 * remap its cross-chip Port VLAN Table entry.
2815 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2826 /* Treat the software bridge as a virtual single-port switch behind the
2827 * CPU and map in the PVT. First dst->last_switch elements are taken by
2828 * physical switches, so start from beyond that range.
2830 static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds,
2831 unsigned int bridge_num)
2833 u8 dev = bridge_num + ds->dst->last_switch;
2834 struct mv88e6xxx_chip *chip = ds->priv;
2836 return mv88e6xxx_pvt_map(chip, dev, 0);
2839 static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
2840 struct dsa_bridge bridge,
2841 bool *tx_fwd_offload,
2842 struct netlink_ext_ack *extack)
2844 struct mv88e6xxx_chip *chip = ds->priv;
2847 mv88e6xxx_reg_lock(chip);
2849 err = mv88e6xxx_bridge_map(chip, bridge);
2853 err = mv88e6xxx_port_set_map_da(chip, port, true);
2857 err = mv88e6xxx_port_commit_pvid(chip, port);
2861 if (mv88e6xxx_has_pvt(chip)) {
2862 err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num);
2866 *tx_fwd_offload = true;
2870 mv88e6xxx_reg_unlock(chip);
2875 static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2876 struct dsa_bridge bridge)
2878 struct mv88e6xxx_chip *chip = ds->priv;
2881 mv88e6xxx_reg_lock(chip);
2883 if (bridge.tx_fwd_offload &&
2884 mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num))
2885 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2887 if (mv88e6xxx_bridge_map(chip, bridge) ||
2888 mv88e6xxx_port_vlan_map(chip, port))
2889 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
2891 err = mv88e6xxx_port_set_map_da(chip, port, false);
2894 "port %d failed to restore map-DA: %pe\n",
2895 port, ERR_PTR(err));
2897 err = mv88e6xxx_port_commit_pvid(chip, port);
2900 "port %d failed to restore standalone pvid: %pe\n",
2901 port, ERR_PTR(err));
2903 mv88e6xxx_reg_unlock(chip);
2906 static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2907 int tree_index, int sw_index,
2908 int port, struct dsa_bridge bridge,
2909 struct netlink_ext_ack *extack)
2911 struct mv88e6xxx_chip *chip = ds->priv;
2914 if (tree_index != ds->dst->index)
2917 mv88e6xxx_reg_lock(chip);
2918 err = mv88e6xxx_pvt_map(chip, sw_index, port);
2919 err = err ? : mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num);
2920 mv88e6xxx_reg_unlock(chip);
2925 static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2926 int tree_index, int sw_index,
2927 int port, struct dsa_bridge bridge)
2929 struct mv88e6xxx_chip *chip = ds->priv;
2931 if (tree_index != ds->dst->index)
2934 mv88e6xxx_reg_lock(chip);
2935 if (mv88e6xxx_pvt_map(chip, sw_index, port) ||
2936 mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num))
2937 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2938 mv88e6xxx_reg_unlock(chip);
2941 static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2943 if (chip->info->ops->reset)
2944 return chip->info->ops->reset(chip);
2949 static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2951 struct gpio_desc *gpiod = chip->reset;
2953 /* If there is a GPIO connected to the reset pin, toggle it */
2955 /* If the switch has just been reset and not yet completed
2956 * loading EEPROM, the reset may interrupt the I2C transaction
2957 * mid-byte, causing the first EEPROM read after the reset
2958 * from the wrong location resulting in the switch booting
2959 * to wrong mode and inoperable.
2961 mv88e6xxx_g1_wait_eeprom_done(chip);
2963 gpiod_set_value_cansleep(gpiod, 1);
2964 usleep_range(10000, 20000);
2965 gpiod_set_value_cansleep(gpiod, 0);
2966 usleep_range(10000, 20000);
2968 mv88e6xxx_g1_wait_eeprom_done(chip);
2972 static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2976 /* Set all ports to the Disabled state */
2977 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2978 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
2983 /* Wait for transmit queues to drain,
2984 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2986 usleep_range(2000, 4000);
2991 static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
2995 err = mv88e6xxx_disable_ports(chip);
2999 mv88e6xxx_hardware_reset(chip);
3001 return mv88e6xxx_software_reset(chip);
3004 static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
3005 enum mv88e6xxx_frame_mode frame,
3006 enum mv88e6xxx_egress_mode egress, u16 etype)
3010 if (!chip->info->ops->port_set_frame_mode)
3013 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
3017 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
3021 if (chip->info->ops->port_set_ether_type)
3022 return chip->info->ops->port_set_ether_type(chip, port, etype);
3027 static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
3029 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
3030 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
3031 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
3034 static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
3036 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
3037 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
3038 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
3041 static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
3043 return mv88e6xxx_set_port_mode(chip, port,
3044 MV88E6XXX_FRAME_MODE_ETHERTYPE,
3045 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
3049 static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
3051 if (dsa_is_dsa_port(chip->ds, port))
3052 return mv88e6xxx_set_port_mode_dsa(chip, port);
3054 if (dsa_is_user_port(chip->ds, port))
3055 return mv88e6xxx_set_port_mode_normal(chip, port);
3057 /* Setup CPU port mode depending on its supported tag format */
3058 if (chip->tag_protocol == DSA_TAG_PROTO_DSA)
3059 return mv88e6xxx_set_port_mode_dsa(chip, port);
3061 if (chip->tag_protocol == DSA_TAG_PROTO_EDSA)
3062 return mv88e6xxx_set_port_mode_edsa(chip, port);
3067 static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
3069 bool message = dsa_is_dsa_port(chip->ds, port);
3071 return mv88e6xxx_port_set_message_port(chip, port, message);
3074 static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
3078 if (chip->info->ops->port_set_ucast_flood) {
3079 err = chip->info->ops->port_set_ucast_flood(chip, port, true);
3083 if (chip->info->ops->port_set_mcast_flood) {
3084 err = chip->info->ops->port_set_mcast_flood(chip, port, true);
3092 static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
3093 enum mv88e6xxx_egress_direction direction,
3098 if (!chip->info->ops->set_egress_port)
3101 err = chip->info->ops->set_egress_port(chip, direction, port);
3105 if (direction == MV88E6XXX_EGRESS_DIR_INGRESS)
3106 chip->ingress_dest_port = port;
3108 chip->egress_dest_port = port;
3113 static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
3115 struct dsa_switch *ds = chip->ds;
3119 upstream_port = dsa_upstream_port(ds, port);
3120 if (chip->info->ops->port_set_upstream_port) {
3121 err = chip->info->ops->port_set_upstream_port(chip, port,
3127 if (port == upstream_port) {
3128 if (chip->info->ops->set_cpu_port) {
3129 err = chip->info->ops->set_cpu_port(chip,
3135 err = mv88e6xxx_set_egress_port(chip,
3136 MV88E6XXX_EGRESS_DIR_INGRESS,
3138 if (err && err != -EOPNOTSUPP)
3141 err = mv88e6xxx_set_egress_port(chip,
3142 MV88E6XXX_EGRESS_DIR_EGRESS,
3144 if (err && err != -EOPNOTSUPP)
3151 static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
3153 struct device_node *phy_handle = NULL;
3154 struct dsa_switch *ds = chip->ds;
3155 struct dsa_port *dp;
3160 chip->ports[port].chip = chip;
3161 chip->ports[port].port = port;
3163 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
3164 SPEED_UNFORCED, DUPLEX_UNFORCED,
3165 PAUSE_ON, PHY_INTERFACE_MODE_NA);
3169 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
3170 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
3171 * tunneling, determine priority by looking at 802.1p and IP
3172 * priority fields (IP prio has precedence), and set STP state
3175 * If this is the CPU link, use DSA or EDSA tagging depending
3176 * on which tagging mode was configured.
3178 * If this is a link to another switch, use DSA tagging mode.
3180 * If this is the upstream port for this switch, enable
3181 * forwarding of unknown unicasts and multicasts.
3183 reg = MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
3184 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
3185 /* Forward any IPv4 IGMP or IPv6 MLD frames received
3186 * by a USER port to the CPU port to allow snooping.
3188 if (dsa_is_user_port(ds, port))
3189 reg |= MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP;
3191 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
3195 err = mv88e6xxx_setup_port_mode(chip, port);
3199 err = mv88e6xxx_setup_egress_floods(chip, port);
3203 /* Port Control 2: don't force a good FCS, set the MTU size to
3204 * 10222 bytes, disable 802.1q tags checking, don't discard
3205 * tagged or untagged frames on this port, skip destination
3206 * address lookup on user ports, disable ARP mirroring and don't
3207 * send a copy of all transmitted/received frames on this port
3210 err = mv88e6xxx_port_set_map_da(chip, port, !dsa_is_user_port(ds, port));
3214 err = mv88e6xxx_setup_upstream_port(chip, port);
3218 /* On chips that support it, set all downstream DSA ports'
3219 * VLAN policy to TRAP. In combination with loading
3220 * MV88E6XXX_VID_STANDALONE as a policy entry in the VTU, this
3221 * provides a better isolation barrier between standalone
3222 * ports, as the ATU is bypassed on any intermediate switches
3223 * between the incoming port and the CPU.
3225 if (dsa_is_downstream_port(ds, port) &&
3226 chip->info->ops->port_set_policy) {
3227 err = chip->info->ops->port_set_policy(chip, port,
3228 MV88E6XXX_POLICY_MAPPING_VTU,
3229 MV88E6XXX_POLICY_ACTION_TRAP);
3234 /* User ports start out in standalone mode and 802.1Q is
3235 * therefore disabled. On DSA ports, all valid VIDs are always
3236 * loaded in the VTU - therefore, enable 802.1Q in order to take
3237 * advantage of VLAN policy on chips that supports it.
3239 err = mv88e6xxx_port_set_8021q_mode(chip, port,
3240 dsa_is_user_port(ds, port) ?
3241 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED :
3242 MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE);
3246 /* Bind MV88E6XXX_VID_STANDALONE to MV88E6XXX_FID_STANDALONE by
3247 * virtue of the fact that mv88e6xxx_atu_new() will pick it as
3248 * the first free FID. This will be used as the private PVID for
3249 * unbridged ports. Shared (DSA and CPU) ports must also be
3250 * members of this VID, in order to trap all frames assigned to
3253 err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_STANDALONE,
3254 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED,
3259 /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the
3260 * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as
3261 * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used
3262 * as the private PVID on ports under a VLAN-unaware bridge.
3263 * Shared (DSA and CPU) ports must also be members of it, to translate
3264 * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of
3265 * relying on their port default FID.
3267 err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED,
3268 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED,
3273 if (chip->info->ops->port_set_jumbo_size) {
3274 err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
3279 /* Port Association Vector: disable automatic address learning
3280 * on all user ports since they start out in standalone
3281 * mode. When joining a bridge, learning will be configured to
3282 * match the bridge port settings. Enable learning on all
3283 * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the
3286 * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData,
3287 * and RefreshLocked. I.e. setup standard automatic learning.
3289 if (dsa_is_user_port(ds, port))
3294 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
3299 /* Egress rate control 2: disable egress rate control. */
3300 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
3305 if (chip->info->ops->port_pause_limit) {
3306 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
3311 if (chip->info->ops->port_disable_learn_limit) {
3312 err = chip->info->ops->port_disable_learn_limit(chip, port);
3317 if (chip->info->ops->port_disable_pri_override) {
3318 err = chip->info->ops->port_disable_pri_override(chip, port);
3323 if (chip->info->ops->port_tag_remap) {
3324 err = chip->info->ops->port_tag_remap(chip, port);
3329 if (chip->info->ops->port_egress_rate_limiting) {
3330 err = chip->info->ops->port_egress_rate_limiting(chip, port);
3335 if (chip->info->ops->port_setup_message_port) {
3336 err = chip->info->ops->port_setup_message_port(chip, port);
3341 if (chip->info->ops->serdes_set_tx_amplitude) {
3342 dp = dsa_to_port(ds, port);
3344 phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0);
3346 if (phy_handle && !of_property_read_u32(phy_handle,
3349 err = chip->info->ops->serdes_set_tx_amplitude(chip,
3352 of_node_put(phy_handle);
3358 /* Port based VLAN map: give each port the same default address
3359 * database, and allow bidirectional communication between the
3360 * CPU and DSA port(s), and the other ports.
3362 err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE);
3366 err = mv88e6xxx_port_vlan_map(chip, port);
3370 /* Default VLAN ID and priority: don't set a default VLAN
3371 * ID, and set the default packet priority to zero.
3373 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
3376 static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
3378 struct mv88e6xxx_chip *chip = ds->priv;
3380 if (chip->info->ops->port_set_jumbo_size)
3381 return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3382 else if (chip->info->ops->set_max_frame_size)
3383 return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3384 return ETH_DATA_LEN;
3387 static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
3389 struct mv88e6xxx_chip *chip = ds->priv;
3392 /* For families where we don't know how to alter the MTU,
3393 * just accept any value up to ETH_DATA_LEN
3395 if (!chip->info->ops->port_set_jumbo_size &&
3396 !chip->info->ops->set_max_frame_size) {
3397 if (new_mtu > ETH_DATA_LEN)
3403 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
3404 new_mtu += EDSA_HLEN;
3406 mv88e6xxx_reg_lock(chip);
3407 if (chip->info->ops->port_set_jumbo_size)
3408 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
3409 else if (chip->info->ops->set_max_frame_size)
3410 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
3411 mv88e6xxx_reg_unlock(chip);
3416 static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
3417 unsigned int ageing_time)
3419 struct mv88e6xxx_chip *chip = ds->priv;
3422 mv88e6xxx_reg_lock(chip);
3423 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
3424 mv88e6xxx_reg_unlock(chip);
3429 static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
3433 /* Initialize the statistics unit */
3434 if (chip->info->ops->stats_set_histogram) {
3435 err = chip->info->ops->stats_set_histogram(chip);
3440 return mv88e6xxx_g1_stats_clear(chip);
3443 /* Check if the errata has already been applied. */
3444 static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
3450 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3451 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
3454 "Error reading hidden register: %d\n", err);
3464 /* The 6390 copper ports have an errata which require poking magic
3465 * values into undocumented hidden registers and then performing a
3468 static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
3473 if (mv88e6390_setup_errata_applied(chip))
3476 /* Set the ports into blocking mode */
3477 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3478 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
3483 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3484 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
3489 return mv88e6xxx_software_reset(chip);
3492 /* prod_id for switch families which do not have a PHY model number */
3493 static const u16 family_prod_id_table[] = {
3494 [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
3495 [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
3496 [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
3499 static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
3501 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3502 struct mv88e6xxx_chip *chip = mdio_bus->chip;
3507 if (!chip->info->ops->phy_read)
3510 mv88e6xxx_reg_lock(chip);
3511 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
3512 mv88e6xxx_reg_unlock(chip);
3514 /* Some internal PHYs don't have a model number. */
3515 if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
3516 chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
3517 prod_id = family_prod_id_table[chip->info->family];
3519 val |= prod_id >> 4;
3522 return err ? err : val;
3525 static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,
3528 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3529 struct mv88e6xxx_chip *chip = mdio_bus->chip;
3533 if (!chip->info->ops->phy_read_c45)
3536 mv88e6xxx_reg_lock(chip);
3537 err = chip->info->ops->phy_read_c45(chip, bus, phy, devad, reg, &val);
3538 mv88e6xxx_reg_unlock(chip);
3540 return err ? err : val;
3543 static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
3545 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3546 struct mv88e6xxx_chip *chip = mdio_bus->chip;
3549 if (!chip->info->ops->phy_write)
3552 mv88e6xxx_reg_lock(chip);
3553 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
3554 mv88e6xxx_reg_unlock(chip);
3559 static int mv88e6xxx_mdio_write_c45(struct mii_bus *bus, int phy, int devad,
3562 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3563 struct mv88e6xxx_chip *chip = mdio_bus->chip;
3566 if (!chip->info->ops->phy_write_c45)
3569 mv88e6xxx_reg_lock(chip);
3570 err = chip->info->ops->phy_write_c45(chip, bus, phy, devad, reg, val);
3571 mv88e6xxx_reg_unlock(chip);
3576 static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
3577 struct device_node *np,
3581 struct mv88e6xxx_mdio_bus *mdio_bus;
3582 struct mii_bus *bus;
3586 mv88e6xxx_reg_lock(chip);
3587 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
3588 mv88e6xxx_reg_unlock(chip);
3594 bus = mdiobus_alloc_size(sizeof(*mdio_bus));
3598 mdio_bus = bus->priv;
3599 mdio_bus->bus = bus;
3600 mdio_bus->chip = chip;
3601 INIT_LIST_HEAD(&mdio_bus->list);
3602 mdio_bus->external = external;
3605 bus->name = np->full_name;
3606 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
3608 bus->name = "mv88e6xxx SMI";
3609 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3612 bus->read = mv88e6xxx_mdio_read;
3613 bus->write = mv88e6xxx_mdio_write;
3614 bus->read_c45 = mv88e6xxx_mdio_read_c45;
3615 bus->write_c45 = mv88e6xxx_mdio_write_c45;
3616 bus->parent = chip->dev;
3617 bus->phy_mask = ~GENMASK(chip->info->phy_base_addr +
3618 mv88e6xxx_num_ports(chip) - 1,
3619 chip->info->phy_base_addr);
3622 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3627 err = of_mdiobus_register(bus, np);
3629 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
3630 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3635 list_add_tail(&mdio_bus->list, &chip->mdios);
3637 list_add(&mdio_bus->list, &chip->mdios);
3646 static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3649 struct mv88e6xxx_mdio_bus *mdio_bus, *p;
3650 struct mii_bus *bus;
3652 list_for_each_entry_safe(mdio_bus, p, &chip->mdios, list) {
3653 bus = mdio_bus->bus;
3655 if (!mdio_bus->external)
3656 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3658 mdiobus_unregister(bus);
3663 static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip)
3665 struct device_node *np = chip->dev->of_node;
3666 struct device_node *child;
3669 /* Always register one mdio bus for the internal/default mdio
3670 * bus. This maybe represented in the device tree, but is
3673 child = of_get_child_by_name(np, "mdio");
3674 err = mv88e6xxx_mdio_register(chip, child, false);
3679 /* Walk the device tree, and see if there are any other nodes
3680 * which say they are compatible with the external mdio
3683 for_each_available_child_of_node(np, child) {
3684 if (of_device_is_compatible(
3685 child, "marvell,mv88e6xxx-mdio-external")) {
3686 err = mv88e6xxx_mdio_register(chip, child, true);
3688 mv88e6xxx_mdios_unregister(chip);
3698 static void mv88e6xxx_teardown(struct dsa_switch *ds)
3700 struct mv88e6xxx_chip *chip = ds->priv;
3702 mv88e6xxx_teardown_devlink_params(ds);
3703 dsa_devlink_resources_unregister(ds);
3704 mv88e6xxx_teardown_devlink_regions_global(ds);
3705 mv88e6xxx_mdios_unregister(chip);
3708 static int mv88e6xxx_setup(struct dsa_switch *ds)
3710 struct mv88e6xxx_chip *chip = ds->priv;
3715 err = mv88e6xxx_mdios_register(chip);
3720 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
3722 /* Since virtual bridges are mapped in the PVT, the number we support
3723 * depends on the physical switch topology. We need to let DSA figure
3724 * that out and therefore we cannot set this at dsa_register_switch()
3727 if (mv88e6xxx_has_pvt(chip))
3728 ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES -
3729 ds->dst->last_switch - 1;
3731 mv88e6xxx_reg_lock(chip);
3733 if (chip->info->ops->setup_errata) {
3734 err = chip->info->ops->setup_errata(chip);
3739 /* Cache the cmode of each port. */
3740 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3741 if (chip->info->ops->port_get_cmode) {
3742 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3746 chip->ports[i].cmode = cmode;
3750 err = mv88e6xxx_vtu_setup(chip);
3754 /* Must be called after mv88e6xxx_vtu_setup (which flushes the
3755 * VTU, thereby also flushing the STU).
3757 err = mv88e6xxx_stu_setup(chip);
3761 /* Setup Switch Port Registers */
3762 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3763 if (dsa_is_unused_port(ds, i))
3766 /* Prevent the use of an invalid port. */
3767 if (mv88e6xxx_is_invalid_port(chip, i)) {
3768 dev_err(chip->dev, "port %d is invalid\n", i);
3773 err = mv88e6xxx_setup_port(chip, i);
3778 err = mv88e6xxx_irl_setup(chip);
3782 err = mv88e6xxx_mac_setup(chip);
3786 err = mv88e6xxx_phy_setup(chip);
3790 err = mv88e6xxx_pvt_setup(chip);
3794 err = mv88e6xxx_atu_setup(chip);
3798 err = mv88e6xxx_broadcast_setup(chip, 0);
3802 err = mv88e6xxx_pot_setup(chip);
3806 err = mv88e6xxx_rmu_setup(chip);
3810 err = mv88e6xxx_rsvd2cpu_setup(chip);
3814 err = mv88e6xxx_trunk_setup(chip);
3818 err = mv88e6xxx_devmap_setup(chip);
3822 err = mv88e6xxx_pri_setup(chip);
3826 /* Setup PTP Hardware Clock and timestamping */
3827 if (chip->info->ptp_support) {
3828 err = mv88e6xxx_ptp_setup(chip);
3832 err = mv88e6xxx_hwtstamp_setup(chip);
3837 err = mv88e6xxx_stats_setup(chip);
3842 mv88e6xxx_reg_unlock(chip);
3847 /* Have to be called without holding the register lock, since
3848 * they take the devlink lock, and we later take the locks in
3849 * the reverse order when getting/setting parameters or
3850 * resource occupancy.
3852 err = mv88e6xxx_setup_devlink_resources(ds);
3856 err = mv88e6xxx_setup_devlink_params(ds);
3860 err = mv88e6xxx_setup_devlink_regions_global(ds);
3867 mv88e6xxx_teardown_devlink_params(ds);
3869 dsa_devlink_resources_unregister(ds);
3871 mv88e6xxx_mdios_unregister(chip);
3876 static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
3878 struct mv88e6xxx_chip *chip = ds->priv;
3881 if (chip->info->ops->pcs_ops->pcs_init) {
3882 err = chip->info->ops->pcs_ops->pcs_init(chip, port);
3887 return mv88e6xxx_setup_devlink_regions_port(ds, port);
3890 static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
3892 struct mv88e6xxx_chip *chip = ds->priv;
3894 mv88e6xxx_teardown_devlink_regions_port(ds, port);
3896 if (chip->info->ops->pcs_ops->pcs_teardown)
3897 chip->info->ops->pcs_ops->pcs_teardown(chip, port);
3900 static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3902 struct mv88e6xxx_chip *chip = ds->priv;
3904 return chip->eeprom_len;
3907 static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3908 struct ethtool_eeprom *eeprom, u8 *data)
3910 struct mv88e6xxx_chip *chip = ds->priv;
3913 if (!chip->info->ops->get_eeprom)
3916 mv88e6xxx_reg_lock(chip);
3917 err = chip->info->ops->get_eeprom(chip, eeprom, data);
3918 mv88e6xxx_reg_unlock(chip);
3923 eeprom->magic = 0xc3ec4951;
3928 static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3929 struct ethtool_eeprom *eeprom, u8 *data)
3931 struct mv88e6xxx_chip *chip = ds->priv;
3934 if (!chip->info->ops->set_eeprom)
3937 if (eeprom->magic != 0xc3ec4951)
3940 mv88e6xxx_reg_lock(chip);
3941 err = chip->info->ops->set_eeprom(chip, eeprom, data);
3942 mv88e6xxx_reg_unlock(chip);
3947 static const struct mv88e6xxx_ops mv88e6085_ops = {
3948 /* MV88E6XXX_FAMILY_6097 */
3949 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3950 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3951 .irl_init_all = mv88e6352_g2_irl_init_all,
3952 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
3953 .phy_read = mv88e6185_phy_ppu_read,
3954 .phy_write = mv88e6185_phy_ppu_write,
3955 .port_set_link = mv88e6xxx_port_set_link,
3956 .port_sync_link = mv88e6xxx_port_sync_link,
3957 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
3958 .port_tag_remap = mv88e6095_port_tag_remap,
3959 .port_set_policy = mv88e6352_port_set_policy,
3960 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3961 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3962 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
3963 .port_set_ether_type = mv88e6351_port_set_ether_type,
3964 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
3965 .port_pause_limit = mv88e6097_port_pause_limit,
3966 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3967 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3968 .port_get_cmode = mv88e6185_port_get_cmode,
3969 .port_setup_message_port = mv88e6xxx_setup_message_port,
3970 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
3971 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
3972 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3973 .stats_get_strings = mv88e6095_stats_get_strings,
3974 .stats_get_stats = mv88e6095_stats_get_stats,
3975 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3976 .set_egress_port = mv88e6095_g1_set_egress_port,
3977 .watchdog_ops = &mv88e6097_watchdog_ops,
3978 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
3979 .pot_clear = mv88e6xxx_g2_pot_clear,
3980 .ppu_enable = mv88e6185_g1_ppu_enable,
3981 .ppu_disable = mv88e6185_g1_ppu_disable,
3982 .reset = mv88e6185_g1_reset,
3983 .rmu_disable = mv88e6085_g1_rmu_disable,
3984 .vtu_getnext = mv88e6352_g1_vtu_getnext,
3985 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
3986 .stu_getnext = mv88e6352_g1_stu_getnext,
3987 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
3988 .phylink_get_caps = mv88e6185_phylink_get_caps,
3989 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
3992 static const struct mv88e6xxx_ops mv88e6095_ops = {
3993 /* MV88E6XXX_FAMILY_6095 */
3994 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3995 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3996 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
3997 .phy_read = mv88e6185_phy_ppu_read,
3998 .phy_write = mv88e6185_phy_ppu_write,
3999 .port_set_link = mv88e6xxx_port_set_link,
4000 .port_sync_link = mv88e6185_port_sync_link,
4001 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4002 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
4003 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4004 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
4005 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
4006 .port_get_cmode = mv88e6185_port_get_cmode,
4007 .port_setup_message_port = mv88e6xxx_setup_message_port,
4008 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4009 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4010 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4011 .stats_get_strings = mv88e6095_stats_get_strings,
4012 .stats_get_stats = mv88e6095_stats_get_stats,
4013 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
4014 .ppu_enable = mv88e6185_g1_ppu_enable,
4015 .ppu_disable = mv88e6185_g1_ppu_disable,
4016 .reset = mv88e6185_g1_reset,
4017 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4018 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4019 .phylink_get_caps = mv88e6095_phylink_get_caps,
4020 .pcs_ops = &mv88e6185_pcs_ops,
4021 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4024 static const struct mv88e6xxx_ops mv88e6097_ops = {
4025 /* MV88E6XXX_FAMILY_6097 */
4026 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4027 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4028 .irl_init_all = mv88e6352_g2_irl_init_all,
4029 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4030 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4031 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4032 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4033 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4034 .port_set_link = mv88e6xxx_port_set_link,
4035 .port_sync_link = mv88e6185_port_sync_link,
4036 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4037 .port_tag_remap = mv88e6095_port_tag_remap,
4038 .port_set_policy = mv88e6352_port_set_policy,
4039 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4040 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4041 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4042 .port_set_ether_type = mv88e6351_port_set_ether_type,
4043 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
4044 .port_pause_limit = mv88e6097_port_pause_limit,
4045 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4046 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4047 .port_get_cmode = mv88e6185_port_get_cmode,
4048 .port_setup_message_port = mv88e6xxx_setup_message_port,
4049 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4050 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4051 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4052 .stats_get_strings = mv88e6095_stats_get_strings,
4053 .stats_get_stats = mv88e6095_stats_get_stats,
4054 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4055 .set_egress_port = mv88e6095_g1_set_egress_port,
4056 .watchdog_ops = &mv88e6097_watchdog_ops,
4057 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4058 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4059 .pot_clear = mv88e6xxx_g2_pot_clear,
4060 .reset = mv88e6352_g1_reset,
4061 .rmu_disable = mv88e6085_g1_rmu_disable,
4062 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4063 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4064 .phylink_get_caps = mv88e6095_phylink_get_caps,
4065 .pcs_ops = &mv88e6185_pcs_ops,
4066 .stu_getnext = mv88e6352_g1_stu_getnext,
4067 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4068 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4071 static const struct mv88e6xxx_ops mv88e6123_ops = {
4072 /* MV88E6XXX_FAMILY_6165 */
4073 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4074 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4075 .irl_init_all = mv88e6352_g2_irl_init_all,
4076 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4077 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4078 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4079 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4080 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4081 .port_set_link = mv88e6xxx_port_set_link,
4082 .port_sync_link = mv88e6xxx_port_sync_link,
4083 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4084 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
4085 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4086 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4087 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4088 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4089 .port_get_cmode = mv88e6185_port_get_cmode,
4090 .port_setup_message_port = mv88e6xxx_setup_message_port,
4091 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4092 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4093 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4094 .stats_get_strings = mv88e6095_stats_get_strings,
4095 .stats_get_stats = mv88e6095_stats_get_stats,
4096 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4097 .set_egress_port = mv88e6095_g1_set_egress_port,
4098 .watchdog_ops = &mv88e6097_watchdog_ops,
4099 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4100 .pot_clear = mv88e6xxx_g2_pot_clear,
4101 .reset = mv88e6352_g1_reset,
4102 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4103 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4104 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4105 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4106 .stu_getnext = mv88e6352_g1_stu_getnext,
4107 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4108 .phylink_get_caps = mv88e6185_phylink_get_caps,
4109 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4112 static const struct mv88e6xxx_ops mv88e6131_ops = {
4113 /* MV88E6XXX_FAMILY_6185 */
4114 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4115 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4116 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
4117 .phy_read = mv88e6185_phy_ppu_read,
4118 .phy_write = mv88e6185_phy_ppu_write,
4119 .port_set_link = mv88e6xxx_port_set_link,
4120 .port_sync_link = mv88e6xxx_port_sync_link,
4121 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4122 .port_tag_remap = mv88e6095_port_tag_remap,
4123 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4124 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4125 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
4126 .port_set_ether_type = mv88e6351_port_set_ether_type,
4127 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
4128 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4129 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4130 .port_pause_limit = mv88e6097_port_pause_limit,
4131 .port_set_pause = mv88e6185_port_set_pause,
4132 .port_get_cmode = mv88e6185_port_get_cmode,
4133 .port_setup_message_port = mv88e6xxx_setup_message_port,
4134 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4135 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4136 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4137 .stats_get_strings = mv88e6095_stats_get_strings,
4138 .stats_get_stats = mv88e6095_stats_get_stats,
4139 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4140 .set_egress_port = mv88e6095_g1_set_egress_port,
4141 .watchdog_ops = &mv88e6097_watchdog_ops,
4142 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
4143 .ppu_enable = mv88e6185_g1_ppu_enable,
4144 .set_cascade_port = mv88e6185_g1_set_cascade_port,
4145 .ppu_disable = mv88e6185_g1_ppu_disable,
4146 .reset = mv88e6185_g1_reset,
4147 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4148 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4149 .phylink_get_caps = mv88e6185_phylink_get_caps,
4152 static const struct mv88e6xxx_ops mv88e6141_ops = {
4153 /* MV88E6XXX_FAMILY_6341 */
4154 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4155 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4156 .irl_init_all = mv88e6352_g2_irl_init_all,
4157 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4158 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4159 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4160 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4161 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4162 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4163 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4164 .port_set_link = mv88e6xxx_port_set_link,
4165 .port_sync_link = mv88e6xxx_port_sync_link,
4166 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4167 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
4168 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
4169 .port_tag_remap = mv88e6095_port_tag_remap,
4170 .port_set_policy = mv88e6352_port_set_policy,
4171 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4172 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4173 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4174 .port_set_ether_type = mv88e6351_port_set_ether_type,
4175 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4176 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4177 .port_pause_limit = mv88e6097_port_pause_limit,
4178 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4179 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4180 .port_get_cmode = mv88e6352_port_get_cmode,
4181 .port_set_cmode = mv88e6341_port_set_cmode,
4182 .port_setup_message_port = mv88e6xxx_setup_message_port,
4183 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4184 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4185 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4186 .stats_get_strings = mv88e6320_stats_get_strings,
4187 .stats_get_stats = mv88e6390_stats_get_stats,
4188 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4189 .set_egress_port = mv88e6390_g1_set_egress_port,
4190 .watchdog_ops = &mv88e6390_watchdog_ops,
4191 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
4192 .pot_clear = mv88e6xxx_g2_pot_clear,
4193 .reset = mv88e6352_g1_reset,
4194 .rmu_disable = mv88e6390_g1_rmu_disable,
4195 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4196 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4197 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4198 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4199 .stu_getnext = mv88e6352_g1_stu_getnext,
4200 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4201 .serdes_get_lane = mv88e6341_serdes_get_lane,
4202 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4203 .gpio_ops = &mv88e6352_gpio_ops,
4204 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4205 .serdes_get_strings = mv88e6390_serdes_get_strings,
4206 .serdes_get_stats = mv88e6390_serdes_get_stats,
4207 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4208 .serdes_get_regs = mv88e6390_serdes_get_regs,
4209 .phylink_get_caps = mv88e6341_phylink_get_caps,
4210 .pcs_ops = &mv88e6390_pcs_ops,
4213 static const struct mv88e6xxx_ops mv88e6161_ops = {
4214 /* MV88E6XXX_FAMILY_6165 */
4215 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4216 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4217 .irl_init_all = mv88e6352_g2_irl_init_all,
4218 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4219 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4220 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4221 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4222 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4223 .port_set_link = mv88e6xxx_port_set_link,
4224 .port_sync_link = mv88e6xxx_port_sync_link,
4225 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4226 .port_tag_remap = mv88e6095_port_tag_remap,
4227 .port_set_policy = mv88e6352_port_set_policy,
4228 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4229 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4230 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4231 .port_set_ether_type = mv88e6351_port_set_ether_type,
4232 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4233 .port_pause_limit = mv88e6097_port_pause_limit,
4234 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4235 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4236 .port_get_cmode = mv88e6185_port_get_cmode,
4237 .port_setup_message_port = mv88e6xxx_setup_message_port,
4238 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4239 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4240 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4241 .stats_get_strings = mv88e6095_stats_get_strings,
4242 .stats_get_stats = mv88e6095_stats_get_stats,
4243 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4244 .set_egress_port = mv88e6095_g1_set_egress_port,
4245 .watchdog_ops = &mv88e6097_watchdog_ops,
4246 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4247 .pot_clear = mv88e6xxx_g2_pot_clear,
4248 .reset = mv88e6352_g1_reset,
4249 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4250 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4251 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4252 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4253 .stu_getnext = mv88e6352_g1_stu_getnext,
4254 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4255 .avb_ops = &mv88e6165_avb_ops,
4256 .ptp_ops = &mv88e6165_ptp_ops,
4257 .phylink_get_caps = mv88e6185_phylink_get_caps,
4258 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4261 static const struct mv88e6xxx_ops mv88e6165_ops = {
4262 /* MV88E6XXX_FAMILY_6165 */
4263 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4264 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4265 .irl_init_all = mv88e6352_g2_irl_init_all,
4266 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4267 .phy_read = mv88e6165_phy_read,
4268 .phy_write = mv88e6165_phy_write,
4269 .port_set_link = mv88e6xxx_port_set_link,
4270 .port_sync_link = mv88e6xxx_port_sync_link,
4271 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4272 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4273 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4274 .port_get_cmode = mv88e6185_port_get_cmode,
4275 .port_setup_message_port = mv88e6xxx_setup_message_port,
4276 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4277 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4278 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4279 .stats_get_strings = mv88e6095_stats_get_strings,
4280 .stats_get_stats = mv88e6095_stats_get_stats,
4281 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4282 .set_egress_port = mv88e6095_g1_set_egress_port,
4283 .watchdog_ops = &mv88e6097_watchdog_ops,
4284 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4285 .pot_clear = mv88e6xxx_g2_pot_clear,
4286 .reset = mv88e6352_g1_reset,
4287 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4288 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4289 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4290 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4291 .stu_getnext = mv88e6352_g1_stu_getnext,
4292 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4293 .avb_ops = &mv88e6165_avb_ops,
4294 .ptp_ops = &mv88e6165_ptp_ops,
4295 .phylink_get_caps = mv88e6185_phylink_get_caps,
4298 static const struct mv88e6xxx_ops mv88e6171_ops = {
4299 /* MV88E6XXX_FAMILY_6351 */
4300 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4301 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4302 .irl_init_all = mv88e6352_g2_irl_init_all,
4303 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4304 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4305 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4306 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4307 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4308 .port_set_link = mv88e6xxx_port_set_link,
4309 .port_sync_link = mv88e6xxx_port_sync_link,
4310 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4311 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4312 .port_tag_remap = mv88e6095_port_tag_remap,
4313 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4314 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4315 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4316 .port_set_ether_type = mv88e6351_port_set_ether_type,
4317 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4318 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4319 .port_pause_limit = mv88e6097_port_pause_limit,
4320 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4321 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4322 .port_get_cmode = mv88e6352_port_get_cmode,
4323 .port_setup_message_port = mv88e6xxx_setup_message_port,
4324 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4325 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4326 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4327 .stats_get_strings = mv88e6095_stats_get_strings,
4328 .stats_get_stats = mv88e6095_stats_get_stats,
4329 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4330 .set_egress_port = mv88e6095_g1_set_egress_port,
4331 .watchdog_ops = &mv88e6097_watchdog_ops,
4332 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4333 .pot_clear = mv88e6xxx_g2_pot_clear,
4334 .reset = mv88e6352_g1_reset,
4335 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4336 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4337 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4338 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4339 .stu_getnext = mv88e6352_g1_stu_getnext,
4340 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4341 .phylink_get_caps = mv88e6185_phylink_get_caps,
4344 static const struct mv88e6xxx_ops mv88e6172_ops = {
4345 /* MV88E6XXX_FAMILY_6352 */
4346 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4347 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4348 .irl_init_all = mv88e6352_g2_irl_init_all,
4349 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4350 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4351 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4352 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4353 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4354 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4355 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4356 .port_set_link = mv88e6xxx_port_set_link,
4357 .port_sync_link = mv88e6xxx_port_sync_link,
4358 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4359 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
4360 .port_tag_remap = mv88e6095_port_tag_remap,
4361 .port_set_policy = mv88e6352_port_set_policy,
4362 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4363 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4364 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4365 .port_set_ether_type = mv88e6351_port_set_ether_type,
4366 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4367 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4368 .port_pause_limit = mv88e6097_port_pause_limit,
4369 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4370 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4371 .port_get_cmode = mv88e6352_port_get_cmode,
4372 .port_setup_message_port = mv88e6xxx_setup_message_port,
4373 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4374 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4375 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4376 .stats_get_strings = mv88e6095_stats_get_strings,
4377 .stats_get_stats = mv88e6095_stats_get_stats,
4378 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4379 .set_egress_port = mv88e6095_g1_set_egress_port,
4380 .watchdog_ops = &mv88e6097_watchdog_ops,
4381 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4382 .pot_clear = mv88e6xxx_g2_pot_clear,
4383 .reset = mv88e6352_g1_reset,
4384 .rmu_disable = mv88e6352_g1_rmu_disable,
4385 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4386 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4387 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4388 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4389 .stu_getnext = mv88e6352_g1_stu_getnext,
4390 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4391 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4392 .serdes_get_regs = mv88e6352_serdes_get_regs,
4393 .gpio_ops = &mv88e6352_gpio_ops,
4394 .phylink_get_caps = mv88e6352_phylink_get_caps,
4395 .pcs_ops = &mv88e6352_pcs_ops,
4398 static const struct mv88e6xxx_ops mv88e6175_ops = {
4399 /* MV88E6XXX_FAMILY_6351 */
4400 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4401 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4402 .irl_init_all = mv88e6352_g2_irl_init_all,
4403 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4404 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4405 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4406 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4407 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4408 .port_set_link = mv88e6xxx_port_set_link,
4409 .port_sync_link = mv88e6xxx_port_sync_link,
4410 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4411 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4412 .port_tag_remap = mv88e6095_port_tag_remap,
4413 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4414 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4415 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4416 .port_set_ether_type = mv88e6351_port_set_ether_type,
4417 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4418 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4419 .port_pause_limit = mv88e6097_port_pause_limit,
4420 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4421 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4422 .port_get_cmode = mv88e6352_port_get_cmode,
4423 .port_setup_message_port = mv88e6xxx_setup_message_port,
4424 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4425 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4426 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4427 .stats_get_strings = mv88e6095_stats_get_strings,
4428 .stats_get_stats = mv88e6095_stats_get_stats,
4429 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4430 .set_egress_port = mv88e6095_g1_set_egress_port,
4431 .watchdog_ops = &mv88e6097_watchdog_ops,
4432 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4433 .pot_clear = mv88e6xxx_g2_pot_clear,
4434 .reset = mv88e6352_g1_reset,
4435 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4436 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4437 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4438 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4439 .stu_getnext = mv88e6352_g1_stu_getnext,
4440 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4441 .phylink_get_caps = mv88e6185_phylink_get_caps,
4444 static const struct mv88e6xxx_ops mv88e6176_ops = {
4445 /* MV88E6XXX_FAMILY_6352 */
4446 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4447 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4448 .irl_init_all = mv88e6352_g2_irl_init_all,
4449 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4450 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4451 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4452 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4453 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4454 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4455 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4456 .port_set_link = mv88e6xxx_port_set_link,
4457 .port_sync_link = mv88e6xxx_port_sync_link,
4458 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4459 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
4460 .port_tag_remap = mv88e6095_port_tag_remap,
4461 .port_set_policy = mv88e6352_port_set_policy,
4462 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4463 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4464 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4465 .port_set_ether_type = mv88e6351_port_set_ether_type,
4466 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4467 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4468 .port_pause_limit = mv88e6097_port_pause_limit,
4469 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4470 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4471 .port_get_cmode = mv88e6352_port_get_cmode,
4472 .port_setup_message_port = mv88e6xxx_setup_message_port,
4473 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4474 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4475 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4476 .stats_get_strings = mv88e6095_stats_get_strings,
4477 .stats_get_stats = mv88e6095_stats_get_stats,
4478 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4479 .set_egress_port = mv88e6095_g1_set_egress_port,
4480 .watchdog_ops = &mv88e6097_watchdog_ops,
4481 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4482 .pot_clear = mv88e6xxx_g2_pot_clear,
4483 .reset = mv88e6352_g1_reset,
4484 .rmu_disable = mv88e6352_g1_rmu_disable,
4485 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4486 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4487 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4488 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4489 .stu_getnext = mv88e6352_g1_stu_getnext,
4490 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4491 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
4492 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4493 .serdes_get_regs = mv88e6352_serdes_get_regs,
4494 .serdes_set_tx_amplitude = mv88e6352_serdes_set_tx_amplitude,
4495 .gpio_ops = &mv88e6352_gpio_ops,
4496 .phylink_get_caps = mv88e6352_phylink_get_caps,
4497 .pcs_ops = &mv88e6352_pcs_ops,
4500 static const struct mv88e6xxx_ops mv88e6185_ops = {
4501 /* MV88E6XXX_FAMILY_6185 */
4502 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4503 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4504 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
4505 .phy_read = mv88e6185_phy_ppu_read,
4506 .phy_write = mv88e6185_phy_ppu_write,
4507 .port_set_link = mv88e6xxx_port_set_link,
4508 .port_sync_link = mv88e6185_port_sync_link,
4509 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4510 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
4511 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4512 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
4513 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
4514 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
4515 .port_set_pause = mv88e6185_port_set_pause,
4516 .port_get_cmode = mv88e6185_port_get_cmode,
4517 .port_setup_message_port = mv88e6xxx_setup_message_port,
4518 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
4519 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4520 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4521 .stats_get_strings = mv88e6095_stats_get_strings,
4522 .stats_get_stats = mv88e6095_stats_get_stats,
4523 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4524 .set_egress_port = mv88e6095_g1_set_egress_port,
4525 .watchdog_ops = &mv88e6097_watchdog_ops,
4526 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
4527 .set_cascade_port = mv88e6185_g1_set_cascade_port,
4528 .ppu_enable = mv88e6185_g1_ppu_enable,
4529 .ppu_disable = mv88e6185_g1_ppu_disable,
4530 .reset = mv88e6185_g1_reset,
4531 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4532 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4533 .phylink_get_caps = mv88e6185_phylink_get_caps,
4534 .pcs_ops = &mv88e6185_pcs_ops,
4535 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4538 static const struct mv88e6xxx_ops mv88e6190_ops = {
4539 /* MV88E6XXX_FAMILY_6390 */
4540 .setup_errata = mv88e6390_setup_errata,
4541 .irl_init_all = mv88e6390_g2_irl_init_all,
4542 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4543 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4544 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4545 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4546 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4547 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4548 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4549 .port_set_link = mv88e6xxx_port_set_link,
4550 .port_sync_link = mv88e6xxx_port_sync_link,
4551 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4552 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
4553 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
4554 .port_tag_remap = mv88e6390_port_tag_remap,
4555 .port_set_policy = mv88e6352_port_set_policy,
4556 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4557 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4558 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4559 .port_set_ether_type = mv88e6351_port_set_ether_type,
4560 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4561 .port_pause_limit = mv88e6390_port_pause_limit,
4562 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4563 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4564 .port_get_cmode = mv88e6352_port_get_cmode,
4565 .port_set_cmode = mv88e6390_port_set_cmode,
4566 .port_setup_message_port = mv88e6xxx_setup_message_port,
4567 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4568 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4569 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4570 .stats_get_strings = mv88e6320_stats_get_strings,
4571 .stats_get_stats = mv88e6390_stats_get_stats,
4572 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4573 .set_egress_port = mv88e6390_g1_set_egress_port,
4574 .watchdog_ops = &mv88e6390_watchdog_ops,
4575 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
4576 .pot_clear = mv88e6xxx_g2_pot_clear,
4577 .reset = mv88e6352_g1_reset,
4578 .rmu_disable = mv88e6390_g1_rmu_disable,
4579 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4580 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4581 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4582 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4583 .stu_getnext = mv88e6390_g1_stu_getnext,
4584 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
4585 .serdes_get_lane = mv88e6390_serdes_get_lane,
4586 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4587 .serdes_get_strings = mv88e6390_serdes_get_strings,
4588 .serdes_get_stats = mv88e6390_serdes_get_stats,
4589 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4590 .serdes_get_regs = mv88e6390_serdes_get_regs,
4591 .gpio_ops = &mv88e6352_gpio_ops,
4592 .phylink_get_caps = mv88e6390_phylink_get_caps,
4593 .pcs_ops = &mv88e6390_pcs_ops,
4596 static const struct mv88e6xxx_ops mv88e6190x_ops = {
4597 /* MV88E6XXX_FAMILY_6390 */
4598 .setup_errata = mv88e6390_setup_errata,
4599 .irl_init_all = mv88e6390_g2_irl_init_all,
4600 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4601 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4602 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4603 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4604 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4605 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4606 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4607 .port_set_link = mv88e6xxx_port_set_link,
4608 .port_sync_link = mv88e6xxx_port_sync_link,
4609 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4610 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
4611 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
4612 .port_tag_remap = mv88e6390_port_tag_remap,
4613 .port_set_policy = mv88e6352_port_set_policy,
4614 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4615 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4616 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4617 .port_set_ether_type = mv88e6351_port_set_ether_type,
4618 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4619 .port_pause_limit = mv88e6390_port_pause_limit,
4620 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4621 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4622 .port_get_cmode = mv88e6352_port_get_cmode,
4623 .port_set_cmode = mv88e6390x_port_set_cmode,
4624 .port_setup_message_port = mv88e6xxx_setup_message_port,
4625 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4626 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4627 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4628 .stats_get_strings = mv88e6320_stats_get_strings,
4629 .stats_get_stats = mv88e6390_stats_get_stats,
4630 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4631 .set_egress_port = mv88e6390_g1_set_egress_port,
4632 .watchdog_ops = &mv88e6390_watchdog_ops,
4633 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
4634 .pot_clear = mv88e6xxx_g2_pot_clear,
4635 .reset = mv88e6352_g1_reset,
4636 .rmu_disable = mv88e6390_g1_rmu_disable,
4637 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4638 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4639 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4640 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4641 .stu_getnext = mv88e6390_g1_stu_getnext,
4642 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
4643 .serdes_get_lane = mv88e6390x_serdes_get_lane,
4644 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4645 .serdes_get_strings = mv88e6390_serdes_get_strings,
4646 .serdes_get_stats = mv88e6390_serdes_get_stats,
4647 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4648 .serdes_get_regs = mv88e6390_serdes_get_regs,
4649 .gpio_ops = &mv88e6352_gpio_ops,
4650 .phylink_get_caps = mv88e6390x_phylink_get_caps,
4651 .pcs_ops = &mv88e6390_pcs_ops,
4654 static const struct mv88e6xxx_ops mv88e6191_ops = {
4655 /* MV88E6XXX_FAMILY_6390 */
4656 .setup_errata = mv88e6390_setup_errata,
4657 .irl_init_all = mv88e6390_g2_irl_init_all,
4658 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4659 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4660 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4661 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4662 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4663 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4664 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4665 .port_set_link = mv88e6xxx_port_set_link,
4666 .port_sync_link = mv88e6xxx_port_sync_link,
4667 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4668 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
4669 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
4670 .port_tag_remap = mv88e6390_port_tag_remap,
4671 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4672 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4673 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4674 .port_set_ether_type = mv88e6351_port_set_ether_type,
4675 .port_pause_limit = mv88e6390_port_pause_limit,
4676 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4677 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4678 .port_get_cmode = mv88e6352_port_get_cmode,
4679 .port_set_cmode = mv88e6390_port_set_cmode,
4680 .port_setup_message_port = mv88e6xxx_setup_message_port,
4681 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4682 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4683 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4684 .stats_get_strings = mv88e6320_stats_get_strings,
4685 .stats_get_stats = mv88e6390_stats_get_stats,
4686 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4687 .set_egress_port = mv88e6390_g1_set_egress_port,
4688 .watchdog_ops = &mv88e6390_watchdog_ops,
4689 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
4690 .pot_clear = mv88e6xxx_g2_pot_clear,
4691 .reset = mv88e6352_g1_reset,
4692 .rmu_disable = mv88e6390_g1_rmu_disable,
4693 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4694 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4695 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4696 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4697 .stu_getnext = mv88e6390_g1_stu_getnext,
4698 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
4699 .serdes_get_lane = mv88e6390_serdes_get_lane,
4700 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4701 .serdes_get_strings = mv88e6390_serdes_get_strings,
4702 .serdes_get_stats = mv88e6390_serdes_get_stats,
4703 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4704 .serdes_get_regs = mv88e6390_serdes_get_regs,
4705 .avb_ops = &mv88e6390_avb_ops,
4706 .ptp_ops = &mv88e6352_ptp_ops,
4707 .phylink_get_caps = mv88e6390_phylink_get_caps,
4708 .pcs_ops = &mv88e6390_pcs_ops,
4711 static const struct mv88e6xxx_ops mv88e6240_ops = {
4712 /* MV88E6XXX_FAMILY_6352 */
4713 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4714 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4715 .irl_init_all = mv88e6352_g2_irl_init_all,
4716 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4717 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4718 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4719 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4720 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4721 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4722 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4723 .port_set_link = mv88e6xxx_port_set_link,
4724 .port_sync_link = mv88e6xxx_port_sync_link,
4725 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4726 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
4727 .port_tag_remap = mv88e6095_port_tag_remap,
4728 .port_set_policy = mv88e6352_port_set_policy,
4729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4730 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4731 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4732 .port_set_ether_type = mv88e6351_port_set_ether_type,
4733 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4734 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4735 .port_pause_limit = mv88e6097_port_pause_limit,
4736 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4737 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4738 .port_get_cmode = mv88e6352_port_get_cmode,
4739 .port_setup_message_port = mv88e6xxx_setup_message_port,
4740 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4741 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4742 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4743 .stats_get_strings = mv88e6095_stats_get_strings,
4744 .stats_get_stats = mv88e6095_stats_get_stats,
4745 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4746 .set_egress_port = mv88e6095_g1_set_egress_port,
4747 .watchdog_ops = &mv88e6097_watchdog_ops,
4748 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4749 .pot_clear = mv88e6xxx_g2_pot_clear,
4750 .reset = mv88e6352_g1_reset,
4751 .rmu_disable = mv88e6352_g1_rmu_disable,
4752 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4753 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4754 .vtu_getnext = mv88e6352_g1_vtu_getnext,
4755 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
4756 .stu_getnext = mv88e6352_g1_stu_getnext,
4757 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
4758 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
4759 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4760 .serdes_get_regs = mv88e6352_serdes_get_regs,
4761 .serdes_set_tx_amplitude = mv88e6352_serdes_set_tx_amplitude,
4762 .gpio_ops = &mv88e6352_gpio_ops,
4763 .avb_ops = &mv88e6352_avb_ops,
4764 .ptp_ops = &mv88e6352_ptp_ops,
4765 .phylink_get_caps = mv88e6352_phylink_get_caps,
4766 .pcs_ops = &mv88e6352_pcs_ops,
4769 static const struct mv88e6xxx_ops mv88e6250_ops = {
4770 /* MV88E6XXX_FAMILY_6250 */
4771 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4772 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4773 .irl_init_all = mv88e6352_g2_irl_init_all,
4774 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4775 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4776 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4777 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4778 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4779 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4780 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4781 .port_set_link = mv88e6xxx_port_set_link,
4782 .port_sync_link = mv88e6xxx_port_sync_link,
4783 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
4784 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
4785 .port_tag_remap = mv88e6095_port_tag_remap,
4786 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4787 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4788 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4789 .port_set_ether_type = mv88e6351_port_set_ether_type,
4790 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4791 .port_pause_limit = mv88e6097_port_pause_limit,
4792 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4793 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4794 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4795 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4796 .stats_get_strings = mv88e6250_stats_get_strings,
4797 .stats_get_stats = mv88e6250_stats_get_stats,
4798 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4799 .set_egress_port = mv88e6095_g1_set_egress_port,
4800 .watchdog_ops = &mv88e6250_watchdog_ops,
4801 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4802 .pot_clear = mv88e6xxx_g2_pot_clear,
4803 .reset = mv88e6250_g1_reset,
4804 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4805 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4806 .avb_ops = &mv88e6352_avb_ops,
4807 .ptp_ops = &mv88e6250_ptp_ops,
4808 .phylink_get_caps = mv88e6250_phylink_get_caps,
4809 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
4812 static const struct mv88e6xxx_ops mv88e6290_ops = {
4813 /* MV88E6XXX_FAMILY_6390 */
4814 .setup_errata = mv88e6390_setup_errata,
4815 .irl_init_all = mv88e6390_g2_irl_init_all,
4816 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4817 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4818 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4819 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4820 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4821 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4822 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4823 .port_set_link = mv88e6xxx_port_set_link,
4824 .port_sync_link = mv88e6xxx_port_sync_link,
4825 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4826 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
4827 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
4828 .port_tag_remap = mv88e6390_port_tag_remap,
4829 .port_set_policy = mv88e6352_port_set_policy,
4830 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4831 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4832 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4833 .port_set_ether_type = mv88e6351_port_set_ether_type,
4834 .port_pause_limit = mv88e6390_port_pause_limit,
4835 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4836 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4837 .port_get_cmode = mv88e6352_port_get_cmode,
4838 .port_set_cmode = mv88e6390_port_set_cmode,
4839 .port_setup_message_port = mv88e6xxx_setup_message_port,
4840 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4841 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4842 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4843 .stats_get_strings = mv88e6320_stats_get_strings,
4844 .stats_get_stats = mv88e6390_stats_get_stats,
4845 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4846 .set_egress_port = mv88e6390_g1_set_egress_port,
4847 .watchdog_ops = &mv88e6390_watchdog_ops,
4848 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
4849 .pot_clear = mv88e6xxx_g2_pot_clear,
4850 .reset = mv88e6352_g1_reset,
4851 .rmu_disable = mv88e6390_g1_rmu_disable,
4852 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4853 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4854 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4855 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4856 .stu_getnext = mv88e6390_g1_stu_getnext,
4857 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
4858 .serdes_get_lane = mv88e6390_serdes_get_lane,
4859 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4860 .serdes_get_strings = mv88e6390_serdes_get_strings,
4861 .serdes_get_stats = mv88e6390_serdes_get_stats,
4862 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4863 .serdes_get_regs = mv88e6390_serdes_get_regs,
4864 .gpio_ops = &mv88e6352_gpio_ops,
4865 .avb_ops = &mv88e6390_avb_ops,
4866 .ptp_ops = &mv88e6390_ptp_ops,
4867 .phylink_get_caps = mv88e6390_phylink_get_caps,
4868 .pcs_ops = &mv88e6390_pcs_ops,
4871 static const struct mv88e6xxx_ops mv88e6320_ops = {
4872 /* MV88E6XXX_FAMILY_6320 */
4873 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4874 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4875 .irl_init_all = mv88e6352_g2_irl_init_all,
4876 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4877 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4878 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4879 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4880 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4881 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4882 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4883 .port_set_link = mv88e6xxx_port_set_link,
4884 .port_sync_link = mv88e6xxx_port_sync_link,
4885 .port_set_rgmii_delay = mv88e6320_port_set_rgmii_delay,
4886 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4887 .port_tag_remap = mv88e6095_port_tag_remap,
4888 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4889 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4890 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4891 .port_set_ether_type = mv88e6351_port_set_ether_type,
4892 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4893 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4894 .port_pause_limit = mv88e6097_port_pause_limit,
4895 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4896 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4897 .port_get_cmode = mv88e6352_port_get_cmode,
4898 .port_setup_message_port = mv88e6xxx_setup_message_port,
4899 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4900 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4901 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4902 .stats_get_strings = mv88e6320_stats_get_strings,
4903 .stats_get_stats = mv88e6320_stats_get_stats,
4904 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4905 .set_egress_port = mv88e6095_g1_set_egress_port,
4906 .watchdog_ops = &mv88e6390_watchdog_ops,
4907 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4908 .pot_clear = mv88e6xxx_g2_pot_clear,
4909 .reset = mv88e6352_g1_reset,
4910 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4911 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4912 .gpio_ops = &mv88e6352_gpio_ops,
4913 .avb_ops = &mv88e6352_avb_ops,
4914 .ptp_ops = &mv88e6352_ptp_ops,
4915 .phylink_get_caps = mv88e6185_phylink_get_caps,
4918 static const struct mv88e6xxx_ops mv88e6321_ops = {
4919 /* MV88E6XXX_FAMILY_6320 */
4920 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4921 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4922 .irl_init_all = mv88e6352_g2_irl_init_all,
4923 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4924 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4925 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4926 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4927 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4928 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4929 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4930 .port_set_link = mv88e6xxx_port_set_link,
4931 .port_sync_link = mv88e6xxx_port_sync_link,
4932 .port_set_rgmii_delay = mv88e6320_port_set_rgmii_delay,
4933 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
4934 .port_tag_remap = mv88e6095_port_tag_remap,
4935 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4936 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4937 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4938 .port_set_ether_type = mv88e6351_port_set_ether_type,
4939 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4940 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4941 .port_pause_limit = mv88e6097_port_pause_limit,
4942 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4943 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4944 .port_get_cmode = mv88e6352_port_get_cmode,
4945 .port_setup_message_port = mv88e6xxx_setup_message_port,
4946 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4947 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4948 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4949 .stats_get_strings = mv88e6320_stats_get_strings,
4950 .stats_get_stats = mv88e6320_stats_get_stats,
4951 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4952 .set_egress_port = mv88e6095_g1_set_egress_port,
4953 .watchdog_ops = &mv88e6390_watchdog_ops,
4954 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4955 .reset = mv88e6352_g1_reset,
4956 .vtu_getnext = mv88e6185_g1_vtu_getnext,
4957 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
4958 .gpio_ops = &mv88e6352_gpio_ops,
4959 .avb_ops = &mv88e6352_avb_ops,
4960 .ptp_ops = &mv88e6352_ptp_ops,
4961 .phylink_get_caps = mv88e6185_phylink_get_caps,
4964 static const struct mv88e6xxx_ops mv88e6341_ops = {
4965 /* MV88E6XXX_FAMILY_6341 */
4966 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4967 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4968 .irl_init_all = mv88e6352_g2_irl_init_all,
4969 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4970 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4971 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4972 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
4973 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
4974 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
4975 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
4976 .port_set_link = mv88e6xxx_port_set_link,
4977 .port_sync_link = mv88e6xxx_port_sync_link,
4978 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4979 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
4980 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
4981 .port_tag_remap = mv88e6095_port_tag_remap,
4982 .port_set_policy = mv88e6352_port_set_policy,
4983 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4984 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4985 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4986 .port_set_ether_type = mv88e6351_port_set_ether_type,
4987 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4988 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4989 .port_pause_limit = mv88e6097_port_pause_limit,
4990 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4991 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4992 .port_get_cmode = mv88e6352_port_get_cmode,
4993 .port_set_cmode = mv88e6341_port_set_cmode,
4994 .port_setup_message_port = mv88e6xxx_setup_message_port,
4995 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4996 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4997 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4998 .stats_get_strings = mv88e6320_stats_get_strings,
4999 .stats_get_stats = mv88e6390_stats_get_stats,
5000 .set_cpu_port = mv88e6390_g1_set_cpu_port,
5001 .set_egress_port = mv88e6390_g1_set_egress_port,
5002 .watchdog_ops = &mv88e6390_watchdog_ops,
5003 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
5004 .pot_clear = mv88e6xxx_g2_pot_clear,
5005 .reset = mv88e6352_g1_reset,
5006 .rmu_disable = mv88e6390_g1_rmu_disable,
5007 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5008 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5009 .vtu_getnext = mv88e6352_g1_vtu_getnext,
5010 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
5011 .stu_getnext = mv88e6352_g1_stu_getnext,
5012 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
5013 .serdes_get_lane = mv88e6341_serdes_get_lane,
5014 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
5015 .gpio_ops = &mv88e6352_gpio_ops,
5016 .avb_ops = &mv88e6390_avb_ops,
5017 .ptp_ops = &mv88e6352_ptp_ops,
5018 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
5019 .serdes_get_strings = mv88e6390_serdes_get_strings,
5020 .serdes_get_stats = mv88e6390_serdes_get_stats,
5021 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
5022 .serdes_get_regs = mv88e6390_serdes_get_regs,
5023 .phylink_get_caps = mv88e6341_phylink_get_caps,
5024 .pcs_ops = &mv88e6390_pcs_ops,
5027 static const struct mv88e6xxx_ops mv88e6350_ops = {
5028 /* MV88E6XXX_FAMILY_6351 */
5029 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
5030 .ip_pri_map = mv88e6085_g1_ip_pri_map,
5031 .irl_init_all = mv88e6352_g2_irl_init_all,
5032 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5033 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5034 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5035 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5036 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5037 .port_set_link = mv88e6xxx_port_set_link,
5038 .port_sync_link = mv88e6xxx_port_sync_link,
5039 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
5040 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
5041 .port_tag_remap = mv88e6095_port_tag_remap,
5042 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5043 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5044 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5045 .port_set_ether_type = mv88e6351_port_set_ether_type,
5046 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5047 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5048 .port_pause_limit = mv88e6097_port_pause_limit,
5049 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5050 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5051 .port_get_cmode = mv88e6352_port_get_cmode,
5052 .port_setup_message_port = mv88e6xxx_setup_message_port,
5053 .stats_snapshot = mv88e6320_g1_stats_snapshot,
5054 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
5055 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
5056 .stats_get_strings = mv88e6095_stats_get_strings,
5057 .stats_get_stats = mv88e6095_stats_get_stats,
5058 .set_cpu_port = mv88e6095_g1_set_cpu_port,
5059 .set_egress_port = mv88e6095_g1_set_egress_port,
5060 .watchdog_ops = &mv88e6097_watchdog_ops,
5061 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
5062 .pot_clear = mv88e6xxx_g2_pot_clear,
5063 .reset = mv88e6352_g1_reset,
5064 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5065 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5066 .vtu_getnext = mv88e6352_g1_vtu_getnext,
5067 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
5068 .stu_getnext = mv88e6352_g1_stu_getnext,
5069 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
5070 .phylink_get_caps = mv88e6185_phylink_get_caps,
5073 static const struct mv88e6xxx_ops mv88e6351_ops = {
5074 /* MV88E6XXX_FAMILY_6351 */
5075 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
5076 .ip_pri_map = mv88e6085_g1_ip_pri_map,
5077 .irl_init_all = mv88e6352_g2_irl_init_all,
5078 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5079 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5080 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5081 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5082 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5083 .port_set_link = mv88e6xxx_port_set_link,
5084 .port_sync_link = mv88e6xxx_port_sync_link,
5085 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
5086 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
5087 .port_tag_remap = mv88e6095_port_tag_remap,
5088 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5089 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5090 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5091 .port_set_ether_type = mv88e6351_port_set_ether_type,
5092 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5093 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5094 .port_pause_limit = mv88e6097_port_pause_limit,
5095 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5096 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5097 .port_get_cmode = mv88e6352_port_get_cmode,
5098 .port_setup_message_port = mv88e6xxx_setup_message_port,
5099 .stats_snapshot = mv88e6320_g1_stats_snapshot,
5100 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
5101 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
5102 .stats_get_strings = mv88e6095_stats_get_strings,
5103 .stats_get_stats = mv88e6095_stats_get_stats,
5104 .set_cpu_port = mv88e6095_g1_set_cpu_port,
5105 .set_egress_port = mv88e6095_g1_set_egress_port,
5106 .watchdog_ops = &mv88e6097_watchdog_ops,
5107 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
5108 .pot_clear = mv88e6xxx_g2_pot_clear,
5109 .reset = mv88e6352_g1_reset,
5110 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5111 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5112 .vtu_getnext = mv88e6352_g1_vtu_getnext,
5113 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
5114 .stu_getnext = mv88e6352_g1_stu_getnext,
5115 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
5116 .avb_ops = &mv88e6352_avb_ops,
5117 .ptp_ops = &mv88e6352_ptp_ops,
5118 .phylink_get_caps = mv88e6185_phylink_get_caps,
5121 static const struct mv88e6xxx_ops mv88e6352_ops = {
5122 /* MV88E6XXX_FAMILY_6352 */
5123 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
5124 .ip_pri_map = mv88e6085_g1_ip_pri_map,
5125 .irl_init_all = mv88e6352_g2_irl_init_all,
5126 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
5127 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
5128 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5129 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5130 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5131 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5132 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5133 .port_set_link = mv88e6xxx_port_set_link,
5134 .port_sync_link = mv88e6xxx_port_sync_link,
5135 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
5136 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
5137 .port_tag_remap = mv88e6095_port_tag_remap,
5138 .port_set_policy = mv88e6352_port_set_policy,
5139 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5140 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5141 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5142 .port_set_ether_type = mv88e6351_port_set_ether_type,
5143 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5144 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5145 .port_pause_limit = mv88e6097_port_pause_limit,
5146 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5147 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5148 .port_get_cmode = mv88e6352_port_get_cmode,
5149 .port_setup_message_port = mv88e6xxx_setup_message_port,
5150 .stats_snapshot = mv88e6320_g1_stats_snapshot,
5151 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
5152 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
5153 .stats_get_strings = mv88e6095_stats_get_strings,
5154 .stats_get_stats = mv88e6095_stats_get_stats,
5155 .set_cpu_port = mv88e6095_g1_set_cpu_port,
5156 .set_egress_port = mv88e6095_g1_set_egress_port,
5157 .watchdog_ops = &mv88e6097_watchdog_ops,
5158 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
5159 .pot_clear = mv88e6xxx_g2_pot_clear,
5160 .reset = mv88e6352_g1_reset,
5161 .rmu_disable = mv88e6352_g1_rmu_disable,
5162 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5163 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5164 .vtu_getnext = mv88e6352_g1_vtu_getnext,
5165 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
5166 .stu_getnext = mv88e6352_g1_stu_getnext,
5167 .stu_loadpurge = mv88e6352_g1_stu_loadpurge,
5168 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
5169 .gpio_ops = &mv88e6352_gpio_ops,
5170 .avb_ops = &mv88e6352_avb_ops,
5171 .ptp_ops = &mv88e6352_ptp_ops,
5172 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
5173 .serdes_get_strings = mv88e6352_serdes_get_strings,
5174 .serdes_get_stats = mv88e6352_serdes_get_stats,
5175 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
5176 .serdes_get_regs = mv88e6352_serdes_get_regs,
5177 .serdes_set_tx_amplitude = mv88e6352_serdes_set_tx_amplitude,
5178 .phylink_get_caps = mv88e6352_phylink_get_caps,
5179 .pcs_ops = &mv88e6352_pcs_ops,
5182 static const struct mv88e6xxx_ops mv88e6390_ops = {
5183 /* MV88E6XXX_FAMILY_6390 */
5184 .setup_errata = mv88e6390_setup_errata,
5185 .irl_init_all = mv88e6390_g2_irl_init_all,
5186 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
5187 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
5188 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5189 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5190 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5191 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5192 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5193 .port_set_link = mv88e6xxx_port_set_link,
5194 .port_sync_link = mv88e6xxx_port_sync_link,
5195 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
5196 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
5197 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
5198 .port_tag_remap = mv88e6390_port_tag_remap,
5199 .port_set_policy = mv88e6352_port_set_policy,
5200 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5201 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5202 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5203 .port_set_ether_type = mv88e6351_port_set_ether_type,
5204 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5205 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5206 .port_pause_limit = mv88e6390_port_pause_limit,
5207 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5208 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5209 .port_get_cmode = mv88e6352_port_get_cmode,
5210 .port_set_cmode = mv88e6390_port_set_cmode,
5211 .port_setup_message_port = mv88e6xxx_setup_message_port,
5212 .stats_snapshot = mv88e6390_g1_stats_snapshot,
5213 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
5214 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
5215 .stats_get_strings = mv88e6320_stats_get_strings,
5216 .stats_get_stats = mv88e6390_stats_get_stats,
5217 .set_cpu_port = mv88e6390_g1_set_cpu_port,
5218 .set_egress_port = mv88e6390_g1_set_egress_port,
5219 .watchdog_ops = &mv88e6390_watchdog_ops,
5220 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
5221 .pot_clear = mv88e6xxx_g2_pot_clear,
5222 .reset = mv88e6352_g1_reset,
5223 .rmu_disable = mv88e6390_g1_rmu_disable,
5224 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5225 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5226 .vtu_getnext = mv88e6390_g1_vtu_getnext,
5227 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
5228 .stu_getnext = mv88e6390_g1_stu_getnext,
5229 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
5230 .serdes_get_lane = mv88e6390_serdes_get_lane,
5231 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
5232 .gpio_ops = &mv88e6352_gpio_ops,
5233 .avb_ops = &mv88e6390_avb_ops,
5234 .ptp_ops = &mv88e6390_ptp_ops,
5235 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
5236 .serdes_get_strings = mv88e6390_serdes_get_strings,
5237 .serdes_get_stats = mv88e6390_serdes_get_stats,
5238 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
5239 .serdes_get_regs = mv88e6390_serdes_get_regs,
5240 .phylink_get_caps = mv88e6390_phylink_get_caps,
5241 .pcs_ops = &mv88e6390_pcs_ops,
5244 static const struct mv88e6xxx_ops mv88e6390x_ops = {
5245 /* MV88E6XXX_FAMILY_6390 */
5246 .setup_errata = mv88e6390_setup_errata,
5247 .irl_init_all = mv88e6390_g2_irl_init_all,
5248 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
5249 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
5250 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5251 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5252 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5253 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5254 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5255 .port_set_link = mv88e6xxx_port_set_link,
5256 .port_sync_link = mv88e6xxx_port_sync_link,
5257 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
5258 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
5259 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
5260 .port_tag_remap = mv88e6390_port_tag_remap,
5261 .port_set_policy = mv88e6352_port_set_policy,
5262 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5263 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5264 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5265 .port_set_ether_type = mv88e6351_port_set_ether_type,
5266 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5267 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5268 .port_pause_limit = mv88e6390_port_pause_limit,
5269 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5270 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5271 .port_get_cmode = mv88e6352_port_get_cmode,
5272 .port_set_cmode = mv88e6390x_port_set_cmode,
5273 .port_setup_message_port = mv88e6xxx_setup_message_port,
5274 .stats_snapshot = mv88e6390_g1_stats_snapshot,
5275 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
5276 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
5277 .stats_get_strings = mv88e6320_stats_get_strings,
5278 .stats_get_stats = mv88e6390_stats_get_stats,
5279 .set_cpu_port = mv88e6390_g1_set_cpu_port,
5280 .set_egress_port = mv88e6390_g1_set_egress_port,
5281 .watchdog_ops = &mv88e6390_watchdog_ops,
5282 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
5283 .pot_clear = mv88e6xxx_g2_pot_clear,
5284 .reset = mv88e6352_g1_reset,
5285 .rmu_disable = mv88e6390_g1_rmu_disable,
5286 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5287 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5288 .vtu_getnext = mv88e6390_g1_vtu_getnext,
5289 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
5290 .stu_getnext = mv88e6390_g1_stu_getnext,
5291 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
5292 .serdes_get_lane = mv88e6390x_serdes_get_lane,
5293 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
5294 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
5295 .serdes_get_strings = mv88e6390_serdes_get_strings,
5296 .serdes_get_stats = mv88e6390_serdes_get_stats,
5297 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
5298 .serdes_get_regs = mv88e6390_serdes_get_regs,
5299 .gpio_ops = &mv88e6352_gpio_ops,
5300 .avb_ops = &mv88e6390_avb_ops,
5301 .ptp_ops = &mv88e6390_ptp_ops,
5302 .phylink_get_caps = mv88e6390x_phylink_get_caps,
5303 .pcs_ops = &mv88e6390_pcs_ops,
5306 static const struct mv88e6xxx_ops mv88e6393x_ops = {
5307 /* MV88E6XXX_FAMILY_6393 */
5308 .irl_init_all = mv88e6390_g2_irl_init_all,
5309 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
5310 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
5311 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
5312 .phy_read = mv88e6xxx_g2_smi_phy_read_c22,
5313 .phy_write = mv88e6xxx_g2_smi_phy_write_c22,
5314 .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45,
5315 .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45,
5316 .port_set_link = mv88e6xxx_port_set_link,
5317 .port_sync_link = mv88e6xxx_port_sync_link,
5318 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
5319 .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
5320 .port_max_speed_mode = mv88e6393x_port_max_speed_mode,
5321 .port_tag_remap = mv88e6390_port_tag_remap,
5322 .port_set_policy = mv88e6393x_port_set_policy,
5323 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
5324 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
5325 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
5326 .port_set_ether_type = mv88e6393x_port_set_ether_type,
5327 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
5328 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
5329 .port_pause_limit = mv88e6390_port_pause_limit,
5330 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
5331 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
5332 .port_get_cmode = mv88e6352_port_get_cmode,
5333 .port_set_cmode = mv88e6393x_port_set_cmode,
5334 .port_setup_message_port = mv88e6xxx_setup_message_port,
5335 .port_set_upstream_port = mv88e6393x_port_set_upstream_port,
5336 .stats_snapshot = mv88e6390_g1_stats_snapshot,
5337 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
5338 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
5339 .stats_get_strings = mv88e6320_stats_get_strings,
5340 .stats_get_stats = mv88e6390_stats_get_stats,
5341 /* .set_cpu_port is missing because this family does not support a global
5342 * CPU port, only per port CPU port which is set via
5343 * .port_set_upstream_port method.
5345 .set_egress_port = mv88e6393x_set_egress_port,
5346 .watchdog_ops = &mv88e6393x_watchdog_ops,
5347 .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
5348 .pot_clear = mv88e6xxx_g2_pot_clear,
5349 .reset = mv88e6352_g1_reset,
5350 .rmu_disable = mv88e6390_g1_rmu_disable,
5351 .atu_get_hash = mv88e6165_g1_atu_get_hash,
5352 .atu_set_hash = mv88e6165_g1_atu_set_hash,
5353 .vtu_getnext = mv88e6390_g1_vtu_getnext,
5354 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
5355 .stu_getnext = mv88e6390_g1_stu_getnext,
5356 .stu_loadpurge = mv88e6390_g1_stu_loadpurge,
5357 .serdes_get_lane = mv88e6393x_serdes_get_lane,
5358 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
5359 /* TODO: serdes stats */
5360 .gpio_ops = &mv88e6352_gpio_ops,
5361 .avb_ops = &mv88e6390_avb_ops,
5362 .ptp_ops = &mv88e6352_ptp_ops,
5363 .phylink_get_caps = mv88e6393x_phylink_get_caps,
5364 .pcs_ops = &mv88e6393x_pcs_ops,
5367 static const struct mv88e6xxx_info mv88e6xxx_table[] = {
5369 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6020,
5370 .family = MV88E6XXX_FAMILY_6250,
5371 .name = "Marvell 88E6020",
5372 .num_databases = 64,
5374 .num_internal_phys = 2,
5376 .port_base_addr = 0x8,
5377 .phy_base_addr = 0x0,
5378 .global1_addr = 0xf,
5379 .global2_addr = 0x7,
5380 .age_time_coeff = 15000,
5383 .atu_move_port_mask = 0xf,
5385 .ops = &mv88e6250_ops,
5389 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6071,
5390 .family = MV88E6XXX_FAMILY_6250,
5391 .name = "Marvell 88E6071",
5392 .num_databases = 64,
5394 .num_internal_phys = 5,
5396 .port_base_addr = 0x08,
5397 .phy_base_addr = 0x00,
5398 .global1_addr = 0x0f,
5399 .global2_addr = 0x07,
5400 .age_time_coeff = 15000,
5403 .atu_move_port_mask = 0xf,
5405 .ops = &mv88e6250_ops,
5409 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
5410 .family = MV88E6XXX_FAMILY_6097,
5411 .name = "Marvell 88E6085",
5412 .num_databases = 4096,
5415 .num_internal_phys = 5,
5418 .port_base_addr = 0x10,
5419 .phy_base_addr = 0x0,
5420 .global1_addr = 0x1b,
5421 .global2_addr = 0x1c,
5422 .age_time_coeff = 15000,
5425 .atu_move_port_mask = 0xf,
5428 .ops = &mv88e6085_ops,
5432 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
5433 .family = MV88E6XXX_FAMILY_6095,
5434 .name = "Marvell 88E6095/88E6095F",
5435 .num_databases = 256,
5438 .num_internal_phys = 0,
5440 .port_base_addr = 0x10,
5441 .phy_base_addr = 0x0,
5442 .global1_addr = 0x1b,
5443 .global2_addr = 0x1c,
5444 .age_time_coeff = 15000,
5446 .atu_move_port_mask = 0xf,
5448 .ops = &mv88e6095_ops,
5452 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
5453 .family = MV88E6XXX_FAMILY_6097,
5454 .name = "Marvell 88E6097/88E6097F",
5455 .num_databases = 4096,
5458 .num_internal_phys = 8,
5461 .port_base_addr = 0x10,
5462 .phy_base_addr = 0x0,
5463 .global1_addr = 0x1b,
5464 .global2_addr = 0x1c,
5465 .age_time_coeff = 15000,
5468 .atu_move_port_mask = 0xf,
5471 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5472 .ops = &mv88e6097_ops,
5476 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
5477 .family = MV88E6XXX_FAMILY_6165,
5478 .name = "Marvell 88E6123",
5479 .num_databases = 4096,
5482 .num_internal_phys = 5,
5485 .port_base_addr = 0x10,
5486 .phy_base_addr = 0x0,
5487 .global1_addr = 0x1b,
5488 .global2_addr = 0x1c,
5489 .age_time_coeff = 15000,
5492 .atu_move_port_mask = 0xf,
5495 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5496 .ops = &mv88e6123_ops,
5500 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
5501 .family = MV88E6XXX_FAMILY_6185,
5502 .name = "Marvell 88E6131",
5503 .num_databases = 256,
5506 .num_internal_phys = 0,
5508 .port_base_addr = 0x10,
5509 .phy_base_addr = 0x0,
5510 .global1_addr = 0x1b,
5511 .global2_addr = 0x1c,
5512 .age_time_coeff = 15000,
5514 .atu_move_port_mask = 0xf,
5516 .ops = &mv88e6131_ops,
5520 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
5521 .family = MV88E6XXX_FAMILY_6341,
5522 .name = "Marvell 88E6141",
5523 .num_databases = 4096,
5526 .num_internal_phys = 5,
5530 .port_base_addr = 0x10,
5531 .phy_base_addr = 0x10,
5532 .global1_addr = 0x1b,
5533 .global2_addr = 0x1c,
5534 .age_time_coeff = 3750,
5535 .atu_move_port_mask = 0x1f,
5540 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5541 .ops = &mv88e6141_ops,
5545 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
5546 .family = MV88E6XXX_FAMILY_6165,
5547 .name = "Marvell 88E6161",
5548 .num_databases = 4096,
5551 .num_internal_phys = 5,
5554 .port_base_addr = 0x10,
5555 .phy_base_addr = 0x0,
5556 .global1_addr = 0x1b,
5557 .global2_addr = 0x1c,
5558 .age_time_coeff = 15000,
5561 .atu_move_port_mask = 0xf,
5564 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5565 .ptp_support = true,
5566 .ops = &mv88e6161_ops,
5570 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
5571 .family = MV88E6XXX_FAMILY_6165,
5572 .name = "Marvell 88E6165",
5573 .num_databases = 4096,
5576 .num_internal_phys = 0,
5579 .port_base_addr = 0x10,
5580 .phy_base_addr = 0x0,
5581 .global1_addr = 0x1b,
5582 .global2_addr = 0x1c,
5583 .age_time_coeff = 15000,
5586 .atu_move_port_mask = 0xf,
5589 .ptp_support = true,
5590 .ops = &mv88e6165_ops,
5594 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
5595 .family = MV88E6XXX_FAMILY_6351,
5596 .name = "Marvell 88E6171",
5597 .num_databases = 4096,
5600 .num_internal_phys = 5,
5603 .port_base_addr = 0x10,
5604 .phy_base_addr = 0x0,
5605 .global1_addr = 0x1b,
5606 .global2_addr = 0x1c,
5607 .age_time_coeff = 15000,
5610 .atu_move_port_mask = 0xf,
5613 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5614 .ops = &mv88e6171_ops,
5618 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
5619 .family = MV88E6XXX_FAMILY_6352,
5620 .name = "Marvell 88E6172",
5621 .num_databases = 4096,
5624 .num_internal_phys = 5,
5628 .port_base_addr = 0x10,
5629 .phy_base_addr = 0x0,
5630 .global1_addr = 0x1b,
5631 .global2_addr = 0x1c,
5632 .age_time_coeff = 15000,
5635 .atu_move_port_mask = 0xf,
5638 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5639 .ops = &mv88e6172_ops,
5643 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
5644 .family = MV88E6XXX_FAMILY_6351,
5645 .name = "Marvell 88E6175",
5646 .num_databases = 4096,
5649 .num_internal_phys = 5,
5652 .port_base_addr = 0x10,
5653 .phy_base_addr = 0x0,
5654 .global1_addr = 0x1b,
5655 .global2_addr = 0x1c,
5656 .age_time_coeff = 15000,
5659 .atu_move_port_mask = 0xf,
5662 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5663 .ops = &mv88e6175_ops,
5667 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
5668 .family = MV88E6XXX_FAMILY_6352,
5669 .name = "Marvell 88E6176",
5670 .num_databases = 4096,
5673 .num_internal_phys = 5,
5677 .port_base_addr = 0x10,
5678 .phy_base_addr = 0x0,
5679 .global1_addr = 0x1b,
5680 .global2_addr = 0x1c,
5681 .age_time_coeff = 15000,
5684 .atu_move_port_mask = 0xf,
5687 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5688 .ops = &mv88e6176_ops,
5692 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
5693 .family = MV88E6XXX_FAMILY_6185,
5694 .name = "Marvell 88E6185",
5695 .num_databases = 256,
5698 .num_internal_phys = 0,
5700 .port_base_addr = 0x10,
5701 .phy_base_addr = 0x0,
5702 .global1_addr = 0x1b,
5703 .global2_addr = 0x1c,
5704 .age_time_coeff = 15000,
5706 .atu_move_port_mask = 0xf,
5708 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5709 .ops = &mv88e6185_ops,
5713 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
5714 .family = MV88E6XXX_FAMILY_6390,
5715 .name = "Marvell 88E6190",
5716 .num_databases = 4096,
5718 .num_ports = 11, /* 10 + Z80 */
5719 .num_internal_phys = 9,
5723 .port_base_addr = 0x0,
5724 .phy_base_addr = 0x0,
5725 .global1_addr = 0x1b,
5726 .global2_addr = 0x1c,
5727 .age_time_coeff = 3750,
5732 .atu_move_port_mask = 0x1f,
5733 .ops = &mv88e6190_ops,
5737 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
5738 .family = MV88E6XXX_FAMILY_6390,
5739 .name = "Marvell 88E6190X",
5740 .num_databases = 4096,
5742 .num_ports = 11, /* 10 + Z80 */
5743 .num_internal_phys = 9,
5747 .port_base_addr = 0x0,
5748 .phy_base_addr = 0x0,
5749 .global1_addr = 0x1b,
5750 .global2_addr = 0x1c,
5751 .age_time_coeff = 3750,
5754 .atu_move_port_mask = 0x1f,
5757 .ops = &mv88e6190x_ops,
5761 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
5762 .family = MV88E6XXX_FAMILY_6390,
5763 .name = "Marvell 88E6191",
5764 .num_databases = 4096,
5766 .num_ports = 11, /* 10 + Z80 */
5767 .num_internal_phys = 9,
5770 .port_base_addr = 0x0,
5771 .phy_base_addr = 0x0,
5772 .global1_addr = 0x1b,
5773 .global2_addr = 0x1c,
5774 .age_time_coeff = 3750,
5777 .atu_move_port_mask = 0x1f,
5780 .ptp_support = true,
5781 .ops = &mv88e6191_ops,
5785 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X,
5786 .family = MV88E6XXX_FAMILY_6393,
5787 .name = "Marvell 88E6191X",
5788 .num_databases = 4096,
5789 .num_ports = 11, /* 10 + Z80 */
5790 .num_internal_phys = 8,
5791 .internal_phys_offset = 1,
5794 .port_base_addr = 0x0,
5795 .phy_base_addr = 0x0,
5796 .global1_addr = 0x1b,
5797 .global2_addr = 0x1c,
5798 .age_time_coeff = 3750,
5801 .atu_move_port_mask = 0x1f,
5804 .ptp_support = true,
5805 .ops = &mv88e6393x_ops,
5809 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X,
5810 .family = MV88E6XXX_FAMILY_6393,
5811 .name = "Marvell 88E6193X",
5812 .num_databases = 4096,
5813 .num_ports = 11, /* 10 + Z80 */
5814 .num_internal_phys = 8,
5815 .internal_phys_offset = 1,
5818 .port_base_addr = 0x0,
5819 .phy_base_addr = 0x0,
5820 .global1_addr = 0x1b,
5821 .global2_addr = 0x1c,
5822 .age_time_coeff = 3750,
5825 .atu_move_port_mask = 0x1f,
5828 .ptp_support = true,
5829 .ops = &mv88e6393x_ops,
5833 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5834 .family = MV88E6XXX_FAMILY_6250,
5835 .name = "Marvell 88E6220",
5836 .num_databases = 64,
5838 /* Ports 2-4 are not routed to pins
5839 * => usable ports 0, 1, 5, 6
5842 .num_internal_phys = 2,
5843 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
5845 .port_base_addr = 0x08,
5846 .phy_base_addr = 0x00,
5847 .global1_addr = 0x0f,
5848 .global2_addr = 0x07,
5849 .age_time_coeff = 15000,
5852 .atu_move_port_mask = 0xf,
5854 .ptp_support = true,
5855 .ops = &mv88e6250_ops,
5859 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
5860 .family = MV88E6XXX_FAMILY_6352,
5861 .name = "Marvell 88E6240",
5862 .num_databases = 4096,
5865 .num_internal_phys = 5,
5869 .port_base_addr = 0x10,
5870 .phy_base_addr = 0x0,
5871 .global1_addr = 0x1b,
5872 .global2_addr = 0x1c,
5873 .age_time_coeff = 15000,
5876 .atu_move_port_mask = 0xf,
5879 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5880 .ptp_support = true,
5881 .ops = &mv88e6240_ops,
5885 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5886 .family = MV88E6XXX_FAMILY_6250,
5887 .name = "Marvell 88E6250",
5888 .num_databases = 64,
5890 .num_internal_phys = 5,
5892 .port_base_addr = 0x08,
5893 .phy_base_addr = 0x00,
5894 .global1_addr = 0x0f,
5895 .global2_addr = 0x07,
5896 .age_time_coeff = 15000,
5899 .atu_move_port_mask = 0xf,
5901 .ptp_support = true,
5902 .ops = &mv88e6250_ops,
5906 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
5907 .family = MV88E6XXX_FAMILY_6390,
5908 .name = "Marvell 88E6290",
5909 .num_databases = 4096,
5910 .num_ports = 11, /* 10 + Z80 */
5911 .num_internal_phys = 9,
5915 .port_base_addr = 0x0,
5916 .phy_base_addr = 0x0,
5917 .global1_addr = 0x1b,
5918 .global2_addr = 0x1c,
5919 .age_time_coeff = 3750,
5922 .atu_move_port_mask = 0x1f,
5925 .ptp_support = true,
5926 .ops = &mv88e6290_ops,
5930 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
5931 .family = MV88E6XXX_FAMILY_6320,
5932 .name = "Marvell 88E6320",
5933 .num_databases = 4096,
5936 .num_internal_phys = 5,
5939 .port_base_addr = 0x10,
5940 .phy_base_addr = 0x0,
5941 .global1_addr = 0x1b,
5942 .global2_addr = 0x1c,
5943 .age_time_coeff = 15000,
5946 .atu_move_port_mask = 0xf,
5949 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5950 .ptp_support = true,
5951 .ops = &mv88e6320_ops,
5955 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
5956 .family = MV88E6XXX_FAMILY_6320,
5957 .name = "Marvell 88E6321",
5958 .num_databases = 4096,
5961 .num_internal_phys = 5,
5964 .port_base_addr = 0x10,
5965 .phy_base_addr = 0x0,
5966 .global1_addr = 0x1b,
5967 .global2_addr = 0x1c,
5968 .age_time_coeff = 15000,
5971 .atu_move_port_mask = 0xf,
5973 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
5974 .ptp_support = true,
5975 .ops = &mv88e6321_ops,
5979 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
5980 .family = MV88E6XXX_FAMILY_6341,
5981 .name = "Marvell 88E6341",
5982 .num_databases = 4096,
5984 .num_internal_phys = 5,
5989 .port_base_addr = 0x10,
5990 .phy_base_addr = 0x10,
5991 .global1_addr = 0x1b,
5992 .global2_addr = 0x1c,
5993 .age_time_coeff = 3750,
5994 .atu_move_port_mask = 0x1f,
5999 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
6000 .ptp_support = true,
6001 .ops = &mv88e6341_ops,
6005 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
6006 .family = MV88E6XXX_FAMILY_6351,
6007 .name = "Marvell 88E6350",
6008 .num_databases = 4096,
6011 .num_internal_phys = 5,
6014 .port_base_addr = 0x10,
6015 .phy_base_addr = 0x0,
6016 .global1_addr = 0x1b,
6017 .global2_addr = 0x1c,
6018 .age_time_coeff = 15000,
6021 .atu_move_port_mask = 0xf,
6024 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
6025 .ops = &mv88e6350_ops,
6029 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
6030 .family = MV88E6XXX_FAMILY_6351,
6031 .name = "Marvell 88E6351",
6032 .num_databases = 4096,
6035 .num_internal_phys = 5,
6038 .port_base_addr = 0x10,
6039 .phy_base_addr = 0x0,
6040 .global1_addr = 0x1b,
6041 .global2_addr = 0x1c,
6042 .age_time_coeff = 15000,
6045 .atu_move_port_mask = 0xf,
6048 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
6049 .ops = &mv88e6351_ops,
6053 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
6054 .family = MV88E6XXX_FAMILY_6352,
6055 .name = "Marvell 88E6352",
6056 .num_databases = 4096,
6059 .num_internal_phys = 5,
6063 .port_base_addr = 0x10,
6064 .phy_base_addr = 0x0,
6065 .global1_addr = 0x1b,
6066 .global2_addr = 0x1c,
6067 .age_time_coeff = 15000,
6070 .atu_move_port_mask = 0xf,
6073 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
6074 .ptp_support = true,
6075 .ops = &mv88e6352_ops,
6078 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6361,
6079 .family = MV88E6XXX_FAMILY_6393,
6080 .name = "Marvell 88E6361",
6081 .num_databases = 4096,
6084 /* Ports 1, 2 and 8 are not routed */
6085 .invalid_port_mask = BIT(1) | BIT(2) | BIT(8),
6086 .num_internal_phys = 5,
6087 .internal_phys_offset = 3,
6090 .port_base_addr = 0x0,
6091 .phy_base_addr = 0x0,
6092 .global1_addr = 0x1b,
6093 .global2_addr = 0x1c,
6094 .age_time_coeff = 3750,
6097 .atu_move_port_mask = 0x1f,
6100 .ptp_support = true,
6101 .ops = &mv88e6393x_ops,
6104 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
6105 .family = MV88E6XXX_FAMILY_6390,
6106 .name = "Marvell 88E6390",
6107 .num_databases = 4096,
6109 .num_ports = 11, /* 10 + Z80 */
6110 .num_internal_phys = 9,
6114 .port_base_addr = 0x0,
6115 .phy_base_addr = 0x0,
6116 .global1_addr = 0x1b,
6117 .global2_addr = 0x1c,
6118 .age_time_coeff = 3750,
6121 .atu_move_port_mask = 0x1f,
6124 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
6125 .ptp_support = true,
6126 .ops = &mv88e6390_ops,
6129 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
6130 .family = MV88E6XXX_FAMILY_6390,
6131 .name = "Marvell 88E6390X",
6132 .num_databases = 4096,
6134 .num_ports = 11, /* 10 + Z80 */
6135 .num_internal_phys = 9,
6139 .port_base_addr = 0x0,
6140 .phy_base_addr = 0x0,
6141 .global1_addr = 0x1b,
6142 .global2_addr = 0x1c,
6143 .age_time_coeff = 3750,
6146 .atu_move_port_mask = 0x1f,
6149 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
6150 .ptp_support = true,
6151 .ops = &mv88e6390x_ops,
6155 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
6156 .family = MV88E6XXX_FAMILY_6393,
6157 .name = "Marvell 88E6393X",
6158 .num_databases = 4096,
6159 .num_ports = 11, /* 10 + Z80 */
6160 .num_internal_phys = 8,
6161 .internal_phys_offset = 1,
6164 .port_base_addr = 0x0,
6165 .phy_base_addr = 0x0,
6166 .global1_addr = 0x1b,
6167 .global2_addr = 0x1c,
6168 .age_time_coeff = 3750,
6171 .atu_move_port_mask = 0x1f,
6174 .ptp_support = true,
6175 .ops = &mv88e6393x_ops,
6179 static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
6183 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
6184 if (mv88e6xxx_table[i].prod_num == prod_num)
6185 return &mv88e6xxx_table[i];
6190 static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
6192 const struct mv88e6xxx_info *info;
6193 unsigned int prod_num, rev;
6197 mv88e6xxx_reg_lock(chip);
6198 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
6199 mv88e6xxx_reg_unlock(chip);
6203 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
6204 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
6206 info = mv88e6xxx_lookup_info(prod_num);
6210 /* Update the compatible info with the probed one */
6213 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
6214 chip->info->prod_num, chip->info->name, rev);
6219 static int mv88e6xxx_single_chip_detect(struct mv88e6xxx_chip *chip,
6220 struct mdio_device *mdiodev)
6224 /* dual_chip takes precedence over single/multi-chip modes */
6225 if (chip->info->dual_chip)
6228 /* If the mdio addr is 16 indicating the first port address of a switch
6229 * (e.g. mv88e6*41) in single chip addressing mode the device may be
6230 * configured in single chip addressing mode. Setup the smi access as
6231 * single chip addressing mode and attempt to detect the model of the
6232 * switch, if this fails the device is not configured in single chip
6235 if (mdiodev->addr != 16)
6238 err = mv88e6xxx_smi_init(chip, mdiodev->bus, 0);
6242 return mv88e6xxx_detect(chip);
6245 static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
6247 struct mv88e6xxx_chip *chip;
6249 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
6255 mutex_init(&chip->reg_lock);
6256 INIT_LIST_HEAD(&chip->mdios);
6257 idr_init(&chip->policies);
6258 INIT_LIST_HEAD(&chip->msts);
6263 static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
6265 enum dsa_tag_protocol m)
6267 struct mv88e6xxx_chip *chip = ds->priv;
6269 return chip->tag_protocol;
6272 static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds,
6273 enum dsa_tag_protocol proto)
6275 struct mv88e6xxx_chip *chip = ds->priv;
6276 enum dsa_tag_protocol old_protocol;
6277 struct dsa_port *cpu_dp;
6281 case DSA_TAG_PROTO_EDSA:
6282 switch (chip->info->edsa_support) {
6283 case MV88E6XXX_EDSA_UNSUPPORTED:
6284 return -EPROTONOSUPPORT;
6285 case MV88E6XXX_EDSA_UNDOCUMENTED:
6286 dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n");
6288 case MV88E6XXX_EDSA_SUPPORTED:
6292 case DSA_TAG_PROTO_DSA:
6295 return -EPROTONOSUPPORT;
6298 old_protocol = chip->tag_protocol;
6299 chip->tag_protocol = proto;
6301 mv88e6xxx_reg_lock(chip);
6302 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
6303 err = mv88e6xxx_setup_port_mode(chip, cpu_dp->index);
6305 mv88e6xxx_reg_unlock(chip);
6309 mv88e6xxx_reg_unlock(chip);
6314 chip->tag_protocol = old_protocol;
6316 mv88e6xxx_reg_lock(chip);
6317 dsa_switch_for_each_cpu_port_continue_reverse(cpu_dp, ds)
6318 mv88e6xxx_setup_port_mode(chip, cpu_dp->index);
6319 mv88e6xxx_reg_unlock(chip);
6324 static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
6325 const struct switchdev_obj_port_mdb *mdb,
6328 struct mv88e6xxx_chip *chip = ds->priv;
6331 mv88e6xxx_reg_lock(chip);
6332 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
6333 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
6334 mv88e6xxx_reg_unlock(chip);
6339 static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
6340 const struct switchdev_obj_port_mdb *mdb,
6343 struct mv88e6xxx_chip *chip = ds->priv;
6346 mv88e6xxx_reg_lock(chip);
6347 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
6348 mv88e6xxx_reg_unlock(chip);
6353 static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
6354 struct dsa_mall_mirror_tc_entry *mirror,
6356 struct netlink_ext_ack *extack)
6358 enum mv88e6xxx_egress_direction direction = ingress ?
6359 MV88E6XXX_EGRESS_DIR_INGRESS :
6360 MV88E6XXX_EGRESS_DIR_EGRESS;
6361 struct mv88e6xxx_chip *chip = ds->priv;
6362 bool other_mirrors = false;
6366 mutex_lock(&chip->reg_lock);
6367 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
6368 mirror->to_local_port) {
6369 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
6370 other_mirrors |= ingress ?
6371 chip->ports[i].mirror_ingress :
6372 chip->ports[i].mirror_egress;
6374 /* Can't change egress port when other mirror is active */
6375 if (other_mirrors) {
6380 err = mv88e6xxx_set_egress_port(chip, direction,
6381 mirror->to_local_port);
6386 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
6388 mutex_unlock(&chip->reg_lock);
6393 static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
6394 struct dsa_mall_mirror_tc_entry *mirror)
6396 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
6397 MV88E6XXX_EGRESS_DIR_INGRESS :
6398 MV88E6XXX_EGRESS_DIR_EGRESS;
6399 struct mv88e6xxx_chip *chip = ds->priv;
6400 bool other_mirrors = false;
6403 mutex_lock(&chip->reg_lock);
6404 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
6405 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
6407 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
6408 other_mirrors |= mirror->ingress ?
6409 chip->ports[i].mirror_ingress :
6410 chip->ports[i].mirror_egress;
6412 /* Reset egress port when no other mirror is active */
6413 if (!other_mirrors) {
6414 if (mv88e6xxx_set_egress_port(chip, direction,
6415 dsa_upstream_port(ds, port)))
6416 dev_err(ds->dev, "failed to set egress port\n");
6419 mutex_unlock(&chip->reg_lock);
6422 static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
6423 struct switchdev_brport_flags flags,
6424 struct netlink_ext_ack *extack)
6426 struct mv88e6xxx_chip *chip = ds->priv;
6427 const struct mv88e6xxx_ops *ops;
6429 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD |
6430 BR_BCAST_FLOOD | BR_PORT_LOCKED | BR_PORT_MAB))
6433 ops = chip->info->ops;
6435 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood)
6438 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood)
6444 static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port,
6445 struct switchdev_brport_flags flags,
6446 struct netlink_ext_ack *extack)
6448 struct mv88e6xxx_chip *chip = ds->priv;
6451 mv88e6xxx_reg_lock(chip);
6453 if (flags.mask & BR_LEARNING) {
6454 bool learning = !!(flags.val & BR_LEARNING);
6455 u16 pav = learning ? (1 << port) : 0;
6457 err = mv88e6xxx_port_set_assoc_vector(chip, port, pav);
6462 if (flags.mask & BR_FLOOD) {
6463 bool unicast = !!(flags.val & BR_FLOOD);
6465 err = chip->info->ops->port_set_ucast_flood(chip, port,
6471 if (flags.mask & BR_MCAST_FLOOD) {
6472 bool multicast = !!(flags.val & BR_MCAST_FLOOD);
6474 err = chip->info->ops->port_set_mcast_flood(chip, port,
6480 if (flags.mask & BR_BCAST_FLOOD) {
6481 bool broadcast = !!(flags.val & BR_BCAST_FLOOD);
6483 err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast);
6488 if (flags.mask & BR_PORT_MAB) {
6489 bool mab = !!(flags.val & BR_PORT_MAB);
6491 mv88e6xxx_port_set_mab(chip, port, mab);
6494 if (flags.mask & BR_PORT_LOCKED) {
6495 bool locked = !!(flags.val & BR_PORT_LOCKED);
6497 err = mv88e6xxx_port_set_lock(chip, port, locked);
6502 mv88e6xxx_reg_unlock(chip);
6507 static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds,
6509 struct netdev_lag_upper_info *info,
6510 struct netlink_ext_ack *extack)
6512 struct mv88e6xxx_chip *chip = ds->priv;
6513 struct dsa_port *dp;
6516 if (!mv88e6xxx_has_lag(chip)) {
6517 NL_SET_ERR_MSG_MOD(extack, "Chip does not support LAG offload");
6524 dsa_lag_foreach_port(dp, ds->dst, &lag)
6525 /* Includes the port joining the LAG */
6529 NL_SET_ERR_MSG_MOD(extack,
6530 "Cannot offload more than 8 LAG ports");
6534 /* We could potentially relax this to include active
6535 * backup in the future.
6537 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) {
6538 NL_SET_ERR_MSG_MOD(extack,
6539 "Can only offload LAG using hash TX type");
6543 /* Ideally we would also validate that the hash type matches
6544 * the hardware. Alas, this is always set to unknown on team
6550 static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct dsa_lag lag)
6552 struct mv88e6xxx_chip *chip = ds->priv;
6553 struct dsa_port *dp;
6557 /* DSA LAG IDs are one-based, hardware is zero-based */
6560 /* Build the map of all ports to distribute flows destined for
6561 * this LAG. This can be either a local user port, or a DSA
6562 * port if the LAG port is on a remote chip.
6564 dsa_lag_foreach_port(dp, ds->dst, &lag)
6565 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index));
6567 return mv88e6xxx_g2_trunk_mapping_write(chip, id, map);
6570 static const u8 mv88e6xxx_lag_mask_table[8][8] = {
6571 /* Row number corresponds to the number of active members in a
6572 * LAG. Each column states which of the eight hash buckets are
6573 * mapped to the column:th port in the LAG.
6575 * Example: In a LAG with three active ports, the second port
6576 * ([2][1]) would be selected for traffic mapped to buckets
6579 { 0xff, 0, 0, 0, 0, 0, 0, 0 },
6580 { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 },
6581 { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 },
6582 { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 },
6583 { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 },
6584 { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 },
6585 { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 },
6586 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
6589 static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port,
6590 int num_tx, int nth)
6595 num_tx = num_tx <= 8 ? num_tx : 8;
6597 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth];
6599 for (i = 0; i < 8; i++) {
6600 if (BIT(i) & active)
6601 mask[i] |= BIT(port);
6605 static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds)
6607 struct mv88e6xxx_chip *chip = ds->priv;
6608 unsigned int id, num_tx;
6609 struct dsa_port *dp;
6610 struct dsa_lag *lag;
6615 /* Assume no port is a member of any LAG. */
6616 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1;
6618 /* Disable all masks for ports that _are_ members of a LAG. */
6619 dsa_switch_for_each_port(dp, ds) {
6623 ivec &= ~BIT(dp->index);
6626 for (i = 0; i < 8; i++)
6629 /* Enable the correct subset of masks for all LAG ports that
6630 * are in the Tx set.
6632 dsa_lags_foreach_id(id, ds->dst) {
6633 lag = dsa_lag_by_id(ds->dst, id);
6638 dsa_lag_foreach_port(dp, ds->dst, lag) {
6639 if (dp->lag_tx_enabled)
6647 dsa_lag_foreach_port(dp, ds->dst, lag) {
6648 if (!dp->lag_tx_enabled)
6652 mv88e6xxx_lag_set_port_mask(mask, dp->index,
6659 for (i = 0; i < 8; i++) {
6660 err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]);
6668 static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds,
6673 err = mv88e6xxx_lag_sync_masks(ds);
6676 err = mv88e6xxx_lag_sync_map(ds, lag);
6681 static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port)
6683 struct mv88e6xxx_chip *chip = ds->priv;
6686 mv88e6xxx_reg_lock(chip);
6687 err = mv88e6xxx_lag_sync_masks(ds);
6688 mv88e6xxx_reg_unlock(chip);
6692 static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port,
6694 struct netdev_lag_upper_info *info,
6695 struct netlink_ext_ack *extack)
6697 struct mv88e6xxx_chip *chip = ds->priv;
6700 if (!mv88e6xxx_lag_can_offload(ds, lag, info, extack))
6703 /* DSA LAG IDs are one-based */
6706 mv88e6xxx_reg_lock(chip);
6708 err = mv88e6xxx_port_set_trunk(chip, port, true, id);
6712 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6714 goto err_clear_trunk;
6716 mv88e6xxx_reg_unlock(chip);
6720 mv88e6xxx_port_set_trunk(chip, port, false, 0);
6722 mv88e6xxx_reg_unlock(chip);
6726 static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port,
6729 struct mv88e6xxx_chip *chip = ds->priv;
6730 int err_sync, err_trunk;
6732 mv88e6xxx_reg_lock(chip);
6733 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6734 err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0);
6735 mv88e6xxx_reg_unlock(chip);
6736 return err_sync ? : err_trunk;
6739 static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index,
6742 struct mv88e6xxx_chip *chip = ds->priv;
6745 mv88e6xxx_reg_lock(chip);
6746 err = mv88e6xxx_lag_sync_masks(ds);
6747 mv88e6xxx_reg_unlock(chip);
6751 static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index,
6752 int port, struct dsa_lag lag,
6753 struct netdev_lag_upper_info *info,
6754 struct netlink_ext_ack *extack)
6756 struct mv88e6xxx_chip *chip = ds->priv;
6759 if (!mv88e6xxx_lag_can_offload(ds, lag, info, extack))
6762 mv88e6xxx_reg_lock(chip);
6764 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6768 err = mv88e6xxx_pvt_map(chip, sw_index, port);
6771 mv88e6xxx_reg_unlock(chip);
6775 static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
6776 int port, struct dsa_lag lag)
6778 struct mv88e6xxx_chip *chip = ds->priv;
6779 int err_sync, err_pvt;
6781 mv88e6xxx_reg_lock(chip);
6782 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6783 err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port);
6784 mv88e6xxx_reg_unlock(chip);
6785 return err_sync ? : err_pvt;
6788 static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
6789 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
6790 .change_tag_protocol = mv88e6xxx_change_tag_protocol,
6791 .setup = mv88e6xxx_setup,
6792 .teardown = mv88e6xxx_teardown,
6793 .port_setup = mv88e6xxx_port_setup,
6794 .port_teardown = mv88e6xxx_port_teardown,
6795 .phylink_get_caps = mv88e6xxx_get_caps,
6796 .phylink_mac_select_pcs = mv88e6xxx_mac_select_pcs,
6797 .phylink_mac_prepare = mv88e6xxx_mac_prepare,
6798 .phylink_mac_config = mv88e6xxx_mac_config,
6799 .phylink_mac_finish = mv88e6xxx_mac_finish,
6800 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
6801 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
6802 .get_strings = mv88e6xxx_get_strings,
6803 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
6804 .get_sset_count = mv88e6xxx_get_sset_count,
6805 .port_max_mtu = mv88e6xxx_get_max_mtu,
6806 .port_change_mtu = mv88e6xxx_change_mtu,
6807 .get_mac_eee = mv88e6xxx_get_mac_eee,
6808 .set_mac_eee = mv88e6xxx_set_mac_eee,
6809 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
6810 .get_eeprom = mv88e6xxx_get_eeprom,
6811 .set_eeprom = mv88e6xxx_set_eeprom,
6812 .get_regs_len = mv88e6xxx_get_regs_len,
6813 .get_regs = mv88e6xxx_get_regs,
6814 .get_rxnfc = mv88e6xxx_get_rxnfc,
6815 .set_rxnfc = mv88e6xxx_set_rxnfc,
6816 .set_ageing_time = mv88e6xxx_set_ageing_time,
6817 .port_bridge_join = mv88e6xxx_port_bridge_join,
6818 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
6819 .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags,
6820 .port_bridge_flags = mv88e6xxx_port_bridge_flags,
6821 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
6822 .port_mst_state_set = mv88e6xxx_port_mst_state_set,
6823 .port_fast_age = mv88e6xxx_port_fast_age,
6824 .port_vlan_fast_age = mv88e6xxx_port_vlan_fast_age,
6825 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
6826 .port_vlan_add = mv88e6xxx_port_vlan_add,
6827 .port_vlan_del = mv88e6xxx_port_vlan_del,
6828 .vlan_msti_set = mv88e6xxx_vlan_msti_set,
6829 .port_fdb_add = mv88e6xxx_port_fdb_add,
6830 .port_fdb_del = mv88e6xxx_port_fdb_del,
6831 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
6832 .port_mdb_add = mv88e6xxx_port_mdb_add,
6833 .port_mdb_del = mv88e6xxx_port_mdb_del,
6834 .port_mirror_add = mv88e6xxx_port_mirror_add,
6835 .port_mirror_del = mv88e6xxx_port_mirror_del,
6836 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
6837 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
6838 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
6839 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
6840 .port_txtstamp = mv88e6xxx_port_txtstamp,
6841 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
6842 .get_ts_info = mv88e6xxx_get_ts_info,
6843 .devlink_param_get = mv88e6xxx_devlink_param_get,
6844 .devlink_param_set = mv88e6xxx_devlink_param_set,
6845 .devlink_info_get = mv88e6xxx_devlink_info_get,
6846 .port_lag_change = mv88e6xxx_port_lag_change,
6847 .port_lag_join = mv88e6xxx_port_lag_join,
6848 .port_lag_leave = mv88e6xxx_port_lag_leave,
6849 .crosschip_lag_change = mv88e6xxx_crosschip_lag_change,
6850 .crosschip_lag_join = mv88e6xxx_crosschip_lag_join,
6851 .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave,
6854 static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
6856 struct device *dev = chip->dev;
6857 struct dsa_switch *ds;
6859 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
6864 ds->num_ports = mv88e6xxx_num_ports(chip);
6867 ds->ops = &mv88e6xxx_switch_ops;
6868 ds->ageing_time_min = chip->info->age_time_coeff;
6869 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
6871 /* Some chips support up to 32, but that requires enabling the
6872 * 5-bit port mode, which we do not support. 640k^W16 ought to
6873 * be enough for anyone.
6875 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0;
6877 dev_set_drvdata(dev, ds);
6879 return dsa_register_switch(ds);
6882 static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
6884 dsa_unregister_switch(chip->ds);
6887 static const void *pdata_device_get_match_data(struct device *dev)
6889 const struct of_device_id *matches = dev->driver->of_match_table;
6890 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
6892 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
6894 if (!strcmp(pdata->compatible, matches->compatible))
6895 return matches->data;
6900 /* There is no suspend to RAM support at DSA level yet, the switch configuration
6901 * would be lost after a power cycle so prevent it to be suspended.
6903 static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
6908 static int __maybe_unused mv88e6xxx_resume(struct device *dev)
6913 static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
6915 static int mv88e6xxx_probe(struct mdio_device *mdiodev)
6917 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
6918 const struct mv88e6xxx_info *compat_info = NULL;
6919 struct device *dev = &mdiodev->dev;
6920 struct device_node *np = dev->of_node;
6921 struct mv88e6xxx_chip *chip;
6929 compat_info = of_device_get_match_data(dev);
6932 compat_info = pdata_device_get_match_data(dev);
6937 for (port = 0; port < DSA_MAX_PORTS; port++) {
6938 if (!(pdata->enabled_ports & (1 << port)))
6940 if (strcmp(pdata->cd.port_names[port], "cpu"))
6942 pdata->cd.netdev[port] = &pdata->netdev->dev;
6950 chip = mv88e6xxx_alloc_chip(dev);
6956 chip->info = compat_info;
6958 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
6959 if (IS_ERR(chip->reset)) {
6960 err = PTR_ERR(chip->reset);
6964 usleep_range(10000, 20000);
6966 /* Detect if the device is configured in single chip addressing mode,
6967 * otherwise continue with address specific smi init/detection.
6969 err = mv88e6xxx_single_chip_detect(chip, mdiodev);
6971 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
6975 err = mv88e6xxx_detect(chip);
6980 if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED)
6981 chip->tag_protocol = DSA_TAG_PROTO_EDSA;
6983 chip->tag_protocol = DSA_TAG_PROTO_DSA;
6985 mv88e6xxx_phy_init(chip);
6987 if (chip->info->ops->get_eeprom) {
6989 of_property_read_u32(np, "eeprom-length",
6992 chip->eeprom_len = pdata->eeprom_len;
6995 mv88e6xxx_reg_lock(chip);
6996 err = mv88e6xxx_switch_reset(chip);
6997 mv88e6xxx_reg_unlock(chip);
7002 chip->irq = of_irq_get(np, 0);
7003 if (chip->irq == -EPROBE_DEFER) {
7010 chip->irq = pdata->irq;
7012 /* Has to be performed before the MDIO bus is created, because
7013 * the PHYs will link their interrupts to these interrupt
7016 mv88e6xxx_reg_lock(chip);
7018 err = mv88e6xxx_g1_irq_setup(chip);
7020 err = mv88e6xxx_irq_poll_setup(chip);
7021 mv88e6xxx_reg_unlock(chip);
7026 if (chip->info->g2_irqs > 0) {
7027 err = mv88e6xxx_g2_irq_setup(chip);
7032 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
7036 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
7038 goto out_g1_atu_prob_irq;
7040 err = mv88e6xxx_register_switch(chip);
7042 goto out_g1_vtu_prob_irq;
7046 out_g1_vtu_prob_irq:
7047 mv88e6xxx_g1_vtu_prob_irq_free(chip);
7048 out_g1_atu_prob_irq:
7049 mv88e6xxx_g1_atu_prob_irq_free(chip);
7051 if (chip->info->g2_irqs > 0)
7052 mv88e6xxx_g2_irq_free(chip);
7055 mv88e6xxx_g1_irq_free(chip);
7057 mv88e6xxx_irq_poll_free(chip);
7060 dev_put(pdata->netdev);
7065 static void mv88e6xxx_remove(struct mdio_device *mdiodev)
7067 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
7068 struct mv88e6xxx_chip *chip;
7075 if (chip->info->ptp_support) {
7076 mv88e6xxx_hwtstamp_free(chip);
7077 mv88e6xxx_ptp_free(chip);
7080 mv88e6xxx_phy_destroy(chip);
7081 mv88e6xxx_unregister_switch(chip);
7083 mv88e6xxx_g1_vtu_prob_irq_free(chip);
7084 mv88e6xxx_g1_atu_prob_irq_free(chip);
7086 if (chip->info->g2_irqs > 0)
7087 mv88e6xxx_g2_irq_free(chip);
7090 mv88e6xxx_g1_irq_free(chip);
7092 mv88e6xxx_irq_poll_free(chip);
7095 static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
7097 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
7102 dsa_switch_shutdown(ds);
7104 dev_set_drvdata(&mdiodev->dev, NULL);
7107 static const struct of_device_id mv88e6xxx_of_match[] = {
7109 .compatible = "marvell,mv88e6085",
7110 .data = &mv88e6xxx_table[MV88E6085],
7113 .compatible = "marvell,mv88e6190",
7114 .data = &mv88e6xxx_table[MV88E6190],
7117 .compatible = "marvell,mv88e6250",
7118 .data = &mv88e6xxx_table[MV88E6250],
7123 MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
7125 static struct mdio_driver mv88e6xxx_driver = {
7126 .probe = mv88e6xxx_probe,
7127 .remove = mv88e6xxx_remove,
7128 .shutdown = mv88e6xxx_shutdown,
7130 .name = "mv88e6085",
7131 .of_match_table = mv88e6xxx_of_match,
7132 .pm = &mv88e6xxx_pm_ops,
7136 mdio_module_driver(mv88e6xxx_driver);
7138 MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
7139 MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
7140 MODULE_LICENSE("GPL");