Lines Matching +full:smi +full:- +full:mdio

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Marvell 88e6xxx Ethernet switch single-chip support
9 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
24 #include <linux/mdio.h>
44 #include "smi.h"
48 if (unlikely(!mutex_is_locked(&chip->reg_lock))) { in assert_reg_lock()
49 dev_err(chip->dev, "Switch registers lock not held!\n"); in assert_reg_lock()
64 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", in mv88e6xxx_read()
80 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", in mv88e6xxx_write()
112 dev_err(chip->dev, "Timeout while waiting for switch\n"); in mv88e6xxx_wait_mask()
113 return -ETIMEDOUT; in mv88e6xxx_wait_mask()
127 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, in mv88e6xxx_default_mdio_bus()
132 return mdio_bus->bus; in mv88e6xxx_default_mdio_bus()
138 unsigned int n = d->hwirq; in mv88e6xxx_g1_irq_mask()
140 chip->g1_irq.masked |= (1 << n); in mv88e6xxx_g1_irq_mask()
146 unsigned int n = d->hwirq; in mv88e6xxx_g1_irq_unmask()
148 chip->g1_irq.masked &= ~(1 << n); in mv88e6xxx_g1_irq_unmask()
168 for (n = 0; n < chip->g1_irq.nirqs; ++n) { in mv88e6xxx_g1_irq_thread_work()
170 sub_irq = irq_find_mapping(chip->g1_irq.domain, in mv88e6xxx_g1_irq_thread_work()
186 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); in mv88e6xxx_g1_irq_thread_work()
210 u16 mask = GENMASK(chip->g1_irq.nirqs, 0); in mv88e6xxx_g1_irq_bus_sync_unlock()
219 reg |= (~chip->g1_irq.masked & mask); in mv88e6xxx_g1_irq_bus_sync_unlock()
230 .name = "mv88e6xxx-g1",
241 struct mv88e6xxx_chip *chip = d->host_data; in mv88e6xxx_g1_irq_domain_map()
243 irq_set_chip_data(irq, d->host_data); in mv88e6xxx_g1_irq_domain_map()
244 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); in mv88e6xxx_g1_irq_domain_map()
262 mask &= ~GENMASK(chip->g1_irq.nirqs, 0); in mv88e6xxx_g1_irq_free_common()
265 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { in mv88e6xxx_g1_irq_free_common()
266 virq = irq_find_mapping(chip->g1_irq.domain, irq); in mv88e6xxx_g1_irq_free_common()
270 irq_domain_remove(chip->g1_irq.domain); in mv88e6xxx_g1_irq_free_common()
279 free_irq(chip->irq, chip); in mv88e6xxx_g1_irq_free()
291 chip->g1_irq.nirqs = chip->info->g1_irqs; in mv88e6xxx_g1_irq_setup_common()
292 chip->g1_irq.domain = irq_domain_add_simple( in mv88e6xxx_g1_irq_setup_common()
293 NULL, chip->g1_irq.nirqs, 0, in mv88e6xxx_g1_irq_setup_common()
295 if (!chip->g1_irq.domain) in mv88e6xxx_g1_irq_setup_common()
296 return -ENOMEM; in mv88e6xxx_g1_irq_setup_common()
298 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) in mv88e6xxx_g1_irq_setup_common()
299 irq_create_mapping(chip->g1_irq.domain, irq); in mv88e6xxx_g1_irq_setup_common()
301 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; in mv88e6xxx_g1_irq_setup_common()
302 chip->g1_irq.masked = ~0; in mv88e6xxx_g1_irq_setup_common()
308 mask &= ~GENMASK(chip->g1_irq.nirqs, 0); in mv88e6xxx_g1_irq_setup_common()
322 mask &= ~GENMASK(chip->g1_irq.nirqs, 0); in mv88e6xxx_g1_irq_setup_common()
327 virq = irq_find_mapping(chip->g1_irq.domain, irq); in mv88e6xxx_g1_irq_setup_common()
331 irq_domain_remove(chip->g1_irq.domain); in mv88e6xxx_g1_irq_setup_common()
350 irq_set_lockdep_class(chip->irq, &lock_key, &request_key); in mv88e6xxx_g1_irq_setup()
352 snprintf(chip->irq_name, sizeof(chip->irq_name), in mv88e6xxx_g1_irq_setup()
353 "mv88e6xxx-%s", dev_name(chip->dev)); in mv88e6xxx_g1_irq_setup()
356 err = request_threaded_irq(chip->irq, NULL, in mv88e6xxx_g1_irq_setup()
359 chip->irq_name, chip); in mv88e6xxx_g1_irq_setup()
374 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, in mv88e6xxx_irq_poll()
386 kthread_init_delayed_work(&chip->irq_poll_work, in mv88e6xxx_irq_poll_setup()
389 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev)); in mv88e6xxx_irq_poll_setup()
390 if (IS_ERR(chip->kworker)) in mv88e6xxx_irq_poll_setup()
391 return PTR_ERR(chip->kworker); in mv88e6xxx_irq_poll_setup()
393 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, in mv88e6xxx_irq_poll_setup()
401 kthread_cancel_delayed_work_sync(&chip->irq_poll_work); in mv88e6xxx_irq_poll_free()
402 kthread_destroy_worker(chip->kworker); in mv88e6xxx_irq_poll_free()
414 if (chip->info->ops->port_set_rgmii_delay) { in mv88e6xxx_port_config_interface()
415 err = chip->info->ops->port_set_rgmii_delay(chip, port, in mv88e6xxx_port_config_interface()
417 if (err && err != -EOPNOTSUPP) in mv88e6xxx_port_config_interface()
421 if (chip->info->ops->port_set_cmode) { in mv88e6xxx_port_config_interface()
422 err = chip->info->ops->port_set_cmode(chip, port, in mv88e6xxx_port_config_interface()
424 if (err && err != -EOPNOTSUPP) in mv88e6xxx_port_config_interface()
437 if (!chip->info->ops->port_set_link) in mv88e6xxx_port_setup_mac()
441 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); in mv88e6xxx_port_setup_mac()
445 if (chip->info->ops->port_set_speed_duplex) { in mv88e6xxx_port_setup_mac()
446 err = chip->info->ops->port_set_speed_duplex(chip, port, in mv88e6xxx_port_setup_mac()
448 if (err && err != -EOPNOTSUPP) in mv88e6xxx_port_setup_mac()
452 if (chip->info->ops->port_set_pause) { in mv88e6xxx_port_setup_mac()
453 err = chip->info->ops->port_set_pause(chip, port, pause); in mv88e6xxx_port_setup_mac()
460 if (chip->info->ops->port_set_link(chip, port, link)) in mv88e6xxx_port_setup_mac()
461 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port); in mv88e6xxx_port_setup_mac()
468 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_phy_is_internal()
470 return port < chip->info->num_internal_phys; in mv88e6xxx_phy_is_internal()
481 if (chip->info->family == MV88E6XXX_FAMILY_6250) in mv88e6xxx_port_ppu_updates()
482 return port < chip->info->num_internal_phys; in mv88e6xxx_port_ppu_updates()
486 dev_err(chip->dev, in mv88e6xxx_port_ppu_updates()
498 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_serdes_pcs_get_state()
504 if (lane >= 0 && chip->info->ops->serdes_pcs_get_state) in mv88e6xxx_serdes_pcs_get_state()
505 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, in mv88e6xxx_serdes_pcs_get_state()
508 err = -EOPNOTSUPP; in mv88e6xxx_serdes_pcs_get_state()
519 const struct mv88e6xxx_ops *ops = chip->info->ops; in mv88e6xxx_serdes_pcs_config()
522 if (ops->serdes_pcs_config) { in mv88e6xxx_serdes_pcs_config()
525 return ops->serdes_pcs_config(chip, port, lane, mode, in mv88e6xxx_serdes_pcs_config()
534 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_serdes_pcs_an_restart()
539 ops = chip->info->ops; in mv88e6xxx_serdes_pcs_an_restart()
541 if (ops->serdes_pcs_an_restart) { in mv88e6xxx_serdes_pcs_an_restart()
545 err = ops->serdes_pcs_an_restart(chip, port, lane); in mv88e6xxx_serdes_pcs_an_restart()
549 dev_err(ds->dev, "p%d: failed to restart AN\n", port); in mv88e6xxx_serdes_pcs_an_restart()
557 const struct mv88e6xxx_ops *ops = chip->info->ops; in mv88e6xxx_serdes_pcs_link_up()
560 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { in mv88e6xxx_serdes_pcs_link_up()
563 return ops->serdes_pcs_link_up(chip, port, lane, in mv88e6xxx_serdes_pcs_link_up()
583 u8 cmode = chip->ports[port].cmode; in mv88e6095_phylink_get_caps()
585 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; in mv88e6095_phylink_get_caps()
587 if (mv88e6xxx_phy_is_internal(chip->ds, port)) { in mv88e6095_phylink_get_caps()
588 __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); in mv88e6095_phylink_get_caps()
593 config->supported_interfaces); in mv88e6095_phylink_get_caps()
595 config->mac_capabilities |= MAC_1000FD; in mv88e6095_phylink_get_caps()
602 u8 cmode = chip->ports[port].cmode; in mv88e6185_phylink_get_caps()
607 config->supported_interfaces); in mv88e6185_phylink_get_caps()
609 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | in mv88e6185_phylink_get_caps()
640 unsigned long *supported = config->supported_interfaces; in mv88e6250_phylink_get_caps()
643 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); in mv88e6250_phylink_get_caps()
645 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; in mv88e6250_phylink_get_caps()
657 /* If PHY_DETECT is zero, then we are not in auto-media mode */ in mv88e6352_get_port4_serdes_cmode()
681 unsigned long *supported = config->supported_interfaces; in mv88e6352_phylink_get_caps()
685 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); in mv88e6352_phylink_get_caps()
687 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | in mv88e6352_phylink_get_caps()
695 dev_err(chip->dev, "p%d: failed to read scratch\n", in mv88e6352_phylink_get_caps()
702 dev_err(chip->dev, "p%d: failed to read serdes cmode\n", in mv88e6352_phylink_get_caps()
714 unsigned long *supported = config->supported_interfaces; in mv88e6341_phylink_get_caps()
717 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); in mv88e6341_phylink_get_caps()
720 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | in mv88e6341_phylink_get_caps()
729 config->mac_capabilities |= MAC_2500FD; in mv88e6341_phylink_get_caps()
736 unsigned long *supported = config->supported_interfaces; in mv88e6390_phylink_get_caps()
739 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); in mv88e6390_phylink_get_caps()
742 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | in mv88e6390_phylink_get_caps()
751 config->mac_capabilities |= MAC_2500FD; in mv88e6390_phylink_get_caps()
758 unsigned long *supported = config->supported_interfaces; in mv88e6390x_phylink_get_caps()
762 /* For the 6x90X, ports 2-7 can be in automedia mode. in mv88e6390x_phylink_get_caps()
765 * Port 2 can also support 1000BASE-X in automedia mode if port 9 is in mv88e6390x_phylink_get_caps()
766 * configured for 1000BASE-X, SGMII or 2500BASE-X. in mv88e6390x_phylink_get_caps()
767 * Port 3-4 can also support 1000BASE-X in automedia mode if port 9 is in mv88e6390x_phylink_get_caps()
768 * configured for RXAUI, 1000BASE-X, SGMII or 2500BASE-X. in mv88e6390x_phylink_get_caps()
770 * Port 5 can also support 1000BASE-X in automedia mode if port 10 is in mv88e6390x_phylink_get_caps()
771 * configured for 1000BASE-X, SGMII or 2500BASE-X. in mv88e6390x_phylink_get_caps()
772 * Port 6-7 can also support 1000BASE-X in automedia mode if port 10 is in mv88e6390x_phylink_get_caps()
773 * configured for RXAUI, 1000BASE-X, SGMII or 2500BASE-X. in mv88e6390x_phylink_get_caps()
775 * For now, be permissive (as the old code was) and allow 1000BASE-X in mv88e6390x_phylink_get_caps()
786 config->mac_capabilities |= MAC_10000FD; in mv88e6390x_phylink_get_caps()
793 unsigned long *supported = config->supported_interfaces; in mv88e6393x_phylink_get_caps()
795 chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X; in mv88e6393x_phylink_get_caps()
797 mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); in mv88e6393x_phylink_get_caps()
799 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | in mv88e6393x_phylink_get_caps()
815 config->mac_capabilities |= MAC_2500FD | MAC_5000FD | in mv88e6393x_phylink_get_caps()
832 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_caps()
834 chip->info->ops->phylink_get_caps(chip, port, config); in mv88e6xxx_get_caps()
838 config->supported_interfaces); in mv88e6xxx_get_caps()
839 /* Internal ports with no phy-mode need GMII for PHYLIB */ in mv88e6xxx_get_caps()
841 config->supported_interfaces); in mv88e6xxx_get_caps()
849 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_mac_config()
853 p = &chip->ports[port]; in mv88e6xxx_mac_config()
863 p->interface != state->interface && in mv88e6xxx_mac_config()
864 chip->info->ops->port_set_link) in mv88e6xxx_mac_config()
865 chip->info->ops->port_set_link(chip, port, in mv88e6xxx_mac_config()
869 state->interface); in mv88e6xxx_mac_config()
870 if (err && err != -EOPNOTSUPP) in mv88e6xxx_mac_config()
874 state->interface, in mv88e6xxx_mac_config()
875 state->advertising); in mv88e6xxx_mac_config()
876 /* FIXME: we should restart negotiation if something changed - in mv88e6xxx_mac_config()
886 * up in the in-band case where there is no separate SERDES. Also in mv88e6xxx_mac_config()
888 * in PHY mode (we treat the PPU as an effective in-band mechanism.) in mv88e6xxx_mac_config()
890 if (chip->info->ops->port_set_link && in mv88e6xxx_mac_config()
891 ((mode == MLO_AN_INBAND && p->interface != state->interface) || in mv88e6xxx_mac_config()
893 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED); in mv88e6xxx_mac_config()
895 p->interface = state->interface; in mv88e6xxx_mac_config()
900 if (err && err != -EOPNOTSUPP) in mv88e6xxx_mac_config()
901 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port); in mv88e6xxx_mac_config()
908 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_mac_link_down()
912 ops = chip->info->ops; in mv88e6xxx_mac_link_down()
916 * updated by the switch or if we are using fixed-link mode. in mv88e6xxx_mac_link_down()
919 mode == MLO_AN_FIXED) && ops->port_sync_link) in mv88e6xxx_mac_link_down()
920 err = ops->port_sync_link(chip, port, mode, false); in mv88e6xxx_mac_link_down()
922 if (!err && ops->port_set_speed_duplex) in mv88e6xxx_mac_link_down()
923 err = ops->port_set_speed_duplex(chip, port, SPEED_UNFORCED, in mv88e6xxx_mac_link_down()
928 dev_err(chip->dev, in mv88e6xxx_mac_link_down()
938 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_mac_link_up()
942 ops = chip->info->ops; in mv88e6xxx_mac_link_up()
946 * automatically updated by the switch or if we are using fixed-link in mv88e6xxx_mac_link_up()
952 * down here - what if the link comes up due to "other" media in mv88e6xxx_mac_link_up()
962 if (ops->port_set_speed_duplex) { in mv88e6xxx_mac_link_up()
963 err = ops->port_set_speed_duplex(chip, port, in mv88e6xxx_mac_link_up()
965 if (err && err != -EOPNOTSUPP) in mv88e6xxx_mac_link_up()
969 if (ops->port_sync_link) in mv88e6xxx_mac_link_up()
970 err = ops->port_sync_link(chip, port, mode, true); in mv88e6xxx_mac_link_up()
975 if (err && err != -EOPNOTSUPP) in mv88e6xxx_mac_link_up()
976 dev_err(ds->dev, in mv88e6xxx_mac_link_up()
982 if (!chip->info->ops->stats_snapshot) in mv88e6xxx_stats_snapshot()
983 return -EOPNOTSUPP; in mv88e6xxx_stats_snapshot()
985 return chip->info->ops->stats_snapshot(chip, port); in mv88e6xxx_stats_snapshot()
1061 switch (s->type) { in _mv88e6xxx_get_ethtool_stat()
1063 err = mv88e6xxx_port_read(chip, port, s->reg, &reg); in _mv88e6xxx_get_ethtool_stat()
1068 if (s->size == 4) { in _mv88e6xxx_get_ethtool_stat()
1069 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg); in _mv88e6xxx_get_ethtool_stat()
1079 reg |= s->reg | histogram; in _mv88e6xxx_get_ethtool_stat()
1081 if (s->size == 8) in _mv88e6xxx_get_ethtool_stat()
1099 if (stat->type & types) { in mv88e6xxx_stats_get_strings()
1100 memcpy(data + j * ETH_GSTRING_LEN, stat->string, in mv88e6xxx_stats_get_strings()
1150 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_strings()
1158 if (chip->info->ops->stats_get_strings) in mv88e6xxx_get_strings()
1159 count = chip->info->ops->stats_get_strings(chip, data); in mv88e6xxx_get_strings()
1161 if (chip->info->ops->serdes_get_strings) { in mv88e6xxx_get_strings()
1163 count = chip->info->ops->serdes_get_strings(chip, port, data); in mv88e6xxx_get_strings()
1180 if (stat->type & types) in mv88e6xxx_stats_get_sset_count()
1205 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_sset_count()
1213 if (chip->info->ops->stats_get_sset_count) in mv88e6xxx_get_sset_count()
1214 count = chip->info->ops->stats_get_sset_count(chip); in mv88e6xxx_get_sset_count()
1218 if (chip->info->ops->serdes_get_sset_count) in mv88e6xxx_get_sset_count()
1219 serdes_count = chip->info->ops->serdes_get_sset_count(chip, in mv88e6xxx_get_sset_count()
1243 if (stat->type & types) { in mv88e6xxx_stats_get_stats()
1292 *data++ = chip->ports[port].atu_member_violation; in mv88e6xxx_atu_vtu_get_stats()
1293 *data++ = chip->ports[port].atu_miss_violation; in mv88e6xxx_atu_vtu_get_stats()
1294 *data++ = chip->ports[port].atu_full_violation; in mv88e6xxx_atu_vtu_get_stats()
1295 *data++ = chip->ports[port].vtu_member_violation; in mv88e6xxx_atu_vtu_get_stats()
1296 *data++ = chip->ports[port].vtu_miss_violation; in mv88e6xxx_atu_vtu_get_stats()
1304 if (chip->info->ops->stats_get_stats) in mv88e6xxx_get_stats()
1305 count = chip->info->ops->stats_get_stats(chip, port, data); in mv88e6xxx_get_stats()
1308 if (chip->info->ops->serdes_get_stats) { in mv88e6xxx_get_stats()
1310 count = chip->info->ops->serdes_get_stats(chip, port, data); in mv88e6xxx_get_stats()
1320 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_ethtool_stats()
1337 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_regs_len()
1341 if (chip->info->ops->serdes_get_regs_len) in mv88e6xxx_get_regs_len()
1342 len += chip->info->ops->serdes_get_regs_len(chip, port); in mv88e6xxx_get_regs_len()
1350 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_regs()
1356 regs->version = chip->info->prod_num; in mv88e6xxx_get_regs()
1369 if (chip->info->ops->serdes_get_regs) in mv88e6xxx_get_regs()
1370 chip->info->ops->serdes_get_regs(chip, port, &p[i]); in mv88e6xxx_get_regs()
1392 struct dsa_switch *ds = chip->ds; in mv88e6xxx_port_vlan()
1393 struct dsa_switch_tree *dst = ds->dst; in mv88e6xxx_port_vlan()
1399 if (dev <= dst->last_switch) { in mv88e6xxx_port_vlan()
1400 list_for_each_entry(dp, &dst->ports, list) { in mv88e6xxx_port_vlan()
1401 if (dp->ds->index == dev && dp->index == port) { in mv88e6xxx_port_vlan()
1412 list_for_each_entry(dp, &dst->ports, list) { in mv88e6xxx_port_vlan()
1418 if (bridge_num + dst->last_switch != dev) in mv88e6xxx_port_vlan()
1431 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA) in mv88e6xxx_port_vlan()
1447 if (other_dp->type == DSA_PORT_TYPE_CPU || in mv88e6xxx_port_vlan()
1448 other_dp->type == DSA_PORT_TYPE_DSA || in mv88e6xxx_port_vlan()
1450 pvlan |= BIT(other_dp->index); in mv88e6xxx_port_vlan()
1457 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); in mv88e6xxx_port_vlan_map()
1468 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_stp_state_set()
1476 dev_err(ds->dev, "p%d: failed to update state\n", port); in mv88e6xxx_port_stp_state_set()
1483 if (chip->info->ops->ieee_pri_map) { in mv88e6xxx_pri_setup()
1484 err = chip->info->ops->ieee_pri_map(chip); in mv88e6xxx_pri_setup()
1489 if (chip->info->ops->ip_pri_map) { in mv88e6xxx_pri_setup()
1490 err = chip->info->ops->ip_pri_map(chip); in mv88e6xxx_pri_setup()
1500 struct dsa_switch *ds = chip->ds; in mv88e6xxx_devmap_setup()
1504 if (!chip->info->global2_addr) in mv88e6xxx_devmap_setup()
1510 if (port == ds->num_ports) in mv88e6xxx_devmap_setup()
1518 if (chip->info->ops->set_cascade_port) { in mv88e6xxx_devmap_setup()
1520 err = chip->info->ops->set_cascade_port(chip, port); in mv88e6xxx_devmap_setup()
1525 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); in mv88e6xxx_devmap_setup()
1535 if (chip->info->global2_addr) in mv88e6xxx_trunk_setup()
1543 if (chip->info->ops->rmu_disable) in mv88e6xxx_rmu_setup()
1544 return chip->info->ops->rmu_disable(chip); in mv88e6xxx_rmu_setup()
1551 if (chip->info->ops->pot_clear) in mv88e6xxx_pot_setup()
1552 return chip->info->ops->pot_clear(chip); in mv88e6xxx_pot_setup()
1559 if (chip->info->ops->mgmt_rsvd2cpu) in mv88e6xxx_rsvd2cpu_setup()
1560 return chip->info->ops->mgmt_rsvd2cpu(chip); in mv88e6xxx_rsvd2cpu_setup()
1576 * ->port_setup_message_port. in mv88e6xxx_atu_setup()
1578 if (chip->info->ops->port_setup_message_port) { in mv88e6xxx_atu_setup()
1592 if (!chip->info->ops->irl_init_all) in mv88e6xxx_irl_setup()
1599 err = chip->info->ops->irl_init_all(chip, port); in mv88e6xxx_irl_setup()
1609 if (chip->info->ops->set_switch_mac) { in mv88e6xxx_mac_setup()
1614 return chip->info->ops->set_switch_mac(chip, addr); in mv88e6xxx_mac_setup()
1622 struct dsa_switch_tree *dst = chip->ds->dst; in mv88e6xxx_pvt_map()
1630 /* Skip the local source device, which uses in-chip port VLAN */ in mv88e6xxx_pvt_map()
1631 if (dev != chip->ds->index) { in mv88e6xxx_pvt_map()
1634 ds = dsa_switch_find(dst->index, dev); in mv88e6xxx_pvt_map()
1636 if (dp && dp->lag) { in mv88e6xxx_pvt_map()
1641 * the LAG ID (one-based) as the port number in mv88e6xxx_pvt_map()
1642 * (zero-based). in mv88e6xxx_pvt_map()
1645 port = dsa_port_lag_id_get(dp) - 1; in mv88e6xxx_pvt_map()
1681 if (dsa_to_port(chip->ds, port)->lag) in mv88e6xxx_port_fast_age_fid()
1682 /* Hardware is incapable of fast-aging a LAG through a in mv88e6xxx_port_fast_age_fid()
1684 * more fancy in place this is a no-op. in mv88e6xxx_port_fast_age_fid()
1686 return -EOPNOTSUPP; in mv88e6xxx_port_fast_age_fid()
1693 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_fast_age()
1701 dev_err(chip->ds->dev, "p%d: failed to flush ATU: %d\n", in mv88e6xxx_port_fast_age()
1718 if (!chip->info->ops->vtu_getnext) in mv88e6xxx_vtu_get()
1719 return -EOPNOTSUPP; in mv88e6xxx_vtu_get()
1721 entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); in mv88e6xxx_vtu_get()
1722 entry->valid = false; in mv88e6xxx_vtu_get()
1724 err = chip->info->ops->vtu_getnext(chip, entry); in mv88e6xxx_vtu_get()
1726 if (entry->vid != vid) in mv88e6xxx_vtu_get()
1727 entry->valid = false; in mv88e6xxx_vtu_get()
1744 if (!chip->info->ops->vtu_getnext) in mv88e6xxx_vtu_walk()
1745 return -EOPNOTSUPP; in mv88e6xxx_vtu_walk()
1748 err = chip->info->ops->vtu_getnext(chip, &entry); in mv88e6xxx_vtu_walk()
1766 if (!chip->info->ops->vtu_loadpurge) in mv88e6xxx_vtu_loadpurge()
1767 return -EOPNOTSUPP; in mv88e6xxx_vtu_loadpurge()
1769 return chip->info->ops->vtu_loadpurge(chip, entry); in mv88e6xxx_vtu_loadpurge()
1778 set_bit(entry->fid, fid_bitmap); in mv88e6xxx_fid_map_vlan()
1803 return -ENOSPC; in mv88e6xxx_atu_new()
1812 if (!chip->info->ops->stu_loadpurge) in mv88e6xxx_stu_loadpurge()
1813 return -EOPNOTSUPP; in mv88e6xxx_stu_loadpurge()
1815 return chip->info->ops->stu_loadpurge(chip, entry); in mv88e6xxx_stu_loadpurge()
1843 list_for_each_entry(mst, &chip->msts, node) in mv88e6xxx_sid_get()
1844 __set_bit(mst->stu.sid, busy); in mv88e6xxx_sid_get()
1848 return (*sid >= mv88e6xxx_max_sid(chip)) ? -ENOSPC : 0; in mv88e6xxx_sid_get()
1859 list_for_each_entry_safe(mst, tmp, &chip->msts, node) { in mv88e6xxx_mst_put()
1860 if (mst->stu.sid != sid) in mv88e6xxx_mst_put()
1863 if (!refcount_dec_and_test(&mst->refcnt)) in mv88e6xxx_mst_put()
1866 mst->stu.valid = false; in mv88e6xxx_mst_put()
1867 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu); in mv88e6xxx_mst_put()
1869 refcount_set(&mst->refcnt, 1); in mv88e6xxx_mst_put()
1873 list_del(&mst->node); in mv88e6xxx_mst_put()
1878 return -ENOENT; in mv88e6xxx_mst_put()
1888 err = -EOPNOTSUPP; in mv88e6xxx_mst_get()
1897 list_for_each_entry(mst, &chip->msts, node) { in mv88e6xxx_mst_get()
1898 if (mst->br == br && mst->msti == msti) { in mv88e6xxx_mst_get()
1899 refcount_inc(&mst->refcnt); in mv88e6xxx_mst_get()
1900 *sid = mst->stu.sid; in mv88e6xxx_mst_get()
1911 err = -ENOMEM; in mv88e6xxx_mst_get()
1915 INIT_LIST_HEAD(&mst->node); in mv88e6xxx_mst_get()
1916 refcount_set(&mst->refcnt, 1); in mv88e6xxx_mst_get()
1917 mst->br = br; in mv88e6xxx_mst_get()
1918 mst->msti = msti; in mv88e6xxx_mst_get()
1919 mst->stu.valid = true; in mv88e6xxx_mst_get()
1920 mst->stu.sid = *sid; in mv88e6xxx_mst_get()
1923 * a STU state of disabled means to go by the port-global in mv88e6xxx_mst_get()
1928 mst->stu.state[i] = dsa_is_user_port(chip->ds, i) ? in mv88e6xxx_mst_get()
1932 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu); in mv88e6xxx_mst_get()
1936 list_add_tail(&mst->node, &chip->msts); in mv88e6xxx_mst_get()
1949 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_mst_state_set()
1955 return -EOPNOTSUPP; in mv88e6xxx_port_mst_state_set()
1957 switch (st->state) { in mv88e6xxx_port_mst_state_set()
1970 return -EINVAL; in mv88e6xxx_port_mst_state_set()
1973 list_for_each_entry(mst, &chip->msts, node) { in mv88e6xxx_port_mst_state_set()
1974 if (mst->br == dsa_port_bridge_dev_get(dp) && in mv88e6xxx_port_mst_state_set()
1975 mst->msti == st->msti) { in mv88e6xxx_port_mst_state_set()
1976 if (mst->stu.state[port] == state) in mv88e6xxx_port_mst_state_set()
1979 mst->stu.state[port] = state; in mv88e6xxx_port_mst_state_set()
1981 err = mv88e6xxx_stu_loadpurge(chip, &mst->stu); in mv88e6xxx_port_mst_state_set()
1987 return -ENOENT; in mv88e6xxx_port_mst_state_set()
1994 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_check_hw_vlan()
2012 if (vlan.member[other_dp->index] == in mv88e6xxx_port_check_hw_vlan()
2023 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", in mv88e6xxx_port_check_hw_vlan()
2024 port, vlan.vid, other_dp->index, netdev_name(other_br)); in mv88e6xxx_port_check_hw_vlan()
2025 return -EOPNOTSUPP; in mv88e6xxx_port_check_hw_vlan()
2033 struct dsa_port *dp = dsa_to_port(chip->ds, port); in mv88e6xxx_port_commit_pvid()
2035 struct mv88e6xxx_port *p = &chip->ports[port]; in mv88e6xxx_port_commit_pvid()
2042 pvid = p->bridge_pvid.vid; in mv88e6xxx_port_commit_pvid()
2043 drop_untagged = !p->bridge_pvid.valid; in mv88e6xxx_port_commit_pvid()
2060 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_vlan_filtering()
2066 return -EOPNOTSUPP; in mv88e6xxx_port_vlan_filtering()
2088 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_vlan_prepare()
2092 return -EOPNOTSUPP; in mv88e6xxx_port_vlan_prepare()
2098 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid); in mv88e6xxx_port_vlan_prepare()
2118 * VLAN ID into the port's database used for VLAN-unaware bridging. in mv88e6xxx_port_db_load_purge()
2127 /* switchdev expects -EOPNOTSUPP to honor software VLANs */ in mv88e6xxx_port_db_load_purge()
2129 return -EOPNOTSUPP; in mv88e6xxx_port_db_load_purge()
2168 enum mv88e6xxx_policy_mapping mapping = policy->mapping; in mv88e6xxx_policy_apply()
2169 enum mv88e6xxx_policy_action action = policy->action; in mv88e6xxx_policy_apply()
2170 const u8 *addr = policy->addr; in mv88e6xxx_policy_apply()
2171 u16 vid = policy->vid; in mv88e6xxx_policy_apply()
2176 if (!chip->info->ops->port_set_policy) in mv88e6xxx_policy_apply()
2177 return -EOPNOTSUPP; in mv88e6xxx_policy_apply()
2191 return -EOPNOTSUPP; in mv88e6xxx_policy_apply()
2199 return -EOPNOTSUPP; in mv88e6xxx_policy_apply()
2204 idr_for_each_entry(&chip->policies, policy, id) in mv88e6xxx_policy_apply()
2205 if (policy->port == port && in mv88e6xxx_policy_apply()
2206 policy->mapping == mapping && in mv88e6xxx_policy_apply()
2207 policy->action != action) in mv88e6xxx_policy_apply()
2210 return chip->info->ops->port_set_policy(chip, port, mapping, action); in mv88e6xxx_policy_apply()
2216 struct ethhdr *mac_entry = &fs->h_u.ether_spec; in mv88e6xxx_policy_insert()
2217 struct ethhdr *mac_mask = &fs->m_u.ether_spec; in mv88e6xxx_policy_insert()
2226 if (fs->location != RX_CLS_LOC_ANY) in mv88e6xxx_policy_insert()
2227 return -EINVAL; in mv88e6xxx_policy_insert()
2229 if (fs->ring_cookie == RX_CLS_FLOW_DISC) in mv88e6xxx_policy_insert()
2232 return -EOPNOTSUPP; in mv88e6xxx_policy_insert()
2234 switch (fs->flow_type & ~FLOW_EXT) { in mv88e6xxx_policy_insert()
2236 if (!is_zero_ether_addr(mac_mask->h_dest) && in mv88e6xxx_policy_insert()
2237 is_zero_ether_addr(mac_mask->h_source)) { in mv88e6xxx_policy_insert()
2239 addr = mac_entry->h_dest; in mv88e6xxx_policy_insert()
2240 } else if (is_zero_ether_addr(mac_mask->h_dest) && in mv88e6xxx_policy_insert()
2241 !is_zero_ether_addr(mac_mask->h_source)) { in mv88e6xxx_policy_insert()
2243 addr = mac_entry->h_source; in mv88e6xxx_policy_insert()
2246 return -EOPNOTSUPP; in mv88e6xxx_policy_insert()
2250 return -EOPNOTSUPP; in mv88e6xxx_policy_insert()
2253 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { in mv88e6xxx_policy_insert()
2254 if (fs->m_ext.vlan_tci != htons(0xffff)) in mv88e6xxx_policy_insert()
2255 return -EOPNOTSUPP; in mv88e6xxx_policy_insert()
2256 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; in mv88e6xxx_policy_insert()
2259 idr_for_each_entry(&chip->policies, policy, id) { in mv88e6xxx_policy_insert()
2260 if (policy->port == port && policy->mapping == mapping && in mv88e6xxx_policy_insert()
2261 policy->action == action && policy->vid == vid && in mv88e6xxx_policy_insert()
2262 ether_addr_equal(policy->addr, addr)) in mv88e6xxx_policy_insert()
2263 return -EEXIST; in mv88e6xxx_policy_insert()
2266 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); in mv88e6xxx_policy_insert()
2268 return -ENOMEM; in mv88e6xxx_policy_insert()
2270 fs->location = 0; in mv88e6xxx_policy_insert()
2271 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, in mv88e6xxx_policy_insert()
2274 devm_kfree(chip->dev, policy); in mv88e6xxx_policy_insert()
2278 memcpy(&policy->fs, fs, sizeof(*fs)); in mv88e6xxx_policy_insert()
2279 ether_addr_copy(policy->addr, addr); in mv88e6xxx_policy_insert()
2280 policy->mapping = mapping; in mv88e6xxx_policy_insert()
2281 policy->action = action; in mv88e6xxx_policy_insert()
2282 policy->port = port; in mv88e6xxx_policy_insert()
2283 policy->vid = vid; in mv88e6xxx_policy_insert()
2287 idr_remove(&chip->policies, fs->location); in mv88e6xxx_policy_insert()
2288 devm_kfree(chip->dev, policy); in mv88e6xxx_policy_insert()
2298 struct ethtool_rx_flow_spec *fs = &rxnfc->fs; in mv88e6xxx_get_rxnfc()
2299 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_rxnfc()
2306 switch (rxnfc->cmd) { in mv88e6xxx_get_rxnfc()
2308 rxnfc->data = 0; in mv88e6xxx_get_rxnfc()
2309 rxnfc->data |= RX_CLS_LOC_SPECIAL; in mv88e6xxx_get_rxnfc()
2310 rxnfc->rule_cnt = 0; in mv88e6xxx_get_rxnfc()
2311 idr_for_each_entry(&chip->policies, policy, id) in mv88e6xxx_get_rxnfc()
2312 if (policy->port == port) in mv88e6xxx_get_rxnfc()
2313 rxnfc->rule_cnt++; in mv88e6xxx_get_rxnfc()
2317 err = -ENOENT; in mv88e6xxx_get_rxnfc()
2318 policy = idr_find(&chip->policies, fs->location); in mv88e6xxx_get_rxnfc()
2320 memcpy(fs, &policy->fs, sizeof(*fs)); in mv88e6xxx_get_rxnfc()
2325 rxnfc->data = 0; in mv88e6xxx_get_rxnfc()
2326 rxnfc->rule_cnt = 0; in mv88e6xxx_get_rxnfc()
2327 idr_for_each_entry(&chip->policies, policy, id) in mv88e6xxx_get_rxnfc()
2328 if (policy->port == port) in mv88e6xxx_get_rxnfc()
2329 rule_locs[rxnfc->rule_cnt++] = id; in mv88e6xxx_get_rxnfc()
2333 err = -EOPNOTSUPP; in mv88e6xxx_get_rxnfc()
2345 struct ethtool_rx_flow_spec *fs = &rxnfc->fs; in mv88e6xxx_set_rxnfc()
2346 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_set_rxnfc()
2352 switch (rxnfc->cmd) { in mv88e6xxx_set_rxnfc()
2357 err = -ENOENT; in mv88e6xxx_set_rxnfc()
2358 policy = idr_remove(&chip->policies, fs->location); in mv88e6xxx_set_rxnfc()
2360 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; in mv88e6xxx_set_rxnfc()
2362 devm_kfree(chip->dev, policy); in mv88e6xxx_set_rxnfc()
2366 err = -EOPNOTSUPP; in mv88e6xxx_set_rxnfc()
2392 struct dsa_port *dp = dsa_to_port(chip->ds, port); in mv88e6xxx_broadcast_setup()
2395 if (dsa_is_unused_port(chip->ds, port)) in mv88e6xxx_broadcast_setup()
2427 if (ctx->flood) in mv88e6xxx_port_broadcast_sync_vlan()
2434 return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, in mv88e6xxx_port_broadcast_sync_vlan()
2435 vlan->vid, state); in mv88e6xxx_port_broadcast_sync_vlan()
2504 dev_info(chip->dev, "p%d: already a member of VLAN %d\n", in mv88e6xxx_port_vlan_join()
2515 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_vlan_add()
2516 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in mv88e6xxx_port_vlan_add()
2517 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in mv88e6xxx_port_vlan_add()
2518 struct mv88e6xxx_port *p = &chip->ports[port]; in mv88e6xxx_port_vlan_add()
2523 if (!vlan->vid) in mv88e6xxx_port_vlan_add()
2544 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn); in mv88e6xxx_port_vlan_add()
2546 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, in mv88e6xxx_port_vlan_add()
2547 vlan->vid, untagged ? 'u' : 't'); in mv88e6xxx_port_vlan_add()
2552 p->bridge_pvid.vid = vlan->vid; in mv88e6xxx_port_vlan_add()
2553 p->bridge_pvid.valid = true; in mv88e6xxx_port_vlan_add()
2558 } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) { in mv88e6xxx_port_vlan_add()
2559 /* The old pvid was reinstalled as a non-pvid VLAN */ in mv88e6xxx_port_vlan_add()
2560 p->bridge_pvid.valid = false; in mv88e6xxx_port_vlan_add()
2591 return -EOPNOTSUPP; in mv88e6xxx_port_vlan_leave()
2621 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_vlan_del()
2622 struct mv88e6xxx_port *p = &chip->ports[port]; in mv88e6xxx_port_vlan_del()
2627 return -EOPNOTSUPP; in mv88e6xxx_port_vlan_del()
2642 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid); in mv88e6xxx_port_vlan_del()
2646 if (vlan->vid == pvid) { in mv88e6xxx_port_vlan_del()
2647 p->bridge_pvid.valid = false; in mv88e6xxx_port_vlan_del()
2662 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_vlan_fast_age()
2684 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_vlan_msti_set()
2690 return -EOPNOTSUPP; in mv88e6xxx_vlan_msti_set()
2694 err = mv88e6xxx_vtu_get(chip, msti->vid, &vlan); in mv88e6xxx_vlan_msti_set()
2699 err = -EINVAL; in mv88e6xxx_vlan_msti_set()
2705 err = mv88e6xxx_mst_get(chip, bridge.dev, msti->msti, &new_sid); in mv88e6xxx_vlan_msti_set()
2730 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_fdb_add()
2745 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_fdb_del()
2802 return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, in mv88e6xxx_port_db_dump_vlan()
2803 ctx->port, ctx->cb, ctx->data); in mv88e6xxx_port_db_dump_vlan()
2832 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_fdb_dump()
2845 struct dsa_switch *ds = chip->ds; in mv88e6xxx_bridge_map()
2846 struct dsa_switch_tree *dst = ds->dst; in mv88e6xxx_bridge_map()
2850 list_for_each_entry(dp, &dst->ports, list) { in mv88e6xxx_bridge_map()
2852 if (dp->ds == ds) { in mv88e6xxx_bridge_map()
2856 err = mv88e6xxx_port_vlan_map(chip, dp->index); in mv88e6xxx_bridge_map()
2861 * remap its cross-chip Port VLAN Table entry. in mv88e6xxx_bridge_map()
2863 err = mv88e6xxx_pvt_map(chip, dp->ds->index, in mv88e6xxx_bridge_map()
2864 dp->index); in mv88e6xxx_bridge_map()
2874 /* Treat the software bridge as a virtual single-port switch behind the
2875 * CPU and map in the PVT. First dst->last_switch elements are taken by
2881 u8 dev = bridge_num + ds->dst->last_switch; in mv88e6xxx_map_virtual_bridge_to_pvt()
2882 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_map_virtual_bridge_to_pvt()
2892 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_bridge_join()
2926 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_bridge_leave()
2933 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); in mv88e6xxx_port_bridge_leave()
2937 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); in mv88e6xxx_port_bridge_leave()
2941 dev_err(ds->dev, in mv88e6xxx_port_bridge_leave()
2942 "port %d failed to restore map-DA: %pe\n", in mv88e6xxx_port_bridge_leave()
2947 dev_err(ds->dev, in mv88e6xxx_port_bridge_leave()
2959 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_crosschip_bridge_join()
2962 if (tree_index != ds->dst->index) in mv88e6xxx_crosschip_bridge_join()
2977 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_crosschip_bridge_leave()
2979 if (tree_index != ds->dst->index) in mv88e6xxx_crosschip_bridge_leave()
2985 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); in mv88e6xxx_crosschip_bridge_leave()
2991 if (chip->info->ops->reset) in mv88e6xxx_software_reset()
2992 return chip->info->ops->reset(chip); in mv88e6xxx_software_reset()
2999 struct gpio_desc *gpiod = chip->reset; in mv88e6xxx_hardware_reset()
3050 if (!chip->info->ops->port_set_frame_mode) in mv88e6xxx_set_port_mode()
3051 return -EOPNOTSUPP; in mv88e6xxx_set_port_mode()
3057 err = chip->info->ops->port_set_frame_mode(chip, port, frame); in mv88e6xxx_set_port_mode()
3061 if (chip->info->ops->port_set_ether_type) in mv88e6xxx_set_port_mode()
3062 return chip->info->ops->port_set_ether_type(chip, port, etype); in mv88e6xxx_set_port_mode()
3091 if (dsa_is_dsa_port(chip->ds, port)) in mv88e6xxx_setup_port_mode()
3094 if (dsa_is_user_port(chip->ds, port)) in mv88e6xxx_setup_port_mode()
3098 if (chip->tag_protocol == DSA_TAG_PROTO_DSA) in mv88e6xxx_setup_port_mode()
3101 if (chip->tag_protocol == DSA_TAG_PROTO_EDSA) in mv88e6xxx_setup_port_mode()
3104 return -EINVAL; in mv88e6xxx_setup_port_mode()
3109 bool message = dsa_is_dsa_port(chip->ds, port); in mv88e6xxx_setup_message_port()
3118 if (chip->info->ops->port_set_ucast_flood) { in mv88e6xxx_setup_egress_floods()
3119 err = chip->info->ops->port_set_ucast_flood(chip, port, true); in mv88e6xxx_setup_egress_floods()
3123 if (chip->info->ops->port_set_mcast_flood) { in mv88e6xxx_setup_egress_floods()
3124 err = chip->info->ops->port_set_mcast_flood(chip, port, true); in mv88e6xxx_setup_egress_floods()
3135 struct mv88e6xxx_chip *chip = mvp->chip; in mv88e6xxx_serdes_irq_thread_fn()
3137 int port = mvp->port; in mv88e6xxx_serdes_irq_thread_fn()
3152 struct mv88e6xxx_port *dev_id = &chip->ports[port]; in mv88e6xxx_serdes_irq_request()
3161 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), in mv88e6xxx_serdes_irq_request()
3162 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); in mv88e6xxx_serdes_irq_request()
3167 IRQF_ONESHOT, dev_id->serdes_irq_name, in mv88e6xxx_serdes_irq_request()
3173 dev_id->serdes_irq = irq; in mv88e6xxx_serdes_irq_request()
3181 struct mv88e6xxx_port *dev_id = &chip->ports[port]; in mv88e6xxx_serdes_irq_free()
3182 unsigned int irq = dev_id->serdes_irq; in mv88e6xxx_serdes_irq_free()
3196 dev_id->serdes_irq = 0; in mv88e6xxx_serdes_irq_free()
3234 if (!chip->info->ops->set_egress_port) in mv88e6xxx_set_egress_port()
3235 return -EOPNOTSUPP; in mv88e6xxx_set_egress_port()
3237 err = chip->info->ops->set_egress_port(chip, direction, port); in mv88e6xxx_set_egress_port()
3242 chip->ingress_dest_port = port; in mv88e6xxx_set_egress_port()
3244 chip->egress_dest_port = port; in mv88e6xxx_set_egress_port()
3251 struct dsa_switch *ds = chip->ds; in mv88e6xxx_setup_upstream_port()
3256 if (chip->info->ops->port_set_upstream_port) { in mv88e6xxx_setup_upstream_port()
3257 err = chip->info->ops->port_set_upstream_port(chip, port, in mv88e6xxx_setup_upstream_port()
3264 if (chip->info->ops->set_cpu_port) { in mv88e6xxx_setup_upstream_port()
3265 err = chip->info->ops->set_cpu_port(chip, in mv88e6xxx_setup_upstream_port()
3274 if (err && err != -EOPNOTSUPP) in mv88e6xxx_setup_upstream_port()
3280 if (err && err != -EOPNOTSUPP) in mv88e6xxx_setup_upstream_port()
3290 struct dsa_switch *ds = chip->ds; in mv88e6xxx_setup_port()
3297 chip->ports[port].chip = chip; in mv88e6xxx_setup_port()
3298 chip->ports[port].port = port; in mv88e6xxx_setup_port()
3314 if (chip->info->ops->port_max_speed_mode) in mv88e6xxx_setup_port()
3315 mode = chip->info->ops->port_max_speed_mode(port); in mv88e6xxx_setup_port()
3344 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, in mv88e6xxx_setup_port()
3396 chip->info->ops->port_set_policy) { in mv88e6xxx_setup_port()
3397 err = chip->info->ops->port_set_policy(chip, port, in mv88e6xxx_setup_port()
3406 * loaded in the VTU - therefore, enable 802.1Q in order to take in mv88e6xxx_setup_port()
3432 * as the private PVID on ports under a VLAN-unaware bridge. in mv88e6xxx_setup_port()
3443 if (chip->info->ops->port_set_jumbo_size) { in mv88e6xxx_setup_port()
3444 err = chip->info->ops->port_set_jumbo_size(chip, port, 10218); in mv88e6xxx_setup_port()
3475 if (chip->info->ops->port_pause_limit) { in mv88e6xxx_setup_port()
3476 err = chip->info->ops->port_pause_limit(chip, port, 0, 0); in mv88e6xxx_setup_port()
3481 if (chip->info->ops->port_disable_learn_limit) { in mv88e6xxx_setup_port()
3482 err = chip->info->ops->port_disable_learn_limit(chip, port); in mv88e6xxx_setup_port()
3487 if (chip->info->ops->port_disable_pri_override) { in mv88e6xxx_setup_port()
3488 err = chip->info->ops->port_disable_pri_override(chip, port); in mv88e6xxx_setup_port()
3493 if (chip->info->ops->port_tag_remap) { in mv88e6xxx_setup_port()
3494 err = chip->info->ops->port_tag_remap(chip, port); in mv88e6xxx_setup_port()
3499 if (chip->info->ops->port_egress_rate_limiting) { in mv88e6xxx_setup_port()
3500 err = chip->info->ops->port_egress_rate_limiting(chip, port); in mv88e6xxx_setup_port()
3505 if (chip->info->ops->port_setup_message_port) { in mv88e6xxx_setup_port()
3506 err = chip->info->ops->port_setup_message_port(chip, port); in mv88e6xxx_setup_port()
3511 if (chip->info->ops->serdes_set_tx_amplitude) { in mv88e6xxx_setup_port()
3513 phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0); in mv88e6xxx_setup_port()
3516 "tx-p2p-microvolt", in mv88e6xxx_setup_port()
3518 err = chip->info->ops->serdes_set_tx_amplitude(chip, in mv88e6xxx_setup_port()
3547 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_max_mtu()
3549 if (chip->info->ops->port_set_jumbo_size) in mv88e6xxx_get_max_mtu()
3550 return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; in mv88e6xxx_get_max_mtu()
3551 else if (chip->info->ops->set_max_frame_size) in mv88e6xxx_get_max_mtu()
3552 return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; in mv88e6xxx_get_max_mtu()
3553 return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; in mv88e6xxx_get_max_mtu()
3558 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_change_mtu()
3565 if (chip->info->ops->port_set_jumbo_size) in mv88e6xxx_change_mtu()
3566 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu); in mv88e6xxx_change_mtu()
3567 else if (chip->info->ops->set_max_frame_size) in mv88e6xxx_change_mtu()
3568 ret = chip->info->ops->set_max_frame_size(chip, new_mtu); in mv88e6xxx_change_mtu()
3571 ret = -EINVAL; in mv88e6xxx_change_mtu()
3580 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_enable()
3592 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_disable()
3596 dev_err(chip->dev, "failed to power off SERDES\n"); in mv88e6xxx_port_disable()
3603 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_set_ageing_time()
3618 if (chip->info->ops->stats_set_histogram) { in mv88e6xxx_stats_setup()
3619 err = chip->info->ops->stats_set_histogram(chip); in mv88e6xxx_stats_setup()
3637 dev_err(chip->dev, in mv88e6390_setup_errata_applied()
3685 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_setup()
3690 chip->ds = ds; in mv88e6xxx_setup()
3691 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); in mv88e6xxx_setup()
3699 ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - in mv88e6xxx_setup()
3700 ds->dst->last_switch - 1; in mv88e6xxx_setup()
3704 if (chip->info->ops->setup_errata) { in mv88e6xxx_setup()
3705 err = chip->info->ops->setup_errata(chip); in mv88e6xxx_setup()
3712 if (chip->info->ops->port_get_cmode) { in mv88e6xxx_setup()
3713 err = chip->info->ops->port_get_cmode(chip, i, &cmode); in mv88e6xxx_setup()
3717 chip->ports[i].cmode = cmode; in mv88e6xxx_setup()
3739 dev_err(chip->dev, "port %d is invalid\n", i); in mv88e6xxx_setup()
3740 err = -EINVAL; in mv88e6xxx_setup()
3798 if (chip->info->ptp_support) { in mv88e6xxx_setup()
3864 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; in mv88e6xxx_mdio_read()
3865 struct mv88e6xxx_chip *chip = mdio_bus->chip; in mv88e6xxx_mdio_read()
3870 if (!chip->info->ops->phy_read) in mv88e6xxx_mdio_read()
3871 return -EOPNOTSUPP; in mv88e6xxx_mdio_read()
3874 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); in mv88e6xxx_mdio_read()
3879 chip->info->family < ARRAY_SIZE(family_prod_id_table)) { in mv88e6xxx_mdio_read()
3880 prod_id = family_prod_id_table[chip->info->family]; in mv88e6xxx_mdio_read()
3890 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; in mv88e6xxx_mdio_write()
3891 struct mv88e6xxx_chip *chip = mdio_bus->chip; in mv88e6xxx_mdio_write()
3894 if (!chip->info->ops->phy_write) in mv88e6xxx_mdio_write()
3895 return -EOPNOTSUPP; in mv88e6xxx_mdio_write()
3898 err = chip->info->ops->phy_write(chip, bus, phy, reg, val); in mv88e6xxx_mdio_write()
3924 return -ENOMEM; in mv88e6xxx_mdio_register()
3926 mdio_bus = bus->priv; in mv88e6xxx_mdio_register()
3927 mdio_bus->bus = bus; in mv88e6xxx_mdio_register()
3928 mdio_bus->chip = chip; in mv88e6xxx_mdio_register()
3929 INIT_LIST_HEAD(&mdio_bus->list); in mv88e6xxx_mdio_register()
3930 mdio_bus->external = external; in mv88e6xxx_mdio_register()
3933 bus->name = np->full_name; in mv88e6xxx_mdio_register()
3934 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); in mv88e6xxx_mdio_register()
3936 bus->name = "mv88e6xxx SMI"; in mv88e6xxx_mdio_register()
3937 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); in mv88e6xxx_mdio_register()
3940 bus->read = mv88e6xxx_mdio_read; in mv88e6xxx_mdio_register()
3941 bus->write = mv88e6xxx_mdio_write; in mv88e6xxx_mdio_register()
3942 bus->parent = chip->dev; in mv88e6xxx_mdio_register()
3952 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); in mv88e6xxx_mdio_register()
3958 list_add_tail(&mdio_bus->list, &chip->mdios); in mv88e6xxx_mdio_register()
3960 list_add(&mdio_bus->list, &chip->mdios); in mv88e6xxx_mdio_register()
3975 list_for_each_entry_safe(mdio_bus, p, &chip->mdios, list) { in mv88e6xxx_mdios_unregister()
3976 bus = mdio_bus->bus; in mv88e6xxx_mdios_unregister()
3978 if (!mdio_bus->external) in mv88e6xxx_mdios_unregister()
3992 /* Always register one mdio bus for the internal/default mdio in mv88e6xxx_mdios_register()
3996 child = of_get_child_by_name(np, "mdio"); in mv88e6xxx_mdios_register()
4003 * which say they are compatible with the external mdio in mv88e6xxx_mdios_register()
4008 child, "marvell,mv88e6xxx-mdio-external")) { in mv88e6xxx_mdios_register()
4023 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_eeprom_len()
4025 return chip->eeprom_len; in mv88e6xxx_get_eeprom_len()
4031 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_eeprom()
4034 if (!chip->info->ops->get_eeprom) in mv88e6xxx_get_eeprom()
4035 return -EOPNOTSUPP; in mv88e6xxx_get_eeprom()
4038 err = chip->info->ops->get_eeprom(chip, eeprom, data); in mv88e6xxx_get_eeprom()
4044 eeprom->magic = 0xc3ec4951; in mv88e6xxx_get_eeprom()
4052 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_set_eeprom()
4055 if (!chip->info->ops->set_eeprom) in mv88e6xxx_set_eeprom()
4056 return -EOPNOTSUPP; in mv88e6xxx_set_eeprom()
4058 if (eeprom->magic != 0xc3ec4951) in mv88e6xxx_set_eeprom()
4059 return -EINVAL; in mv88e6xxx_set_eeprom()
4062 err = chip->info->ops->set_eeprom(chip, eeprom, data); in mv88e6xxx_set_eeprom()
5961 /* Ports 2-4 are not routed to pins
6304 return -ENODEV; in mv88e6xxx_detect()
6307 chip->info = info; in mv88e6xxx_detect()
6309 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", in mv88e6xxx_detect()
6310 chip->info->prod_num, chip->info->name, rev); in mv88e6xxx_detect()
6320 /* dual_chip takes precedence over single/multi-chip modes */ in mv88e6xxx_single_chip_detect()
6321 if (chip->info->dual_chip) in mv88e6xxx_single_chip_detect()
6322 return -EINVAL; in mv88e6xxx_single_chip_detect()
6324 /* If the mdio addr is 16 indicating the first port address of a switch in mv88e6xxx_single_chip_detect()
6326 * configured in single chip addressing mode. Setup the smi access as in mv88e6xxx_single_chip_detect()
6331 if (mdiodev->addr != 16) in mv88e6xxx_single_chip_detect()
6332 return -EINVAL; in mv88e6xxx_single_chip_detect()
6334 err = mv88e6xxx_smi_init(chip, mdiodev->bus, 0); in mv88e6xxx_single_chip_detect()
6349 chip->dev = dev; in mv88e6xxx_alloc_chip()
6351 mutex_init(&chip->reg_lock); in mv88e6xxx_alloc_chip()
6352 INIT_LIST_HEAD(&chip->mdios); in mv88e6xxx_alloc_chip()
6353 idr_init(&chip->policies); in mv88e6xxx_alloc_chip()
6354 INIT_LIST_HEAD(&chip->msts); in mv88e6xxx_alloc_chip()
6363 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_get_tag_protocol()
6365 return chip->tag_protocol; in mv88e6xxx_get_tag_protocol()
6371 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_change_tag_protocol()
6378 switch (chip->info->edsa_support) { in mv88e6xxx_change_tag_protocol()
6380 return -EPROTONOSUPPORT; in mv88e6xxx_change_tag_protocol()
6382 dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n"); in mv88e6xxx_change_tag_protocol()
6391 return -EPROTONOSUPPORT; in mv88e6xxx_change_tag_protocol()
6394 old_protocol = chip->tag_protocol; in mv88e6xxx_change_tag_protocol()
6395 chip->tag_protocol = proto; in mv88e6xxx_change_tag_protocol()
6399 err = mv88e6xxx_setup_port_mode(chip, cpu_dp->index); in mv88e6xxx_change_tag_protocol()
6410 chip->tag_protocol = old_protocol; in mv88e6xxx_change_tag_protocol()
6414 mv88e6xxx_setup_port_mode(chip, cpu_dp->index); in mv88e6xxx_change_tag_protocol()
6424 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_mdb_add()
6428 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, in mv88e6xxx_port_mdb_add()
6439 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_mdb_del()
6443 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0); in mv88e6xxx_port_mdb_del()
6457 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_mirror_add()
6462 mutex_lock(&chip->reg_lock); in mv88e6xxx_port_mirror_add()
6463 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != in mv88e6xxx_port_mirror_add()
6464 mirror->to_local_port) { in mv88e6xxx_port_mirror_add()
6467 chip->ports[i].mirror_ingress : in mv88e6xxx_port_mirror_add()
6468 chip->ports[i].mirror_egress; in mv88e6xxx_port_mirror_add()
6472 err = -EBUSY; in mv88e6xxx_port_mirror_add()
6477 mirror->to_local_port); in mv88e6xxx_port_mirror_add()
6484 mutex_unlock(&chip->reg_lock); in mv88e6xxx_port_mirror_add()
6492 enum mv88e6xxx_egress_direction direction = mirror->ingress ? in mv88e6xxx_port_mirror_del()
6495 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_mirror_del()
6499 mutex_lock(&chip->reg_lock); in mv88e6xxx_port_mirror_del()
6501 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); in mv88e6xxx_port_mirror_del()
6504 other_mirrors |= mirror->ingress ? in mv88e6xxx_port_mirror_del()
6505 chip->ports[i].mirror_ingress : in mv88e6xxx_port_mirror_del()
6506 chip->ports[i].mirror_egress; in mv88e6xxx_port_mirror_del()
6512 dev_err(ds->dev, "failed to set egress port\n"); in mv88e6xxx_port_mirror_del()
6515 mutex_unlock(&chip->reg_lock); in mv88e6xxx_port_mirror_del()
6522 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_pre_bridge_flags()
6527 return -EINVAL; in mv88e6xxx_port_pre_bridge_flags()
6529 ops = chip->info->ops; in mv88e6xxx_port_pre_bridge_flags()
6531 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood) in mv88e6xxx_port_pre_bridge_flags()
6532 return -EINVAL; in mv88e6xxx_port_pre_bridge_flags()
6534 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood) in mv88e6xxx_port_pre_bridge_flags()
6535 return -EINVAL; in mv88e6xxx_port_pre_bridge_flags()
6544 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_bridge_flags()
6545 int err = -EOPNOTSUPP; in mv88e6xxx_port_bridge_flags()
6561 err = chip->info->ops->port_set_ucast_flood(chip, port, in mv88e6xxx_port_bridge_flags()
6570 err = chip->info->ops->port_set_mcast_flood(chip, port, in mv88e6xxx_port_bridge_flags()
6602 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_lag_can_offload()
6614 dsa_lag_foreach_port(dp, ds->dst, &lag) in mv88e6xxx_lag_can_offload()
6627 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { in mv88e6xxx_lag_can_offload()
6642 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_lag_sync_map()
6647 /* DSA LAG IDs are one-based, hardware is zero-based */ in mv88e6xxx_lag_sync_map()
6648 id = lag.id - 1; in mv88e6xxx_lag_sync_map()
6654 dsa_lag_foreach_port(dp, ds->dst, &lag) in mv88e6xxx_lag_sync_map()
6655 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index)); in mv88e6xxx_lag_sync_map()
6687 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth]; in mv88e6xxx_lag_set_port_mask()
6697 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_lag_sync_masks()
6706 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1; in mv88e6xxx_lag_sync_masks()
6710 if (!dp->lag) in mv88e6xxx_lag_sync_masks()
6713 ivec &= ~BIT(dp->index); in mv88e6xxx_lag_sync_masks()
6722 dsa_lags_foreach_id(id, ds->dst) { in mv88e6xxx_lag_sync_masks()
6723 lag = dsa_lag_by_id(ds->dst, id); in mv88e6xxx_lag_sync_masks()
6728 dsa_lag_foreach_port(dp, ds->dst, lag) { in mv88e6xxx_lag_sync_masks()
6729 if (dp->lag_tx_enabled) in mv88e6xxx_lag_sync_masks()
6737 dsa_lag_foreach_port(dp, ds->dst, lag) { in mv88e6xxx_lag_sync_masks()
6738 if (!dp->lag_tx_enabled) in mv88e6xxx_lag_sync_masks()
6741 if (dp->ds == ds) in mv88e6xxx_lag_sync_masks()
6742 mv88e6xxx_lag_set_port_mask(mask, dp->index, in mv88e6xxx_lag_sync_masks()
6773 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_lag_change()
6787 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_lag_join()
6791 return -EOPNOTSUPP; in mv88e6xxx_port_lag_join()
6793 /* DSA LAG IDs are one-based */ in mv88e6xxx_port_lag_join()
6794 id = lag.id - 1; in mv88e6xxx_port_lag_join()
6819 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_port_lag_leave()
6832 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_crosschip_lag_change()
6846 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_crosschip_lag_join()
6850 return -EOPNOTSUPP; in mv88e6xxx_crosschip_lag_join()
6868 struct mv88e6xxx_chip *chip = ds->priv; in mv88e6xxx_crosschip_lag_leave()
6947 struct device *dev = chip->dev; in mv88e6xxx_register_switch()
6952 return -ENOMEM; in mv88e6xxx_register_switch()
6954 ds->dev = dev; in mv88e6xxx_register_switch()
6955 ds->num_ports = mv88e6xxx_num_ports(chip); in mv88e6xxx_register_switch()
6956 ds->priv = chip; in mv88e6xxx_register_switch()
6957 ds->dev = dev; in mv88e6xxx_register_switch()
6958 ds->ops = &mv88e6xxx_switch_ops; in mv88e6xxx_register_switch()
6959 ds->ageing_time_min = chip->info->age_time_coeff; in mv88e6xxx_register_switch()
6960 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; in mv88e6xxx_register_switch()
6963 * 5-bit port mode, which we do not support. 640k^W16 ought to in mv88e6xxx_register_switch()
6966 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; in mv88e6xxx_register_switch()
6975 dsa_unregister_switch(chip->ds); in mv88e6xxx_unregister_switch()
6980 const struct of_device_id *matches = dev->driver->of_match_table; in pdata_device_get_match_data()
6981 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; in pdata_device_get_match_data()
6983 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; in pdata_device_get_match_data()
6985 if (!strcmp(pdata->compatible, matches->compatible)) in pdata_device_get_match_data()
6986 return matches->data; in pdata_device_get_match_data()
6996 return -EOPNOTSUPP; in mv88e6xxx_suspend()
7008 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; in mv88e6xxx_probe()
7010 struct device *dev = &mdiodev->dev; in mv88e6xxx_probe()
7011 struct device_node *np = dev->of_node; in mv88e6xxx_probe()
7017 return -EINVAL; in mv88e6xxx_probe()
7025 if (!pdata->netdev) in mv88e6xxx_probe()
7026 return -EINVAL; in mv88e6xxx_probe()
7029 if (!(pdata->enabled_ports & (1 << port))) in mv88e6xxx_probe()
7031 if (strcmp(pdata->cd.port_names[port], "cpu")) in mv88e6xxx_probe()
7033 pdata->cd.netdev[port] = &pdata->netdev->dev; in mv88e6xxx_probe()
7039 return -EINVAL; in mv88e6xxx_probe()
7043 err = -ENOMEM; in mv88e6xxx_probe()
7047 chip->info = compat_info; in mv88e6xxx_probe()
7049 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in mv88e6xxx_probe()
7050 if (IS_ERR(chip->reset)) { in mv88e6xxx_probe()
7051 err = PTR_ERR(chip->reset); in mv88e6xxx_probe()
7054 if (chip->reset) in mv88e6xxx_probe()
7058 * otherwise continue with address specific smi init/detection. in mv88e6xxx_probe()
7062 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); in mv88e6xxx_probe()
7071 if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED) in mv88e6xxx_probe()
7072 chip->tag_protocol = DSA_TAG_PROTO_EDSA; in mv88e6xxx_probe()
7074 chip->tag_protocol = DSA_TAG_PROTO_DSA; in mv88e6xxx_probe()
7078 if (chip->info->ops->get_eeprom) { in mv88e6xxx_probe()
7080 of_property_read_u32(np, "eeprom-length", in mv88e6xxx_probe()
7081 &chip->eeprom_len); in mv88e6xxx_probe()
7083 chip->eeprom_len = pdata->eeprom_len; in mv88e6xxx_probe()
7093 chip->irq = of_irq_get(np, 0); in mv88e6xxx_probe()
7094 if (chip->irq == -EPROBE_DEFER) { in mv88e6xxx_probe()
7095 err = chip->irq; in mv88e6xxx_probe()
7101 chip->irq = pdata->irq; in mv88e6xxx_probe()
7103 /* Has to be performed before the MDIO bus is created, because in mv88e6xxx_probe()
7108 if (chip->irq > 0) in mv88e6xxx_probe()
7117 if (chip->info->g2_irqs > 0) { in mv88e6xxx_probe()
7148 if (chip->info->g2_irqs > 0) in mv88e6xxx_probe()
7151 if (chip->irq > 0) in mv88e6xxx_probe()
7157 dev_put(pdata->netdev); in mv88e6xxx_probe()
7164 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); in mv88e6xxx_remove()
7170 chip = ds->priv; in mv88e6xxx_remove()
7172 if (chip->info->ptp_support) { in mv88e6xxx_remove()
7184 if (chip->info->g2_irqs > 0) in mv88e6xxx_remove()
7187 if (chip->irq > 0) in mv88e6xxx_remove()
7195 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); in mv88e6xxx_shutdown()
7202 dev_set_drvdata(&mdiodev->dev, NULL); in mv88e6xxx_shutdown()