Lines Matching +full:bcm7445 +full:- +full:gpio

4  * Copyright (C) 2011-2013 Jonas Gorski <jogo@openwrt.org>
22 #include <linux/gpio.h>
231 b53_write8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], VTA_START_CMD | op); in b53_do_vlan_op()
236 b53_read8(dev, B53_ARLIO_PAGE, dev->vta_regs[0], &vta); in b53_do_vlan_op()
243 return -EIO; in b53_do_vlan_op()
252 if (vlan->members) { in b53_set_vlan_entry()
253 entry = ((vlan->untag & VA_UNTAG_MASK_25) << in b53_set_vlan_entry()
254 VA_UNTAG_S_25) | vlan->members; in b53_set_vlan_entry()
255 if (dev->core_rev >= 3) in b53_set_vlan_entry()
267 if (vlan->members) in b53_set_vlan_entry()
268 entry = ((vlan->untag & VA_UNTAG_MASK_65) << in b53_set_vlan_entry()
269 VA_UNTAG_S_65) | vlan->members | VA_VALID_65; in b53_set_vlan_entry()
275 b53_write16(dev, B53_ARLIO_PAGE, dev->vta_regs[1], vid); in b53_set_vlan_entry()
276 b53_write32(dev, B53_ARLIO_PAGE, dev->vta_regs[2], in b53_set_vlan_entry()
277 (vlan->untag << VTE_UNTAG_S) | vlan->members); in b53_set_vlan_entry()
282 dev_dbg(dev->ds->dev, "VID: %d, members: 0x%04x, untag: 0x%04x\n", in b53_set_vlan_entry()
283 vid, vlan->members, vlan->untag); in b53_set_vlan_entry()
296 if (dev->core_rev >= 3) in b53_get_vlan_entry()
297 vlan->valid = !!(entry & VA_VALID_25_R4); in b53_get_vlan_entry()
299 vlan->valid = !!(entry & VA_VALID_25); in b53_get_vlan_entry()
300 vlan->members = entry & VA_MEMBER_MASK; in b53_get_vlan_entry()
301 vlan->untag = (entry >> VA_UNTAG_S_25) & VA_UNTAG_MASK_25; in b53_get_vlan_entry()
310 vlan->valid = !!(entry & VA_VALID_65); in b53_get_vlan_entry()
311 vlan->members = entry & VA_MEMBER_MASK; in b53_get_vlan_entry()
312 vlan->untag = (entry >> VA_UNTAG_S_65) & VA_UNTAG_MASK_65; in b53_get_vlan_entry()
316 b53_write16(dev, B53_ARLIO_PAGE, dev->vta_regs[1], vid); in b53_get_vlan_entry()
318 b53_read32(dev, B53_ARLIO_PAGE, dev->vta_regs[2], &entry); in b53_get_vlan_entry()
319 vlan->members = entry & VTE_MEMBERS; in b53_get_vlan_entry()
320 vlan->untag = (entry >> VTE_UNTAG_S) & VTE_MEMBERS; in b53_get_vlan_entry()
321 vlan->valid = true; in b53_get_vlan_entry()
433 dev->vlan_enabled = enable; in b53_enable_vlan()
435 dev_dbg(dev->dev, "Port %d VLAN enabled: %d, filtering: %d\n", in b53_enable_vlan()
445 return -EINVAL; in b53_set_jumbo()
448 port_mask = dev->enabled_ports; in b53_set_jumbo()
454 b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask); in b53_set_jumbo()
455 return b53_write16(dev, B53_JUMBO_PAGE, dev->jumbo_size_reg, max_size); in b53_set_jumbo()
477 return -ETIMEDOUT; in b53_flush_arl()
500 struct b53_device *dev = ds->priv; in b53_imp_vlan_setup()
505 * on a per-port basis such that we only have Port i and IMP in in b53_imp_vlan_setup()
564 struct b53_device *dev = ds->priv; in b53_enable_port()
572 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_enable_port()
578 if (dev->ops->irq_enable) in b53_enable_port()
579 ret = dev->ops->irq_enable(dev, port); in b53_enable_port()
593 pvlan |= dev->ports[port].vlan_ctl_mask; in b53_enable_port()
599 if (dev->ports[port].eee.eee_enabled) in b53_enable_port()
608 struct b53_device *dev = ds->priv; in b53_disable_port()
616 if (dev->ops->irq_disable) in b53_disable_port()
617 dev->ops->irq_disable(dev, port); in b53_disable_port()
623 struct b53_device *dev = ds->priv; in b53_brcm_hdr_setup()
624 bool tag_en = !(dev->tag_protocol == DSA_TAG_PROTO_NONE); in b53_brcm_hdr_setup()
683 * allow delivering frames to the per-port net_devices in b53_brcm_hdr_setup()
707 b53_brcm_hdr_setup(dev->ds, port); in b53_enable_cpu_port()
733 struct b53_device *dev = ds->priv; in b53_vlan_port_needs_forced_tagged()
735 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); in b53_vlan_port_needs_forced_tagged()
740 struct b53_device *dev = ds->priv; in b53_configure_vlan()
750 for (i = def_vid; i < dev->num_vlans; i++) in b53_configure_vlan()
756 b53_enable_vlan(dev, -1, dev->vlan_enabled, ds->vlan_filtering); in b53_configure_vlan()
765 v = &dev->vlans[def_vid]; in b53_configure_vlan()
766 v->members |= BIT(i); in b53_configure_vlan()
768 v->untag = v->members; in b53_configure_vlan()
773 /* Upon initial call we have not set-up any VLANs, but upon in b53_configure_vlan()
776 for (vid = def_vid; vid < dev->num_vlans; vid++) { in b53_configure_vlan()
777 v = &dev->vlans[vid]; in b53_configure_vlan()
779 if (!v->members) in b53_configure_vlan()
792 int gpio = dev->reset_gpio; in b53_switch_reset_gpio() local
794 if (gpio < 0) in b53_switch_reset_gpio()
797 /* Reset sequence: RESET low(50ms)->high(20ms) in b53_switch_reset_gpio()
799 gpio_set_value(gpio, 0); in b53_switch_reset_gpio()
802 gpio_set_value(gpio, 1); in b53_switch_reset_gpio()
805 dev->current_page = 0xff; in b53_switch_reset_gpio()
825 if (dev->chip_id == BCM58XX_DEVICE_ID || in b53_switch_reset()
826 dev->chip_id == BCM583XX_DEVICE_ID) { in b53_switch_reset()
837 } while (timeout-- > 0); in b53_switch_reset()
840 dev_err(dev->dev, in b53_switch_reset()
842 return -ETIMEDOUT; in b53_switch_reset()
856 dev_err(dev->dev, "Failed to enable switch!\n"); in b53_switch_reset()
857 return -EINVAL; in b53_switch_reset()
868 struct b53_device *priv = ds->priv; in b53_phy_read16()
872 if (priv->ops->phy_read16) in b53_phy_read16()
873 ret = priv->ops->phy_read16(priv, addr, reg, &value); in b53_phy_read16()
883 struct b53_device *priv = ds->priv; in b53_phy_write16()
885 if (priv->ops->phy_write16) in b53_phy_write16()
886 return priv->ops->phy_write16(priv, addr, reg, val); in b53_phy_write16()
894 memset(priv->vlans, 0, sizeof(*priv->vlans) * priv->num_vlans); in b53_reset_switch()
895 memset(priv->ports, 0, sizeof(*priv->ports) * priv->num_ports); in b53_reset_switch()
897 priv->serdes_lane = B53_INVALID_LANE; in b53_reset_switch()
907 b53_configure_vlan(priv->ds); in b53_apply_config()
953 /* These ports typically do not have built-in PHYs */ in b53_get_phy_device()
961 return mdiobus_get_phy(ds->slave_mii_bus, port); in b53_get_phy_device()
967 struct b53_device *dev = ds->priv; in b53_get_strings()
989 struct b53_device *dev = ds->priv; in b53_get_ethtool_stats()
999 mutex_lock(&dev->stats_mutex); in b53_get_ethtool_stats()
1004 if (s->size == 8) { in b53_get_ethtool_stats()
1005 b53_read64(dev, B53_MIB_PAGE(port), s->offset, &val); in b53_get_ethtool_stats()
1009 b53_read32(dev, B53_MIB_PAGE(port), s->offset, in b53_get_ethtool_stats()
1016 mutex_unlock(&dev->stats_mutex); in b53_get_ethtool_stats()
1034 struct b53_device *dev = ds->priv; in b53_get_sset_count()
1062 for (i = 0; i < dev->num_vlans; i++) { in b53_devlink_vlan_table_get()
1063 vl = &dev->vlans[i]; in b53_devlink_vlan_table_get()
1064 if (vl->members) in b53_devlink_vlan_table_get()
1074 struct b53_device *dev = ds->priv; in b53_setup_devlink_resources()
1077 devlink_resource_size_params_init(&size_params, dev->num_vlans, in b53_setup_devlink_resources()
1078 dev->num_vlans, in b53_setup_devlink_resources()
1081 err = dsa_devlink_resource_register(ds, "VLAN", dev->num_vlans, in b53_setup_devlink_resources()
1101 struct b53_device *dev = ds->priv; in b53_setup()
1108 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; in b53_setup()
1112 dev_err(ds->dev, "failed to reset switch\n"); in b53_setup()
1120 dev_err(ds->dev, "failed to apply configuration\n"); in b53_setup()
1127 for (port = 0; port < dev->num_ports; port++) { in b53_setup()
1147 if (port == dev->imp_port) { in b53_force_link()
1171 if (port == dev->imp_port) { in b53_force_port_config()
1200 dev_err(dev->dev, "unknown speed: %d\n", speed); in b53_force_port_config()
1215 struct b53_device *dev = ds->priv; in b53_adjust_link()
1216 struct ethtool_eee *p = &dev->ports[port].eee; in b53_adjust_link()
1228 if (phydev->pause) { in b53_adjust_link()
1229 if (phydev->asym_pause) in b53_adjust_link()
1234 b53_force_port_config(dev, port, phydev->speed, phydev->duplex, in b53_adjust_link()
1236 b53_force_link(dev, port, phydev->link); in b53_adjust_link()
1239 if (port == dev->imp_port) in b53_adjust_link()
1265 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) in b53_adjust_link()
1267 if (phydev->interface == PHY_INTERFACE_MODE_RGMII) in b53_adjust_link()
1272 dev_info(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_link()
1273 phy_modes(phydev->interface)); in b53_adjust_link()
1289 dev_err(ds->dev, in b53_adjust_link()
1296 /* Re-negotiate EEE if it was enabled already */ in b53_adjust_link()
1297 p->eee_enabled = b53_eee_init(ds, port, phydev); in b53_adjust_link()
1302 struct b53_device *dev = ds->priv; in b53_port_event()
1315 struct b53_device *dev = ds->priv; in b53_phylink_get_caps()
1318 __set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces); in b53_phylink_get_caps()
1331 __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); in b53_phylink_get_caps()
1332 __set_bit(PHY_INTERFACE_MODE_REVMII, config->supported_interfaces); in b53_phylink_get_caps()
1334 config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in b53_phylink_get_caps()
1344 config->mac_capabilities |= MAC_1000; in b53_phylink_get_caps()
1347 if (dev->ops->phylink_get_caps) in b53_phylink_get_caps()
1348 dev->ops->phylink_get_caps(dev, port, config); in b53_phylink_get_caps()
1352 * as non-legacy. in b53_phylink_get_caps()
1354 config->legacy_pre_march2020 = false; in b53_phylink_get_caps()
1361 struct b53_device *dev = ds->priv; in b53_phylink_mac_select_pcs()
1363 if (!dev->ops->phylink_mac_select_pcs) in b53_phylink_mac_select_pcs()
1366 return dev->ops->phylink_mac_select_pcs(dev, port, interface); in b53_phylink_mac_select_pcs()
1380 struct b53_device *dev = ds->priv; in b53_phylink_mac_link_down()
1391 dev->ops->serdes_link_set) in b53_phylink_mac_link_down()
1392 dev->ops->serdes_link_set(dev, port, mode, interface, false); in b53_phylink_mac_link_down()
1403 struct b53_device *dev = ds->priv; in b53_phylink_mac_link_up()
1416 dev->ops->serdes_link_set) in b53_phylink_mac_link_up()
1417 dev->ops->serdes_link_set(dev, port, mode, interface, true); in b53_phylink_mac_link_up()
1424 struct b53_device *dev = ds->priv; in b53_vlan_filtering()
1426 b53_enable_vlan(dev, port, dev->vlan_enabled, vlan_filtering); in b53_vlan_filtering()
1435 struct b53_device *dev = ds->priv; in b53_vlan_prepare()
1437 if ((is5325(dev) || is5365(dev)) && vlan->vid == 0) in b53_vlan_prepare()
1438 return -EOPNOTSUPP; in b53_vlan_prepare()
1444 if (dev->chip_id == BCM7278_DEVICE_ID && port == 7 && in b53_vlan_prepare()
1445 !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED)) in b53_vlan_prepare()
1446 return -EINVAL; in b53_vlan_prepare()
1448 if (vlan->vid >= dev->num_vlans) in b53_vlan_prepare()
1449 return -ERANGE; in b53_vlan_prepare()
1451 b53_enable_vlan(dev, port, true, ds->vlan_filtering); in b53_vlan_prepare()
1460 struct b53_device *dev = ds->priv; in b53_vlan_add()
1461 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in b53_vlan_add()
1462 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; in b53_vlan_add()
1470 vl = &dev->vlans[vlan->vid]; in b53_vlan_add()
1472 b53_get_vlan_entry(dev, vlan->vid, vl); in b53_vlan_add()
1474 if (vlan->vid == 0 && vlan->vid == b53_default_pvid(dev)) in b53_vlan_add()
1477 vl->members |= BIT(port); in b53_vlan_add()
1479 vl->untag |= BIT(port); in b53_vlan_add()
1481 vl->untag &= ~BIT(port); in b53_vlan_add()
1483 b53_set_vlan_entry(dev, vlan->vid, vl); in b53_vlan_add()
1484 b53_fast_age_vlan(dev, vlan->vid); in b53_vlan_add()
1488 vlan->vid); in b53_vlan_add()
1489 b53_fast_age_vlan(dev, vlan->vid); in b53_vlan_add()
1499 struct b53_device *dev = ds->priv; in b53_vlan_del()
1500 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in b53_vlan_del()
1506 vl = &dev->vlans[vlan->vid]; in b53_vlan_del()
1508 b53_get_vlan_entry(dev, vlan->vid, vl); in b53_vlan_del()
1510 vl->members &= ~BIT(port); in b53_vlan_del()
1512 if (pvid == vlan->vid) in b53_vlan_del()
1516 vl->untag &= ~(BIT(port)); in b53_vlan_del()
1518 b53_set_vlan_entry(dev, vlan->vid, vl); in b53_vlan_del()
1519 b53_fast_age_vlan(dev, vlan->vid); in b53_vlan_del()
1528 /* Address Resolution Logic routines. Caller must hold &dev->arl_mutex. */
1540 } while (timeout--); in b53_arl_op_wait()
1542 dev_warn(dev->dev, "timeout waiting for ARL to finish: 0x%02x\n", reg); in b53_arl_op_wait()
1544 return -ETIMEDOUT; in b53_arl_op_wait()
1552 return -EINVAL; in b53_arl_rw_op()
1560 if (dev->vlan_enabled) in b53_arl_rw_op()
1580 bitmap_zero(free_bins, dev->num_arl_bins); in b53_arl_read()
1583 for (i = 0; i < dev->num_arl_bins; i++) { in b53_arl_read()
1599 if (dev->vlan_enabled && in b53_arl_read()
1606 *idx = find_first_bit(free_bins, dev->num_arl_bins); in b53_arl_read()
1607 return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; in b53_arl_read()
1619 /* Convert the array into a 64-bit MAC */ in b53_arl_op()
1638 case -ETIMEDOUT: in b53_arl_op()
1640 case -ENOSPC: in b53_arl_op()
1641 dev_dbg(dev->dev, "{%pM,%.4d} no space left in ARL\n", in b53_arl_op()
1644 case -ENOENT: in b53_arl_op()
1646 dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n", in b53_arl_op()
1651 dev_dbg(dev->dev, "{%pM,%.4d} found, using idx: %d\n", in b53_arl_op()
1689 struct b53_device *priv = ds->priv; in b53_fdb_add()
1696 return -EOPNOTSUPP; in b53_fdb_add()
1698 mutex_lock(&priv->arl_mutex); in b53_fdb_add()
1700 mutex_unlock(&priv->arl_mutex); in b53_fdb_add()
1710 struct b53_device *priv = ds->priv; in b53_fdb_del()
1713 mutex_lock(&priv->arl_mutex); in b53_fdb_del()
1715 mutex_unlock(&priv->arl_mutex); in b53_fdb_del()
1735 } while (timeout--); in b53_arl_search_wait()
1737 return -ETIMEDOUT; in b53_arl_search_wait()
1756 if (!ent->is_valid) in b53_fdb_copy()
1759 if (port != ent->port) in b53_fdb_copy()
1762 return cb(ent->mac, ent->vid, ent->is_static, data); in b53_fdb_copy()
1768 struct b53_device *priv = ds->priv; in b53_fdb_dump()
1774 mutex_lock(&priv->arl_mutex); in b53_fdb_dump()
1790 if (priv->num_arl_bins > 2) { in b53_fdb_dump()
1802 mutex_unlock(&priv->arl_mutex); in b53_fdb_dump()
1812 struct b53_device *priv = ds->priv; in b53_mdb_add()
1819 return -EOPNOTSUPP; in b53_mdb_add()
1821 mutex_lock(&priv->arl_mutex); in b53_mdb_add()
1822 ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true); in b53_mdb_add()
1823 mutex_unlock(&priv->arl_mutex); in b53_mdb_add()
1833 struct b53_device *priv = ds->priv; in b53_mdb_del()
1836 mutex_lock(&priv->arl_mutex); in b53_mdb_del()
1837 ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, false); in b53_mdb_del()
1838 mutex_unlock(&priv->arl_mutex); in b53_mdb_del()
1840 dev_err(ds->dev, "failed to delete MDB entry\n"); in b53_mdb_del()
1849 struct b53_device *dev = ds->priv; in b53_br_join()
1850 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_join()
1857 if (dev->chip_id == BCM7278_DEVICE_ID && port == 7) in b53_br_join()
1858 return -EINVAL; in b53_br_join()
1883 dev->ports[i].vlan_ctl_mask = reg; in b53_br_join()
1892 dev->ports[port].vlan_ctl_mask = pvlan; in b53_br_join()
1900 struct b53_device *dev = ds->priv; in b53_br_leave()
1901 struct b53_vlan *vl = &dev->vlans[0]; in b53_br_leave()
1902 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_leave()
1916 dev->ports[port].vlan_ctl_mask = reg; in b53_br_leave()
1924 dev->ports[port].vlan_ctl_mask = pvlan; in b53_br_leave()
1937 vl->members |= BIT(port) | BIT(cpu_port); in b53_br_leave()
1938 vl->untag |= BIT(port) | BIT(cpu_port); in b53_br_leave()
1946 struct b53_device *dev = ds->priv; in b53_br_set_stp_state()
1967 dev_err(ds->dev, "invalid STP state: %d\n", state); in b53_br_set_stp_state()
1980 struct b53_device *dev = ds->priv; in b53_br_fast_age()
1983 dev_err(ds->dev, "fast ageing failed\n"); in b53_br_fast_age()
1992 return -EINVAL; in b53_br_flags_pre()
2003 b53_port_set_ucast_flood(ds->priv, port, in b53_br_flags()
2006 b53_port_set_mcast_flood(ds->priv, port, in b53_br_flags()
2009 b53_port_set_learning(ds->priv, port, in b53_br_flags()
2037 dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", in b53_can_enable_brcm_tags()
2045 dev_warn(ds->dev, in b53_can_enable_brcm_tags()
2060 struct b53_device *dev = ds->priv; in b53_get_tag_protocol()
2063 dev->tag_protocol = DSA_TAG_PROTO_NONE; in b53_get_tag_protocol()
2069 dev->tag_protocol = DSA_TAG_PROTO_BRCM_LEGACY; in b53_get_tag_protocol()
2076 if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT) { in b53_get_tag_protocol()
2077 dev->tag_protocol = DSA_TAG_PROTO_BRCM_PREPEND; in b53_get_tag_protocol()
2081 dev->tag_protocol = DSA_TAG_PROTO_BRCM; in b53_get_tag_protocol()
2083 return dev->tag_protocol; in b53_get_tag_protocol()
2091 struct b53_device *dev = ds->priv; in b53_mirror_add()
2105 reg |= mirror->to_local_port; in b53_mirror_add()
2116 struct b53_device *dev = ds->priv; in b53_mirror_del()
2120 if (mirror->ingress) in b53_mirror_del()
2135 if (mirror->ingress) in b53_mirror_del()
2146 reg &= ~mirror->to_local_port; in b53_mirror_del()
2154 struct b53_device *dev = ds->priv; in b53_eee_enable_set()
2185 struct b53_device *dev = ds->priv; in b53_get_mac_eee()
2186 struct ethtool_eee *p = &dev->ports[port].eee; in b53_get_mac_eee()
2190 return -EOPNOTSUPP; in b53_get_mac_eee()
2193 e->eee_enabled = p->eee_enabled; in b53_get_mac_eee()
2194 e->eee_active = !!(reg & BIT(port)); in b53_get_mac_eee()
2202 struct b53_device *dev = ds->priv; in b53_set_mac_eee()
2203 struct ethtool_eee *p = &dev->ports[port].eee; in b53_set_mac_eee()
2206 return -EOPNOTSUPP; in b53_set_mac_eee()
2208 p->eee_enabled = e->eee_enabled; in b53_set_mac_eee()
2209 b53_eee_enable_set(ds, port, e->eee_enabled); in b53_set_mac_eee()
2217 struct b53_device *dev = ds->priv; in b53_change_mtu()
2222 return -EOPNOTSUPP; in b53_change_mtu()
2225 allow_10_100 = (dev->chip_id == BCM583XX_DEVICE_ID); in b53_change_mtu()
2529 .dev_name = "BCM7445",
2563 if (chip->chip_id == dev->chip_id) { in b53_switch_init()
2564 if (!dev->enabled_ports) in b53_switch_init()
2565 dev->enabled_ports = chip->enabled_ports; in b53_switch_init()
2566 dev->name = chip->dev_name; in b53_switch_init()
2567 dev->duplex_reg = chip->duplex_reg; in b53_switch_init()
2568 dev->vta_regs[0] = chip->vta_regs[0]; in b53_switch_init()
2569 dev->vta_regs[1] = chip->vta_regs[1]; in b53_switch_init()
2570 dev->vta_regs[2] = chip->vta_regs[2]; in b53_switch_init()
2571 dev->jumbo_pm_reg = chip->jumbo_pm_reg; in b53_switch_init()
2572 dev->imp_port = chip->imp_port; in b53_switch_init()
2573 dev->num_vlans = chip->vlans; in b53_switch_init()
2574 dev->num_arl_bins = chip->arl_bins; in b53_switch_init()
2575 dev->num_arl_buckets = chip->arl_buckets; in b53_switch_init()
2592 /* BCM5325F - do not use port 4 */ in b53_switch_init()
2593 dev->enabled_ports &= ~BIT(4); in b53_switch_init()
2599 return -EINVAL; in b53_switch_init()
2606 dev->num_ports = fls(dev->enabled_ports); in b53_switch_init()
2608 dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); in b53_switch_init()
2610 /* Include non standard CPU port built-in PHYs to be probed */ in b53_switch_init()
2612 for (i = 0; i < dev->num_ports; i++) { in b53_switch_init()
2613 if (!(dev->ds->phys_mii_mask & BIT(i)) && in b53_switch_init()
2614 !b53_possible_cpu_port(dev->ds, i)) in b53_switch_init()
2615 dev->ds->phys_mii_mask |= BIT(i); in b53_switch_init()
2619 dev->ports = devm_kcalloc(dev->dev, in b53_switch_init()
2620 dev->num_ports, sizeof(struct b53_port), in b53_switch_init()
2622 if (!dev->ports) in b53_switch_init()
2623 return -ENOMEM; in b53_switch_init()
2625 dev->vlans = devm_kcalloc(dev->dev, in b53_switch_init()
2626 dev->num_vlans, sizeof(struct b53_vlan), in b53_switch_init()
2628 if (!dev->vlans) in b53_switch_init()
2629 return -ENOMEM; in b53_switch_init()
2631 dev->reset_gpio = b53_switch_get_reset_gpio(dev); in b53_switch_init()
2632 if (dev->reset_gpio >= 0) { in b53_switch_init()
2633 ret = devm_gpio_request_one(dev->dev, dev->reset_gpio, in b53_switch_init()
2653 ds->dev = base; in b53_switch_alloc()
2659 ds->priv = dev; in b53_switch_alloc()
2660 dev->dev = base; in b53_switch_alloc()
2662 dev->ds = ds; in b53_switch_alloc()
2663 dev->priv = priv; in b53_switch_alloc()
2664 dev->ops = ops; in b53_switch_alloc()
2665 ds->ops = &b53_switch_ops; in b53_switch_alloc()
2666 dev->vlan_enabled = true; in b53_switch_alloc()
2672 ds->vlan_filtering_is_global = true; in b53_switch_alloc()
2674 mutex_init(&dev->reg_mutex); in b53_switch_alloc()
2675 mutex_init(&dev->stats_mutex); in b53_switch_alloc()
2676 mutex_init(&dev->arl_mutex); in b53_switch_alloc()
2706 dev->chip_id = BCM5325_DEVICE_ID; in b53_switch_detect()
2708 dev->chip_id = BCM5365_DEVICE_ID; in b53_switch_detect()
2714 dev->chip_id = id8; in b53_switch_detect()
2730 dev->chip_id = id32; in b53_switch_detect()
2733 dev_err(dev->dev, in b53_switch_detect()
2736 return -ENODEV; in b53_switch_detect()
2740 if (dev->chip_id == BCM5325_DEVICE_ID) in b53_switch_detect()
2742 &dev->core_rev); in b53_switch_detect()
2745 &dev->core_rev); in b53_switch_detect()
2753 if (dev->pdata) { in b53_switch_register()
2754 dev->chip_id = dev->pdata->chip_id; in b53_switch_register()
2755 dev->enabled_ports = dev->pdata->enabled_ports; in b53_switch_register()
2758 if (!dev->chip_id && b53_switch_detect(dev)) in b53_switch_register()
2759 return -EINVAL; in b53_switch_register()
2765 dev_info(dev->dev, "found switch: %s, rev %i\n", in b53_switch_register()
2766 dev->name, dev->core_rev); in b53_switch_register()
2768 return dsa_register_switch(dev->ds); in b53_switch_register()