Lines Matching +full:gpio +full:- +full:ctrl2
1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/gpio.h>
16 #include <linux/platform_data/microchip-ksz.h>
47 regs = dev->info->regs; in ksz8_ind_write8()
49 mutex_lock(&dev->alu_mutex); in ksz8_ind_write8()
56 mutex_unlock(&dev->alu_mutex); in ksz8_ind_write8()
81 u8 ctrl2 = 0; in ksz8863_change_mtu() local
84 ctrl2 |= KSZ8863_LEGAL_PACKET_ENABLE; in ksz8863_change_mtu()
86 ctrl2 |= KSZ8863_HUGE_PACKET_ENABLE; in ksz8863_change_mtu()
89 KSZ8863_HUGE_PACKET_ENABLE, ctrl2); in ksz8863_change_mtu()
94 u8 ctrl1 = 0, ctrl2 = 0; in ksz8795_change_mtu() local
98 ctrl2 |= SW_LEGAL_PACKET_DISABLE; in ksz8795_change_mtu()
106 return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2); in ksz8795_change_mtu()
113 if (!dsa_is_cpu_port(dev->ds, port)) in ksz8_change_mtu()
118 switch (dev->chip_id) { in ksz8_change_mtu()
127 return -EOPNOTSUPP; in ksz8_change_mtu()
172 masks = dev->info->masks; in ksz8_r_mib_cnt()
173 regs = dev->info->regs; in ksz8_r_mib_cnt()
175 ctrl_addr = addr + dev->info->reg_mib_cnt * port; in ksz8_r_mib_cnt()
178 mutex_lock(&dev->alu_mutex); in ksz8_r_mib_cnt()
184 for (loop = 2; loop > 0; loop--) { in ksz8_r_mib_cnt()
195 mutex_unlock(&dev->alu_mutex); in ksz8_r_mib_cnt()
208 masks = dev->info->masks; in ksz8795_r_mib_pkt()
209 regs = dev->info->regs; in ksz8795_r_mib_pkt()
211 addr -= dev->info->reg_mib_cnt; in ksz8795_r_mib_pkt()
212 ctrl_addr = (KSZ8795_MIB_TOTAL_RX_1 - KSZ8795_MIB_TOTAL_RX_0) * port; in ksz8795_r_mib_pkt()
216 mutex_lock(&dev->alu_mutex); in ksz8795_r_mib_pkt()
222 for (loop = 2; loop > 0; loop--) { in ksz8795_r_mib_pkt()
247 mutex_unlock(&dev->alu_mutex); in ksz8795_r_mib_pkt()
259 regs = dev->info->regs; in ksz8863_r_mib_pkt()
261 addr -= dev->info->reg_mib_cnt; in ksz8863_r_mib_pkt()
267 mutex_lock(&dev->alu_mutex); in ksz8863_r_mib_pkt()
270 mutex_unlock(&dev->alu_mutex); in ksz8863_r_mib_pkt()
278 data -= cur; in ksz8863_r_mib_pkt()
309 struct ksz_port_mib *mib = &dev->ports[port].mib; in ksz8_port_init_cnt()
319 mib->cnt_ptr = 0; in ksz8_port_init_cnt()
322 while (mib->cnt_ptr < dev->info->reg_mib_cnt) { in ksz8_port_init_cnt()
323 dev->dev_ops->r_mib_cnt(dev, port, mib->cnt_ptr, in ksz8_port_init_cnt()
324 &mib->counters[mib->cnt_ptr]); in ksz8_port_init_cnt()
325 ++mib->cnt_ptr; in ksz8_port_init_cnt()
329 dropped = &mib->counters[dev->info->mib_cnt]; in ksz8_port_init_cnt()
332 while (mib->cnt_ptr < dev->info->mib_cnt) { in ksz8_port_init_cnt()
333 dev->dev_ops->r_mib_pkt(dev, port, mib->cnt_ptr, in ksz8_port_init_cnt()
334 dropped, &mib->counters[mib->cnt_ptr]); in ksz8_port_init_cnt()
335 ++mib->cnt_ptr; in ksz8_port_init_cnt()
345 regs = dev->info->regs; in ksz8_r_table()
349 mutex_lock(&dev->alu_mutex); in ksz8_r_table()
356 mutex_unlock(&dev->alu_mutex); in ksz8_r_table()
367 regs = dev->info->regs; in ksz8_w_table()
371 mutex_lock(&dev->alu_mutex); in ksz8_w_table()
378 mutex_unlock(&dev->alu_mutex); in ksz8_w_table()
389 masks = dev->info->masks; in ksz8_valid_dyn_entry()
390 regs = dev->info->regs; in ksz8_valid_dyn_entry()
394 timeout--; in ksz8_valid_dyn_entry()
399 return -EAGAIN; in ksz8_valid_dyn_entry()
406 return -ENXIO; in ksz8_valid_dyn_entry()
422 shifts = dev->info->shifts; in ksz8_r_dyn_mac_table()
423 masks = dev->info->masks; in ksz8_r_dyn_mac_table()
424 regs = dev->info->regs; in ksz8_r_dyn_mac_table()
428 mutex_lock(&dev->alu_mutex); in ksz8_r_dyn_mac_table()
432 if (rc == -EAGAIN) { in ksz8_r_dyn_mac_table()
435 } else if (rc == -ENXIO) { in ksz8_r_dyn_mac_table()
469 mutex_unlock(&dev->alu_mutex); in ksz8_r_dyn_mac_table()
483 shifts = dev->info->shifts; in ksz8_r_sta_mac_table()
484 masks = dev->info->masks; in ksz8_r_sta_mac_table()
499 alu->mac[5] = (u8)data_lo; in ksz8_r_sta_mac_table()
500 alu->mac[4] = (u8)(data_lo >> 8); in ksz8_r_sta_mac_table()
501 alu->mac[3] = (u8)(data_lo >> 16); in ksz8_r_sta_mac_table()
502 alu->mac[2] = (u8)(data_lo >> 24); in ksz8_r_sta_mac_table()
503 alu->mac[1] = (u8)data_hi; in ksz8_r_sta_mac_table()
504 alu->mac[0] = (u8)(data_hi >> 8); in ksz8_r_sta_mac_table()
505 alu->port_forward = in ksz8_r_sta_mac_table()
508 alu->is_override = (data_hi & masks[STATIC_MAC_TABLE_OVERRIDE]) ? 1 : 0; in ksz8_r_sta_mac_table()
516 alu->is_static = true; in ksz8_r_sta_mac_table()
517 alu->is_use_fid = (data_hi & masks[STATIC_MAC_TABLE_USE_FID]) ? 1 : 0; in ksz8_r_sta_mac_table()
518 alu->fid = (data_hi & masks[STATIC_MAC_TABLE_FID]) >> in ksz8_r_sta_mac_table()
534 shifts = dev->info->shifts; in ksz8_w_sta_mac_table()
535 masks = dev->info->masks; in ksz8_w_sta_mac_table()
537 data_lo = ((u32)alu->mac[2] << 24) | in ksz8_w_sta_mac_table()
538 ((u32)alu->mac[3] << 16) | in ksz8_w_sta_mac_table()
539 ((u32)alu->mac[4] << 8) | alu->mac[5]; in ksz8_w_sta_mac_table()
540 data_hi = ((u32)alu->mac[0] << 8) | alu->mac[1]; in ksz8_w_sta_mac_table()
541 data_hi |= (u32)alu->port_forward << shifts[STATIC_MAC_FWD_PORTS]; in ksz8_w_sta_mac_table()
543 if (alu->is_override) in ksz8_w_sta_mac_table()
545 if (alu->is_use_fid) { in ksz8_w_sta_mac_table()
547 data_hi |= (u32)alu->fid << shifts[STATIC_MAC_FID]; in ksz8_w_sta_mac_table()
549 if (alu->is_static) in ksz8_w_sta_mac_table()
565 shifts = dev->info->shifts; in ksz8_from_vlan()
566 masks = dev->info->masks; in ksz8_from_vlan()
580 shifts = dev->info->shifts; in ksz8_to_vlan()
581 masks = dev->info->masks; in ksz8_to_vlan()
595 shifts = dev->info->shifts; in ksz8_r_vlan_entries()
600 dev->vlan_cache[addr + i].table[0] = (u16)data; in ksz8_r_vlan_entries()
631 dev->vlan_cache[vid].table[0] = vlan; in ksz8_w_vlan_table()
645 regs = dev->info->regs; in ksz8_r_phy()
796 regs = dev->info->regs; in ksz8_w_phy()
836 /* Fiber port does not support auto-negotiation. */ in ksz8_w_phy()
837 if (dev->ports[p].fiber) in ksz8_w_phy()
942 data |= (member & dev->port_mask); in ksz8_cfg_port_member()
952 regs = dev->info->regs; in ksz8_flush_dyn_mac_table()
954 if ((uint)port < dev->info->port_cnt) { in ksz8_flush_dyn_mac_table()
960 cnt = dev->info->port_cnt; in ksz8_flush_dyn_mac_table()
1010 for (index = 0; index < dev->info->num_statics; index++) { in ksz8_add_sta_mac()
1028 if (index == dev->info->num_statics && !empty) in ksz8_add_sta_mac()
1029 return -ENOSPC; in ksz8_add_sta_mac()
1032 if (index == dev->info->num_statics) { in ksz8_add_sta_mac()
1033 index = empty - 1; in ksz8_add_sta_mac()
1055 for (index = 0; index < dev->info->num_statics; index++) { in ksz8_del_sta_mac()
1069 if (index == dev->info->num_statics) in ksz8_del_sta_mac()
1083 return ksz8_add_sta_mac(dev, port, mdb->addr, mdb->vid); in ksz8_mdb_add()
1089 return ksz8_del_sta_mac(dev, port, mdb->addr, mdb->vid); in ksz8_mdb_del()
1108 return -ENOTSUPP; in ksz8_port_vlan_filtering()
1114 for (port = 0; port < dev->phy_port_cnt; ++port) in ksz8_port_vlan_filtering()
1125 0x03 << (4 - 2 * port), state); in ksz8_port_enable_pvid()
1135 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; in ksz8_port_vlan_add()
1136 struct ksz_port *p = &dev->ports[port]; in ksz8_port_vlan_add()
1141 return -ENOTSUPP; in ksz8_port_vlan_add()
1148 if (untagged != p->remove_tag && vlan->vid != 0 && in ksz8_port_vlan_add()
1149 port != dev->cpu_port) { in ksz8_port_vlan_add()
1156 for (vid = 1; vid < dev->info->num_vlans; ++vid) { in ksz8_port_vlan_add()
1158 if (vid == vlan->vid) in ksz8_port_vlan_add()
1161 ksz8_from_vlan(dev, dev->vlan_cache[vid].table[0], in ksz8_port_vlan_add()
1164 return -EINVAL; in ksz8_port_vlan_add()
1168 p->remove_tag = untagged; in ksz8_port_vlan_add()
1171 ksz8_r_vlan_table(dev, vlan->vid, &data); in ksz8_port_vlan_add()
1183 ksz8_w_vlan_table(dev, vlan->vid, data); in ksz8_port_vlan_add()
1186 if (vlan->flags & BRIDGE_VLAN_INFO_PVID) in ksz8_port_vlan_add()
1187 new_pvid = vlan->vid; in ksz8_port_vlan_add()
1210 return -ENOTSUPP; in ksz8_port_vlan_del()
1215 ksz8_r_vlan_table(dev, vlan->vid, &data); in ksz8_port_vlan_del()
1227 ksz8_w_vlan_table(dev, vlan->vid, data); in ksz8_port_vlan_del()
1229 if (pvid == vlan->vid) in ksz8_port_vlan_del()
1241 dev->mirror_rx |= BIT(port); in ksz8_port_mirror_add()
1244 dev->mirror_tx |= BIT(port); in ksz8_port_mirror_add()
1250 if (dev->mirror_rx || dev->mirror_tx) in ksz8_port_mirror_add()
1251 ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL, in ksz8_port_mirror_add()
1262 if (mirror->ingress) { in ksz8_port_mirror_del()
1264 dev->mirror_rx &= ~BIT(port); in ksz8_port_mirror_del()
1267 dev->mirror_tx &= ~BIT(port); in ksz8_port_mirror_del()
1272 if (!dev->mirror_rx && !dev->mirror_tx) in ksz8_port_mirror_del()
1273 ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL, in ksz8_port_mirror_del()
1279 struct ksz_port *p = &dev->ports[port]; in ksz8795_cpu_interface_select()
1281 if (!p->interface && dev->compat_interface) { in ksz8795_cpu_interface_select()
1282 dev_warn(dev->dev, in ksz8795_cpu_interface_select()
1283 "Using legacy switch \"phy-mode\" property, because it is missing on port %d node. " in ksz8795_cpu_interface_select()
1286 p->interface = dev->compat_interface; in ksz8795_cpu_interface_select()
1292 struct dsa_switch *ds = dev->ds; in ksz8_port_setup()
1296 masks = dev->info->masks; in ksz8_port_setup()
1328 struct ksz_device *dev = ds->priv; in ksz8_config_cpu_port()
1335 masks = dev->info->masks; in ksz8_config_cpu_port()
1336 regs = dev->info->regs; in ksz8_config_cpu_port()
1340 ksz8_port_setup(dev, dev->cpu_port, true); in ksz8_config_cpu_port()
1342 for (i = 0; i < dev->phy_port_cnt; i++) { in ksz8_config_cpu_port()
1345 for (i = 0; i < dev->phy_port_cnt; i++) { in ksz8_config_cpu_port()
1346 p = &dev->ports[i]; in ksz8_config_cpu_port()
1351 p->fiber = 1; in ksz8_config_cpu_port()
1353 if (p->fiber) in ksz8_config_cpu_port()
1364 struct ksz_device *dev = ds->priv; in ksz8_handle_global_errata()
1373 if (dev->info->ksz87xx_eee_link_erratum) in ksz8_handle_global_errata()
1388 alu.port_forward = dev->info->cpu_ports; in ksz8_enable_stp_addr()
1395 struct ksz_device *dev = ds->priv; in ksz8_setup()
1398 ds->mtu_enforcement_ingress = true; in ksz8_setup()
1403 ds->untag_bridge_pvid = true; in ksz8_setup()
1408 ds->vlan_filtering_is_global = true; in ksz8_setup()
1434 for (i = 0; i < (dev->info->num_vlans / 4); i++) in ksz8_setup()
1443 config->mac_capabilities = MAC_10 | MAC_100; in ksz8_get_caps()
1451 config->mac_capabilities |= MAC_SYM_PAUSE; in ksz8_get_caps()
1455 config->mac_capabilities |= MAC_ASYM_PAUSE; in ksz8_get_caps()
1465 dev->cpu_port = fls(dev->info->cpu_ports) - 1; in ksz8_switch_init()
1466 dev->phy_port_cnt = dev->info->port_cnt - 1; in ksz8_switch_init()
1467 dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info->cpu_ports; in ksz8_switch_init()