Lines Matching full:adapter

31 static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)  in pci11x1x_strap_get_status()  argument
40 ret = lan743x_hs_syslock_acquire(adapter, 100); in pci11x1x_strap_get_status()
42 netif_err(adapter, drv, adapter->netdev, in pci11x1x_strap_get_status()
47 cfg_load = lan743x_csr_read(adapter, ETH_SYS_CONFIG_LOAD_STARTED_REG); in pci11x1x_strap_get_status()
48 lan743x_hs_syslock_release(adapter); in pci11x1x_strap_get_status()
49 hw_cfg = lan743x_csr_read(adapter, HW_CFG); in pci11x1x_strap_get_status()
53 strap = lan743x_csr_read(adapter, STRAP_READ); in pci11x1x_strap_get_status()
55 adapter->is_sgmii_en = true; in pci11x1x_strap_get_status()
57 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
59 chip_rev = lan743x_csr_read(adapter, FPGA_REV); in pci11x1x_strap_get_status()
62 adapter->is_sgmii_en = true; in pci11x1x_strap_get_status()
64 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
66 adapter->is_sgmii_en = false; in pci11x1x_strap_get_status()
69 netif_dbg(adapter, drv, adapter->netdev, in pci11x1x_strap_get_status()
70 "SGMII I/F %sable\n", adapter->is_sgmii_en ? "En" : "Dis"); in pci11x1x_strap_get_status()
73 static bool is_pci11x1x_chip(struct lan743x_adapter *adapter) in is_pci11x1x_chip() argument
75 struct lan743x_csr *csr = &adapter->csr; in is_pci11x1x_chip()
85 static void lan743x_pci_cleanup(struct lan743x_adapter *adapter) in lan743x_pci_cleanup() argument
87 pci_release_selected_regions(adapter->pdev, in lan743x_pci_cleanup()
88 pci_select_bars(adapter->pdev, in lan743x_pci_cleanup()
90 pci_disable_device(adapter->pdev); in lan743x_pci_cleanup()
93 static int lan743x_pci_init(struct lan743x_adapter *adapter, in lan743x_pci_init() argument
99 adapter->pdev = pdev; in lan743x_pci_init()
104 netif_info(adapter, probe, adapter->netdev, in lan743x_pci_init()
119 pci_disable_device(adapter->pdev); in lan743x_pci_init()
125 u32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset) in lan743x_csr_read() argument
127 return ioread32(&adapter->csr.csr_address[offset]); in lan743x_csr_read()
130 void lan743x_csr_write(struct lan743x_adapter *adapter, int offset, in lan743x_csr_write() argument
133 iowrite32(data, &adapter->csr.csr_address[offset]); in lan743x_csr_write()
136 #define LAN743X_CSR_READ_OP(offset) lan743x_csr_read(adapter, offset)
138 static int lan743x_csr_light_reset(struct lan743x_adapter *adapter) in lan743x_csr_light_reset() argument
142 data = lan743x_csr_read(adapter, HW_CFG); in lan743x_csr_light_reset()
144 lan743x_csr_write(adapter, HW_CFG, data); in lan743x_csr_light_reset()
150 static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter, in lan743x_csr_wait_for_bit_atomic() argument
162 static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter, in lan743x_csr_wait_for_bit() argument
174 static int lan743x_csr_init(struct lan743x_adapter *adapter) in lan743x_csr_init() argument
176 struct lan743x_csr *csr = &adapter->csr; in lan743x_csr_init()
179 bar_start = pci_resource_start(adapter->pdev, 0); in lan743x_csr_init()
180 bar_length = pci_resource_len(adapter->pdev, 0); in lan743x_csr_init()
181 csr->csr_address = devm_ioremap(&adapter->pdev->dev, in lan743x_csr_init()
186 csr->id_rev = lan743x_csr_read(adapter, ID_REV); in lan743x_csr_init()
187 csr->fpga_rev = lan743x_csr_read(adapter, FPGA_REV); in lan743x_csr_init()
188 netif_info(adapter, probe, adapter->netdev, in lan743x_csr_init()
206 return lan743x_csr_light_reset(adapter); in lan743x_csr_init()
209 static void lan743x_intr_software_isr(struct lan743x_adapter *adapter) in lan743x_intr_software_isr() argument
211 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_software_isr()
214 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_SW_GP_); in lan743x_intr_software_isr()
222 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_isr() local
225 lan743x_csr_read(adapter, INT_EN_SET); in lan743x_tx_isr()
227 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_tx_isr()
237 dmac_int_sts = lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_tx_isr()
241 dmac_int_en = lan743x_csr_read(adapter, in lan743x_tx_isr()
256 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_isr()
263 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_isr() local
267 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_rx_isr()
277 dmac_int_sts = lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_rx_isr()
281 dmac_int_en = lan743x_csr_read(adapter, in lan743x_rx_isr()
296 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_isr()
303 struct lan743x_adapter *adapter = context; in lan743x_intr_shared_isr() local
312 lan743x_rx_isr(&adapter->rx[channel], in lan743x_intr_shared_isr()
319 for (channel = 0; channel < adapter->used_tx_channels; in lan743x_intr_shared_isr()
324 lan743x_tx_isr(&adapter->tx[channel], in lan743x_intr_shared_isr()
332 lan743x_intr_software_isr(adapter); in lan743x_intr_shared_isr()
336 lan743x_ptp_isr(adapter); in lan743x_intr_shared_isr()
341 lan743x_csr_write(adapter, INT_EN_CLR, int_sts); in lan743x_intr_shared_isr()
347 struct lan743x_adapter *adapter = vector->adapter; in lan743x_intr_entry_isr() local
353 int_sts = lan743x_csr_read(adapter, INT_STS); in lan743x_intr_entry_isr()
357 int_sts = lan743x_csr_read(adapter, INT_STS_R2C); in lan743x_intr_entry_isr()
368 lan743x_csr_write(adapter, in lan743x_intr_entry_isr()
374 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_MAS_); in lan743x_intr_entry_isr()
377 int_enables = lan743x_csr_read(adapter, INT_EN_SET); in lan743x_intr_entry_isr()
391 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_intr_entry_isr()
399 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_MAS_); in lan743x_intr_entry_isr()
403 lan743x_csr_write(adapter, in lan743x_intr_entry_isr()
410 static int lan743x_intr_test_isr(struct lan743x_adapter *adapter) in lan743x_intr_test_isr() argument
412 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_test_isr()
418 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
419 lan743x_csr_write(adapter, INT_SET, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
426 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_SW_GP_); in lan743x_intr_test_isr()
431 static int lan743x_intr_register_isr(struct lan743x_adapter *adapter, in lan743x_intr_register_isr() argument
437 struct lan743x_vector *vector = &adapter->intr.vector_list in lan743x_intr_register_isr()
441 vector->adapter = adapter; in lan743x_intr_register_isr()
461 static void lan743x_intr_unregister_isr(struct lan743x_adapter *adapter, in lan743x_intr_unregister_isr() argument
464 struct lan743x_vector *vector = &adapter->intr.vector_list in lan743x_intr_unregister_isr()
474 static u32 lan743x_intr_get_vector_flags(struct lan743x_adapter *adapter, in lan743x_intr_get_vector_flags() argument
479 for (index = 0; index < adapter->max_vector_count; index++) { in lan743x_intr_get_vector_flags()
480 if (adapter->intr.vector_list[index].int_mask & int_mask) in lan743x_intr_get_vector_flags()
481 return adapter->intr.vector_list[index].flags; in lan743x_intr_get_vector_flags()
486 static void lan743x_intr_close(struct lan743x_adapter *adapter) in lan743x_intr_close() argument
488 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_close()
491 lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_MAS_); in lan743x_intr_close()
492 if (adapter->is_pci11x1x) in lan743x_intr_close()
493 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x0000FFFF); in lan743x_intr_close()
495 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x000000FF); in lan743x_intr_close()
499 lan743x_intr_unregister_isr(adapter, index); in lan743x_intr_close()
505 pci_disable_msi(adapter->pdev); in lan743x_intr_close()
510 pci_disable_msix(adapter->pdev); in lan743x_intr_close()
515 static int lan743x_intr_open(struct lan743x_adapter *adapter) in lan743x_intr_open() argument
518 struct lan743x_intr *intr = &adapter->intr; in lan743x_intr_open()
531 max_vector_count = adapter->max_vector_count; in lan743x_intr_open()
536 used_tx_channels = adapter->used_tx_channels; in lan743x_intr_open()
537 ret = pci_enable_msix_range(adapter->pdev, in lan743x_intr_open()
549 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
556 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_intr_open()
557 if (!pci_enable_msi(adapter->pdev)) { in lan743x_intr_open()
562 adapter->pdev->irq; in lan743x_intr_open()
563 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
575 netif_info(adapter, ifup, adapter->netdev, in lan743x_intr_open()
580 lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0xFFFFFFFF); in lan743x_intr_open()
583 lan743x_csr_write(adapter, INT_VEC_MAP0, 0x00000000); in lan743x_intr_open()
584 lan743x_csr_write(adapter, INT_VEC_MAP1, 0x00000000); in lan743x_intr_open()
585 lan743x_csr_write(adapter, INT_VEC_MAP2, 0x00000000); in lan743x_intr_open()
600 if (adapter->csr.flags & LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR) { in lan743x_intr_open()
611 ret = lan743x_intr_register_isr(adapter, 0, flags, in lan743x_intr_open()
614 lan743x_intr_shared_isr, adapter); in lan743x_intr_open()
620 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
623 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_intr_open()
624 lan743x_csr_write(adapter, INT_MOD_CFG0, LAN743X_INT_MOD); in lan743x_intr_open()
625 lan743x_csr_write(adapter, INT_MOD_CFG1, LAN743X_INT_MOD); in lan743x_intr_open()
626 lan743x_csr_write(adapter, INT_MOD_CFG2, LAN743X_INT_MOD); in lan743x_intr_open()
627 lan743x_csr_write(adapter, INT_MOD_CFG3, LAN743X_INT_MOD); in lan743x_intr_open()
628 lan743x_csr_write(adapter, INT_MOD_CFG4, LAN743X_INT_MOD); in lan743x_intr_open()
629 lan743x_csr_write(adapter, INT_MOD_CFG5, LAN743X_INT_MOD); in lan743x_intr_open()
630 lan743x_csr_write(adapter, INT_MOD_CFG6, LAN743X_INT_MOD); in lan743x_intr_open()
631 lan743x_csr_write(adapter, INT_MOD_CFG7, LAN743X_INT_MOD); in lan743x_intr_open()
632 if (adapter->is_pci11x1x) { in lan743x_intr_open()
633 lan743x_csr_write(adapter, INT_MOD_CFG8, LAN743X_INT_MOD); in lan743x_intr_open()
634 lan743x_csr_write(adapter, INT_MOD_CFG9, LAN743X_INT_MOD); in lan743x_intr_open()
635 lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00007654); in lan743x_intr_open()
636 lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00003210); in lan743x_intr_open()
638 lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00005432); in lan743x_intr_open()
639 lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00000001); in lan743x_intr_open()
641 lan743x_csr_write(adapter, INT_MOD_MAP2, 0x00FFFFFF); in lan743x_intr_open()
645 lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_MAS_); in lan743x_intr_open()
646 ret = lan743x_intr_test_isr(adapter); in lan743x_intr_open()
662 if (adapter->csr.flags & in lan743x_intr_open()
676 lan743x_csr_write(adapter, INT_VEC_MAP1, int_vec_map1); in lan743x_intr_open()
680 ret = lan743x_intr_register_isr(adapter, vector, flags, in lan743x_intr_open()
682 &adapter->tx[index]); in lan743x_intr_open()
688 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
706 if (adapter->csr.flags & in lan743x_intr_open()
720 lan743x_csr_write(adapter, INT_VEC_MAP0, int_vec_map0); in lan743x_intr_open()
724 lan743x_csr_write(adapter, INT_VEC_EN_AUTO_CLR, in lan743x_intr_open()
730 ret = lan743x_intr_register_isr(adapter, vector, flags, in lan743x_intr_open()
732 &adapter->rx[index]); in lan743x_intr_open()
737 lan743x_csr_write(adapter, INT_VEC_EN_SET, in lan743x_intr_open()
744 lan743x_intr_close(adapter); in lan743x_intr_open()
748 static int lan743x_dp_write(struct lan743x_adapter *adapter, in lan743x_dp_write() argument
754 if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, DP_SEL_DPRDY_, in lan743x_dp_write()
757 dp_sel = lan743x_csr_read(adapter, DP_SEL); in lan743x_dp_write()
760 lan743x_csr_write(adapter, DP_SEL, dp_sel); in lan743x_dp_write()
763 lan743x_csr_write(adapter, DP_ADDR, addr + i); in lan743x_dp_write()
764 lan743x_csr_write(adapter, DP_DATA_0, buf[i]); in lan743x_dp_write()
765 lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_); in lan743x_dp_write()
766 if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, in lan743x_dp_write()
793 static int lan743x_mac_mii_wait_till_not_busy(struct lan743x_adapter *adapter) in lan743x_mac_mii_wait_till_not_busy() argument
803 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_read_c22() local
808 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c22()
814 lan743x_csr_write(adapter, MAC_MII_ACC, mii_access); in lan743x_mdiobus_read_c22()
815 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c22()
819 val = lan743x_csr_read(adapter, MAC_MII_DATA); in lan743x_mdiobus_read_c22()
826 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_write_c22() local
831 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c22()
835 lan743x_csr_write(adapter, MAC_MII_DATA, val); in lan743x_mdiobus_write_c22()
839 lan743x_csr_write(adapter, MAC_MII_ACC, mii_access); in lan743x_mdiobus_write_c22()
840 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c22()
868 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_read_c45() local
873 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
878 lan743x_csr_write(adapter, MAC_MII_DATA, index); in lan743x_mdiobus_read_c45()
881 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_read_c45()
882 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
889 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_read_c45()
890 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_read_c45()
894 ret = lan743x_csr_read(adapter, MAC_MII_DATA); in lan743x_mdiobus_read_c45()
901 struct lan743x_adapter *adapter = bus->priv; in lan743x_mdiobus_write_c45() local
906 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
911 lan743x_csr_write(adapter, MAC_MII_DATA, (u32)index); in lan743x_mdiobus_write_c45()
914 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_write_c45()
915 ret = lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
920 lan743x_csr_write(adapter, MAC_MII_DATA, (u32)regval); in lan743x_mdiobus_write_c45()
923 lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access); in lan743x_mdiobus_write_c45()
925 return lan743x_mac_mii_wait_till_not_busy(adapter); in lan743x_mdiobus_write_c45()
928 static int lan743x_sgmii_wait_till_not_busy(struct lan743x_adapter *adapter) in lan743x_sgmii_wait_till_not_busy() argument
936 netif_err(adapter, drv, adapter->netdev, in lan743x_sgmii_wait_till_not_busy()
942 int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr) in lan743x_sgmii_read() argument
949 netif_err(adapter, probe, adapter->netdev, in lan743x_sgmii_read()
954 mutex_lock(&adapter->sgmii_rw_lock); in lan743x_sgmii_read()
958 lan743x_csr_write(adapter, SGMII_ACC, mmd_access); in lan743x_sgmii_read()
959 ret = lan743x_sgmii_wait_till_not_busy(adapter); in lan743x_sgmii_read()
963 val = lan743x_csr_read(adapter, SGMII_DATA); in lan743x_sgmii_read()
967 mutex_unlock(&adapter->sgmii_rw_lock); in lan743x_sgmii_read()
972 static int lan743x_sgmii_write(struct lan743x_adapter *adapter, in lan743x_sgmii_write() argument
979 netif_err(adapter, probe, adapter->netdev, in lan743x_sgmii_write()
983 mutex_lock(&adapter->sgmii_rw_lock); in lan743x_sgmii_write()
985 lan743x_csr_write(adapter, SGMII_DATA, (u32)(val & SGMII_DATA_MASK_)); in lan743x_sgmii_write()
989 lan743x_csr_write(adapter, SGMII_ACC, mmd_access); in lan743x_sgmii_write()
990 ret = lan743x_sgmii_wait_till_not_busy(adapter); in lan743x_sgmii_write()
991 mutex_unlock(&adapter->sgmii_rw_lock); in lan743x_sgmii_write()
1032 static int lan743x_sgmii_mpll_set(struct lan743x_adapter *adapter, in lan743x_sgmii_mpll_set() argument
1040 mpllctrl0 = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1056 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1061 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1066 return lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_sgmii_mpll_set()
1070 static int lan743x_sgmii_2_5G_mode_set(struct lan743x_adapter *adapter, in lan743x_sgmii_2_5G_mode_set() argument
1074 return lan743x_sgmii_mpll_set(adapter, in lan743x_sgmii_2_5G_mode_set()
1077 return lan743x_sgmii_mpll_set(adapter, in lan743x_sgmii_2_5G_mode_set()
1081 static int lan743x_serdes_clock_and_aneg_update(struct lan743x_adapter *adapter) in lan743x_serdes_clock_and_aneg_update() argument
1083 enum lan743x_sgmii_lsd lsd = adapter->sgmii_lsd; in lan743x_serdes_clock_and_aneg_update()
1091 ret = lan743x_sgmii_2_5G_mode_set(adapter, true); in lan743x_serdes_clock_and_aneg_update()
1094 ret = lan743x_sgmii_2_5G_mode_set(adapter, false); in lan743x_serdes_clock_and_aneg_update()
1099 mii_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); in lan743x_serdes_clock_and_aneg_update()
1103 an_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, VR_MII_AN_CTRL); in lan743x_serdes_clock_and_aneg_update()
1107 dgt_ctrl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_serdes_clock_and_aneg_update()
1123 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_serdes_clock_and_aneg_update()
1134 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, in lan743x_serdes_clock_and_aneg_update()
1139 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_serdes_clock_and_aneg_update()
1144 return lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, in lan743x_serdes_clock_and_aneg_update()
1148 static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state) in lan743x_pcs_seq_state() argument
1154 dig_sts = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, in lan743x_pcs_seq_state()
1168 static int lan743x_pcs_power_reset(struct lan743x_adapter *adapter) in lan743x_pcs_power_reset() argument
1174 mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); in lan743x_pcs_power_reset()
1179 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); in lan743x_pcs_power_reset()
1183 ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN); in lan743x_pcs_power_reset()
1189 ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); in lan743x_pcs_power_reset()
1193 return lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP); in lan743x_pcs_power_reset()
1196 static void lan743x_mac_set_address(struct lan743x_adapter *adapter, in lan743x_mac_set_address() argument
1207 lan743x_csr_write(adapter, MAC_RX_ADDRL, addr_lo); in lan743x_mac_set_address()
1208 lan743x_csr_write(adapter, MAC_RX_ADDRH, addr_hi); in lan743x_mac_set_address()
1210 ether_addr_copy(adapter->mac_address, addr); in lan743x_mac_set_address()
1211 netif_info(adapter, drv, adapter->netdev, in lan743x_mac_set_address()
1215 static int lan743x_mac_init(struct lan743x_adapter *adapter) in lan743x_mac_init() argument
1223 netdev = adapter->netdev; in lan743x_mac_init()
1226 data = lan743x_csr_read(adapter, MAC_CR); in lan743x_mac_init()
1229 lan743x_csr_write(adapter, MAC_CR, data); in lan743x_mac_init()
1231 if (!is_valid_ether_addr(adapter->mac_address)) { in lan743x_mac_init()
1232 mac_addr_hi = lan743x_csr_read(adapter, MAC_RX_ADDRH); in lan743x_mac_init()
1233 mac_addr_lo = lan743x_csr_read(adapter, MAC_RX_ADDRL); in lan743x_mac_init()
1234 adapter->mac_address[0] = mac_addr_lo & 0xFF; in lan743x_mac_init()
1235 adapter->mac_address[1] = (mac_addr_lo >> 8) & 0xFF; in lan743x_mac_init()
1236 adapter->mac_address[2] = (mac_addr_lo >> 16) & 0xFF; in lan743x_mac_init()
1237 adapter->mac_address[3] = (mac_addr_lo >> 24) & 0xFF; in lan743x_mac_init()
1238 adapter->mac_address[4] = mac_addr_hi & 0xFF; in lan743x_mac_init()
1239 adapter->mac_address[5] = (mac_addr_hi >> 8) & 0xFF; in lan743x_mac_init()
1244 } else if (!is_valid_ether_addr(adapter->mac_address)) { in lan743x_mac_init()
1249 eth_random_addr(adapter->mac_address); in lan743x_mac_init()
1251 lan743x_mac_set_address(adapter, adapter->mac_address); in lan743x_mac_init()
1252 eth_hw_addr_set(netdev, adapter->mac_address); in lan743x_mac_init()
1257 static int lan743x_mac_open(struct lan743x_adapter *adapter) in lan743x_mac_open() argument
1261 temp = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_open()
1262 lan743x_csr_write(adapter, MAC_RX, temp | MAC_RX_RXEN_); in lan743x_mac_open()
1263 temp = lan743x_csr_read(adapter, MAC_TX); in lan743x_mac_open()
1264 lan743x_csr_write(adapter, MAC_TX, temp | MAC_TX_TXEN_); in lan743x_mac_open()
1268 static void lan743x_mac_close(struct lan743x_adapter *adapter) in lan743x_mac_close() argument
1272 temp = lan743x_csr_read(adapter, MAC_TX); in lan743x_mac_close()
1274 lan743x_csr_write(adapter, MAC_TX, temp); in lan743x_mac_close()
1275 lan743x_csr_wait_for_bit(adapter, MAC_TX, MAC_TX_TXD_, in lan743x_mac_close()
1278 temp = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_close()
1280 lan743x_csr_write(adapter, MAC_RX, temp); in lan743x_mac_close()
1281 lan743x_csr_wait_for_bit(adapter, MAC_RX, MAC_RX_RXD_, in lan743x_mac_close()
1285 void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter, in lan743x_mac_flow_ctrl_set_enables() argument
1298 lan743x_csr_write(adapter, MAC_FLOW, flow_setting); in lan743x_mac_flow_ctrl_set_enables()
1301 static int lan743x_mac_set_mtu(struct lan743x_adapter *adapter, int new_mtu) in lan743x_mac_set_mtu() argument
1306 mac_rx = lan743x_csr_read(adapter, MAC_RX); in lan743x_mac_set_mtu()
1310 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1314 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1315 lan743x_csr_wait_for_bit(adapter, MAC_RX, MAC_RX_RXD_, in lan743x_mac_set_mtu()
1317 lan743x_csr_write(adapter, MAC_RX, mac_rx | MAC_RX_RXD_); in lan743x_mac_set_mtu()
1323 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1327 lan743x_csr_write(adapter, MAC_RX, mac_rx); in lan743x_mac_set_mtu()
1333 static int lan743x_phy_reset(struct lan743x_adapter *adapter) in lan743x_phy_reset() argument
1339 data = lan743x_csr_read(adapter, PMT_CTL); in lan743x_phy_reset()
1341 lan743x_csr_write(adapter, PMT_CTL, data); in lan743x_phy_reset()
1349 static int lan743x_phy_init(struct lan743x_adapter *adapter) in lan743x_phy_init() argument
1351 return lan743x_phy_reset(adapter); in lan743x_phy_init()
1354 static void lan743x_phy_interface_select(struct lan743x_adapter *adapter) in lan743x_phy_interface_select() argument
1359 data = lan743x_csr_read(adapter, MAC_CR); in lan743x_phy_interface_select()
1360 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_; in lan743x_phy_interface_select()
1362 if (adapter->is_pci11x1x && adapter->is_sgmii_en) in lan743x_phy_interface_select()
1363 adapter->phy_interface = PHY_INTERFACE_MODE_SGMII; in lan743x_phy_interface_select()
1365 adapter->phy_interface = PHY_INTERFACE_MODE_GMII; in lan743x_phy_interface_select()
1367 adapter->phy_interface = PHY_INTERFACE_MODE_MII; in lan743x_phy_interface_select()
1369 adapter->phy_interface = PHY_INTERFACE_MODE_RGMII; in lan743x_phy_interface_select()
1371 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phy_interface_select()
1372 "selected phy interface: 0x%X\n", adapter->phy_interface); in lan743x_phy_interface_select()
1375 static void lan743x_rfe_open(struct lan743x_adapter *adapter) in lan743x_rfe_open() argument
1377 lan743x_csr_write(adapter, RFE_RSS_CFG, in lan743x_rfe_open()
1393 static void lan743x_rfe_update_mac_address(struct lan743x_adapter *adapter) in lan743x_rfe_update_mac_address() argument
1400 mac_addr = adapter->mac_address; in lan743x_rfe_update_mac_address()
1408 lan743x_csr_write(adapter, RFE_ADDR_FILT_LO(0), mac_addr_lo); in lan743x_rfe_update_mac_address()
1409 lan743x_csr_write(adapter, RFE_ADDR_FILT_HI(0), in lan743x_rfe_update_mac_address()
1413 static void lan743x_rfe_set_multicast(struct lan743x_adapter *adapter) in lan743x_rfe_set_multicast() argument
1415 struct net_device *netdev = adapter->netdev; in lan743x_rfe_set_multicast()
1420 rfctl = lan743x_csr_read(adapter, RFE_CTL); in lan743x_rfe_set_multicast()
1444 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1450 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1455 lan743x_csr_write(adapter, in lan743x_rfe_set_multicast()
1467 lan743x_dp_write(adapter, DP_SEL_RFE_RAM, in lan743x_rfe_set_multicast()
1470 lan743x_csr_write(adapter, RFE_CTL, rfctl); in lan743x_rfe_set_multicast()
1473 static int lan743x_dmac_init(struct lan743x_adapter *adapter) in lan743x_dmac_init() argument
1477 lan743x_csr_write(adapter, DMAC_CMD, DMAC_CMD_SWR_); in lan743x_dmac_init()
1478 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, DMAC_CMD_SWR_, in lan743x_dmac_init()
1496 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_dmac_init()
1500 lan743x_csr_write(adapter, DMAC_CFG, data); in lan743x_dmac_init()
1508 lan743x_csr_write(adapter, DMAC_COAL_CFG, data); in lan743x_dmac_init()
1511 lan743x_csr_write(adapter, DMAC_OBFF_CFG, data); in lan743x_dmac_init()
1515 static int lan743x_dmac_tx_get_state(struct lan743x_adapter *adapter, in lan743x_dmac_tx_get_state() argument
1520 dmac_cmd = lan743x_csr_read(adapter, DMAC_CMD); in lan743x_dmac_tx_get_state()
1527 static int lan743x_dmac_tx_wait_till_stopped(struct lan743x_adapter *adapter, in lan743x_dmac_tx_wait_till_stopped() argument
1534 ((result = lan743x_dmac_tx_get_state(adapter, tx_channel)) == in lan743x_dmac_tx_wait_till_stopped()
1544 static int lan743x_dmac_rx_get_state(struct lan743x_adapter *adapter, in lan743x_dmac_rx_get_state() argument
1549 dmac_cmd = lan743x_csr_read(adapter, DMAC_CMD); in lan743x_dmac_rx_get_state()
1556 static int lan743x_dmac_rx_wait_till_stopped(struct lan743x_adapter *adapter, in lan743x_dmac_rx_wait_till_stopped() argument
1563 ((result = lan743x_dmac_rx_get_state(adapter, rx_channel)) == in lan743x_dmac_rx_wait_till_stopped()
1597 dma_unmap_page(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1602 dma_unmap_single(&tx->adapter->pdev->dev, in lan743x_tx_release_desc()
1619 lan743x_ptp_unrequest_tx_timestamp(tx->adapter); in lan743x_tx_release_desc()
1624 lan743x_ptp_tx_timestamp_skb(tx->adapter, in lan743x_tx_release_desc()
1691 static void lan743x_rx_cfg_b_tstamp_config(struct lan743x_adapter *adapter, in lan743x_rx_cfg_b_tstamp_config() argument
1699 channel_number = adapter->rx[index].channel_number; in lan743x_rx_cfg_b_tstamp_config()
1700 data = lan743x_csr_read(adapter, RX_CFG_B(channel_number)); in lan743x_rx_cfg_b_tstamp_config()
1703 lan743x_csr_write(adapter, RX_CFG_B(channel_number), in lan743x_rx_cfg_b_tstamp_config()
1708 int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter, in lan743x_rx_set_tstamp_mode() argument
1715 lan743x_rx_cfg_b_tstamp_config(adapter, in lan743x_rx_set_tstamp_mode()
1717 data = lan743x_csr_read(adapter, PTP_RX_TS_CFG); in lan743x_rx_set_tstamp_mode()
1719 lan743x_csr_write(adapter, PTP_RX_TS_CFG, data); in lan743x_rx_set_tstamp_mode()
1722 lan743x_rx_cfg_b_tstamp_config(adapter, in lan743x_rx_set_tstamp_mode()
1726 lan743x_rx_cfg_b_tstamp_config(adapter, in lan743x_rx_set_tstamp_mode()
1761 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_start() local
1762 struct device *dev = &adapter->pdev->dev; in lan743x_tx_frame_start()
1853 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_add_fragment() local
1854 struct device *dev = &adapter->pdev->dev; in lan743x_tx_frame_add_fragment()
1919 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_frame_end() local
1949 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_frame_end()
1981 txq = netdev_get_tx_queue(tx->adapter->netdev, in lan743x_tx_xmit_frame()
1991 (lan743x_ptp_request_tx_timestamp(tx->adapter))) { in lan743x_tx_xmit_frame()
2048 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_napi_poll() local
2054 lan743x_csr_read(adapter, DMAC_INT_STS); in lan743x_tx_napi_poll()
2056 lan743x_csr_write(adapter, DMAC_INT_STS, ioc_bit); in lan743x_tx_napi_poll()
2061 txq = netdev_get_tx_queue(adapter->netdev, tx->channel_number); in lan743x_tx_napi_poll()
2079 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_napi_poll()
2081 lan743x_csr_read(adapter, INT_STS); in lan743x_tx_napi_poll()
2090 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2100 dma_free_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_cleanup()
2122 if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2124 dev_warn(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2133 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2151 cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, in lan743x_tx_ring_init()
2175 struct lan743x_adapter *adapter = tx->adapter; in lan743x_tx_close() local
2177 lan743x_csr_write(adapter, in lan743x_tx_close()
2180 lan743x_dmac_tx_wait_till_stopped(adapter, tx->channel_number); in lan743x_tx_close()
2182 lan743x_csr_write(adapter, in lan743x_tx_close()
2185 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_tx_close()
2190 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_close()
2192 lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL, in lan743x_tx_close()
2205 struct lan743x_adapter *adapter = NULL; in lan743x_tx_open() local
2209 adapter = tx->adapter; in lan743x_tx_open()
2215 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_open()
2217 lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL, in lan743x_tx_open()
2222 lan743x_csr_write(adapter, FCT_TX_CTL, in lan743x_tx_open()
2226 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_tx_open()
2228 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, in lan743x_tx_open()
2233 lan743x_csr_write(adapter, in lan743x_tx_open()
2236 lan743x_csr_write(adapter, in lan743x_tx_open()
2241 data = lan743x_csr_read(adapter, TX_CFG_B(tx->channel_number)); in lan743x_tx_open()
2244 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_tx_open()
2246 lan743x_csr_write(adapter, TX_CFG_B(tx->channel_number), data); in lan743x_tx_open()
2250 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_tx_open()
2256 lan743x_csr_write(adapter, TX_CFG_A(tx->channel_number), data); in lan743x_tx_open()
2259 lan743x_csr_write(adapter, in lan743x_tx_open()
2262 lan743x_csr_write(adapter, in lan743x_tx_open()
2267 tx->last_head = lan743x_csr_read(adapter, TX_HEAD(tx->channel_number)); in lan743x_tx_open()
2271 lan743x_csr_write(adapter, TX_TAIL(tx->channel_number), in lan743x_tx_open()
2273 tx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_tx_open()
2276 netif_napi_add_tx_weight(adapter->netdev, in lan743x_tx_open()
2290 lan743x_csr_write(adapter, TX_CFG_C(tx->channel_number), data); in lan743x_tx_open()
2293 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_tx_open()
2295 lan743x_csr_write(adapter, DMAC_INT_EN_SET, in lan743x_tx_open()
2299 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_tx_open()
2313 lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), in lan743x_rx_update_tail()
2320 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_init_ring_element()
2321 struct device *dev = &rx->adapter->pdev->dev; in lan743x_rx_init_ring_element()
2402 dma_unmap_single(&rx->adapter->pdev->dev, in lan743x_rx_release_ring_element()
2436 struct net_device *netdev = rx->adapter->netdev; in lan743x_rx_process_buffer()
2557 rx->adapter->netdev); in lan743x_rx_process_buffer()
2558 if (rx->adapter->netdev->features & NETIF_F_RXCSUM) { in lan743x_rx_process_buffer()
2580 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_napi_poll() local
2587 lan743x_csr_write(adapter, DMAC_INT_STS, in lan743x_rx_napi_poll()
2608 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_napi_poll()
2613 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_napi_poll()
2629 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2640 dma_free_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_cleanup()
2669 if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2671 dev_warn(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2680 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2698 cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, in lan743x_rx_ring_init()
2722 netif_warn(rx->adapter, ifup, rx->adapter->netdev, in lan743x_rx_ring_init()
2731 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_close() local
2733 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_close()
2735 lan743x_csr_wait_for_bit(adapter, FCT_RX_CTL, in lan743x_rx_close()
2739 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_close()
2741 lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number); in lan743x_rx_close()
2743 lan743x_csr_write(adapter, DMAC_INT_EN_CLR, in lan743x_rx_close()
2745 lan743x_csr_write(adapter, INT_EN_CLR, in lan743x_rx_close()
2756 struct lan743x_adapter *adapter = rx->adapter; in lan743x_rx_open() local
2765 netif_napi_add(adapter->netdev, &rx->napi, lan743x_rx_napi_poll); in lan743x_rx_open()
2767 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_open()
2769 lan743x_csr_wait_for_bit(adapter, DMAC_CMD, in lan743x_rx_open()
2774 lan743x_csr_write(adapter, in lan743x_rx_open()
2777 lan743x_csr_write(adapter, in lan743x_rx_open()
2782 lan743x_csr_write(adapter, in lan743x_rx_open()
2785 lan743x_csr_write(adapter, in lan743x_rx_open()
2789 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) { in lan743x_rx_open()
2797 lan743x_csr_write(adapter, in lan743x_rx_open()
2801 data = lan743x_csr_read(adapter, RX_CFG_B(rx->channel_number)); in lan743x_rx_open()
2809 if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) in lan743x_rx_open()
2812 lan743x_csr_write(adapter, RX_CFG_B(rx->channel_number), data); in lan743x_rx_open()
2813 rx->vector_flags = lan743x_intr_get_vector_flags(adapter, in lan743x_rx_open()
2827 lan743x_csr_write(adapter, RX_CFG_C(rx->channel_number), data); in lan743x_rx_open()
2830 lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), in lan743x_rx_open()
2832 rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number)); in lan743x_rx_open()
2840 lan743x_csr_write(adapter, INT_EN_SET, in lan743x_rx_open()
2842 lan743x_csr_write(adapter, DMAC_INT_STS, in lan743x_rx_open()
2844 lan743x_csr_write(adapter, DMAC_INT_EN_SET, in lan743x_rx_open()
2846 lan743x_csr_write(adapter, DMAC_CMD, in lan743x_rx_open()
2850 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_open()
2852 lan743x_csr_wait_for_bit(adapter, FCT_RX_CTL, in lan743x_rx_open()
2855 lan743x_csr_write(adapter, FCT_FLOW(rx->channel_number), in lan743x_rx_open()
2861 lan743x_csr_write(adapter, FCT_RX_CTL, in lan743x_rx_open()
2873 static int lan743x_phylink_sgmii_config(struct lan743x_adapter *adapter) in lan743x_phylink_sgmii_config() argument
2881 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_sgmii_config()
2886 adapter->sgmii_lsd = ret; in lan743x_phylink_sgmii_config()
2887 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_sgmii_config()
2888 "Link Speed Duplex (lsd) : 0x%X\n", adapter->sgmii_lsd); in lan743x_phylink_sgmii_config()
2891 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_phylink_sgmii_config()
2893 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_phylink_sgmii_config()
2895 ret = lan743x_serdes_clock_and_aneg_update(adapter); in lan743x_phylink_sgmii_config()
2897 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_sgmii_config()
2902 return lan743x_pcs_power_reset(adapter); in lan743x_phylink_sgmii_config()
2905 static int lan743x_phylink_1000basex_config(struct lan743x_adapter *adapter) in lan743x_phylink_1000basex_config() argument
2913 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_1000basex_config()
2918 adapter->sgmii_lsd = ret; in lan743x_phylink_1000basex_config()
2919 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_1000basex_config()
2920 "Link Speed Duplex (lsd) : 0x%X\n", adapter->sgmii_lsd); in lan743x_phylink_1000basex_config()
2923 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_phylink_1000basex_config()
2925 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_phylink_1000basex_config()
2927 ret = lan743x_serdes_clock_and_aneg_update(adapter); in lan743x_phylink_1000basex_config()
2929 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_1000basex_config()
2934 return lan743x_pcs_power_reset(adapter); in lan743x_phylink_1000basex_config()
2937 static int lan743x_phylink_2500basex_config(struct lan743x_adapter *adapter) in lan743x_phylink_2500basex_config() argument
2945 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_2500basex_config()
2950 adapter->sgmii_lsd = ret; in lan743x_phylink_2500basex_config()
2951 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_2500basex_config()
2952 "Link Speed Duplex (lsd) : 0x%X\n", adapter->sgmii_lsd); in lan743x_phylink_2500basex_config()
2955 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_phylink_2500basex_config()
2957 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_phylink_2500basex_config()
2959 ret = lan743x_serdes_clock_and_aneg_update(adapter); in lan743x_phylink_2500basex_config()
2961 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_2500basex_config()
2966 return lan743x_pcs_power_reset(adapter); in lan743x_phylink_2500basex_config()
2969 void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable) in lan743x_mac_eee_enable() argument
2973 mac_cr = lan743x_csr_read(adapter, MAC_CR); in lan743x_mac_eee_enable()
2978 lan743x_csr_write(adapter, MAC_CR, mac_cr); in lan743x_mac_eee_enable()
2986 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_phylink_mac_config() local
2991 ret = lan743x_phylink_2500basex_config(adapter); in lan743x_phylink_mac_config()
2993 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
2996 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3000 ret = lan743x_phylink_1000basex_config(adapter); in lan743x_phylink_mac_config()
3002 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3005 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3009 ret = lan743x_phylink_sgmii_config(adapter); in lan743x_phylink_mac_config()
3011 netif_err(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3014 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3018 netif_dbg(adapter, drv, adapter->netdev, in lan743x_phylink_mac_config()
3030 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_phylink_mac_link_down() local
3033 lan743x_mac_eee_enable(adapter, false); in lan743x_phylink_mac_link_down()
3044 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_phylink_mac_link_up() local
3048 mac_cr = lan743x_csr_read(adapter, MAC_CR); in lan743x_phylink_mac_link_up()
3060 lan743x_csr_write(adapter, MAC_CR, mac_cr); in lan743x_phylink_mac_link_up()
3062 lan743x_ptp_update_latency(adapter, speed); in lan743x_phylink_mac_link_up()
3071 lan743x_mac_flow_ctrl_set_enables(adapter, in lan743x_phylink_mac_link_up()
3076 lan743x_mac_eee_enable(adapter, phydev->enable_tx_lpi); in lan743x_phylink_mac_link_up()
3087 static int lan743x_phylink_create(struct lan743x_adapter *adapter) in lan743x_phylink_create() argument
3089 struct net_device *netdev = adapter->netdev; in lan743x_phylink_create()
3092 adapter->phylink_config.dev = &netdev->dev; in lan743x_phylink_create()
3093 adapter->phylink_config.type = PHYLINK_NETDEV; in lan743x_phylink_create()
3094 adapter->phylink_config.mac_managed_pm = false; in lan743x_phylink_create()
3096 adapter->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | in lan743x_phylink_create()
3099 lan743x_phy_interface_select(adapter); in lan743x_phylink_create()
3101 switch (adapter->phy_interface) { in lan743x_phylink_create()
3104 adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3106 adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3108 adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3109 adapter->phylink_config.mac_capabilities |= MAC_2500FD; in lan743x_phylink_create()
3113 adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3117 adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3120 phy_interface_set_rgmii(adapter->phylink_config.supported_interfaces); in lan743x_phylink_create()
3123 pl = phylink_create(&adapter->phylink_config, NULL, in lan743x_phylink_create()
3124 adapter->phy_interface, &lan743x_phylink_mac_ops); in lan743x_phylink_create()
3131 adapter->phylink = pl; in lan743x_phylink_create()
3144 static int lan743x_phylink_connect(struct lan743x_adapter *adapter) in lan743x_phylink_connect() argument
3146 struct device_node *dn = adapter->pdev->dev.of_node; in lan743x_phylink_connect()
3147 struct net_device *dev = adapter->netdev; in lan743x_phylink_connect()
3152 ret = phylink_of_phy_connect(adapter->phylink, dn, 0); in lan743x_phylink_connect()
3155 phydev = phy_find_first(adapter->mdiobus); in lan743x_phylink_connect()
3158 ret = phylink_connect_phy(adapter->phylink, phydev); in lan743x_phylink_connect()
3159 } else if (((adapter->csr.id_rev & ID_REV_ID_MASK_) == in lan743x_phylink_connect()
3160 ID_REV_ID_LAN7431_) || adapter->is_pci11x1x) { in lan743x_phylink_connect()
3164 caps = adapter->phylink_config.mac_capabilities; in lan743x_phylink_connect()
3176 ret = phylink_set_fixed_link(adapter->phylink, &state); in lan743x_phylink_connect()
3192 phylink_start(adapter->phylink); in lan743x_phylink_connect()
3197 static void lan743x_phylink_disconnect(struct lan743x_adapter *adapter) in lan743x_phylink_disconnect() argument
3199 phylink_stop(adapter->phylink); in lan743x_phylink_disconnect()
3200 phylink_disconnect_phy(adapter->phylink); in lan743x_phylink_disconnect()
3205 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_close() local
3208 for (index = 0; index < adapter->used_tx_channels; index++) in lan743x_netdev_close()
3209 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_close()
3212 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_close()
3214 lan743x_ptp_close(adapter); in lan743x_netdev_close()
3216 lan743x_phylink_disconnect(adapter); in lan743x_netdev_close()
3218 lan743x_mac_close(adapter); in lan743x_netdev_close()
3220 lan743x_intr_close(adapter); in lan743x_netdev_close()
3227 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_open() local
3231 ret = lan743x_intr_open(adapter); in lan743x_netdev_open()
3235 ret = lan743x_mac_open(adapter); in lan743x_netdev_open()
3239 ret = lan743x_phylink_connect(adapter); in lan743x_netdev_open()
3243 ret = lan743x_ptp_open(adapter); in lan743x_netdev_open()
3247 lan743x_rfe_open(adapter); in lan743x_netdev_open()
3250 ret = lan743x_rx_open(&adapter->rx[index]); in lan743x_netdev_open()
3255 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_netdev_open()
3256 ret = lan743x_tx_open(&adapter->tx[index]); in lan743x_netdev_open()
3265 if (adapter->netdev->phydev) { in lan743x_netdev_open()
3269 adapter->phy_wol_supported = wol.supported; in lan743x_netdev_open()
3270 adapter->phy_wolopts = wol.wolopts; in lan743x_netdev_open()
3277 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_netdev_open()
3278 if (adapter->tx[index].ring_cpu_ptr) in lan743x_netdev_open()
3279 lan743x_tx_close(&adapter->tx[index]); in lan743x_netdev_open()
3284 if (adapter->rx[index].ring_cpu_ptr) in lan743x_netdev_open()
3285 lan743x_rx_close(&adapter->rx[index]); in lan743x_netdev_open()
3287 lan743x_ptp_close(adapter); in lan743x_netdev_open()
3288 if (adapter->phylink) in lan743x_netdev_open()
3289 lan743x_phylink_disconnect(adapter); in lan743x_netdev_open()
3292 lan743x_mac_close(adapter); in lan743x_netdev_open()
3295 lan743x_intr_close(adapter); in lan743x_netdev_open()
3298 netif_warn(adapter, ifup, adapter->netdev, in lan743x_netdev_open()
3306 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_xmit_frame() local
3309 if (adapter->is_pci11x1x) in lan743x_netdev_xmit_frame()
3312 return lan743x_tx_xmit_frame(&adapter->tx[ch], skb); in lan743x_netdev_xmit_frame()
3318 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_ioctl() local
3325 return phylink_mii_ioctl(adapter->phylink, ifr, cmd); in lan743x_netdev_ioctl()
3330 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_set_multicast() local
3332 lan743x_rfe_set_multicast(adapter); in lan743x_netdev_set_multicast()
3337 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_change_mtu() local
3340 ret = lan743x_mac_set_mtu(adapter, new_mtu); in lan743x_netdev_change_mtu()
3349 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_get_stats64() local
3351 stats->rx_packets = lan743x_csr_read(adapter, STAT_RX_TOTAL_FRAMES); in lan743x_netdev_get_stats64()
3352 stats->tx_packets = lan743x_csr_read(adapter, STAT_TX_TOTAL_FRAMES); in lan743x_netdev_get_stats64()
3353 stats->rx_bytes = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3355 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3357 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3359 stats->tx_bytes = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3361 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3363 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3365 stats->rx_errors = lan743x_csr_read(adapter, STAT_RX_FCS_ERRORS) + in lan743x_netdev_get_stats64()
3366 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3368 lan743x_csr_read(adapter, STAT_RX_JABBER_ERRORS) + in lan743x_netdev_get_stats64()
3369 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3371 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3373 stats->tx_errors = lan743x_csr_read(adapter, STAT_TX_FCS_ERRORS) + in lan743x_netdev_get_stats64()
3374 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3376 lan743x_csr_read(adapter, STAT_TX_CARRIER_ERRORS); in lan743x_netdev_get_stats64()
3377 stats->rx_dropped = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3379 stats->tx_dropped = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3381 stats->multicast = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3383 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3385 stats->collisions = lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3387 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3389 lan743x_csr_read(adapter, in lan743x_netdev_get_stats64()
3396 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_netdev_set_mac_address() local
3404 lan743x_mac_set_address(adapter, sock_addr->sa_data); in lan743x_netdev_set_mac_address()
3405 lan743x_rfe_update_mac_address(adapter); in lan743x_netdev_set_mac_address()
3420 static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter) in lan743x_hardware_cleanup() argument
3422 lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF); in lan743x_hardware_cleanup()
3425 static void lan743x_mdiobus_cleanup(struct lan743x_adapter *adapter) in lan743x_mdiobus_cleanup() argument
3427 mdiobus_unregister(adapter->mdiobus); in lan743x_mdiobus_cleanup()
3430 static void lan743x_destroy_phylink(struct lan743x_adapter *adapter) in lan743x_destroy_phylink() argument
3432 phylink_destroy(adapter->phylink); in lan743x_destroy_phylink()
3433 adapter->phylink = NULL; in lan743x_destroy_phylink()
3436 static void lan743x_full_cleanup(struct lan743x_adapter *adapter) in lan743x_full_cleanup() argument
3438 unregister_netdev(adapter->netdev); in lan743x_full_cleanup()
3440 lan743x_destroy_phylink(adapter); in lan743x_full_cleanup()
3441 lan743x_mdiobus_cleanup(adapter); in lan743x_full_cleanup()
3442 lan743x_hardware_cleanup(adapter); in lan743x_full_cleanup()
3443 lan743x_pci_cleanup(adapter); in lan743x_full_cleanup()
3446 static void pci11x1x_set_rfe_rd_fifo_threshold(struct lan743x_adapter *adapter) in pci11x1x_set_rfe_rd_fifo_threshold() argument
3448 u16 rev = adapter->csr.id_rev & ID_REV_CHIP_REV_MASK_; in pci11x1x_set_rfe_rd_fifo_threshold()
3453 misc_ctl = lan743x_csr_read(adapter, MISC_CTL_0); in pci11x1x_set_rfe_rd_fifo_threshold()
3457 lan743x_csr_write(adapter, MISC_CTL_0, misc_ctl); in pci11x1x_set_rfe_rd_fifo_threshold()
3461 static int lan743x_hardware_init(struct lan743x_adapter *adapter, in lan743x_hardware_init() argument
3468 adapter->is_pci11x1x = is_pci11x1x_chip(adapter); in lan743x_hardware_init()
3469 if (adapter->is_pci11x1x) { in lan743x_hardware_init()
3470 adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS; in lan743x_hardware_init()
3471 adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS; in lan743x_hardware_init()
3472 adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT; in lan743x_hardware_init()
3473 pci11x1x_strap_get_status(adapter); in lan743x_hardware_init()
3474 spin_lock_init(&adapter->eth_syslock_spinlock); in lan743x_hardware_init()
3475 mutex_init(&adapter->sgmii_rw_lock); in lan743x_hardware_init()
3476 pci11x1x_set_rfe_rd_fifo_threshold(adapter); in lan743x_hardware_init()
3478 adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS; in lan743x_hardware_init()
3479 adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS; in lan743x_hardware_init()
3480 adapter->max_vector_count = LAN743X_MAX_VECTOR_COUNT; in lan743x_hardware_init()
3483 adapter->intr.irq = adapter->pdev->irq; in lan743x_hardware_init()
3484 lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF); in lan743x_hardware_init()
3486 ret = lan743x_gpio_init(adapter); in lan743x_hardware_init()
3490 ret = lan743x_mac_init(adapter); in lan743x_hardware_init()
3494 ret = lan743x_phy_init(adapter); in lan743x_hardware_init()
3498 ret = lan743x_ptp_init(adapter); in lan743x_hardware_init()
3502 lan743x_rfe_update_mac_address(adapter); in lan743x_hardware_init()
3504 ret = lan743x_dmac_init(adapter); in lan743x_hardware_init()
3509 adapter->rx[index].adapter = adapter; in lan743x_hardware_init()
3510 adapter->rx[index].channel_number = index; in lan743x_hardware_init()
3513 for (index = 0; index < adapter->used_tx_channels; index++) { in lan743x_hardware_init()
3514 tx = &adapter->tx[index]; in lan743x_hardware_init()
3515 tx->adapter = adapter; in lan743x_hardware_init()
3523 static int lan743x_mdiobus_init(struct lan743x_adapter *adapter) in lan743x_mdiobus_init() argument
3528 adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev); in lan743x_mdiobus_init()
3529 if (!(adapter->mdiobus)) { in lan743x_mdiobus_init()
3534 adapter->mdiobus->priv = (void *)adapter; in lan743x_mdiobus_init()
3535 if (adapter->is_pci11x1x) { in lan743x_mdiobus_init()
3536 if (adapter->is_sgmii_en) { in lan743x_mdiobus_init()
3537 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_mdiobus_init()
3540 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_mdiobus_init()
3541 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3543 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3544 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3545 adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45; in lan743x_mdiobus_init()
3546 adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45; in lan743x_mdiobus_init()
3547 adapter->mdiobus->name = "lan743x-mdiobus-c45"; in lan743x_mdiobus_init()
3548 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3551 sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); in lan743x_mdiobus_init()
3554 lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); in lan743x_mdiobus_init()
3555 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3558 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3559 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3560 adapter->mdiobus->name = "lan743x-mdiobus"; in lan743x_mdiobus_init()
3561 netif_dbg(adapter, drv, adapter->netdev, in lan743x_mdiobus_init()
3565 adapter->mdiobus->read = lan743x_mdiobus_read_c22; in lan743x_mdiobus_init()
3566 adapter->mdiobus->write = lan743x_mdiobus_write_c22; in lan743x_mdiobus_init()
3567 adapter->mdiobus->name = "lan743x-mdiobus"; in lan743x_mdiobus_init()
3568 netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n"); in lan743x_mdiobus_init()
3571 snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE, in lan743x_mdiobus_init()
3572 "pci-%s", pci_name(adapter->pdev)); in lan743x_mdiobus_init()
3574 if ((adapter->csr.id_rev & ID_REV_ID_MASK_) == ID_REV_ID_LAN7430_) in lan743x_mdiobus_init()
3576 adapter->mdiobus->phy_mask = ~(u32)BIT(1); in lan743x_mdiobus_init()
3579 ret = mdiobus_register(adapter->mdiobus); in lan743x_mdiobus_init()
3594 * initializes an adapter identified by a pci_dev structure.
3595 * The OS initialization, configuring of the adapter private structure,
3601 struct lan743x_adapter *adapter = NULL; in lan743x_pcidev_probe() local
3623 adapter = netdev_priv(netdev); in lan743x_pcidev_probe()
3624 adapter->netdev = netdev; in lan743x_pcidev_probe()
3625 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | in lan743x_pcidev_probe()
3630 of_get_mac_address(pdev->dev.of_node, adapter->mac_address); in lan743x_pcidev_probe()
3632 ret = lan743x_pci_init(adapter, pdev); in lan743x_pcidev_probe()
3636 ret = lan743x_csr_init(adapter); in lan743x_pcidev_probe()
3640 ret = lan743x_hardware_init(adapter, pdev); in lan743x_pcidev_probe()
3644 ret = lan743x_mdiobus_init(adapter); in lan743x_pcidev_probe()
3648 adapter->netdev->netdev_ops = &lan743x_netdev_ops; in lan743x_pcidev_probe()
3649 adapter->netdev->ethtool_ops = &lan743x_ethtool_ops; in lan743x_pcidev_probe()
3650 adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO | in lan743x_pcidev_probe()
3652 adapter->netdev->hw_features = adapter->netdev->features; in lan743x_pcidev_probe()
3654 ret = lan743x_phylink_create(adapter); in lan743x_pcidev_probe()
3656 netif_err(adapter, probe, netdev, in lan743x_pcidev_probe()
3661 ret = register_netdev(adapter->netdev); in lan743x_pcidev_probe()
3667 lan743x_destroy_phylink(adapter); in lan743x_pcidev_probe()
3670 lan743x_mdiobus_cleanup(adapter); in lan743x_pcidev_probe()
3673 lan743x_hardware_cleanup(adapter); in lan743x_pcidev_probe()
3676 lan743x_pci_cleanup(adapter); in lan743x_pcidev_probe()
3695 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pcidev_remove() local
3697 lan743x_full_cleanup(adapter); in lan743x_pcidev_remove()
3703 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pcidev_shutdown() local
3721 lan743x_hardware_cleanup(adapter); in lan743x_pcidev_shutdown()
3730 static void lan743x_pm_set_wol(struct lan743x_adapter *adapter) in lan743x_pm_set_wol() argument
3743 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), 0); in lan743x_pm_set_wol()
3746 pmtctl = lan743x_csr_read(adapter, PMT_CTL); in lan743x_pm_set_wol()
3752 macrx = lan743x_csr_read(adapter, MAC_RX); in lan743x_pm_set_wol()
3759 if (adapter->phy_wolopts) in lan743x_pm_set_wol()
3762 if (adapter->wolopts & WAKE_MAGIC) { in lan743x_pm_set_wol()
3767 if (adapter->wolopts & WAKE_UCAST) { in lan743x_pm_set_wol()
3773 if (adapter->wolopts & WAKE_BCAST) { in lan743x_pm_set_wol()
3779 if (adapter->wolopts & WAKE_MCAST) { in lan743x_pm_set_wol()
3782 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3786 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 7); in lan743x_pm_set_wol()
3787 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3788 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3789 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3794 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3798 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 3); in lan743x_pm_set_wol()
3799 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3800 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3801 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3809 if (adapter->wolopts & WAKE_ARP) { in lan743x_pm_set_wol()
3814 lan743x_csr_write(adapter, MAC_WUF_CFG(mask_index), in lan743x_pm_set_wol()
3818 lan743x_csr_write(adapter, MAC_WUF_MASK0(mask_index), 0x3000); in lan743x_pm_set_wol()
3819 lan743x_csr_write(adapter, MAC_WUF_MASK1(mask_index), 0); in lan743x_pm_set_wol()
3820 lan743x_csr_write(adapter, MAC_WUF_MASK2(mask_index), 0); in lan743x_pm_set_wol()
3821 lan743x_csr_write(adapter, MAC_WUF_MASK3(mask_index), 0); in lan743x_pm_set_wol()
3830 if (adapter->wolopts & WAKE_MAGICSECURE) { in lan743x_pm_set_wol()
3831 sopass = *(u32 *)adapter->sopass; in lan743x_pm_set_wol()
3832 lan743x_csr_write(adapter, MAC_MP_SO_LO, sopass); in lan743x_pm_set_wol()
3833 sopass = *(u16 *)&adapter->sopass[4]; in lan743x_pm_set_wol()
3834 lan743x_csr_write(adapter, MAC_MP_SO_HI, sopass); in lan743x_pm_set_wol()
3838 lan743x_csr_write(adapter, MAC_WUCSR, wucsr); in lan743x_pm_set_wol()
3839 lan743x_csr_write(adapter, PMT_CTL, pmtctl); in lan743x_pm_set_wol()
3840 lan743x_csr_write(adapter, MAC_RX, macrx); in lan743x_pm_set_wol()
3847 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pm_suspend() local
3853 lan743x_csr_write(adapter, MAC_WUCSR, 0); in lan743x_pm_suspend()
3854 lan743x_csr_write(adapter, MAC_WUCSR2, 0); in lan743x_pm_suspend()
3855 lan743x_csr_write(adapter, MAC_WK_SRC, 0xFFFFFFFF); in lan743x_pm_suspend()
3857 if (adapter->wolopts || adapter->phy_wolopts) in lan743x_pm_suspend()
3858 lan743x_pm_set_wol(adapter); in lan743x_pm_suspend()
3860 if (adapter->is_pci11x1x) { in lan743x_pm_suspend()
3862 data = lan743x_csr_read(adapter, HW_CFG); in lan743x_pm_suspend()
3863 adapter->hw_cfg = data; in lan743x_pm_suspend()
3869 lan743x_csr_write(adapter, HW_CFG, data); in lan743x_pm_suspend()
3880 struct lan743x_adapter *adapter = netdev_priv(netdev); in lan743x_pm_resume() local
3889 if (adapter->is_pci11x1x) in lan743x_pm_resume()
3890 lan743x_csr_write(adapter, HW_CFG, adapter->hw_cfg); in lan743x_pm_resume()
3892 ret = lan743x_hardware_init(adapter, pdev); in lan743x_pm_resume()
3894 netif_err(adapter, probe, adapter->netdev, in lan743x_pm_resume()
3896 lan743x_pci_cleanup(adapter); in lan743x_pm_resume()
3900 ret = lan743x_csr_read(adapter, MAC_WK_SRC); in lan743x_pm_resume()
3901 netif_dbg(adapter, drv, adapter->netdev, in lan743x_pm_resume()
3910 lan743x_csr_write(adapter, MAC_WUCSR, data); in lan743x_pm_resume()
3914 lan743x_csr_write(adapter, MAC_WUCSR2, data); in lan743x_pm_resume()
3922 lan743x_csr_write(adapter, MAC_WK_SRC, data); in lan743x_pm_resume()