26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28 #include <asm/unaligned.h>
30 #include <linux/pci.h>
74 data = ath5k_hw_reg_read(ah, reg);
75 if (is_set && (data & flag))
77 else if ((data & flag) == val)
82 return (i <= 0) ? -
EAGAIN : 0;
136 u32 usec_reg, txlat, rxlat, usec,
clock, sclock, txf2txs;
256 usec_reg = (usec | sclock | txlat | rxlat);
257 ath5k_hw_reg_write(ah, usec_reg,
AR5K_USEC);
284 u32 scal, spending, sclock;
448 u32 mask = flags ? flags : ~0
U;
463 if (mask & AR5K_RESET_CTL_PCU)
469 if (mask & AR5K_RESET_CTL_PCU)
492 if ((flags & AR5K_RESET_CTL_PCU) == 0)
515 bool set_chip,
u16 sleep_duration)
528 ath5k_hw_reg_write(ah,
556 if (data & 0xffc00000)
566 for (i = 200; i > 0; i--) {
613 if (ath5k_get_bus_type(ah) ==
ATH_AHB)
619 ATH5K_ERR(ah,
"failed to wakeup the MAC Chip\n");
634 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
639 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
644 ATH5K_ERR(ah,
"failed to put device on warm reset\n");
651 ATH5K_ERR(ah,
"failed to put device on hold\n");
679 if ((ath5k_get_bus_type(ah) !=
ATH_AHB) || channel) {
683 ATH5K_ERR(ah,
"failed to wakeup the MAC Chip\n");
699 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
704 if (ath5k_get_bus_type(ah) ==
ATH_AHB)
705 ret = ath5k_hw_wisoc_reset(ah, AR5K_RESET_CTL_PCU |
708 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
713 ATH5K_ERR(ah,
"failed to reset the MAC Chip\n");
720 ATH5K_ERR(ah,
"failed to resume the MAC Chip\n");
727 if (ath5k_get_bus_type(ah) ==
ATH_AHB)
728 ret = ath5k_hw_wisoc_reset(ah, 0);
730 ret = ath5k_hw_nic_reset(ah, 0);
733 ATH5K_ERR(ah,
"failed to warm reset the MAC Chip\n");
784 ATH5K_ERR(ah,
"invalid radio frequency mode\n");
848 ath5k_hw_tweak_initval_settings(
struct ath5k_hw *ah,
855 ath5k_hw_reg_write(ah,
898 ath5k_hw_reg_write(ah, fast_adc,
947 ath5k_hw_reg_write(ah,
976 ath5k_hw_commit_eeprom_settings(
struct ath5k_hw *ah,
980 s16 cck_ofdm_pwr_delta;
1002 ath5k_hw_reg_write(ah,
1013 ah->
ah_txpower.txp_cck_ofdm_pwr_delta = cck_ofdm_pwr_delta;
1023 ath5k_hw_reg_write(ah,
1081 ath5k_hw_reg_write(ah,
1149 u32 s_seq[10], s_led[3], tsf_up, tsf_lo;
1170 ath5k_hw_set_sleep_clock(ah,
false);
1189 "DMA didn't stop, falling back to normal reset\n");
1203 "G mode not available on 5210/5211");
1210 "B mode not available on 5210");
1228 "fast chan change failed, falling back to normal reset\n");
1234 "fast chan change successful\n");
1250 for (i = 0; i < 10; i++)
1251 s_seq[i] = ath5k_hw_reg_read(ah,
1255 s_seq[0] = ath5k_hw_reg_read(ah,
1315 ath5k_hw_init_core_clock(ah);
1322 ath5k_hw_tweak_initval_settings(ah, channel);
1325 ath5k_hw_commit_eeprom_settings(ah, channel);
1335 for (i = 0; i < 10; i++)
1336 ath5k_hw_reg_write(ah, s_seq[i],
1339 ath5k_hw_reg_write(ah, s_seq[0],
1367 "failed to initialize PHY (%i) !\n", ret);
1396 ath5k_hw_set_sleep_clock(ah,
true);