Lines Matching +full:8 +full:- +full:port

4  * Copyright (C) 2011-2013 Jonas Gorski <jogo@openwrt.org>
46 { 8, 0x00, "TxOctets" },
58 { 8, 0x44, "RxOctets" },
71 { 8, 0x7c, "RxGoodOctets" },
84 { 8, 0x00, "TxOctets" },
97 { 8, 0x3c, "TxQoSOctets" },
98 { 8, 0x44, "RxOctets" },
111 { 8, 0x7c, "RxGoodOctets" },
120 { 8, 0xa8, "RxQoSOctets" },
132 { 8, 0x00, "TxOctets" },
144 { 8, 0x50, "RxOctets" },
157 { 8, 0x88, "RxGoodOctets" },
172 { 8, 0x00, "TxOctets" },
191 { 8, 0x50, "RxOctets" },
204 { 8, 0x88, "RxGoodOctets" },
230 #define B53_MAX_MTU_25 (1536 - ETH_HLEN - VLAN_HLEN - ETH_FCS_LEN)
231 #define B53_MAX_MTU (9720 - ETH_HLEN - VLAN_HLEN - ETH_FCS_LEN)
237 b53_write8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], VTA_START_CMD | op); in b53_do_vlan_op()
242 b53_read8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], &vta); in b53_do_vlan_op()
249 return -EIO; in b53_do_vlan_op()
258 if (vlan->members) { in b53_set_vlan_entry()
259 entry = ((vlan->untag & VA_UNTAG_MASK_25) << in b53_set_vlan_entry()
260 VA_UNTAG_S_25) | vlan->members; in b53_set_vlan_entry()
261 if (dev->core_rev >= 3) in b53_set_vlan_entry()
273 if (vlan->members) in b53_set_vlan_entry()
274 entry = ((vlan->untag & VA_UNTAG_MASK_65) << in b53_set_vlan_entry()
275 VA_UNTAG_S_65) | vlan->members | VA_VALID_65; in b53_set_vlan_entry()
281 b53_write16(dev, B53_ARLIO_PAGE, dev->vta_regs[1], vid); in b53_set_vlan_entry()
282 b53_write32(dev, B53_ARLIO_PAGE, dev->vta_regs[2], in b53_set_vlan_entry()
283 (vlan->untag << VTE_UNTAG_S) | vlan->members); in b53_set_vlan_entry()
288 dev_dbg(dev->ds->dev, "VID: %d, members: 0x%04x, untag: 0x%04x\n", in b53_set_vlan_entry()
289 vid, vlan->members, vlan->untag); in b53_set_vlan_entry()
302 if (dev->core_rev >= 3) in b53_get_vlan_entry()
303 vlan->valid = !!(entry & VA_VALID_25_R4); in b53_get_vlan_entry()
305 vlan->valid = !!(entry & VA_VALID_25); in b53_get_vlan_entry()
306 vlan->members = entry & VA_MEMBER_MASK; in b53_get_vlan_entry()
307 vlan->untag = (entry >> VA_UNTAG_S_25) & VA_UNTAG_MASK_25; in b53_get_vlan_entry()
316 vlan->valid = !!(entry & VA_VALID_65); in b53_get_vlan_entry()
317 vlan->members = entry & VA_MEMBER_MASK; in b53_get_vlan_entry()
318 vlan->untag = (entry >> VA_UNTAG_S_65) & VA_UNTAG_MASK_65; in b53_get_vlan_entry()
322 b53_write16(dev, B53_ARLIO_PAGE, dev->vta_regs[1], vid); in b53_get_vlan_entry()
324 b53_read32(dev, B53_ARLIO_PAGE, dev->vta_regs[2], &entry); in b53_get_vlan_entry()
325 vlan->members = entry & VTE_MEMBERS; in b53_get_vlan_entry()
326 vlan->untag = (entry >> VTE_UNTAG_S) & VTE_MEMBERS; in b53_get_vlan_entry()
327 vlan->valid = true; in b53_get_vlan_entry()
331 static void b53_set_eap_mode(struct b53_device *dev, int port, int mode) in b53_set_eap_mode() argument
335 if (is5325(dev) || is5365(dev) || dev->chip_id == BCM5389_DEVICE_ID) in b53_set_eap_mode()
338 b53_read64(dev, B53_EAP_PAGE, B53_PORT_EAP_CONF(port), &eap_conf); in b53_set_eap_mode()
348 b53_write64(dev, B53_EAP_PAGE, B53_PORT_EAP_CONF(port), eap_conf); in b53_set_eap_mode()
365 /* Include IMP port in dumb forwarding mode */ in b53_set_forwarding()
383 static void b53_enable_vlan(struct b53_device *dev, int port, bool enable, in b53_enable_vlan() argument
445 /* enable the high 8 bit vid check on 5325 */ in b53_enable_vlan()
466 dev->vlan_enabled = enable; in b53_enable_vlan()
468 dev_dbg(dev->dev, "Port %d VLAN enabled: %d, filtering: %d\n", in b53_enable_vlan()
469 port, enable, enable_filtering); in b53_enable_vlan()
478 return -EINVAL; in b53_set_jumbo()
481 port_mask = dev->enabled_ports; in b53_set_jumbo()
487 b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask); in b53_set_jumbo()
488 return b53_write16(dev, B53_JUMBO_PAGE, dev->jumbo_size_reg, max_size); in b53_set_jumbo()
513 return -ETIMEDOUT; in b53_flush_arl()
520 static int b53_fast_age_port(struct b53_device *dev, int port) in b53_fast_age_port() argument
525 b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_PORT_CTRL, port); in b53_fast_age_port()
542 struct b53_device *dev = ds->priv; in b53_imp_vlan_setup()
546 /* BCM5325 CPU port is at 8 */ in b53_imp_vlan_setup()
550 /* Enable the IMP port to be in the same VLAN as the other ports in b53_imp_vlan_setup()
551 * on a per-port basis such that we only have Port i and IMP in in b53_imp_vlan_setup()
562 static void b53_port_set_ucast_flood(struct b53_device *dev, int port, in b53_port_set_ucast_flood() argument
568 if (port == B53_CPU_PORT_25) in b53_port_set_ucast_flood()
569 port = B53_CPU_PORT; in b53_port_set_ucast_flood()
573 uc |= BIT(port) | B53_IEEE_UCAST_DROP_EN; in b53_port_set_ucast_flood()
575 uc &= ~BIT(port); in b53_port_set_ucast_flood()
580 uc |= BIT(port); in b53_port_set_ucast_flood()
582 uc &= ~BIT(port); in b53_port_set_ucast_flood()
587 static void b53_port_set_mcast_flood(struct b53_device *dev, int port, in b53_port_set_mcast_flood() argument
593 if (port == B53_CPU_PORT_25) in b53_port_set_mcast_flood()
594 port = B53_CPU_PORT; in b53_port_set_mcast_flood()
598 mc |= BIT(port) | B53_IEEE_MCAST_DROP_EN; in b53_port_set_mcast_flood()
600 mc &= ~BIT(port); in b53_port_set_mcast_flood()
605 mc |= BIT(port); in b53_port_set_mcast_flood()
607 mc &= ~BIT(port); in b53_port_set_mcast_flood()
612 mc |= BIT(port); in b53_port_set_mcast_flood()
614 mc &= ~BIT(port); in b53_port_set_mcast_flood()
619 static void b53_port_set_learning(struct b53_device *dev, int port, in b53_port_set_learning() argument
629 reg &= ~BIT(port); in b53_port_set_learning()
631 reg |= BIT(port); in b53_port_set_learning()
635 static void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable) in b53_eee_enable_set() argument
637 struct b53_device *dev = ds->priv; in b53_eee_enable_set()
642 reg |= BIT(port); in b53_eee_enable_set()
644 reg &= ~BIT(port); in b53_eee_enable_set()
648 int b53_setup_port(struct dsa_switch *ds, int port) in b53_setup_port() argument
650 struct b53_device *dev = ds->priv; in b53_setup_port()
652 b53_port_set_ucast_flood(dev, port, true); in b53_setup_port()
653 b53_port_set_mcast_flood(dev, port, true); in b53_setup_port()
654 b53_port_set_learning(dev, port, false); in b53_setup_port()
656 /* Force all traffic to go to the CPU port to prevent the ASIC from in b53_setup_port()
660 if (dsa_is_user_port(ds, port)) in b53_setup_port()
661 b53_set_eap_mode(dev, port, EAP_MODE_SIMPLIFIED); in b53_setup_port()
664 in_range(port, 1, 4)) { in b53_setup_port()
669 if (dsa_is_unused_port(ds, port)) in b53_setup_port()
670 reg |= PD_MODE_POWER_DOWN_PORT(port); in b53_setup_port()
672 reg &= ~PD_MODE_POWER_DOWN_PORT(port); in b53_setup_port()
680 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_enable_port() argument
682 struct b53_device *dev = ds->priv; in b53_enable_port()
687 if (!dsa_is_user_port(ds, port)) in b53_enable_port()
690 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_enable_port()
692 if (dev->ops->phy_enable) in b53_enable_port()
693 dev->ops->phy_enable(dev, port); in b53_enable_port()
695 if (dev->ops->irq_enable) in b53_enable_port()
696 ret = dev->ops->irq_enable(dev, port); in b53_enable_port()
701 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), 0); in b53_enable_port()
703 /* Set this port, and only this one to be in the default VLAN, in b53_enable_port()
705 * bringing down this port. in b53_enable_port()
707 b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); in b53_enable_port()
709 pvlan |= BIT(port); in b53_enable_port()
710 pvlan |= dev->ports[port].vlan_ctl_mask; in b53_enable_port()
711 b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); in b53_enable_port()
716 if (dev->ports[port].eee.eee_enabled) in b53_enable_port()
717 b53_eee_enable_set(ds, port, true); in b53_enable_port()
723 void b53_disable_port(struct dsa_switch *ds, int port) in b53_disable_port() argument
725 struct b53_device *dev = ds->priv; in b53_disable_port()
728 /* Disable Tx/Rx for the port */ in b53_disable_port()
729 b53_read8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), &reg); in b53_disable_port()
731 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), reg); in b53_disable_port()
733 if (dev->ops->phy_disable) in b53_disable_port()
734 dev->ops->phy_disable(dev, port); in b53_disable_port()
736 if (dev->ops->irq_disable) in b53_disable_port()
737 dev->ops->irq_disable(dev, port); in b53_disable_port()
741 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port) in b53_brcm_hdr_setup() argument
743 struct b53_device *dev = ds->priv; in b53_brcm_hdr_setup()
744 bool tag_en = !(dev->tag_protocol == DSA_TAG_PROTO_NONE); in b53_brcm_hdr_setup()
749 switch (port) { in b53_brcm_hdr_setup()
750 case 8: in b53_brcm_hdr_setup()
772 /* Configure the appropriate IMP port */ in b53_brcm_hdr_setup()
774 if (port == 8) in b53_brcm_hdr_setup()
776 else if (port == 5) in b53_brcm_hdr_setup()
781 if (dev->tag_protocol == DSA_TAG_PROTO_BRCM_LEGACY || in b53_brcm_hdr_setup()
782 dev->tag_protocol == DSA_TAG_PROTO_BRCM_LEGACY_FCS) in b53_brcm_hdr_setup()
785 /* Enable Broadcom tags for IMP port */ in b53_brcm_hdr_setup()
802 reg &= ~BIT(port); in b53_brcm_hdr_setup()
804 reg |= BIT(port); in b53_brcm_hdr_setup()
808 * allow delivering frames to the per-port net_devices in b53_brcm_hdr_setup()
812 reg &= ~BIT(port); in b53_brcm_hdr_setup()
814 reg |= BIT(port); in b53_brcm_hdr_setup()
819 static void b53_enable_cpu_port(struct b53_device *dev, int port) in b53_enable_cpu_port() argument
823 /* BCM5325 CPU port is at 8 */ in b53_enable_cpu_port()
824 if ((is5325(dev) || is5365(dev)) && port == B53_CPU_PORT_25) in b53_enable_cpu_port()
825 port = B53_CPU_PORT; in b53_enable_cpu_port()
830 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl); in b53_enable_cpu_port()
832 b53_brcm_hdr_setup(dev->ds, port); in b53_enable_cpu_port()
861 static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port) in b53_vlan_port_needs_forced_tagged() argument
863 struct b53_device *dev = ds->priv; in b53_vlan_port_needs_forced_tagged()
865 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); in b53_vlan_port_needs_forced_tagged()
868 static bool b53_vlan_port_may_join_untagged(struct dsa_switch *ds, int port) in b53_vlan_port_may_join_untagged() argument
870 struct b53_device *dev = ds->priv; in b53_vlan_port_may_join_untagged()
873 if (!dev->vlan_filtering) in b53_vlan_port_may_join_untagged()
876 dp = dsa_to_port(ds, port); in b53_vlan_port_may_join_untagged()
881 return dp->bridge == NULL; in b53_vlan_port_may_join_untagged()
886 struct b53_device *dev = ds->priv; in b53_configure_vlan()
896 for (i = def_vid; i < dev->num_vlans; i++) in b53_configure_vlan()
902 b53_enable_vlan(dev, -1, dev->vlan_enabled, dev->vlan_filtering); in b53_configure_vlan()
910 v = &dev->vlans[def_vid]; in b53_configure_vlan()
923 if (dev->vlan_filtering) { in b53_configure_vlan()
924 /* Upon initial call we have not set-up any VLANs, but upon in b53_configure_vlan()
927 for (vid = def_vid + 1; vid < dev->num_vlans; vid++) { in b53_configure_vlan()
928 v = &dev->vlans[vid]; in b53_configure_vlan()
930 if (!v->members) in b53_configure_vlan()
941 dev->ports[i].pvid); in b53_configure_vlan()
951 int gpio = dev->reset_gpio; in b53_switch_reset_gpio()
956 /* Reset sequence: RESET low(50ms)->high(20ms) in b53_switch_reset_gpio()
964 dev->current_page = 0xff; in b53_switch_reset_gpio()
984 if (dev->chip_id == BCM58XX_DEVICE_ID || in b53_switch_reset()
985 dev->chip_id == BCM583XX_DEVICE_ID) { in b53_switch_reset()
996 } while (timeout-- > 0); in b53_switch_reset()
999 dev_err(dev->dev, in b53_switch_reset()
1001 return -ETIMEDOUT; in b53_switch_reset()
1015 dev_err(dev->dev, "Failed to enable switch!\n"); in b53_switch_reset()
1016 return -EINVAL; in b53_switch_reset()
1028 struct b53_device *priv = ds->priv; in b53_phy_read16()
1032 if (priv->ops->phy_read16) in b53_phy_read16()
1033 ret = priv->ops->phy_read16(priv, addr, reg, &value); in b53_phy_read16()
1043 struct b53_device *priv = ds->priv; in b53_phy_write16()
1045 if (priv->ops->phy_write16) in b53_phy_write16()
1046 return priv->ops->phy_write16(priv, addr, reg, val); in b53_phy_write16()
1054 memset(priv->vlans, 0, sizeof(*priv->vlans) * priv->num_vlans); in b53_reset_switch()
1055 memset(priv->ports, 0, sizeof(*priv->ports) * priv->num_ports); in b53_reset_switch()
1057 priv->serdes_lane = B53_INVALID_LANE; in b53_reset_switch()
1067 b53_configure_vlan(priv->ds); in b53_apply_config()
1111 static struct phy_device *b53_get_phy_device(struct dsa_switch *ds, int port) in b53_get_phy_device() argument
1113 /* These ports typically do not have built-in PHYs */ in b53_get_phy_device()
1114 switch (port) { in b53_get_phy_device()
1121 return mdiobus_get_phy(ds->user_mii_bus, port); in b53_get_phy_device()
1124 void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, in b53_get_strings() argument
1127 struct b53_device *dev = ds->priv; in b53_get_strings()
1137 phydev = b53_get_phy_device(ds, port); in b53_get_strings()
1146 void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_stats() argument
1148 struct b53_device *dev = ds->priv; in b53_get_ethtool_stats()
1155 if (is5365(dev) && port == 5) in b53_get_ethtool_stats()
1156 port = 8; in b53_get_ethtool_stats()
1158 mutex_lock(&dev->stats_mutex); in b53_get_ethtool_stats()
1163 if (s->size == 8) { in b53_get_ethtool_stats()
1164 b53_read64(dev, B53_MIB_PAGE(port), s->offset, &val); in b53_get_ethtool_stats()
1168 b53_read32(dev, B53_MIB_PAGE(port), s->offset, in b53_get_ethtool_stats()
1175 mutex_unlock(&dev->stats_mutex); in b53_get_ethtool_stats()
1179 void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_phy_stats() argument
1183 phydev = b53_get_phy_device(ds, port); in b53_get_ethtool_phy_stats()
1191 int b53_get_sset_count(struct dsa_switch *ds, int port, int sset) in b53_get_sset_count() argument
1193 struct b53_device *dev = ds->priv; in b53_get_sset_count()
1199 phydev = b53_get_phy_device(ds, port); in b53_get_sset_count()
1221 for (i = 0; i < dev->num_vlans; i++) { in b53_devlink_vlan_table_get()
1222 vl = &dev->vlans[i]; in b53_devlink_vlan_table_get()
1223 if (vl->members) in b53_devlink_vlan_table_get()
1233 struct b53_device *dev = ds->priv; in b53_setup_devlink_resources()
1236 devlink_resource_size_params_init(&size_params, dev->num_vlans, in b53_setup_devlink_resources()
1237 dev->num_vlans, in b53_setup_devlink_resources()
1240 err = dsa_devlink_resource_register(ds, "VLAN", dev->num_vlans, in b53_setup_devlink_resources()
1260 struct b53_device *dev = ds->priv; in b53_setup()
1262 unsigned int port; in b53_setup() local
1267 * which forces the CPU port to be tagged in all VLANs. in b53_setup()
1269 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; in b53_setup()
1272 * packets, so keep the CPU port always tagged. in b53_setup()
1274 ds->untag_vlan_aware_bridge_pvid = true; in b53_setup()
1276 if (dev->chip_id == BCM53101_DEVICE_ID) { in b53_setup()
1278 ds->ageing_time_min = 1 * 500; in b53_setup()
1279 ds->ageing_time_max = AGE_TIME_MAX * 500; in b53_setup()
1282 ds->ageing_time_min = 1 * 1000; in b53_setup()
1283 ds->ageing_time_max = AGE_TIME_MAX * 1000; in b53_setup()
1288 dev_err(ds->dev, "failed to reset switch\n"); in b53_setup()
1294 vl = &dev->vlans[pvid]; in b53_setup()
1295 b53_for_each_port(dev, port) { in b53_setup()
1296 vl->members |= BIT(port); in b53_setup()
1297 if (!b53_vlan_port_needs_forced_tagged(ds, port)) in b53_setup()
1298 vl->untag |= BIT(port); in b53_setup()
1305 dev_err(ds->dev, "failed to apply configuration\n"); in b53_setup()
1309 /* Configure IMP/CPU port, disable all other ports. Enabled in b53_setup()
1312 for (port = 0; port < dev->num_ports; port++) { in b53_setup()
1313 if (dsa_is_cpu_port(ds, port)) in b53_setup()
1314 b53_enable_cpu_port(dev, port); in b53_setup()
1316 b53_disable_port(ds, port); in b53_setup()
1327 static void b53_force_link(struct b53_device *dev, int port, int link) in b53_force_link() argument
1331 /* Override the port settings */ in b53_force_link()
1332 if (port == dev->imp_port) { in b53_force_link()
1338 off = B53_GMII_PORT_OVERRIDE_CTRL(port); in b53_force_link()
1351 static void b53_force_port_config(struct b53_device *dev, int port, in b53_force_port_config() argument
1357 /* Override the port settings */ in b53_force_port_config()
1358 if (port == dev->imp_port) { in b53_force_port_config()
1364 off = B53_GMII_PORT_OVERRIDE_CTRL(port); in b53_force_port_config()
1393 dev_err(dev->dev, "unknown speed: %d\n", speed); in b53_force_port_config()
1419 static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port, in b53_adjust_63xx_rgmii() argument
1422 struct b53_device *dev = ds->priv; in b53_adjust_63xx_rgmii()
1425 b53_read8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), &rgmii_ctrl); in b53_adjust_63xx_rgmii()
1433 b53_write8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), rgmii_ctrl); in b53_adjust_63xx_rgmii()
1435 dev_dbg(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_63xx_rgmii()
1439 static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port, in b53_adjust_531x5_rgmii() argument
1442 struct b53_device *dev = ds->priv; in b53_adjust_531x5_rgmii()
1445 if (port == dev->imp_port) in b53_adjust_531x5_rgmii()
1448 off = B53_RGMII_CTRL_P(port); in b53_adjust_531x5_rgmii()
1450 /* Configure the port RGMII clock delay by DLL disabled and in b53_adjust_531x5_rgmii()
1457 * sure that we enable the port TX clock internal delay to in b53_adjust_531x5_rgmii()
1475 if (dev->chip_id != BCM53115_DEVICE_ID) in b53_adjust_531x5_rgmii()
1480 dev_info(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_531x5_rgmii()
1484 static void b53_adjust_5325_mii(struct dsa_switch *ds, int port) in b53_adjust_5325_mii() argument
1486 struct b53_device *dev = ds->priv; in b53_adjust_5325_mii()
1500 dev_err(ds->dev, in b53_adjust_5325_mii()
1507 void b53_port_event(struct dsa_switch *ds, int port) in b53_port_event() argument
1509 struct b53_device *dev = ds->priv; in b53_port_event()
1514 link = !!(sts & BIT(port)); in b53_port_event()
1515 dsa_port_phylink_mac_change(ds, port, link); in b53_port_event()
1519 static void b53_phylink_get_caps(struct dsa_switch *ds, int port, in b53_phylink_get_caps() argument
1522 struct b53_device *dev = ds->priv; in b53_phylink_get_caps()
1525 __set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces); in b53_phylink_get_caps()
1536 * For MDIO, port 8 can be RGMII_TXID. in b53_phylink_get_caps()
1538 __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); in b53_phylink_get_caps()
1539 __set_bit(PHY_INTERFACE_MODE_REVMII, config->supported_interfaces); in b53_phylink_get_caps()
1542 if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) in b53_phylink_get_caps()
1543 phy_interface_set_rgmii(config->supported_interfaces); in b53_phylink_get_caps()
1545 config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in b53_phylink_get_caps()
1555 config->mac_capabilities |= MAC_1000; in b53_phylink_get_caps()
1558 if (dev->ops->phylink_get_caps) in b53_phylink_get_caps()
1559 dev->ops->phylink_get_caps(dev, port, config); in b53_phylink_get_caps()
1566 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_select_pcs()
1568 if (!dev->ops->phylink_mac_select_pcs) in b53_phylink_mac_select_pcs()
1571 return dev->ops->phylink_mac_select_pcs(dev, dp->index, interface); in b53_phylink_mac_select_pcs()
1579 phy_interface_t interface = state->interface; in b53_phylink_mac_config()
1580 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_config()
1581 struct b53_device *dev = ds->priv; in b53_phylink_mac_config()
1582 int port = dp->index; in b53_phylink_mac_config() local
1584 if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) in b53_phylink_mac_config()
1585 b53_adjust_63xx_rgmii(ds, port, interface); in b53_phylink_mac_config()
1589 b53_adjust_531x5_rgmii(ds, port, interface); in b53_phylink_mac_config()
1591 /* configure MII port if necessary */ in b53_phylink_mac_config()
1593 b53_adjust_5325_mii(ds, port); in b53_phylink_mac_config()
1602 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_link_down()
1603 int port = dp->index; in b53_phylink_mac_link_down() local
1606 if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) in b53_phylink_mac_link_down()
1607 b53_force_link(dev, port, false); in b53_phylink_mac_link_down()
1612 b53_force_link(dev, port, false); in b53_phylink_mac_link_down()
1617 dev->ops->serdes_link_set) in b53_phylink_mac_link_down()
1618 dev->ops->serdes_link_set(dev, port, mode, interface, false); in b53_phylink_mac_link_down()
1629 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_link_up()
1630 struct b53_device *dev = ds->priv; in b53_phylink_mac_link_up()
1631 struct ethtool_keee *p = &dev->ports[dp->index].eee; in b53_phylink_mac_link_up()
1632 int port = dp->index; in b53_phylink_mac_link_up() local
1635 /* Re-negotiate EEE if it was enabled already */ in b53_phylink_mac_link_up()
1636 p->eee_enabled = b53_eee_init(ds, port, phydev); in b53_phylink_mac_link_up()
1638 if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) { in b53_phylink_mac_link_up()
1639 b53_force_port_config(dev, port, speed, duplex, in b53_phylink_mac_link_up()
1641 b53_force_link(dev, port, true); in b53_phylink_mac_link_up()
1648 /* Force flow control on BCM5301x's CPU port */ in b53_phylink_mac_link_up()
1649 if (is5301x(dev) && dsa_is_cpu_port(ds, port)) in b53_phylink_mac_link_up()
1652 b53_force_port_config(dev, port, speed, duplex, in b53_phylink_mac_link_up()
1654 b53_force_link(dev, port, true); in b53_phylink_mac_link_up()
1659 dev->ops->serdes_link_set) in b53_phylink_mac_link_up()
1660 dev->ops->serdes_link_set(dev, port, mode, interface, true); in b53_phylink_mac_link_up()
1663 int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, in b53_vlan_filtering() argument
1666 struct b53_device *dev = ds->priv; in b53_vlan_filtering()
1668 if (dev->vlan_filtering != vlan_filtering) { in b53_vlan_filtering()
1669 dev->vlan_filtering = vlan_filtering; in b53_vlan_filtering()
1677 static int b53_vlan_prepare(struct dsa_switch *ds, int port, in b53_vlan_prepare() argument
1680 struct b53_device *dev = ds->priv; in b53_vlan_prepare()
1682 if ((is5325(dev) || is5365(dev)) && vlan->vid == 0) in b53_vlan_prepare()
1683 return -EOPNOTSUPP; in b53_vlan_prepare()
1685 /* Port 7 on 7278 connects to the ASP's UniMAC which is not capable of in b53_vlan_prepare()
1686 * receiving VLAN tagged frames at all, we can still allow the port to in b53_vlan_prepare()
1689 if (dev->chip_id == BCM7278_DEVICE_ID && port == 7 && in b53_vlan_prepare()
1690 !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED)) in b53_vlan_prepare()
1691 return -EINVAL; in b53_vlan_prepare()
1693 if (vlan->vid >= dev->num_vlans) in b53_vlan_prepare()
1694 return -ERANGE; in b53_vlan_prepare()
1696 b53_enable_vlan(dev, port, true, dev->vlan_filtering); in b53_vlan_prepare()
1701 int b53_vlan_add(struct dsa_switch *ds, int port, in b53_vlan_add() argument
1705 struct b53_device *dev = ds->priv; in b53_vlan_add()
1706 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in b53_vlan_add()
1707 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in b53_vlan_add()
1712 err = b53_vlan_prepare(ds, port, vlan); in b53_vlan_add()
1716 if (vlan->vid == 0) in b53_vlan_add()
1719 old_pvid = dev->ports[port].pvid; in b53_vlan_add()
1721 new_pvid = vlan->vid; in b53_vlan_add()
1722 else if (!pvid && vlan->vid == old_pvid) in b53_vlan_add()
1726 dev->ports[port].pvid = new_pvid; in b53_vlan_add()
1728 vl = &dev->vlans[vlan->vid]; in b53_vlan_add()
1730 if (dsa_is_cpu_port(ds, port)) in b53_vlan_add()
1733 vl->members |= BIT(port); in b53_vlan_add()
1734 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_add()
1735 vl->untag |= BIT(port); in b53_vlan_add()
1737 vl->untag &= ~BIT(port); in b53_vlan_add()
1739 if (!dev->vlan_filtering) in b53_vlan_add()
1742 b53_set_vlan_entry(dev, vlan->vid, vl); in b53_vlan_add()
1743 b53_fast_age_vlan(dev, vlan->vid); in b53_vlan_add()
1745 if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) { in b53_vlan_add()
1746 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), in b53_vlan_add()
1755 int b53_vlan_del(struct dsa_switch *ds, int port, in b53_vlan_del() argument
1758 struct b53_device *dev = ds->priv; in b53_vlan_del()
1759 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in b53_vlan_del()
1763 if (vlan->vid == 0) in b53_vlan_del()
1766 pvid = dev->ports[port].pvid; in b53_vlan_del()
1768 vl = &dev->vlans[vlan->vid]; in b53_vlan_del()
1770 vl->members &= ~BIT(port); in b53_vlan_del()
1772 if (pvid == vlan->vid) in b53_vlan_del()
1774 dev->ports[port].pvid = pvid; in b53_vlan_del()
1776 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_del()
1777 vl->untag &= ~(BIT(port)); in b53_vlan_del()
1779 if (!dev->vlan_filtering) in b53_vlan_del()
1782 b53_set_vlan_entry(dev, vlan->vid, vl); in b53_vlan_del()
1783 b53_fast_age_vlan(dev, vlan->vid); in b53_vlan_del()
1785 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), pvid); in b53_vlan_del()
1792 /* Address Resolution Logic routines. Caller must hold &dev->arl_mutex. */
1804 } while (timeout--); in b53_arl_op_wait()
1806 dev_warn(dev->dev, "timeout waiting for ARL to finish: 0x%02x\n", reg); in b53_arl_op_wait()
1808 return -ETIMEDOUT; in b53_arl_op_wait()
1816 return -EINVAL; in b53_arl_rw_op()
1824 if (dev->vlan_enabled) in b53_arl_rw_op()
1844 bitmap_zero(free_bins, dev->num_arl_bins); in b53_arl_read()
1847 for (i = 0; i < dev->num_arl_bins; i++) { in b53_arl_read()
1863 if (dev->vlan_enabled && in b53_arl_read()
1870 *idx = find_first_bit(free_bins, dev->num_arl_bins); in b53_arl_read()
1871 return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; in b53_arl_read()
1885 bitmap_zero(free_bins, dev->num_arl_bins); in b53_arl_read_25()
1888 for (i = 0; i < dev->num_arl_bins; i++) { in b53_arl_read_25()
1902 if (dev->vlan_enabled && in b53_arl_read_25()
1909 *idx = find_first_bit(free_bins, dev->num_arl_bins); in b53_arl_read_25()
1910 return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; in b53_arl_read_25()
1913 static int b53_arl_op(struct b53_device *dev, int op, int port, in b53_arl_op() argument
1922 /* Convert the array into a 64-bit MAC */ in b53_arl_op()
1945 case -ETIMEDOUT: in b53_arl_op()
1947 case -ENOSPC: in b53_arl_op()
1948 dev_dbg(dev->dev, "{%pM,%.4d} no space left in ARL\n", in b53_arl_op()
1951 case -ENOENT: in b53_arl_op()
1953 dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n", in b53_arl_op()
1958 dev_dbg(dev->dev, "{%pM,%.4d} found, using idx: %d\n", in b53_arl_op()
1963 /* For multicast address, the port is a bitmask and the validity in b53_arl_op()
1964 * is determined by having at least one port being still active in b53_arl_op()
1967 ent.port = port; in b53_arl_op()
1971 ent.port |= BIT(port); in b53_arl_op()
1973 ent.port &= ~BIT(port); in b53_arl_op()
1975 ent.is_valid = !!(ent.port); in b53_arl_op()
1997 int b53_fdb_add(struct dsa_switch *ds, int port, in b53_fdb_add() argument
2001 struct b53_device *priv = ds->priv; in b53_fdb_add()
2004 mutex_lock(&priv->arl_mutex); in b53_fdb_add()
2005 ret = b53_arl_op(priv, 0, port, addr, vid, true); in b53_fdb_add()
2006 mutex_unlock(&priv->arl_mutex); in b53_fdb_add()
2012 int b53_fdb_del(struct dsa_switch *ds, int port, in b53_fdb_del() argument
2016 struct b53_device *priv = ds->priv; in b53_fdb_del()
2019 mutex_lock(&priv->arl_mutex); in b53_fdb_del()
2020 ret = b53_arl_op(priv, 0, port, addr, vid, false); in b53_fdb_del()
2021 mutex_unlock(&priv->arl_mutex); in b53_fdb_del()
2040 return -ENOENT; in b53_arl_search_wait()
2046 } while (timeout--); in b53_arl_search_wait()
2048 return -ETIMEDOUT; in b53_arl_search_wait()
2075 static int b53_fdb_copy(int port, const struct b53_arl_entry *ent, in b53_fdb_copy() argument
2078 if (!ent->is_valid) in b53_fdb_copy()
2081 if (port != ent->port) in b53_fdb_copy()
2084 return cb(ent->mac, ent->vid, ent->is_static, data); in b53_fdb_copy()
2087 int b53_fdb_dump(struct dsa_switch *ds, int port, in b53_fdb_dump() argument
2091 struct b53_device *priv = ds->priv; in b53_fdb_dump()
2097 if (priv->num_arl_bins > 2) in b53_fdb_dump()
2100 mutex_lock(&priv->arl_mutex); in b53_fdb_dump()
2117 ret = b53_fdb_copy(port, &results[0], cb, data); in b53_fdb_dump()
2123 ret = b53_fdb_copy(port, &results[1], cb, data); in b53_fdb_dump()
2133 mutex_unlock(&priv->arl_mutex); in b53_fdb_dump()
2139 int b53_mdb_add(struct dsa_switch *ds, int port, in b53_mdb_add() argument
2143 struct b53_device *priv = ds->priv; in b53_mdb_add()
2150 return -EOPNOTSUPP; in b53_mdb_add()
2152 mutex_lock(&priv->arl_mutex); in b53_mdb_add()
2153 ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true); in b53_mdb_add()
2154 mutex_unlock(&priv->arl_mutex); in b53_mdb_add()
2160 int b53_mdb_del(struct dsa_switch *ds, int port, in b53_mdb_del() argument
2164 struct b53_device *priv = ds->priv; in b53_mdb_del()
2167 mutex_lock(&priv->arl_mutex); in b53_mdb_del()
2168 ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, false); in b53_mdb_del()
2169 mutex_unlock(&priv->arl_mutex); in b53_mdb_del()
2171 dev_err(ds->dev, "failed to delete MDB entry\n"); in b53_mdb_del()
2177 int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, in b53_br_join() argument
2180 struct b53_device *dev = ds->priv; in b53_br_join()
2182 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_join()
2186 /* On 7278, port 7 which connects to the ASP should only receive in b53_br_join()
2189 if (dev->chip_id == BCM7278_DEVICE_ID && port == 7) in b53_br_join()
2190 return -EINVAL; in b53_br_join()
2193 vl = &dev->vlans[pvid]; in b53_br_join()
2195 if (dev->vlan_filtering) { in b53_br_join()
2196 /* Make this port leave the all VLANs join since we will have in b53_br_join()
2202 reg &= ~BIT(port); in b53_br_join()
2210 vl->members &= ~BIT(port); in b53_br_join()
2214 b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); in b53_br_join()
2220 /* Add this local port to the remote port VLAN control in b53_br_join()
2221 * membership and update the remote port bitmask in b53_br_join()
2224 reg |= BIT(port); in b53_br_join()
2226 dev->ports[i].vlan_ctl_mask = reg; in b53_br_join()
2231 /* Disable redirection of unknown SA to the CPU port */ in b53_br_join()
2232 b53_set_eap_mode(dev, port, EAP_MODE_BASIC); in b53_br_join()
2234 /* Configure the local port VLAN control membership to include in b53_br_join()
2235 * remote ports and update the local port bitmask in b53_br_join()
2237 b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); in b53_br_join()
2238 dev->ports[port].vlan_ctl_mask = pvlan; in b53_br_join()
2244 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge) in b53_br_leave() argument
2246 struct b53_device *dev = ds->priv; in b53_br_leave()
2248 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_leave()
2252 b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); in b53_br_leave()
2260 reg &= ~BIT(port); in b53_br_leave()
2262 dev->ports[port].vlan_ctl_mask = reg; in b53_br_leave()
2265 if (port != i) in b53_br_leave()
2269 /* Enable redirection of unknown SA to the CPU port */ in b53_br_leave()
2270 b53_set_eap_mode(dev, port, EAP_MODE_SIMPLIFIED); in b53_br_leave()
2272 b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); in b53_br_leave()
2273 dev->ports[port].vlan_ctl_mask = pvlan; in b53_br_leave()
2276 vl = &dev->vlans[pvid]; in b53_br_leave()
2278 if (dev->vlan_filtering) { in b53_br_leave()
2279 /* Make this port join all VLANs without VLAN entries */ in b53_br_leave()
2282 reg |= BIT(port); in b53_br_leave()
2289 vl->members |= BIT(port); in b53_br_leave()
2295 void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state) in b53_br_set_stp_state() argument
2297 struct b53_device *dev = ds->priv; in b53_br_set_stp_state()
2318 dev_err(ds->dev, "invalid STP state: %d\n", state); in b53_br_set_stp_state()
2322 b53_read8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), &reg); in b53_br_set_stp_state()
2325 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), reg); in b53_br_set_stp_state()
2329 void b53_br_fast_age(struct dsa_switch *ds, int port) in b53_br_fast_age() argument
2331 struct b53_device *dev = ds->priv; in b53_br_fast_age()
2333 if (b53_fast_age_port(dev, port)) in b53_br_fast_age()
2334 dev_err(ds->dev, "fast ageing failed\n"); in b53_br_fast_age()
2338 int b53_br_flags_pre(struct dsa_switch *ds, int port, in b53_br_flags_pre() argument
2342 struct b53_device *dev = ds->priv; in b53_br_flags_pre()
2349 return -EINVAL; in b53_br_flags_pre()
2355 int b53_br_flags(struct dsa_switch *ds, int port, in b53_br_flags() argument
2360 b53_port_set_ucast_flood(ds->priv, port, in b53_br_flags()
2363 b53_port_set_mcast_flood(ds->priv, port, in b53_br_flags()
2366 b53_port_set_learning(ds->priv, port, in b53_br_flags()
2373 static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) in b53_possible_cpu_port() argument
2376 * following ports: 5, 7 and 8, any other port is not supported in b53_possible_cpu_port()
2378 switch (port) { in b53_possible_cpu_port()
2388 static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port, in b53_can_enable_brcm_tags() argument
2391 bool ret = b53_possible_cpu_port(ds, port); in b53_can_enable_brcm_tags()
2394 dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", in b53_can_enable_brcm_tags()
2395 port); in b53_can_enable_brcm_tags()
2402 dev_warn(ds->dev, in b53_can_enable_brcm_tags()
2403 "Port %d is stacked to Broadcom tag switch\n", port); in b53_can_enable_brcm_tags()
2414 enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, in b53_get_tag_protocol() argument
2417 struct b53_device *dev = ds->priv; in b53_get_tag_protocol()
2419 if (!b53_can_enable_brcm_tags(ds, port, mprot)) { in b53_get_tag_protocol()
2420 dev->tag_protocol = DSA_TAG_PROTO_NONE; in b53_get_tag_protocol()
2426 dev->tag_protocol = DSA_TAG_PROTO_BRCM_LEGACY_FCS; in b53_get_tag_protocol()
2429 dev->tag_protocol = DSA_TAG_PROTO_BRCM_LEGACY; in b53_get_tag_protocol()
2433 /* Broadcom BCM58xx chips have a flow accelerator on Port 8 in b53_get_tag_protocol()
2436 if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT) { in b53_get_tag_protocol()
2437 dev->tag_protocol = DSA_TAG_PROTO_BRCM_PREPEND; in b53_get_tag_protocol()
2441 dev->tag_protocol = DSA_TAG_PROTO_BRCM; in b53_get_tag_protocol()
2443 return dev->tag_protocol; in b53_get_tag_protocol()
2447 int b53_mirror_add(struct dsa_switch *ds, int port, in b53_mirror_add() argument
2451 struct b53_device *dev = ds->priv; in b53_mirror_add()
2460 reg |= BIT(port); in b53_mirror_add()
2465 reg |= mirror->to_local_port; in b53_mirror_add()
2473 void b53_mirror_del(struct dsa_switch *ds, int port, in b53_mirror_del() argument
2476 struct b53_device *dev = ds->priv; in b53_mirror_del()
2480 if (mirror->ingress) in b53_mirror_del()
2487 reg &= ~BIT(port); in b53_mirror_del()
2495 if (mirror->ingress) in b53_mirror_del()
2506 reg &= ~mirror->to_local_port; in b53_mirror_del()
2514 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_eee_init() argument
2518 if (!b53_support_eee(ds, port)) in b53_eee_init()
2525 b53_eee_enable_set(ds, port, true); in b53_eee_init()
2531 bool b53_support_eee(struct dsa_switch *ds, int port) in b53_support_eee() argument
2533 struct b53_device *dev = ds->priv; in b53_support_eee()
2539 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) in b53_set_mac_eee() argument
2541 struct b53_device *dev = ds->priv; in b53_set_mac_eee()
2542 struct ethtool_keee *p = &dev->ports[port].eee; in b53_set_mac_eee()
2544 p->eee_enabled = e->eee_enabled; in b53_set_mac_eee()
2545 b53_eee_enable_set(ds, port, e->eee_enabled); in b53_set_mac_eee()
2551 static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu) in b53_change_mtu() argument
2553 struct b53_device *dev = ds->priv; in b53_change_mtu()
2560 if (!dsa_is_cpu_port(ds, port)) in b53_change_mtu()
2569 static int b53_get_max_mtu(struct dsa_switch *ds, int port) in b53_get_max_mtu() argument
2571 struct b53_device *dev = ds->priv; in b53_get_max_mtu()
2581 struct b53_device *dev = ds->priv; in b53_set_ageing_time()
2590 if (dev->chip_id == BCM53101_DEVICE_ID) in b53_set_ageing_time()
2698 .imp_port = 8,
2711 .imp_port = 8,
2724 .imp_port = 8,
2737 .imp_port = 8,
2751 .imp_port = 8,
2764 .imp_port = 8,
2776 .imp_port = 8,
2789 .imp_port = 8,
2802 .imp_port = 8,
2815 .imp_port = 8,
2828 .imp_port = 8,
2841 .imp_port = 8,
2854 .imp_port = 8,
2867 .imp_port = 8,
2880 .imp_port = 8,
2893 .imp_port = 8,
2907 .imp_port = 8,
2920 .imp_port = 8,
2933 .imp_port = 8,
2944 .imp_port = 8,
2957 u32 chip_id = dev->chip_id; in b53_switch_init()
2967 if (chip->chip_id == chip_id) { in b53_switch_init()
2968 if (!dev->enabled_ports) in b53_switch_init()
2969 dev->enabled_ports = chip->enabled_ports; in b53_switch_init()
2970 dev->name = chip->dev_name; in b53_switch_init()
2971 dev->duplex_reg = chip->duplex_reg; in b53_switch_init()
2972 dev->vta_regs[0] = chip->vta_regs[0]; in b53_switch_init()
2973 dev->vta_regs[1] = chip->vta_regs[1]; in b53_switch_init()
2974 dev->vta_regs[2] = chip->vta_regs[2]; in b53_switch_init()
2975 dev->jumbo_pm_reg = chip->jumbo_pm_reg; in b53_switch_init()
2976 dev->imp_port = chip->imp_port; in b53_switch_init()
2977 dev->num_vlans = chip->vlans; in b53_switch_init()
2978 dev->num_arl_bins = chip->arl_bins; in b53_switch_init()
2979 dev->num_arl_buckets = chip->arl_buckets; in b53_switch_init()
2996 /* BCM5325F - do not use port 4 */ in b53_switch_init()
2997 dev->enabled_ports &= ~BIT(4); in b53_switch_init()
3003 return -EINVAL; in b53_switch_init()
3011 dev->num_arl_buckets = 512; in b53_switch_init()
3013 dev->num_ports = fls(dev->enabled_ports); in b53_switch_init()
3015 dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); in b53_switch_init()
3017 /* Include non standard CPU port built-in PHYs to be probed */ in b53_switch_init()
3019 for (i = 0; i < dev->num_ports; i++) { in b53_switch_init()
3020 if (!(dev->ds->phys_mii_mask & BIT(i)) && in b53_switch_init()
3021 !b53_possible_cpu_port(dev->ds, i)) in b53_switch_init()
3022 dev->ds->phys_mii_mask |= BIT(i); in b53_switch_init()
3026 dev->ports = devm_kcalloc(dev->dev, in b53_switch_init()
3027 dev->num_ports, sizeof(struct b53_port), in b53_switch_init()
3029 if (!dev->ports) in b53_switch_init()
3030 return -ENOMEM; in b53_switch_init()
3032 dev->vlans = devm_kcalloc(dev->dev, in b53_switch_init()
3033 dev->num_vlans, sizeof(struct b53_vlan), in b53_switch_init()
3035 if (!dev->vlans) in b53_switch_init()
3036 return -ENOMEM; in b53_switch_init()
3038 dev->reset_gpio = b53_switch_get_reset_gpio(dev); in b53_switch_init()
3039 if (dev->reset_gpio >= 0) { in b53_switch_init()
3040 ret = devm_gpio_request_one(dev->dev, dev->reset_gpio, in b53_switch_init()
3060 ds->dev = base; in b53_switch_alloc()
3066 ds->priv = dev; in b53_switch_alloc()
3067 dev->dev = base; in b53_switch_alloc()
3069 dev->ds = ds; in b53_switch_alloc()
3070 dev->priv = priv; in b53_switch_alloc()
3071 dev->ops = ops; in b53_switch_alloc()
3072 ds->ops = &b53_switch_ops; in b53_switch_alloc()
3073 ds->phylink_mac_ops = &b53_phylink_mac_ops; in b53_switch_alloc()
3074 dev->vlan_enabled = true; in b53_switch_alloc()
3075 dev->vlan_filtering = false; in b53_switch_alloc()
3081 ds->vlan_filtering_is_global = true; in b53_switch_alloc()
3083 mutex_init(&dev->reg_mutex); in b53_switch_alloc()
3084 mutex_init(&dev->stats_mutex); in b53_switch_alloc()
3085 mutex_init(&dev->arl_mutex); in b53_switch_alloc()
3118 dev->chip_id = BCM5325_DEVICE_ID; in b53_switch_detect()
3120 val = b53_phy_read16(dev->ds, 0, MII_PHYSID1); in b53_switch_detect()
3122 val = b53_phy_read16(dev->ds, 0, MII_PHYSID2); in b53_switch_detect()
3126 dev->variant_id = B53_VARIANT_5325M; in b53_switch_detect()
3128 dev->variant_id = B53_VARIANT_5325E; in b53_switch_detect()
3130 dev->chip_id = BCM5365_DEVICE_ID; in b53_switch_detect()
3137 dev->chip_id = id8; in b53_switch_detect()
3155 dev->chip_id = id32; in b53_switch_detect()
3158 dev_err(dev->dev, in b53_switch_detect()
3161 return -ENODEV; in b53_switch_detect()
3165 if (dev->chip_id == BCM5325_DEVICE_ID) in b53_switch_detect()
3167 &dev->core_rev); in b53_switch_detect()
3170 &dev->core_rev); in b53_switch_detect()
3178 if (dev->pdata) { in b53_switch_register()
3179 dev->chip_id = dev->pdata->chip_id; in b53_switch_register()
3180 dev->enabled_ports = dev->pdata->enabled_ports; in b53_switch_register()
3183 if (!dev->chip_id && b53_switch_detect(dev)) in b53_switch_register()
3184 return -EINVAL; in b53_switch_register()
3190 dev_info(dev->dev, "found switch: %s, rev %i\n", in b53_switch_register()
3191 dev->name, dev->core_rev); in b53_switch_register()
3193 return dsa_register_switch(dev->ds); in b53_switch_register()