Lines Matching full:hw

19 int atl1c_check_eeprom_exist(struct atl1c_hw *hw)  in atl1c_check_eeprom_exist()  argument
23 AT_READ_REG(hw, REG_TWSI_DEBUG, &data); in atl1c_check_eeprom_exist()
27 AT_READ_REG(hw, REG_MASTER_CTRL, &data); in atl1c_check_eeprom_exist()
33 void atl1c_hw_set_mac_addr(struct atl1c_hw *hw, u8 *mac_addr) in atl1c_hw_set_mac_addr() argument
45 AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 0, value); in atl1c_hw_set_mac_addr()
49 AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 1, value); in atl1c_hw_set_mac_addr()
53 static bool atl1c_read_current_addr(struct atl1c_hw *hw, u8 *eth_addr) in atl1c_read_current_addr() argument
57 AT_READ_REG(hw, REG_MAC_STA_ADDR, &addr[0]); in atl1c_read_current_addr()
58 AT_READ_REG(hw, REG_MAC_STA_ADDR + 4, &addr[1]); in atl1c_read_current_addr()
70 static int atl1c_get_permanent_address(struct atl1c_hw *hw) in atl1c_get_permanent_address() argument
79 if (atl1c_read_current_addr(hw, hw->perm_mac_addr)) in atl1c_get_permanent_address()
83 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data); in atl1c_get_permanent_address()
84 if (atl1c_check_eeprom_exist(hw)) { in atl1c_get_permanent_address()
85 if (hw->nic_type == athr_l1c || hw->nic_type == athr_l2c) { in atl1c_get_permanent_address()
89 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_get_permanent_address()
90 AT_WRITE_FLUSH(hw); in atl1c_get_permanent_address()
95 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_get_permanent_address()
96 atl1c_read_phy_dbg(hw, MIIDBG_ANACTRL, &phy_data); in atl1c_get_permanent_address()
98 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, phy_data); in atl1c_get_permanent_address()
99 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_get_permanent_address()
101 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_get_permanent_address()
106 AT_READ_REG(hw, REG_TWSI_CTRL, &twsi_ctrl_data); in atl1c_get_permanent_address()
108 AT_WRITE_REG(hw, REG_TWSI_CTRL, twsi_ctrl_data); in atl1c_get_permanent_address()
111 AT_READ_REG(hw, REG_TWSI_CTRL, &twsi_ctrl_data); in atl1c_get_permanent_address()
119 if ((hw->nic_type == athr_l1c || hw->nic_type == athr_l2c)) { in atl1c_get_permanent_address()
121 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_get_permanent_address()
125 atl1c_read_phy_dbg(hw, MIIDBG_ANACTRL, &phy_data); in atl1c_get_permanent_address()
127 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, phy_data); in atl1c_get_permanent_address()
128 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_get_permanent_address()
130 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_get_permanent_address()
134 if (atl1c_read_current_addr(hw, hw->perm_mac_addr)) in atl1c_get_permanent_address()
140 bool atl1c_read_eeprom(struct atl1c_hw *hw, u32 offset, u32 *p_value) in atl1c_read_eeprom() argument
151 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data); in atl1c_read_eeprom()
153 AT_WRITE_REG(hw, REG_OTP_CTRL, in atl1c_read_eeprom()
156 AT_WRITE_REG(hw, REG_EEPROM_DATA_LO, 0); in atl1c_read_eeprom()
158 AT_WRITE_REG(hw, REG_EEPROM_CTRL, control); in atl1c_read_eeprom()
162 AT_READ_REG(hw, REG_EEPROM_CTRL, &control); in atl1c_read_eeprom()
167 AT_READ_REG(hw, REG_EEPROM_CTRL, &data); in atl1c_read_eeprom()
168 AT_READ_REG(hw, REG_EEPROM_DATA_LO, p_value); in atl1c_read_eeprom()
174 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_read_eeprom()
181 * hw - Struct containing variables accessed by shared code
183 int atl1c_read_mac_addr(struct atl1c_hw *hw) in atl1c_read_mac_addr() argument
187 err = atl1c_get_permanent_address(hw); in atl1c_read_mac_addr()
189 eth_random_addr(hw->perm_mac_addr); in atl1c_read_mac_addr()
191 memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr)); in atl1c_read_mac_addr()
203 u32 atl1c_hash_mc_addr(struct atl1c_hw *hw, u8 *mc_addr) in atl1c_hash_mc_addr() argument
218 * hw - Struct containing variables accessed by shared code
221 void atl1c_hash_set(struct atl1c_hw *hw, u32 hash_value) in atl1c_hash_set() argument
238 mta = AT_READ_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg); in atl1c_hash_set()
242 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg, mta); in atl1c_hash_set()
250 bool atl1c_wait_mdio_idle(struct atl1c_hw *hw) in atl1c_wait_mdio_idle() argument
256 AT_READ_REG(hw, REG_MDIO_CTRL, &val); in atl1c_wait_mdio_idle()
265 void atl1c_stop_phy_polling(struct atl1c_hw *hw) in atl1c_stop_phy_polling() argument
267 if (!(hw->ctrl_flags & ATL1C_FPGA_VERSION)) in atl1c_stop_phy_polling()
270 AT_WRITE_REG(hw, REG_MDIO_CTRL, 0); in atl1c_stop_phy_polling()
271 atl1c_wait_mdio_idle(hw); in atl1c_stop_phy_polling()
274 void atl1c_start_phy_polling(struct atl1c_hw *hw, u16 clk_sel) in atl1c_start_phy_polling() argument
278 if (!(hw->ctrl_flags & ATL1C_FPGA_VERSION)) in atl1c_start_phy_polling()
286 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_start_phy_polling()
287 atl1c_wait_mdio_idle(hw); in atl1c_start_phy_polling()
290 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_start_phy_polling()
302 int atl1c_read_phy_core(struct atl1c_hw *hw, bool ext, u8 dev, in atl1c_read_phy_core() argument
308 atl1c_stop_phy_polling(hw); in atl1c_read_phy_core()
313 if ((hw->nic_type == athr_l2c_b2 || hw->nic_type == athr_l1d_2) && in atl1c_read_phy_core()
314 hw->hibernate) in atl1c_read_phy_core()
318 AT_WRITE_REG(hw, REG_MDIO_EXTN, val); in atl1c_read_phy_core()
331 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_read_phy_core()
333 if (!atl1c_wait_mdio_idle(hw)) in atl1c_read_phy_core()
336 AT_READ_REG(hw, REG_MDIO_CTRL, &val); in atl1c_read_phy_core()
339 atl1c_start_phy_polling(hw, clk_sel); in atl1c_read_phy_core()
351 int atl1c_write_phy_core(struct atl1c_hw *hw, bool ext, u8 dev, in atl1c_write_phy_core() argument
357 atl1c_stop_phy_polling(hw); in atl1c_write_phy_core()
361 if ((hw->nic_type == athr_l2c_b2 || hw->nic_type == athr_l1d_2) && in atl1c_write_phy_core()
362 hw->hibernate) in atl1c_write_phy_core()
367 AT_WRITE_REG(hw, REG_MDIO_EXTN, val); in atl1c_write_phy_core()
380 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_write_phy_core()
382 if (!atl1c_wait_mdio_idle(hw)) in atl1c_write_phy_core()
385 atl1c_start_phy_polling(hw, clk_sel); in atl1c_write_phy_core()
392 * hw - Struct containing variables accessed by shared code
395 int atl1c_read_phy_reg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data) in atl1c_read_phy_reg() argument
397 return atl1c_read_phy_core(hw, false, 0, reg_addr, phy_data); in atl1c_read_phy_reg()
402 * hw - Struct containing variables accessed by shared code
406 int atl1c_write_phy_reg(struct atl1c_hw *hw, u32 reg_addr, u16 phy_data) in atl1c_write_phy_reg() argument
408 return atl1c_write_phy_core(hw, false, 0, reg_addr, phy_data); in atl1c_write_phy_reg()
412 int atl1c_read_phy_ext(struct atl1c_hw *hw, u8 dev_addr, in atl1c_read_phy_ext() argument
415 return atl1c_read_phy_core(hw, true, dev_addr, reg_addr, phy_data); in atl1c_read_phy_ext()
419 int atl1c_write_phy_ext(struct atl1c_hw *hw, u8 dev_addr, in atl1c_write_phy_ext() argument
422 return atl1c_write_phy_core(hw, true, dev_addr, reg_addr, phy_data); in atl1c_write_phy_ext()
425 int atl1c_read_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data) in atl1c_read_phy_dbg() argument
429 err = atl1c_write_phy_reg(hw, MII_DBG_ADDR, reg_addr); in atl1c_read_phy_dbg()
433 err = atl1c_read_phy_reg(hw, MII_DBG_DATA, phy_data); in atl1c_read_phy_dbg()
438 int atl1c_write_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 phy_data) in atl1c_write_phy_dbg() argument
442 err = atl1c_write_phy_reg(hw, MII_DBG_ADDR, reg_addr); in atl1c_write_phy_dbg()
446 err = atl1c_write_phy_reg(hw, MII_DBG_DATA, phy_data); in atl1c_write_phy_dbg()
454 * hw - Struct containing variables accessed by shared code
456 static int atl1c_phy_setup_adv(struct atl1c_hw *hw) in atl1c_phy_setup_adv() argument
462 if (hw->autoneg_advertised & ADVERTISED_10baseT_Half) in atl1c_phy_setup_adv()
464 if (hw->autoneg_advertised & ADVERTISED_10baseT_Full) in atl1c_phy_setup_adv()
466 if (hw->autoneg_advertised & ADVERTISED_100baseT_Half) in atl1c_phy_setup_adv()
468 if (hw->autoneg_advertised & ADVERTISED_100baseT_Full) in atl1c_phy_setup_adv()
471 if (hw->autoneg_advertised & ADVERTISED_Autoneg) in atl1c_phy_setup_adv()
475 if (hw->link_cap_flags & ATL1C_LINK_CAP_1000M) { in atl1c_phy_setup_adv()
476 if (hw->autoneg_advertised & ADVERTISED_1000baseT_Half) in atl1c_phy_setup_adv()
478 if (hw->autoneg_advertised & ADVERTISED_1000baseT_Full) in atl1c_phy_setup_adv()
480 if (hw->autoneg_advertised & ADVERTISED_Autoneg) in atl1c_phy_setup_adv()
485 if (atl1c_write_phy_reg(hw, MII_ADVERTISE, mii_adv_data) != 0 || in atl1c_phy_setup_adv()
486 atl1c_write_phy_reg(hw, MII_CTRL1000, mii_giga_ctrl_data) != 0) in atl1c_phy_setup_adv()
491 void atl1c_phy_disable(struct atl1c_hw *hw) in atl1c_phy_disable() argument
493 atl1c_power_saving(hw, 0); in atl1c_phy_disable()
497 int atl1c_phy_reset(struct atl1c_hw *hw) in atl1c_phy_reset() argument
499 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_reset()
506 AT_READ_REG(hw, REG_GPHY_CTRL, &phy_ctrl_data); in atl1c_phy_reset()
510 if (!(hw->ctrl_flags & ATL1C_HIB_DISABLE)) in atl1c_phy_reset()
514 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl_data); in atl1c_phy_reset()
515 AT_WRITE_FLUSH(hw); in atl1c_phy_reset()
517 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl_data | GPHY_CTRL_EXT_RESET); in atl1c_phy_reset()
518 AT_WRITE_FLUSH(hw); in atl1c_phy_reset()
522 if (hw->nic_type == athr_l2c_b) { in atl1c_phy_reset()
523 atl1c_read_phy_dbg(hw, MIIDBG_CFGLPSPD, &phy_data); in atl1c_phy_reset()
524 atl1c_write_phy_dbg(hw, MIIDBG_CFGLPSPD, in atl1c_phy_reset()
529 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
530 atl1c_read_phy_dbg(hw, MIIDBG_CABLE1TH_DET, &phy_data); in atl1c_phy_reset()
532 atl1c_write_phy_dbg(hw, MIIDBG_CABLE1TH_DET, phy_data); in atl1c_phy_reset()
536 if (!(hw->ctrl_flags & ATL1C_HIB_DISABLE)) { in atl1c_phy_reset()
537 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
538 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_phy_reset()
540 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_phy_reset()
544 hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2 ? in atl1c_phy_reset()
546 atl1c_write_phy_dbg(hw, MIIDBG_LEGCYPS, phy_data); in atl1c_phy_reset()
548 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_phy_reset()
552 atl1c_read_phy_dbg(hw, MIIDBG_LEGCYPS, &phy_data); in atl1c_phy_reset()
553 atl1c_write_phy_dbg(hw, MIIDBG_LEGCYPS, in atl1c_phy_reset()
556 atl1c_read_phy_dbg(hw, MIIDBG_HIBNEG, &phy_data); in atl1c_phy_reset()
557 atl1c_write_phy_dbg(hw, MIIDBG_HIBNEG, in atl1c_phy_reset()
561 if (hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2 || in atl1c_phy_reset()
562 hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
563 AT_READ_REG(hw, REG_LPI_CTRL, &lpi_ctrl); in atl1c_phy_reset()
564 AT_WRITE_REG(hw, REG_LPI_CTRL, lpi_ctrl & ~LPI_CTRL_EN); in atl1c_phy_reset()
565 atl1c_write_phy_ext(hw, MIIEXT_ANEG, MIIEXT_LOCAL_EEEADV, 0); in atl1c_phy_reset()
566 atl1c_write_phy_ext(hw, MIIEXT_PCS, MIIEXT_CLDCTRL3, in atl1c_phy_reset()
571 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, ANACTRL_DEF); in atl1c_phy_reset()
572 atl1c_write_phy_dbg(hw, MIIDBG_SRDSYSMOD, SRDSYSMOD_DEF); in atl1c_phy_reset()
573 atl1c_write_phy_dbg(hw, MIIDBG_TST10BTCFG, TST10BTCFG_DEF); in atl1c_phy_reset()
575 atl1c_write_phy_dbg(hw, MIIDBG_TST100BTCFG, in atl1c_phy_reset()
580 err = atl1c_write_phy_reg(hw, MII_IER, phy_data); in atl1c_phy_reset()
590 int atl1c_phy_init(struct atl1c_hw *hw) in atl1c_phy_init() argument
592 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_init()
597 if (hw->nic_type == athr_mt) { in atl1c_phy_init()
598 hw->phy_configured = true; in atl1c_phy_init()
602 if ((atl1c_read_phy_reg(hw, MII_PHYSID1, &hw->phy_id1) != 0) || in atl1c_phy_init()
603 (atl1c_read_phy_reg(hw, MII_PHYSID2, &hw->phy_id2) != 0)) { in atl1c_phy_init()
607 switch (hw->media_type) { in atl1c_phy_init()
609 ret_val = atl1c_phy_setup_adv(hw); in atl1c_phy_init()
632 hw->media_type); in atl1c_phy_init()
636 ret_val = atl1c_write_phy_reg(hw, MII_BMCR, mii_bmcr_data); in atl1c_phy_init()
639 hw->phy_configured = true; in atl1c_phy_init()
644 bool atl1c_get_link_status(struct atl1c_hw *hw) in atl1c_get_link_status() argument
648 if (hw->nic_type == athr_mt) { in atl1c_get_link_status()
651 AT_READ_REG(hw, REG_MT_SPEED, &spd); in atl1c_get_link_status()
656 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_get_link_status()
657 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_get_link_status()
664 * hw - Struct containing variables accessed by shared code
668 int atl1c_get_speed_and_duplex(struct atl1c_hw *hw, u16 *speed, u16 *duplex) in atl1c_get_speed_and_duplex() argument
673 if (hw->nic_type == athr_mt) { in atl1c_get_speed_and_duplex()
676 AT_READ_REG(hw, REG_MT_SPEED, &spd); in atl1c_get_speed_and_duplex()
683 err = atl1c_read_phy_reg(hw, MII_GIGA_PSSR, &phy_data); in atl1c_get_speed_and_duplex()
713 int atl1c_phy_to_ps_link(struct atl1c_hw *hw) in atl1c_phy_to_ps_link() argument
715 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_to_ps_link()
725 if (atl1c_get_link_status(hw)) { in atl1c_phy_to_ps_link()
726 atl1c_read_phy_reg(hw, MII_LPA, &mii_lpa_data); in atl1c_phy_to_ps_link()
736 save_autoneg_advertised = hw->autoneg_advertised; in atl1c_phy_to_ps_link()
737 hw->phy_configured = false; in atl1c_phy_to_ps_link()
738 hw->autoneg_advertised = autoneg_advertised; in atl1c_phy_to_ps_link()
739 if (atl1c_restart_autoneg(hw) != 0) { in atl1c_phy_to_ps_link()
743 hw->autoneg_advertised = save_autoneg_advertised; in atl1c_phy_to_ps_link()
748 if (atl1c_get_link_status(hw)) { in atl1c_phy_to_ps_link()
749 if (atl1c_get_speed_and_duplex(hw, &speed, in atl1c_phy_to_ps_link()
767 int atl1c_restart_autoneg(struct atl1c_hw *hw) in atl1c_restart_autoneg() argument
772 err = atl1c_phy_setup_adv(hw); in atl1c_restart_autoneg()
777 return atl1c_write_phy_reg(hw, MII_BMCR, mii_bmcr_data); in atl1c_restart_autoneg()
780 int atl1c_power_saving(struct atl1c_hw *hw, u32 wufc) in atl1c_power_saving() argument
782 struct atl1c_adapter *adapter = hw->adapter; in atl1c_power_saving()
792 AT_READ_REG(hw, REG_MASTER_CTRL, &master_ctrl); in atl1c_power_saving()
793 AT_READ_REG(hw, REG_MAC_CTRL, &mac_ctrl); in atl1c_power_saving()
794 AT_READ_REG(hw, REG_GPHY_CTRL, &phy_ctrl); in atl1c_power_saving()
807 AT_WRITE_REG(hw, REG_MASTER_CTRL, master_ctrl); in atl1c_power_saving()
808 AT_WRITE_REG(hw, REG_MAC_CTRL, mac_ctrl); in atl1c_power_saving()
809 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl); in atl1c_power_saving()
810 AT_WRITE_REG(hw, REG_WOL_CTRL, 0); in atl1c_power_saving()
811 hw->phy_configured = false; /* re-init PHY when resume */ in atl1c_power_saving()
818 if (hw->nic_type == athr_l2c_b && hw->revision_id == L2CB_V11) in atl1c_power_saving()
823 if (atl1c_write_phy_reg(hw, MII_IER, IER_LINK_UP) != 0) { in atl1c_power_saving()
829 atl1c_read_phy_reg(hw, MII_ISR, &phy_data); in atl1c_power_saving()
833 AT_WRITE_REG(hw, REG_MASTER_CTRL, master_ctrl); in atl1c_power_saving()
834 AT_WRITE_REG(hw, REG_MAC_CTRL, mac_ctrl); in atl1c_power_saving()
835 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl); in atl1c_power_saving()
836 AT_WRITE_REG(hw, REG_WOL_CTRL, wol_ctrl); in atl1c_power_saving()
843 void atl1c_post_phy_linkchg(struct atl1c_hw *hw, u16 link_speed) in atl1c_post_phy_linkchg() argument
848 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2 || in atl1c_post_phy_linkchg()
849 hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2) in atl1c_post_phy_linkchg()
854 if (hw->nic_type == athr_l1d_2) { in atl1c_post_phy_linkchg()
855 atl1c_read_phy_ext(hw, MIIEXT_PCS, MIIEXT_CLDCTRL6, in atl1c_post_phy_linkchg()
860 atl1c_write_phy_dbg(hw, MIIDBG_AZ_ANADECT, phy_val); in atl1c_post_phy_linkchg()
863 if (adj_thresh && link_speed == SPEED_100 && hw->msi_lnkpatch) { in atl1c_post_phy_linkchg()
864 atl1c_write_phy_dbg(hw, MIIDBG_MSE16DB, L1D_MSE16DB_UP); in atl1c_post_phy_linkchg()
865 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_post_phy_linkchg()
869 if (adj_thresh && hw->msi_lnkpatch) { in atl1c_post_phy_linkchg()
870 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_post_phy_linkchg()
872 atl1c_write_phy_dbg(hw, MIIDBG_MSE16DB, in atl1c_post_phy_linkchg()