Lines Matching refs:hw

32 int atl1c_check_eeprom_exist(struct atl1c_hw *hw)  in atl1c_check_eeprom_exist()  argument
36 AT_READ_REG(hw, REG_TWSI_DEBUG, &data); in atl1c_check_eeprom_exist()
40 AT_READ_REG(hw, REG_MASTER_CTRL, &data); in atl1c_check_eeprom_exist()
46 void atl1c_hw_set_mac_addr(struct atl1c_hw *hw, u8 *mac_addr) in atl1c_hw_set_mac_addr() argument
58 AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 0, value); in atl1c_hw_set_mac_addr()
62 AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 1, value); in atl1c_hw_set_mac_addr()
66 static bool atl1c_read_current_addr(struct atl1c_hw *hw, u8 *eth_addr) in atl1c_read_current_addr() argument
70 AT_READ_REG(hw, REG_MAC_STA_ADDR, &addr[0]); in atl1c_read_current_addr()
71 AT_READ_REG(hw, REG_MAC_STA_ADDR + 4, &addr[1]); in atl1c_read_current_addr()
83 static int atl1c_get_permanent_address(struct atl1c_hw *hw) in atl1c_get_permanent_address() argument
92 if (atl1c_read_current_addr(hw, hw->perm_mac_addr)) in atl1c_get_permanent_address()
96 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data); in atl1c_get_permanent_address()
97 if (atl1c_check_eeprom_exist(hw)) { in atl1c_get_permanent_address()
98 if (hw->nic_type == athr_l1c || hw->nic_type == athr_l2c) { in atl1c_get_permanent_address()
102 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_get_permanent_address()
103 AT_WRITE_FLUSH(hw); in atl1c_get_permanent_address()
108 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_get_permanent_address()
109 atl1c_read_phy_dbg(hw, MIIDBG_ANACTRL, &phy_data); in atl1c_get_permanent_address()
111 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, phy_data); in atl1c_get_permanent_address()
112 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_get_permanent_address()
114 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_get_permanent_address()
119 AT_READ_REG(hw, REG_TWSI_CTRL, &twsi_ctrl_data); in atl1c_get_permanent_address()
121 AT_WRITE_REG(hw, REG_TWSI_CTRL, twsi_ctrl_data); in atl1c_get_permanent_address()
124 AT_READ_REG(hw, REG_TWSI_CTRL, &twsi_ctrl_data); in atl1c_get_permanent_address()
132 if ((hw->nic_type == athr_l1c || hw->nic_type == athr_l2c)) { in atl1c_get_permanent_address()
134 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_get_permanent_address()
138 atl1c_read_phy_dbg(hw, MIIDBG_ANACTRL, &phy_data); in atl1c_get_permanent_address()
140 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, phy_data); in atl1c_get_permanent_address()
141 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_get_permanent_address()
143 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_get_permanent_address()
147 if (atl1c_read_current_addr(hw, hw->perm_mac_addr)) in atl1c_get_permanent_address()
153 bool atl1c_read_eeprom(struct atl1c_hw *hw, u32 offset, u32 *p_value) in atl1c_read_eeprom() argument
164 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data); in atl1c_read_eeprom()
166 AT_WRITE_REG(hw, REG_OTP_CTRL, in atl1c_read_eeprom()
169 AT_WRITE_REG(hw, REG_EEPROM_DATA_LO, 0); in atl1c_read_eeprom()
171 AT_WRITE_REG(hw, REG_EEPROM_CTRL, control); in atl1c_read_eeprom()
175 AT_READ_REG(hw, REG_EEPROM_CTRL, &control); in atl1c_read_eeprom()
180 AT_READ_REG(hw, REG_EEPROM_CTRL, &data); in atl1c_read_eeprom()
181 AT_READ_REG(hw, REG_EEPROM_DATA_LO, p_value); in atl1c_read_eeprom()
187 AT_WRITE_REG(hw, REG_OTP_CTRL, otp_ctrl_data); in atl1c_read_eeprom()
196 int atl1c_read_mac_addr(struct atl1c_hw *hw) in atl1c_read_mac_addr() argument
200 err = atl1c_get_permanent_address(hw); in atl1c_read_mac_addr()
202 eth_random_addr(hw->perm_mac_addr); in atl1c_read_mac_addr()
204 memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr)); in atl1c_read_mac_addr()
216 u32 atl1c_hash_mc_addr(struct atl1c_hw *hw, u8 *mc_addr) in atl1c_hash_mc_addr() argument
234 void atl1c_hash_set(struct atl1c_hw *hw, u32 hash_value) in atl1c_hash_set() argument
251 mta = AT_READ_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg); in atl1c_hash_set()
255 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg, mta); in atl1c_hash_set()
263 bool atl1c_wait_mdio_idle(struct atl1c_hw *hw) in atl1c_wait_mdio_idle() argument
269 AT_READ_REG(hw, REG_MDIO_CTRL, &val); in atl1c_wait_mdio_idle()
278 void atl1c_stop_phy_polling(struct atl1c_hw *hw) in atl1c_stop_phy_polling() argument
280 if (!(hw->ctrl_flags & ATL1C_FPGA_VERSION)) in atl1c_stop_phy_polling()
283 AT_WRITE_REG(hw, REG_MDIO_CTRL, 0); in atl1c_stop_phy_polling()
284 atl1c_wait_mdio_idle(hw); in atl1c_stop_phy_polling()
287 void atl1c_start_phy_polling(struct atl1c_hw *hw, u16 clk_sel) in atl1c_start_phy_polling() argument
291 if (!(hw->ctrl_flags & ATL1C_FPGA_VERSION)) in atl1c_start_phy_polling()
299 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_start_phy_polling()
300 atl1c_wait_mdio_idle(hw); in atl1c_start_phy_polling()
303 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_start_phy_polling()
315 int atl1c_read_phy_core(struct atl1c_hw *hw, bool ext, u8 dev, in atl1c_read_phy_core() argument
321 atl1c_stop_phy_polling(hw); in atl1c_read_phy_core()
326 if ((hw->nic_type == athr_l2c_b2 || hw->nic_type == athr_l1d_2) && in atl1c_read_phy_core()
327 hw->hibernate) in atl1c_read_phy_core()
331 AT_WRITE_REG(hw, REG_MDIO_EXTN, val); in atl1c_read_phy_core()
344 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_read_phy_core()
346 if (!atl1c_wait_mdio_idle(hw)) in atl1c_read_phy_core()
349 AT_READ_REG(hw, REG_MDIO_CTRL, &val); in atl1c_read_phy_core()
352 atl1c_start_phy_polling(hw, clk_sel); in atl1c_read_phy_core()
364 int atl1c_write_phy_core(struct atl1c_hw *hw, bool ext, u8 dev, in atl1c_write_phy_core() argument
370 atl1c_stop_phy_polling(hw); in atl1c_write_phy_core()
374 if ((hw->nic_type == athr_l2c_b2 || hw->nic_type == athr_l1d_2) && in atl1c_write_phy_core()
375 hw->hibernate) in atl1c_write_phy_core()
380 AT_WRITE_REG(hw, REG_MDIO_EXTN, val); in atl1c_write_phy_core()
393 AT_WRITE_REG(hw, REG_MDIO_CTRL, val); in atl1c_write_phy_core()
395 if (!atl1c_wait_mdio_idle(hw)) in atl1c_write_phy_core()
398 atl1c_start_phy_polling(hw, clk_sel); in atl1c_write_phy_core()
408 int atl1c_read_phy_reg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data) in atl1c_read_phy_reg() argument
410 return atl1c_read_phy_core(hw, false, 0, reg_addr, phy_data); in atl1c_read_phy_reg()
419 int atl1c_write_phy_reg(struct atl1c_hw *hw, u32 reg_addr, u16 phy_data) in atl1c_write_phy_reg() argument
421 return atl1c_write_phy_core(hw, false, 0, reg_addr, phy_data); in atl1c_write_phy_reg()
425 int atl1c_read_phy_ext(struct atl1c_hw *hw, u8 dev_addr, in atl1c_read_phy_ext() argument
428 return atl1c_read_phy_core(hw, true, dev_addr, reg_addr, phy_data); in atl1c_read_phy_ext()
432 int atl1c_write_phy_ext(struct atl1c_hw *hw, u8 dev_addr, in atl1c_write_phy_ext() argument
435 return atl1c_write_phy_core(hw, true, dev_addr, reg_addr, phy_data); in atl1c_write_phy_ext()
438 int atl1c_read_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 *phy_data) in atl1c_read_phy_dbg() argument
442 err = atl1c_write_phy_reg(hw, MII_DBG_ADDR, reg_addr); in atl1c_read_phy_dbg()
446 err = atl1c_read_phy_reg(hw, MII_DBG_DATA, phy_data); in atl1c_read_phy_dbg()
451 int atl1c_write_phy_dbg(struct atl1c_hw *hw, u16 reg_addr, u16 phy_data) in atl1c_write_phy_dbg() argument
455 err = atl1c_write_phy_reg(hw, MII_DBG_ADDR, reg_addr); in atl1c_write_phy_dbg()
459 err = atl1c_write_phy_reg(hw, MII_DBG_DATA, phy_data); in atl1c_write_phy_dbg()
469 static int atl1c_phy_setup_adv(struct atl1c_hw *hw) in atl1c_phy_setup_adv() argument
475 if (hw->autoneg_advertised & ADVERTISED_10baseT_Half) in atl1c_phy_setup_adv()
477 if (hw->autoneg_advertised & ADVERTISED_10baseT_Full) in atl1c_phy_setup_adv()
479 if (hw->autoneg_advertised & ADVERTISED_100baseT_Half) in atl1c_phy_setup_adv()
481 if (hw->autoneg_advertised & ADVERTISED_100baseT_Full) in atl1c_phy_setup_adv()
484 if (hw->autoneg_advertised & ADVERTISED_Autoneg) in atl1c_phy_setup_adv()
488 if (hw->link_cap_flags & ATL1C_LINK_CAP_1000M) { in atl1c_phy_setup_adv()
489 if (hw->autoneg_advertised & ADVERTISED_1000baseT_Half) in atl1c_phy_setup_adv()
491 if (hw->autoneg_advertised & ADVERTISED_1000baseT_Full) in atl1c_phy_setup_adv()
493 if (hw->autoneg_advertised & ADVERTISED_Autoneg) in atl1c_phy_setup_adv()
498 if (atl1c_write_phy_reg(hw, MII_ADVERTISE, mii_adv_data) != 0 || in atl1c_phy_setup_adv()
499 atl1c_write_phy_reg(hw, MII_CTRL1000, mii_giga_ctrl_data) != 0) in atl1c_phy_setup_adv()
504 void atl1c_phy_disable(struct atl1c_hw *hw) in atl1c_phy_disable() argument
506 atl1c_power_saving(hw, 0); in atl1c_phy_disable()
510 int atl1c_phy_reset(struct atl1c_hw *hw) in atl1c_phy_reset() argument
512 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_reset()
519 AT_READ_REG(hw, REG_GPHY_CTRL, &phy_ctrl_data); in atl1c_phy_reset()
523 if (!(hw->ctrl_flags & ATL1C_HIB_DISABLE)) in atl1c_phy_reset()
527 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl_data); in atl1c_phy_reset()
528 AT_WRITE_FLUSH(hw); in atl1c_phy_reset()
530 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl_data | GPHY_CTRL_EXT_RESET); in atl1c_phy_reset()
531 AT_WRITE_FLUSH(hw); in atl1c_phy_reset()
535 if (hw->nic_type == athr_l2c_b) { in atl1c_phy_reset()
536 atl1c_read_phy_dbg(hw, MIIDBG_CFGLPSPD, &phy_data); in atl1c_phy_reset()
537 atl1c_write_phy_dbg(hw, MIIDBG_CFGLPSPD, in atl1c_phy_reset()
542 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
543 atl1c_read_phy_dbg(hw, MIIDBG_CABLE1TH_DET, &phy_data); in atl1c_phy_reset()
545 atl1c_write_phy_dbg(hw, MIIDBG_CABLE1TH_DET, phy_data); in atl1c_phy_reset()
549 if (!(hw->ctrl_flags & ATL1C_HIB_DISABLE)) { in atl1c_phy_reset()
550 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
551 atl1c_read_phy_dbg(hw, MIIDBG_VOLT_CTRL, &phy_data); in atl1c_phy_reset()
553 atl1c_write_phy_dbg(hw, MIIDBG_VOLT_CTRL, phy_data); in atl1c_phy_reset()
557 hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2 ? in atl1c_phy_reset()
559 atl1c_write_phy_dbg(hw, MIIDBG_LEGCYPS, phy_data); in atl1c_phy_reset()
561 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_phy_reset()
565 atl1c_read_phy_dbg(hw, MIIDBG_LEGCYPS, &phy_data); in atl1c_phy_reset()
566 atl1c_write_phy_dbg(hw, MIIDBG_LEGCYPS, in atl1c_phy_reset()
569 atl1c_read_phy_dbg(hw, MIIDBG_HIBNEG, &phy_data); in atl1c_phy_reset()
570 atl1c_write_phy_dbg(hw, MIIDBG_HIBNEG, in atl1c_phy_reset()
574 if (hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2 || in atl1c_phy_reset()
575 hw->nic_type == athr_l2c_b2) { in atl1c_phy_reset()
576 AT_READ_REG(hw, REG_LPI_CTRL, &lpi_ctrl); in atl1c_phy_reset()
577 AT_WRITE_REG(hw, REG_LPI_CTRL, lpi_ctrl & ~LPI_CTRL_EN); in atl1c_phy_reset()
578 atl1c_write_phy_ext(hw, MIIEXT_ANEG, MIIEXT_LOCAL_EEEADV, 0); in atl1c_phy_reset()
579 atl1c_write_phy_ext(hw, MIIEXT_PCS, MIIEXT_CLDCTRL3, in atl1c_phy_reset()
584 atl1c_write_phy_dbg(hw, MIIDBG_ANACTRL, ANACTRL_DEF); in atl1c_phy_reset()
585 atl1c_write_phy_dbg(hw, MIIDBG_SRDSYSMOD, SRDSYSMOD_DEF); in atl1c_phy_reset()
586 atl1c_write_phy_dbg(hw, MIIDBG_TST10BTCFG, TST10BTCFG_DEF); in atl1c_phy_reset()
588 atl1c_write_phy_dbg(hw, MIIDBG_TST100BTCFG, in atl1c_phy_reset()
593 err = atl1c_write_phy_reg(hw, MII_IER, phy_data); in atl1c_phy_reset()
603 int atl1c_phy_init(struct atl1c_hw *hw) in atl1c_phy_init() argument
605 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_init()
610 if ((atl1c_read_phy_reg(hw, MII_PHYSID1, &hw->phy_id1) != 0) || in atl1c_phy_init()
611 (atl1c_read_phy_reg(hw, MII_PHYSID2, &hw->phy_id2) != 0)) { in atl1c_phy_init()
615 switch (hw->media_type) { in atl1c_phy_init()
617 ret_val = atl1c_phy_setup_adv(hw); in atl1c_phy_init()
640 hw->media_type); in atl1c_phy_init()
644 ret_val = atl1c_write_phy_reg(hw, MII_BMCR, mii_bmcr_data); in atl1c_phy_init()
647 hw->phy_configured = true; in atl1c_phy_init()
659 int atl1c_get_speed_and_duplex(struct atl1c_hw *hw, u16 *speed, u16 *duplex) in atl1c_get_speed_and_duplex() argument
665 err = atl1c_read_phy_reg(hw, MII_GIGA_PSSR, &phy_data); in atl1c_get_speed_and_duplex()
695 int atl1c_phy_to_ps_link(struct atl1c_hw *hw) in atl1c_phy_to_ps_link() argument
697 struct atl1c_adapter *adapter = hw->adapter; in atl1c_phy_to_ps_link()
708 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_phy_to_ps_link()
709 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_phy_to_ps_link()
711 atl1c_read_phy_reg(hw, MII_LPA, &mii_lpa_data); in atl1c_phy_to_ps_link()
721 save_autoneg_advertised = hw->autoneg_advertised; in atl1c_phy_to_ps_link()
722 hw->phy_configured = false; in atl1c_phy_to_ps_link()
723 hw->autoneg_advertised = autoneg_advertised; in atl1c_phy_to_ps_link()
724 if (atl1c_restart_autoneg(hw) != 0) { in atl1c_phy_to_ps_link()
728 hw->autoneg_advertised = save_autoneg_advertised; in atl1c_phy_to_ps_link()
733 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_phy_to_ps_link()
734 atl1c_read_phy_reg(hw, MII_BMSR, &phy_data); in atl1c_phy_to_ps_link()
736 if (atl1c_get_speed_and_duplex(hw, &speed, in atl1c_phy_to_ps_link()
754 int atl1c_restart_autoneg(struct atl1c_hw *hw) in atl1c_restart_autoneg() argument
759 err = atl1c_phy_setup_adv(hw); in atl1c_restart_autoneg()
764 return atl1c_write_phy_reg(hw, MII_BMCR, mii_bmcr_data); in atl1c_restart_autoneg()
767 int atl1c_power_saving(struct atl1c_hw *hw, u32 wufc) in atl1c_power_saving() argument
769 struct atl1c_adapter *adapter = hw->adapter; in atl1c_power_saving()
779 AT_READ_REG(hw, REG_MASTER_CTRL, &master_ctrl); in atl1c_power_saving()
780 AT_READ_REG(hw, REG_MAC_CTRL, &mac_ctrl); in atl1c_power_saving()
781 AT_READ_REG(hw, REG_GPHY_CTRL, &phy_ctrl); in atl1c_power_saving()
794 AT_WRITE_REG(hw, REG_MASTER_CTRL, master_ctrl); in atl1c_power_saving()
795 AT_WRITE_REG(hw, REG_MAC_CTRL, mac_ctrl); in atl1c_power_saving()
796 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl); in atl1c_power_saving()
797 AT_WRITE_REG(hw, REG_WOL_CTRL, 0); in atl1c_power_saving()
798 hw->phy_configured = false; /* re-init PHY when resume */ in atl1c_power_saving()
805 if (hw->nic_type == athr_l2c_b && hw->revision_id == L2CB_V11) in atl1c_power_saving()
810 if (atl1c_write_phy_reg(hw, MII_IER, IER_LINK_UP) != 0) { in atl1c_power_saving()
816 atl1c_read_phy_reg(hw, MII_ISR, &phy_data); in atl1c_power_saving()
820 AT_WRITE_REG(hw, REG_MASTER_CTRL, master_ctrl); in atl1c_power_saving()
821 AT_WRITE_REG(hw, REG_MAC_CTRL, mac_ctrl); in atl1c_power_saving()
822 AT_WRITE_REG(hw, REG_GPHY_CTRL, phy_ctrl); in atl1c_power_saving()
823 AT_WRITE_REG(hw, REG_WOL_CTRL, wol_ctrl); in atl1c_power_saving()
830 void atl1c_post_phy_linkchg(struct atl1c_hw *hw, u16 link_speed) in atl1c_post_phy_linkchg() argument
835 if (hw->nic_type == athr_l2c_b || hw->nic_type == athr_l2c_b2 || in atl1c_post_phy_linkchg()
836 hw->nic_type == athr_l1d || hw->nic_type == athr_l1d_2) in atl1c_post_phy_linkchg()
841 if (hw->nic_type == athr_l1d_2) { in atl1c_post_phy_linkchg()
842 atl1c_read_phy_ext(hw, MIIEXT_PCS, MIIEXT_CLDCTRL6, in atl1c_post_phy_linkchg()
847 atl1c_write_phy_dbg(hw, MIIDBG_AZ_ANADECT, phy_val); in atl1c_post_phy_linkchg()
850 if (adj_thresh && link_speed == SPEED_100 && hw->msi_lnkpatch) { in atl1c_post_phy_linkchg()
851 atl1c_write_phy_dbg(hw, MIIDBG_MSE16DB, L1D_MSE16DB_UP); in atl1c_post_phy_linkchg()
852 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_post_phy_linkchg()
856 if (adj_thresh && hw->msi_lnkpatch) { in atl1c_post_phy_linkchg()
857 atl1c_write_phy_dbg(hw, MIIDBG_SYSMODCTRL, in atl1c_post_phy_linkchg()
859 atl1c_write_phy_dbg(hw, MIIDBG_MSE16DB, in atl1c_post_phy_linkchg()