Lines Matching full:adapter
30 static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter) in pci11x1x_strap_get_status() argument
39 ret = lan743x_hs_syslock_acquire(adapter, 100); in pci11x1x_strap_get_status()
41 netif_err(adapter, drv, adapter->netdev, in pci11x1x_strap_get_status()
46 cfg_load = lan743x_csr_read(adapter, ETH_SYS_CONFIG_LOAD_STARTED_REG); in pci11x1x_strap_get_status()
47 lan743x_hs_syslock_release(adapter); in pci11x1x_strap_get_status()
48 hw_cfg = lan743x_csr_read(adapter, HW_CFG); in pci11x1x_strap_get_status()
52 strap = lan743x_csr_read(adapter, STRAP_READ); in pci11x1x_strap_get_status()
54 adapter->is_sgmii_en = true; in pci11x1x_strap_get_status()
56 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
58 chip_rev = lan743x_csr_read(adapter, FPGA_REV); in pci11x1x_strap_get_status()
61 adapter->is_sgmii_en = true; in pci11x1x_strap_get_status()
63 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
65 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
68 netif_dbg(adapter, drv, adapter->netdev, in pci11x1x_strap_get_status()
69 "SGMII I/F %sable\n", adapter->is_sgmii_en ? "En" : "Dis"); in pci11x1x_strap_get_status()
72 static bool is_pci11x1x_chip(struct lan743x_adapter *adapter) in is_pci11x1x_chip() argument
74 struct lan743x_csr *csr = &adapter->csr; in is_pci11x1x_chip()
84 static void lan743x_pci_cleanup(struct lan743x_adapter *adapter) in lan743x_pci_cleanup() argument
86 pci_release_selected_regions(adapter->pdev, in lan743x_pci_cleanup()
87 pci_select_bars(adapter->pdev, in lan743x_pci_cleanup()
89 pci_disable_device(adapter->pdev); in lan743x_pci_cleanup()
92 static int lan743x_pci_init(struct lan743x_adapter *adapter, in lan743x_pci_init() argument
98 adapter->pdev = pdev; in lan743x_pci_init()
103 netif_info(adapter, probe, adapter->netdev, in lan743x_pci_init()
118 pci_disable_device(adapter->pdev); in lan743x_pci_init()
124 u32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset) in lan743x_csr_read() argument
126 return ioread32(&adapter->csr.csr_address[offset]); in lan743x_csr_read()
129 void lan743x_csr_write(struct lan743x_adapter *adapter, int offset, in lan743x_csr_write() argument
132 iowrite32(data, &adapter->csr.csr_address[offset]); in lan743x_csr_write()
135 #define LAN743X_CSR_READ_OP(offset) lan743x_csr_read(adapter, offset)
137 static int lan743x_csr_light_reset(struct lan743x_adapter *adapter) in lan743x_csr_light_reset() argument
141 data = lan743x_csr_read(adapter, HW_CFG); in lan743x_csr_light_reset()
143 lan743x_csr_write(adapter, HW_CFG, data); in lan743x_csr_light_reset()
149 static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter, in lan743x_csr_wait_for_bit_atomic() argument
161 static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter, in lan743x_csr_wait_for_bit() argument
173 static int lan743x_csr_init(struct lan743x_adapter *adapter) in lan743x_csr_init() argument
175 struct lan743x_csr *csr = &adapter->csr; in lan743x_csr_init()
178 bar_start = pci_resource_start(adapter->pdev, 0); in lan743x_csr_init()
179 bar_length = pci_resource_len(adapter->pdev, 0); in lan743x_csr_init()
180 csr->csr_address = devm_ioremap(&adapter->pdev->dev, in lan743x_csr_init()
185 csr->id_rev = lan743x_csr_read(adapter, ID_REV); in lan743x_csr_init()
186 csr->fpga_rev = lan743x_csr_read(adapter, FPGA_REV); in lan743x_csr_init()
187 netif_info(adapter, probe, adapter->netdev, in lan743x_csr_init()
205 return lan743x_csr_light_reset(adapter); in lan743x_csr_init()
208 static void lan743x_intr_software_isr(struct lan743x_adapter *adapter) in lan743x_intr_software_isr() argument
210 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_software_isr()
213 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_SW_GP_); in lan743x_intr_software_isr()
221 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_isr() local
224 lan743x_csr_read(adapter, INT_EN_SET); in lan743x_tx_isr()
226 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_tx_isr()
236 dmac_int_sts = lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_tx_isr()
240 dmac_int_en = lan743x_csr_read(adapter, in lan743x_tx_isr()
255 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_isr()
262 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_isr() local
266 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_rx_isr()
276 dmac_int_sts = lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_rx_isr()
280 dmac_int_en = lan743x_csr_read(adapter, in lan743x_rx_isr()
295 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_isr()
302 struct lan743x_adapter *adapter = context; in lan743x_intr_shared_isr() local
311 lan743x_rx_isr(&adapter->rx[channel], in lan743x_intr_shared_isr()
318 for (channel = 0; channel < adapter->used_tx_channels; in lan743x_intr_shared_isr()
323 lan743x_tx_isr(&adapter->tx[channel], in lan743x_intr_shared_isr()
331 lan743x_intr_software_isr(adapter); in lan743x_intr_shared_isr()
335 lan743x_ptp_isr(adapter); in lan743x_intr_shared_isr()
340 lan743x_csr_write(adapter, INT_EN_CLR, int_sts); in lan743x_intr_shared_isr()
346 struct lan743x_adapter *adapter = vector->adapter; in lan743x_intr_entry_isr() local
352 int_sts = lan743x_csr_read(adapter, INT_STS); in lan743x_intr_entry_isr()
356 int_sts = lan743x_csr_read(adapter, INT_STS_R2C); in lan743x_intr_entry_isr()
367 lan743x_csr_write(adapter, in lan743x_intr_entry_isr()
373 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_MAS_); in lan743x_intr_entry_isr()
376 int_enables = lan743x_csr_read(adapter, INT_EN_SET); in lan743x_intr_entry_isr()
390 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_intr_entry_isr()
398 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_MAS_); in lan743x_intr_entry_isr()
402 lan743x_csr_write(adapter, in lan743x_intr_entry_isr()
409 static int lan743x_intr_test_isr(struct lan743x_adapter *adapter) in lan743x_intr_test_isr() argument
411 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_test_isr()
417 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
418 lan743x_csr_write(adapter, INT_SET, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
425 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
430 static int lan743x_intr_register_isr(struct lan743x_adapter *adapter, in lan743x_intr_register_isr() argument
436 struct lan743x_vector *vector = &adapter->intr.vector_list in lan743x_intr_register_isr()
440 vector->adapter = adapter; in lan743x_intr_register_isr()
460 static void lan743x_intr_unregister_isr(struct lan743x_adapter *adapter, in lan743x_intr_unregister_isr() argument
463 struct lan743x_vector *vector = &adapter->intr.vector_list in lan743x_intr_unregister_isr()
473 static u32 lan743x_intr_get_vector_flags(struct lan743x_adapter *adapter, in lan743x_intr_get_vector_flags() argument
478 for (index = 0; index < adapter->max_vector_count; index++) { in lan743x_intr_get_vector_flags()
479 if (adapter->intr.vector_list[index].int_mask & int_mask) in lan743x_intr_get_vector_flags()
480 return adapter->intr.vector_list[index].flags; in lan743x_intr_get_vector_flags()
485 static void lan743x_intr_close(struct lan743x_adapter *adapter) in lan743x_intr_close() argument
487 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_close()
490 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_MAS_); in lan743x_intr_close()
491 if (adapter->is_pci11x1x) in lan743x_intr_close()
492 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x0000FFFF); in lan743x_intr_close()
494 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x000000FF); in lan743x_intr_close()
498 lan743x_intr_unregister_isr(adapter, index); in lan743x_intr_close()
504 pci_disable_msi(adapter->pdev); in lan743x_intr_close()
509 pci_disable_msix(adapter->pdev); in lan743x_intr_close()
514 static int lan743x_intr_open(struct lan743x_adapter *adapter) in lan743x_intr_open() argument
517 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_open()
530 max_vector_count = adapter->max_vector_count; in lan743x_intr_open()
535 used_tx_channels = adapter->used_tx_channels; in lan743x_intr_open()
536 ret = pci_enable_msix_range(adapter->pdev, in lan743x_intr_open()
548 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
555 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_intr_open()
556 if (!pci_enable_msi(adapter->pdev)) { in lan743x_intr_open()
561 adapter->pdev->irq; in lan743x_intr_open()
562 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
574 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
579 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0xFFFFFFFF); in lan743x_intr_open()
582 lan743x_csr_write(adapter, INT_VEC_MAP0, 0x00000000); in lan743x_intr_open()
583 lan743x_csr_write(adapter, INT_VEC_MAP1, 0x00000000); in lan743x_intr_open()
584 lan743x_csr_write(adapter, INT_VEC_MAP2, 0x00000000); in lan743x_intr_open()
599 if (adapter->csr.flags & LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR) { in lan743x_intr_open()
610 ret = lan743x_intr_register_isr(adapter, 0, flags, in lan743x_intr_open()
613 lan743x_intr_shared_isr, adapter); in lan743x_intr_open()
619 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
622 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_intr_open()
623 lan743x_csr_write(adapter, INT_MOD_CFG0, LAN743X_INT_MOD); in lan743x_intr_open()
624 lan743x_csr_write(adapter, INT_MOD_CFG1, LAN743X_INT_MOD); in lan743x_intr_open()
625 lan743x_csr_write(adapter, INT_MOD_CFG2, LAN743X_INT_MOD); in lan743x_intr_open()
626 lan743x_csr_write(adapter, INT_MOD_CFG3, LAN743X_INT_MOD); in lan743x_intr_open()
627 lan743x_csr_write(adapter, INT_MOD_CFG4, LAN743X_INT_MOD); in lan743x_intr_open()
628 lan743x_csr_write(adapter, INT_MOD_CFG5, LAN743X_INT_MOD); in lan743x_intr_open()
629 lan743x_csr_write(adapter, INT_MOD_CFG6, LAN743X_INT_MOD); in lan743x_intr_open()
630 lan743x_csr_write(adapter, INT_MOD_CFG7, LAN743X_INT_MOD); in lan743x_intr_open()
631 if (adapter->is_pci11x1x) { in lan743x_intr_open()
632 lan743x_csr_write(adapter, INT_MOD_CFG8, LAN743X_INT_MOD); in lan743x_intr_open()
633 lan743x_csr_write(adapter, INT_MOD_CFG9, LAN743X_INT_MOD); in lan743x_intr_open()
634 lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00007654); in lan743x_intr_open()
635 lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00003210); in lan743x_intr_open()
637 lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00005432); in lan743x_intr_open()
638 lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00000001); in lan743x_intr_open()
640 lan743x_csr_write(adapter, INT_MOD_MAP2, 0x00FFFFFF); in lan743x_intr_open()
644 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_MAS_); in lan743x_intr_open()
645 ret = lan743x_intr_test_isr(adapter); in lan743x_intr_open()
661 if (adapter->csr.flags & in lan743x_intr_open()
675 lan743x_csr_write(adapter, INT_VEC_MAP1, int_vec_map1); in lan743x_intr_open()
679 ret = lan743x_intr_register_isr(adapter, vector, flags, in lan743x_intr_open()
681 &adapter->tx[index]); in lan743x_intr_open()
687 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
705 if (adapter->csr.flags & in lan743x_intr_open()
719 lan743x_csr_write(adapter, INT_VEC_MAP0, int_vec_map0); in lan743x_intr_open()
723 lan743x_csr_write(adapter, INT_VEC_EN_AUTO_CLR, in lan743x_intr_open()
729 ret = lan743x_intr_register_isr(adapter, vector, flags, in lan743x_intr_open()
731 &adapter->rx[index]); in lan743x_intr_open()
736 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
743 lan743x_intr_close(adapter); in lan743x_intr_open()
747 static int lan743x_dp_write(struct lan743x_adapter *adapter, in lan743x_dp_write() argument
753 if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, DP_SEL_DPRDY_, in lan743x_dp_write()
756 dp_sel = lan743x_csr_read(adapter, DP_SEL); in lan743x_dp_write()
759 lan743x_csr_write(adapter, DP_SEL, dp_sel); in lan743x_dp_write()
762 lan743x_csr_write(adapter, DP_ADDR, addr + i); in lan743x_dp_write()
763 lan743x_csr_write(adapter, DP_DATA_0, buf[i]); in lan743x_dp_write()
764 lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_); in lan743x_dp_write()
765 if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, in lan743x_dp_write()
792 static int lan743x_mac_mii_wait_till_not_busy(struct lan743x_adapter *adapter) in lan743x_mac_mii_wait_till_not_busy() argument
802 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_read_c22() local
807 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c22()
813 lan743x_csr_write(adapter, MAC_MII_ACC, mii_access); in lan743x_mdiobus_read_c22()
814 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c22()
818 val = lan743x_csr_read(adapter, MAC_MII_DATA); in lan743x_mdiobus_read_c22()
825 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_write_c22() local
830 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c22()
834 lan743x_csr_write(adapter, MAC_MII_DATA, val); in lan743x_mdiobus_write_c22()
838 lan743x_csr_write(adapter, MAC_MII_ACC, mii_access); in lan743x_mdiobus_write_c22()
839 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c22()
867 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_read_c45() local
872 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
877 lan743x_csr_write(adapter, MAC_MII_DATA, index); in lan743x_mdiobus_read_c45()
880 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_read_c45()
881 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
888 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_read_c45()
889 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
893 ret = lan743x_csr_read(adapter, MAC_MII_DATA); in lan743x_mdiobus_read_c45()
900 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_write_c45() local
905 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
910 lan743x_csr_write(adapter, MAC_MII_DATA, (u32)index); in lan743x_mdiobus_write_c45()
913 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_write_c45()
914 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
919 lan743x_csr_write(adapter, MAC_MII_DATA, (u32)regval); in lan743x_mdiobus_write_c45()
922 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_write_c45()
924 return lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
927 static int lan743x_sgmii_wait_till_not_busy(struct lan743x_adapter *adapter) in lan743x_sgmii_wait_till_not_busy() argument
935 netif_err(adapter, drv, adapter->netdev, in lan743x_sgmii_wait_till_not_busy()
941 int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr) in lan743x_sgmii_read() argument
948 netif_err(adapter, probe, adapter->netdev, in lan743x_sgmii_read()
953 mutex_lock(&adapter->sgmii_rw_lock); in lan743x_sgmii_read()
957 lan743x_csr_write(adapter, SGMII_ACC, mmd_access); in lan743x_sgmii_read()
958 ret = lan743x_sgmii_wait_till_not_busy(adapter); in lan743x_sgmii_read()
962 val = lan743x_csr_read(adapter, SGMII_DATA); in lan743x_sgmii_read()
966 mutex_unlock(&adapter->sgmii_rw_lock); in lan743x_sgmii_read()
971 static int lan743x_sgmii_write(struct lan743x_adapter *adapter, in lan743x_sgmii_write() argument
978 netif_err(adapter, probe, adapter->netdev, in lan743x_sgmii_write()
982 mutex_lock(&adapter->sgmii_rw_lock); in lan743x_sgmii_write()
984 lan743x_csr_write(adapter, SGMII_DATA, (u32)(val & SGMII_DATA_MASK_)); in lan743x_sgmii_write()
988 lan743x_csr_write(adapter, SGMII_ACC, mmd_access); in lan743x_sgmii_write()
989 ret = lan743x_sgmii_wait_till_not_busy(adapter); in lan743x_sgmii_write()
990 mutex_unlock(&adapter->sgmii_rw_lock); in lan743x_sgmii_write()
995 static int lan743x_sgmii_mpll_set(struct lan743x_adapter *adapter, in lan743x_sgmii_mpll_set() argument
1003 mpllctrl0 = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1019 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1024 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1029 return lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1033 static int lan743x_sgmii_2_5G_mode_set(struct lan743x_adapter *adapter, in lan743x_sgmii_2_5G_mode_set() argument
1037 return lan743x_sgmii_mpll_set(adapter, in lan743x_sgmii_2_5G_mode_set()
1040 return lan743x_sgmii_mpll_set(adapter, in lan743x_sgmii_2_5G_mode_set()
1044 static int lan743x_is_sgmii_2_5G_mode(struct lan743x_adapter *adapter, in lan743x_is_sgmii_2_5G_mode() argument
1049 ret = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_is_sgmii_2_5G_mode()
1063 static int lan743x_sgmii_aneg_update(struct lan743x_adapter *adapter) in lan743x_sgmii_aneg_update() argument
1065 enum lan743x_sgmii_lsd lsd = adapter->sgmii_lsd; in lan743x_sgmii_aneg_update()
1073 ret = lan743x_sgmii_2_5G_mode_set(adapter, true); in lan743x_sgmii_aneg_update()
1076 ret = lan743x_sgmii_2_5G_mode_set(adapter, false); in lan743x_sgmii_aneg_update()
1081 mii_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); in lan743x_sgmii_aneg_update()
1085 an_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, VR_MII_AN_CTRL); in lan743x_sgmii_aneg_update()
1089 dgt_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_aneg_update()
1105 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_aneg_update()
1116 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, in lan743x_sgmii_aneg_update()
1121 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_aneg_update()
1126 return lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_aneg_update()
1130 static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state) in lan743x_pcs_seq_state() argument
1136 dig_sts = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_pcs_seq_state()
1150 static int lan743x_sgmii_config(struct lan743x_adapter *adapter) in lan743x_sgmii_config() argument
1152 struct net_device *netdev = adapter->netdev; in lan743x_sgmii_config()
1185 netif_err(adapter, drv, adapter->netdev, in lan743x_sgmii_config()
1190 adapter->sgmii_lsd = lsd; in lan743x_sgmii_config()
1191 ret = lan743x_sgmii_aneg_update(adapter); in lan743x_sgmii_config()
1193 netif_err(adapter, drv, adapter->netdev, in lan743x_sgmii_config()
1198 ret = lan743x_is_sgmii_2_5G_mode(adapter, &status); in lan743x_sgmii_config()
1200 netif_err(adapter, drv, adapter->netdev, in lan743x_sgmii_config()
1206 netif_dbg(adapter, drv, adapter->netdev, in lan743x_sgmii_config()
1209 netif_dbg(adapter, drv, adapter->netdev, in lan743x_sgmii_config()
1213 mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); in lan743x_sgmii_config()
1218 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); in lan743x_sgmii_config()
1222 ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN); in lan743x_sgmii_config()
1228 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); in lan743x_sgmii_config()
1232 ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP); in lan743x_sgmii_config()
1239 static void lan743x_mac_set_address(struct lan743x_adapter *adapter, in lan743x_mac_set_address() argument
1250 lan743x_csr_write(adapter, MAC_RX_ADDRL, addr_lo); in lan743x_mac_set_address()
1251 lan743x_csr_write(adapter, MAC_RX_ADDRH, addr_hi); in lan743x_mac_set_address()
1253 ether_addr_copy(adapter->mac_address, addr); in lan743x_mac_set_address()
1254 netif_info(adapter, drv, adapter->netdev, in lan743x_mac_set_address()
1258 static int lan743x_mac_init(struct lan743x_adapter *adapter) in lan743x_mac_init() argument
1266 netdev = adapter->netdev; in lan743x_mac_init()
1269 data = lan743x_csr_read(adapter, MAC_CR); in lan743x_mac_init()
1272 lan743x_csr_write(adapter, MAC_CR, data); in lan743x_mac_init()
1274 if (!is_valid_ether_addr(adapter->mac_address)) { in lan743x_mac_init()
1275 mac_addr_hi = lan743x_csr_read(adapter, MAC_RX_ADDRH); in lan743x_mac_init()
1276 mac_addr_lo = lan743x_csr_read(adapter, MAC_RX_ADDRL); in lan743x_mac_init()
1277 adapter->mac_address[0] = mac_addr_lo & 0xFF; in lan743x_mac_init()
1278 adapter->mac_address[1] = (mac_addr_lo >> 8) & 0xFF; in lan743x_mac_init()
1279 adapter->mac_address[2] = (mac_addr_lo >> 16) & 0xFF; in lan743x_mac_init()
1280 adapter->mac_address[3] = (mac_addr_lo >> 24) & 0xFF; in lan743x_mac_init()
1281 adapter->mac_address[4] = mac_addr_hi & 0xFF; in lan743x_mac_init()
1282 adapter->mac_address[5] = (mac_addr_hi >> 8) & 0xFF; in lan743x_mac_init()
1287 } else if (!is_valid_ether_addr(adapter->mac_address)) { in lan743x_mac_init()
1292 eth_random_addr(adapter->mac_address); in lan743x_mac_init()
1294 lan743x_mac_set_address(adapter, adapter->mac_address); in lan743x_mac_init()
1295 eth_hw_addr_set(netdev, adapter->mac_address); in lan743x_mac_init()
1300 static int lan743x_mac_open(struct lan743x_adapter *adapter) in lan743x_mac_open() argument
1304 temp = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_open()
1305 lan743x_csr_write(adapter, MAC_RX, temp | MAC_RX_RXEN_); in lan743x_mac_open()
1306 temp = lan743x_csr_read(adapter, MAC_TX); in lan743x_mac_open()
1307 lan743x_csr_write(adapter, MAC_TX, temp | MAC_TX_TXEN_); in lan743x_mac_open()
1311 static void lan743x_mac_close(struct lan743x_adapter *adapter) in lan743x_mac_close() argument
1315 temp = lan743x_csr_read(adapter, MAC_TX); in lan743x_mac_close()
1317 lan743x_csr_write(adapter, MAC_TX, temp); in lan743x_mac_close()
1318 lan743x_csr_wait_for_bit(adapter, MAC_TX, MAC_TX_TXD_, in lan743x_mac_close()
1321 temp = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_close()
1323 lan743x_csr_write(adapter, MAC_RX, temp); in lan743x_mac_close()
1324 lan743x_csr_wait_for_bit(adapter, MAC_RX, MAC_RX_RXD_, in lan743x_mac_close()
1328 void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter, in lan743x_mac_flow_ctrl_set_enables() argument
1341 lan743x_csr_write(adapter, MAC_FLOW, flow_setting); in lan743x_mac_flow_ctrl_set_enables()
1344 static int lan743x_mac_set_mtu(struct lan743x_adapter *adapter, int new_mtu) in lan743x_mac_set_mtu() argument
1349 mac_rx = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_set_mtu()
1353 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1357 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1358 lan743x_csr_wait_for_bit(adapter, MAC_RX, MAC_RX_RXD_, in lan743x_mac_set_mtu()
1360 lan743x_csr_write(adapter, MAC_RX, mac_rx | MAC_RX_RXD_); in lan743x_mac_set_mtu()
1366 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1370 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1376 static int lan743x_phy_reset(struct lan743x_adapter *adapter) in lan743x_phy_reset() argument
1382 data = lan743x_csr_read(adapter, PMT_CTL); in lan743x_phy_reset()
1384 lan743x_csr_write(adapter, PMT_CTL, data); in lan743x_phy_reset()
1392 static void lan743x_phy_update_flowcontrol(struct lan743x_adapter *adapter, in lan743x_phy_update_flowcontrol() argument
1395 struct lan743x_phy *phy = &adapter->phy; in lan743x_phy_update_flowcontrol()
1403 lan743x_mac_flow_ctrl_set_enables(adapter, in lan743x_phy_update_flowcontrol()
1408 static int lan743x_phy_init(struct lan743x_adapter *adapter) in lan743x_phy_init() argument
1410 return lan743x_phy_reset(adapter); in lan743x_phy_init()
1415 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_phy_link_status_change() local
1424 data = lan743x_csr_read(adapter, MAC_CR); in lan743x_phy_link_status_change()
1451 lan743x_csr_write(adapter, MAC_CR, data); in lan743x_phy_link_status_change()
1458 lan743x_phy_update_flowcontrol(adapter, local_advertisement, in lan743x_phy_link_status_change()
1460 lan743x_ptp_update_latency(adapter, phydev->speed); in lan743x_phy_link_status_change()
1464 lan743x_sgmii_config(adapter); in lan743x_phy_link_status_change()
1468 static void lan743x_phy_close(struct lan743x_adapter *adapter) in lan743x_phy_close() argument
1470 struct net_device *netdev = adapter->netdev; in lan743x_phy_close()
1476 static void lan743x_phy_interface_select(struct lan743x_adapter *adapter) in lan743x_phy_interface_select() argument
1481 data = lan743x_csr_read(adapter, MAC_CR); in lan743x_phy_interface_select()
1482 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_; in lan743x_phy_interface_select()
1484 if (adapter->is_pci11x1x && adapter->is_sgmii_en) in lan743x_phy_interface_select()
1485 adapter->phy_interface = PHY_INTERFACE_MODE_SGMII; in lan743x_phy_interface_select()
1487 adapter->phy_interface = PHY_INTERFACE_MODE_GMII; in lan743x_phy_interface_select()
1489 adapter->phy_interface = PHY_INTERFACE_MODE_MII; in lan743x_phy_interface_select()
1491 adapter->phy_interface = PHY_INTERFACE_MODE_RGMII; in lan743x_phy_interface_select()
1494 static int lan743x_phy_open(struct lan743x_adapter *adapter) in lan743x_phy_open() argument
1496 struct net_device *netdev = adapter->netdev; in lan743x_phy_open()
1497 struct lan743x_phy *phy = &adapter->phy; in lan743x_phy_open()
1507 phydev = of_phy_get_and_connect(netdev, adapter->pdev->dev.of_node, in lan743x_phy_open()
1512 phydev = phy_find_first(adapter->mdiobus); in lan743x_phy_open()
1514 if ((adapter->csr.id_rev & ID_REV_ID_MASK_) == in lan743x_phy_open()
1527 lan743x_phy_interface_select(adapter); in lan743x_phy_open()
1531 adapter->phy_interface); in lan743x_phy_open()
1553 static void lan743x_rfe_open(struct lan743x_adapter *adapter) in lan743x_rfe_open() argument
1555 lan743x_csr_write(adapter, RFE_RSS_CFG, in lan743x_rfe_open()
1571 static void lan743x_rfe_update_mac_address(struct lan743x_adapter *adapter) in lan743x_rfe_update_mac_address() argument
1578 mac_addr = adapter->mac_address; in lan743x_rfe_update_mac_address()
1586 lan743x_csr_write(adapter, RFE_ADDR_FILT_LO(0), mac_addr_lo); in lan743x_rfe_update_mac_address()
1587 lan743x_csr_write(adapter, RFE_ADDR_FILT_HI(0), in lan743x_rfe_update_mac_address()
1591 static void lan743x_rfe_set_multicast(struct lan743x_adapter *adapter) in lan743x_rfe_set_multicast() argument
1593 struct net_device *netdev = adapter->netdev; in lan743x_rfe_set_multicast()
1598 rfctl = lan743x_csr_read(adapter, RFE_CTL); in lan743x_rfe_set_multicast()
1622 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1628 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1633 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1645 lan743x_dp_write(adapter, DP_SEL_RFE_RAM, in lan743x_rfe_set_multicast()
1648 lan743x_csr_write(adapter, RFE_CTL, rfctl); in lan743x_rfe_set_multicast()
1651 static int lan743x_dmac_init(struct lan743x_adapter *adapter) in lan743x_dmac_init() argument
1655 lan743x_csr_write(adapter, DMAC_CMD, DMAC_CMD_SWR_); in lan743x_dmac_init()
1656 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, DMAC_CMD_SWR_, in lan743x_dmac_init()
1674 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_dmac_init()
1678 lan743x_csr_write(adapter, DMAC_CFG, data); in lan743x_dmac_init()
1686 lan743x_csr_write(adapter, DMAC_COAL_CFG, data); in lan743x_dmac_init()
1689 lan743x_csr_write(adapter, DMAC_OBFF_CFG, data); in lan743x_dmac_init()
1693 static int lan743x_dmac_tx_get_state(struct lan743x_adapter *adapter, in lan743x_dmac_tx_get_state() argument
1698 dmac_cmd = lan743x_csr_read(adapter, DMAC_CMD); in lan743x_dmac_tx_get_state()
1705 static int lan743x_dmac_tx_wait_till_stopped(struct lan743x_adapter *adapter, in lan743x_dmac_tx_wait_till_stopped() argument
1712 ((result = lan743x_dmac_tx_get_state(adapter, tx_channel)) == in lan743x_dmac_tx_wait_till_stopped()
1722 static int lan743x_dmac_rx_get_state(struct lan743x_adapter *adapter, in lan743x_dmac_rx_get_state() argument
1727 dmac_cmd = lan743x_csr_read(adapter, DMAC_CMD); in lan743x_dmac_rx_get_state()
1734 static int lan743x_dmac_rx_wait_till_stopped(struct lan743x_adapter *adapter, in lan743x_dmac_rx_wait_till_stopped() argument
1741 ((result = lan743x_dmac_rx_get_state(adapter, rx_channel)) == in lan743x_dmac_rx_wait_till_stopped()
1775 dma_unmap_page(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1780 dma_unmap_single(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1797 lan743x_ptp_unrequest_tx_timestamp(tx->adapter); in lan743x_tx_release_desc()
1802 lan743x_ptp_tx_timestamp_skb(tx->adapter, in lan743x_tx_release_desc()
1895 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_start() local
1896 struct device *dev = &adapter->pdev->dev; in lan743x_tx_frame_start()
1987 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_add_fragment() local
1988 struct device *dev = &adapter->pdev->dev; in lan743x_tx_frame_add_fragment()
2053 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_end() local
2083 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_frame_end()
2115 txq = netdev_get_tx_queue(tx->adapter->netdev, in lan743x_tx_xmit_frame()
2125 (lan743x_ptp_request_tx_timestamp(tx->adapter))) { in lan743x_tx_xmit_frame()
2182 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_napi_poll() local
2188 lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_tx_napi_poll()
2190 lan743x_csr_write(adapter, DMAC_INT_STS, ioc_bit); in lan743x_tx_napi_poll()
2195 txq = netdev_get_tx_queue(adapter->netdev, tx->channel_number); in lan743x_tx_napi_poll()
2213 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_napi_poll()
2215 lan743x_csr_read(adapter, INT_STS); in lan743x_tx_napi_poll()
2224 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2234 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2256 if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2258 dev_warn(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2267 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2285 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2309 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_close() local
2311 lan743x_csr_write(adapter, in lan743x_tx_close()
2314 lan743x_dmac_tx_wait_till_stopped(adapter, tx->channel_number); in lan743x_tx_close()
2316 lan743x_csr_write(adapter, in lan743x_tx_close()
2319 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_tx_close()
2324 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_close()
2326 lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL, in lan743x_tx_close()
2339 struct lan743x_adapter *adapter = NULL; in lan743x_tx_open() local
2343 adapter = tx->adapter; in lan743x_tx_open()
2349 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_open()
2351 lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL, in lan743x_tx_open()
2356 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_open()
2360 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_tx_open()
2362 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, in lan743x_tx_open()
2367 lan743x_csr_write(adapter, in lan743x_tx_open()
2370 lan743x_csr_write(adapter, in lan743x_tx_open()
2375 data = lan743x_csr_read(adapter, TX_CFG_B(tx->channel_number)); in lan743x_tx_open()
2378 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_tx_open()
2380 lan743x_csr_write(adapter, TX_CFG_B(tx->channel_number), data); in lan743x_tx_open()
2384 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_tx_open()
2390 lan743x_csr_write(adapter, TX_CFG_A(tx->channel_number), data); in lan743x_tx_open()
2393 lan743x_csr_write(adapter, in lan743x_tx_open()
2396 lan743x_csr_write(adapter, in lan743x_tx_open()
2401 tx->last_head = lan743x_csr_read(adapter, TX_HEAD(tx->channel_number)); in lan743x_tx_open()
2405 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_open()
2407 tx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_tx_open()
2410 netif_napi_add_tx_weight(adapter->netdev, in lan743x_tx_open()
2424 lan743x_csr_write(adapter, TX_CFG_C(tx->channel_number), data); in lan743x_tx_open()
2427 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_open()
2429 lan743x_csr_write(adapter, DMAC_INT_EN_SET, in lan743x_tx_open()
2433 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_tx_open()
2447 lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), in lan743x_rx_update_tail()
2454 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_init_ring_element()
2455 struct device *dev = &rx->adapter->pdev->dev; in lan743x_rx_init_ring_element()
2536 dma_unmap_single(&rx->adapter->pdev->dev, in lan743x_rx_release_ring_element()
2570 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_process_buffer()
2691 rx->adapter->netdev); in lan743x_rx_process_buffer()
2692 if (rx->adapter->netdev->features & NETIF_F_RXCSUM) { in lan743x_rx_process_buffer()
2714 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_napi_poll() local
2721 lan743x_csr_write(adapter, DMAC_INT_STS, in lan743x_rx_napi_poll()
2742 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_napi_poll()
2747 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_napi_poll()
2763 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2774 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2803 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2805 dev_warn(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2814 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2832 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2856 netif_warn(rx->adapter, ifup, rx->adapter->netdev, in lan743x_rx_ring_init()
2865 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_close() local
2867 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_close()
2869 lan743x_csr_wait_for_bit(adapter, FCT_RX_CTL, in lan743x_rx_close()
2873 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_close()
2875 lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number); in lan743x_rx_close()
2877 lan743x_csr_write(adapter, DMAC_INT_EN_CLR, in lan743x_rx_close()
2879 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_rx_close()
2890 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_open() local
2899 netif_napi_add(adapter->netdev, &rx->napi, lan743x_rx_napi_poll); in lan743x_rx_open()
2901 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_open()
2903 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, in lan743x_rx_open()
2908 lan743x_csr_write(adapter, in lan743x_rx_open()
2911 lan743x_csr_write(adapter, in lan743x_rx_open()
2916 lan743x_csr_write(adapter, in lan743x_rx_open()
2919 lan743x_csr_write(adapter, in lan743x_rx_open()
2923 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_rx_open()
2931 lan743x_csr_write(adapter, in lan743x_rx_open()
2935 data = lan743x_csr_read(adapter, RX_CFG_B(rx->channel_number)); in lan743x_rx_open()
2944 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_rx_open()
2947 lan743x_csr_write(adapter, RX_CFG_B(rx->channel_number), data); in lan743x_rx_open()
2948 rx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_rx_open()
2962 lan743x_csr_write(adapter, RX_CFG_C(rx->channel_number), data); in lan743x_rx_open()
2965 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_open()
2967 rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number)); in lan743x_rx_open()
2975 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_open()
2977 lan743x_csr_write(adapter, DMAC_INT_STS, in lan743x_rx_open()
2979 lan743x_csr_write(adapter, DMAC_INT_EN_SET, in lan743x_rx_open()
2981 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_open()
2985 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_open()
2987 lan743x_csr_wait_for_bit(adapter, FCT_RX_CTL, in lan743x_rx_open()
2990 lan743x_csr_write(adapter, FCT_FLOW(rx->channel_number), in lan743x_rx_open()
2996 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_open()
3010 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_close() local
3013 for (index = 0; index < adapter->used_tx_channels; index++) in lan743x_netdev_close()
3014 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_close()
3017 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_close()
3019 lan743x_ptp_close(adapter); in lan743x_netdev_close()
3021 lan743x_phy_close(adapter); in lan743x_netdev_close()
3023 lan743x_mac_close(adapter); in lan743x_netdev_close()
3025 lan743x_intr_close(adapter); in lan743x_netdev_close()
3032 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_open() local
3036 ret = lan743x_intr_open(adapter); in lan743x_netdev_open()
3040 ret = lan743x_mac_open(adapter); in lan743x_netdev_open()
3044 ret = lan743x_phy_open(adapter); in lan743x_netdev_open()
3048 ret = lan743x_ptp_open(adapter); in lan743x_netdev_open()
3052 lan743x_rfe_open(adapter); in lan743x_netdev_open()
3055 ret = lan743x_rx_open(&adapter->rx[index]); in lan743x_netdev_open()
3060 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_netdev_open()
3061 ret = lan743x_tx_open(&adapter->tx[index]); in lan743x_netdev_open()
3067 if (adapter->netdev->phydev) { in lan743x_netdev_open()
3071 adapter->phy_wol_supported = wol.supported; in lan743x_netdev_open()
3072 adapter->phy_wolopts = wol.wolopts; in lan743x_netdev_open()
3079 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_netdev_open()
3080 if (adapter->tx[index].ring_cpu_ptr) in lan743x_netdev_open()
3081 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_open()
3086 if (adapter->rx[index].ring_cpu_ptr) in lan743x_netdev_open()
3087 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_open()
3089 lan743x_ptp_close(adapter); in lan743x_netdev_open()
3092 lan743x_phy_close(adapter); in lan743x_netdev_open()
3095 lan743x_mac_close(adapter); in lan743x_netdev_open()
3098 lan743x_intr_close(adapter); in lan743x_netdev_open()
3101 netif_warn(adapter, ifup, adapter->netdev, in lan743x_netdev_open()
3109 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_xmit_frame() local
3112 if (adapter->is_pci11x1x) in lan743x_netdev_xmit_frame()
3115 return lan743x_tx_xmit_frame(&adapter->tx[ch], skb); in lan743x_netdev_xmit_frame()
3130 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_set_multicast() local
3132 lan743x_rfe_set_multicast(adapter); in lan743x_netdev_set_multicast()
3137 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_change_mtu() local
3140 ret = lan743x_mac_set_mtu(adapter, new_mtu); in lan743x_netdev_change_mtu()
3149 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_get_stats64() local
3151 stats->rx_packets = lan743x_csr_read(adapter, STAT_RX_TOTAL_FRAMES); in lan743x_netdev_get_stats64()
3152 stats->tx_packets = lan743x_csr_read(adapter, STAT_TX_TOTAL_FRAMES); in lan743x_netdev_get_stats64()
3153 stats->rx_bytes = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3155 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3157 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3159 stats->tx_bytes = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3161 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3163 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3165 stats->rx_errors = lan743x_csr_read(adapter, STAT_RX_FCS_ERRORS) + in lan743x_netdev_get_stats64()
3166 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3168 lan743x_csr_read(adapter, STAT_RX_JABBER_ERRORS) + in lan743x_netdev_get_stats64()
3169 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3171 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3173 stats->tx_errors = lan743x_csr_read(adapter, STAT_TX_FCS_ERRORS) + in lan743x_netdev_get_stats64()
3174 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3176 lan743x_csr_read(adapter, STAT_TX_CARRIER_ERRORS); in lan743x_netdev_get_stats64()
3177 stats->rx_dropped = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3179 stats->tx_dropped = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3181 stats->multicast = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3183 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3185 stats->collisions = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3187 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3189 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3196 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_set_mac_address() local
3204 lan743x_mac_set_address(adapter, sock_addr->sa_data); in lan743x_netdev_set_mac_address()
3205 lan743x_rfe_update_mac_address(adapter); in lan743x_netdev_set_mac_address()
3220 static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter) in lan743x_hardware_cleanup() argument
3222 lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF); in lan743x_hardware_cleanup()
3225 static void lan743x_mdiobus_cleanup(struct lan743x_adapter *adapter) in lan743x_mdiobus_cleanup() argument
3227 mdiobus_unregister(adapter->mdiobus); in lan743x_mdiobus_cleanup()
3230 static void lan743x_full_cleanup(struct lan743x_adapter *adapter) in lan743x_full_cleanup() argument
3232 unregister_netdev(adapter->netdev); in lan743x_full_cleanup()
3234 lan743x_mdiobus_cleanup(adapter); in lan743x_full_cleanup()
3235 lan743x_hardware_cleanup(adapter); in lan743x_full_cleanup()
3236 lan743x_pci_cleanup(adapter); in lan743x_full_cleanup()
3239 static void pci11x1x_set_rfe_rd_fifo_threshold(struct lan743x_adapter *adapter) in pci11x1x_set_rfe_rd_fifo_threshold() argument
3241 u16 rev = adapter->csr.id_rev & ID_REV_CHIP_REV_MASK_; in pci11x1x_set_rfe_rd_fifo_threshold()
3246 misc_ctl = lan743x_csr_read(adapter, MISC_CTL_0); in pci11x1x_set_rfe_rd_fifo_threshold()
3250 lan743x_csr_write(adapter, MISC_CTL_0, misc_ctl); in pci11x1x_set_rfe_rd_fifo_threshold()
3254 static int lan743x_hardware_init(struct lan743x_adapter *adapter, in lan743x_hardware_init() argument
3261 adapter->is_pci11x1x = is_pci11x1x_chip(adapter); in lan743x_hardware_init()
3262 if (adapter->is_pci11x1x) { in lan743x_hardware_init()
3263 adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS; in lan743x_hardware_init()
3264 adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS; in lan743x_hardware_init()
3265 adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT; in lan743x_hardware_init()
3266 pci11x1x_strap_get_status(adapter); in lan743x_hardware_init()
3267 spin_lock_init(&adapter->eth_syslock_spinlock); in lan743x_hardware_init()
3268 mutex_init(&adapter->sgmii_rw_lock); in lan743x_hardware_init()
3269 pci11x1x_set_rfe_rd_fifo_threshold(adapter); in lan743x_hardware_init()
3271 adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS; in lan743x_hardware_init()
3272 adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS; in lan743x_hardware_init()
3273 adapter->max_vector_count = LAN743X_MAX_VECTOR_COUNT; in lan743x_hardware_init()
3276 adapter->intr.irq = adapter->pdev->irq; in lan743x_hardware_init()
3277 lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF); in lan743x_hardware_init()
3279 ret = lan743x_gpio_init(adapter); in lan743x_hardware_init()
3283 ret = lan743x_mac_init(adapter); in lan743x_hardware_init()
3287 ret = lan743x_phy_init(adapter); in lan743x_hardware_init()
3291 ret = lan743x_ptp_init(adapter); in lan743x_hardware_init()
3295 lan743x_rfe_update_mac_address(adapter); in lan743x_hardware_init()
3297 ret = lan743x_dmac_init(adapter); in lan743x_hardware_init()
3302 adapter->rx[index].adapter = adapter; in lan743x_hardware_init()
3303 adapter->rx[index].channel_number = index; in lan743x_hardware_init()
3306 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_hardware_init()
3307 tx = &adapter->tx[index]; in lan743x_hardware_init()
3308 tx->adapter = adapter; in lan743x_hardware_init()
3316 static int lan743x_mdiobus_init(struct lan743x_adapter *adapter) in lan743x_mdiobus_init() argument
3321 adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev); in lan743x_mdiobus_init()
3322 if (!(adapter->mdiobus)) { in lan743x_mdiobus_init()
3327 adapter->mdiobus->priv = (void *)adapter; in lan743x_mdiobus_init()
3328 if (adapter->is_pci11x1x) { in lan743x_mdiobus_init()
3329 if (adapter->is_sgmii_en) { in lan743x_mdiobus_init()
3330 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_mdiobus_init()
3333 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_mdiobus_init()
3334 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3336 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3337 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3338 adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45; in lan743x_mdiobus_init()
3339 adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45; in lan743x_mdiobus_init()
3340 adapter->mdiobus->name = "lan743x-mdiobus-c45"; in lan743x_mdiobus_init()
3341 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3344 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_mdiobus_init()
3347 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_mdiobus_init()
3348 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3351 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3352 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3353 adapter->mdiobus->name = "lan743x-mdiobus"; in lan743x_mdiobus_init()
3354 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3358 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3359 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3360 adapter->mdiobus->name = "lan743x-mdiobus"; in lan743x_mdiobus_init()
3361 netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n"); in lan743x_mdiobus_init()
3364 snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE, in lan743x_mdiobus_init()
3365 "pci-%s", pci_name(adapter->pdev)); in lan743x_mdiobus_init()
3367 if ((adapter->csr.id_rev & ID_REV_ID_MASK_) == ID_REV_ID_LAN7430_) in lan743x_mdiobus_init()
3369 adapter->mdiobus->phy_mask = ~(u32)BIT(1); in lan743x_mdiobus_init()
3372 ret = mdiobus_register(adapter->mdiobus); in lan743x_mdiobus_init()
3387 * initializes an adapter identified by a pci_dev structure.
3388 * The OS initialization, configuring of the adapter private structure,
3394 struct lan743x_adapter *adapter = NULL; in lan743x_pcidev_probe() local
3416 adapter = netdev_priv(netdev); in lan743x_pcidev_probe()
3417 adapter->netdev = netdev; in lan743x_pcidev_probe()
3418 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | in lan743x_pcidev_probe()
3423 of_get_mac_address(pdev->dev.of_node, adapter->mac_address); in lan743x_pcidev_probe()
3425 ret = lan743x_pci_init(adapter, pdev); in lan743x_pcidev_probe()
3429 ret = lan743x_csr_init(adapter); in lan743x_pcidev_probe()
3433 ret = lan743x_hardware_init(adapter, pdev); in lan743x_pcidev_probe()
3437 ret = lan743x_mdiobus_init(adapter); in lan743x_pcidev_probe()
3441 adapter->netdev->netdev_ops = &lan743x_netdev_ops; in lan743x_pcidev_probe()
3442 adapter->netdev->ethtool_ops = &lan743x_ethtool_ops; in lan743x_pcidev_probe()
3443 adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO | in lan743x_pcidev_probe()
3445 adapter->netdev->hw_features = adapter->netdev->features; in lan743x_pcidev_probe()
3450 ret = register_netdev(adapter->netdev); in lan743x_pcidev_probe()
3456 lan743x_mdiobus_cleanup(adapter); in lan743x_pcidev_probe()
3459 lan743x_hardware_cleanup(adapter); in lan743x_pcidev_probe()
3462 lan743x_pci_cleanup(adapter); in lan743x_pcidev_probe()
3481 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pcidev_remove() local
3483 lan743x_full_cleanup(adapter); in lan743x_pcidev_remove()
3489 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pcidev_shutdown() local
3507 lan743x_hardware_cleanup(adapter); in lan743x_pcidev_shutdown()
3516 static void lan743x_pm_set_wol(struct lan743x_adapter *adapter) in lan743x_pm_set_wol() argument
3529 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), 0); in lan743x_pm_set_wol()
3532 pmtctl = lan743x_csr_read(adapter, PMT_CTL); in lan743x_pm_set_wol()
3538 macrx = lan743x_csr_read(adapter, MAC_RX); in lan743x_pm_set_wol()
3545 if (adapter->phy_wolopts) in lan743x_pm_set_wol()
3548 if (adapter->wolopts & WAKE_MAGIC) { in lan743x_pm_set_wol()
3553 if (adapter->wolopts & WAKE_UCAST) { in lan743x_pm_set_wol()
3559 if (adapter->wolopts & WAKE_BCAST) { in lan743x_pm_set_wol()
3565 if (adapter->wolopts & WAKE_MCAST) { in lan743x_pm_set_wol()
3568 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3572 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 7); in lan743x_pm_set_wol()
3573 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3574 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3575 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3580 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3584 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 3); in lan743x_pm_set_wol()
3585 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3586 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3587 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3595 if (adapter->wolopts & WAKE_ARP) { in lan743x_pm_set_wol()
3600 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3604 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 0x3000); in lan743x_pm_set_wol()
3605 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3606 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3607 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3616 if (adapter->wolopts & WAKE_MAGICSECURE) { in lan743x_pm_set_wol()
3617 sopass = *(u32 *)adapter->sopass; in lan743x_pm_set_wol()
3618 lan743x_csr_write(adapter, MAC_MP_SO_LO, sopass); in lan743x_pm_set_wol()
3619 sopass = *(u16 *)&adapter->sopass[4]; in lan743x_pm_set_wol()
3620 lan743x_csr_write(adapter, MAC_MP_SO_HI, sopass); in lan743x_pm_set_wol()
3624 lan743x_csr_write(adapter, MAC_WUCSR, wucsr); in lan743x_pm_set_wol()
3625 lan743x_csr_write(adapter, PMT_CTL, pmtctl); in lan743x_pm_set_wol()
3626 lan743x_csr_write(adapter, MAC_RX, macrx); in lan743x_pm_set_wol()
3633 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pm_suspend() local
3639 lan743x_csr_write(adapter, MAC_WUCSR, 0); in lan743x_pm_suspend()
3640 lan743x_csr_write(adapter, MAC_WUCSR2, 0); in lan743x_pm_suspend()
3641 lan743x_csr_write(adapter, MAC_WK_SRC, 0xFFFFFFFF); in lan743x_pm_suspend()
3643 if (adapter->wolopts || adapter->phy_wolopts) in lan743x_pm_suspend()
3644 lan743x_pm_set_wol(adapter); in lan743x_pm_suspend()
3646 if (adapter->is_pci11x1x) { in lan743x_pm_suspend()
3648 data = lan743x_csr_read(adapter, HW_CFG); in lan743x_pm_suspend()
3649 adapter->hw_cfg = data; in lan743x_pm_suspend()
3655 lan743x_csr_write(adapter, HW_CFG, data); in lan743x_pm_suspend()
3666 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pm_resume() local
3675 if (adapter->is_pci11x1x) in lan743x_pm_resume()
3676 lan743x_csr_write(adapter, HW_CFG, adapter->hw_cfg); in lan743x_pm_resume()
3678 ret = lan743x_hardware_init(adapter, pdev); in lan743x_pm_resume()
3680 netif_err(adapter, probe, adapter->netdev, in lan743x_pm_resume()
3682 lan743x_pci_cleanup(adapter); in lan743x_pm_resume()
3686 ret = lan743x_csr_read(adapter, MAC_WK_SRC); in lan743x_pm_resume()
3687 netif_dbg(adapter, drv, adapter->netdev, in lan743x_pm_resume()
3696 lan743x_csr_write(adapter, MAC_WUCSR, data); in lan743x_pm_resume()
3700 lan743x_csr_write(adapter, MAC_WUCSR2, data); in lan743x_pm_resume()
3708 lan743x_csr_write(adapter, MAC_WK_SRC, data); in lan743x_pm_resume()