diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 134 |
1 files changed, 68 insertions, 66 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 1fb14edfcb2a..77db932c3137 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -499,8 +499,10 @@ static int ath9k_hw_post_init(struct ath_hw *ah) | |||
499 | { | 499 | { |
500 | int ecode; | 500 | int ecode; |
501 | 501 | ||
502 | if (!ath9k_hw_chip_test(ah)) | 502 | if (!AR_SREV_9271(ah)) { |
503 | return -ENODEV; | 503 | if (!ath9k_hw_chip_test(ah)) |
504 | return -ENODEV; | ||
505 | } | ||
504 | 506 | ||
505 | ecode = ath9k_hw_rf_claim(ah); | 507 | ecode = ath9k_hw_rf_claim(ah); |
506 | if (ecode != 0) | 508 | if (ecode != 0) |
@@ -603,9 +605,23 @@ static void ath9k_hw_init_mode_regs(struct ath_hw *ah) | |||
603 | ARRAY_SIZE(ar9271Modes_9271), 6); | 605 | ARRAY_SIZE(ar9271Modes_9271), 6); |
604 | INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, | 606 | INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, |
605 | ARRAY_SIZE(ar9271Common_9271), 2); | 607 | ARRAY_SIZE(ar9271Common_9271), 2); |
608 | INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271, | ||
609 | ar9271Common_normal_cck_fir_coeff_9271, | ||
610 | ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2); | ||
611 | INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271, | ||
612 | ar9271Common_japan_2484_cck_fir_coeff_9271, | ||
613 | ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2); | ||
606 | INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, | 614 | INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, |
607 | ar9271Modes_9271_1_0_only, | 615 | ar9271Modes_9271_1_0_only, |
608 | ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6); | 616 | ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6); |
617 | INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg, | ||
618 | ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 6); | ||
619 | INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271, | ||
620 | ar9271Modes_high_power_tx_gain_9271, | ||
621 | ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 6); | ||
622 | INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, | ||
623 | ar9271Modes_normal_power_tx_gain_9271, | ||
624 | ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 6); | ||
609 | return; | 625 | return; |
610 | } | 626 | } |
611 | 627 | ||
@@ -990,22 +1006,6 @@ static void ath9k_hw_init_qos(struct ath_hw *ah) | |||
990 | REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); | 1006 | REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); |
991 | } | 1007 | } |
992 | 1008 | ||
993 | static void ath9k_hw_change_target_baud(struct ath_hw *ah, u32 freq, u32 baud) | ||
994 | { | ||
995 | u32 lcr; | ||
996 | u32 baud_divider = freq * 1000 * 1000 / 16 / baud; | ||
997 | |||
998 | lcr = REG_READ(ah , 0x5100c); | ||
999 | lcr |= 0x80; | ||
1000 | |||
1001 | REG_WRITE(ah, 0x5100c, lcr); | ||
1002 | REG_WRITE(ah, 0x51004, (baud_divider >> 8)); | ||
1003 | REG_WRITE(ah, 0x51000, (baud_divider & 0xff)); | ||
1004 | |||
1005 | lcr &= ~0x80; | ||
1006 | REG_WRITE(ah, 0x5100c, lcr); | ||
1007 | } | ||
1008 | |||
1009 | static void ath9k_hw_init_pll(struct ath_hw *ah, | 1009 | static void ath9k_hw_init_pll(struct ath_hw *ah, |
1010 | struct ath9k_channel *chan) | 1010 | struct ath9k_channel *chan) |
1011 | { | 1011 | { |
@@ -1071,22 +1071,8 @@ static void ath9k_hw_init_pll(struct ath_hw *ah, | |||
1071 | 1071 | ||
1072 | /* Switch the core clock for ar9271 to 117Mhz */ | 1072 | /* Switch the core clock for ar9271 to 117Mhz */ |
1073 | if (AR_SREV_9271(ah)) { | 1073 | if (AR_SREV_9271(ah)) { |
1074 | if ((pll == 0x142c) || (pll == 0x2850) ) { | 1074 | udelay(500); |
1075 | udelay(500); | 1075 | REG_WRITE(ah, 0x50040, 0x304); |
1076 | /* set CLKOBS to output AHB clock */ | ||
1077 | REG_WRITE(ah, 0x7020, 0xe); | ||
1078 | /* | ||
1079 | * 0x304: 117Mhz, ahb_ratio: 1x1 | ||
1080 | * 0x306: 40Mhz, ahb_ratio: 1x1 | ||
1081 | */ | ||
1082 | REG_WRITE(ah, 0x50040, 0x304); | ||
1083 | /* | ||
1084 | * makes adjustments for the baud dividor to keep the | ||
1085 | * targetted baud rate based on the used core clock. | ||
1086 | */ | ||
1087 | ath9k_hw_change_target_baud(ah, AR9271_CORE_CLOCK, | ||
1088 | AR9271_TARGET_BAUD_RATE); | ||
1089 | } | ||
1090 | } | 1076 | } |
1091 | 1077 | ||
1092 | udelay(RTC_PLL_SETTLE_DELAY); | 1078 | udelay(RTC_PLL_SETTLE_DELAY); |
@@ -1241,7 +1227,7 @@ void ath9k_hw_deinit(struct ath_hw *ah) | |||
1241 | { | 1227 | { |
1242 | struct ath_common *common = ath9k_hw_common(ah); | 1228 | struct ath_common *common = ath9k_hw_common(ah); |
1243 | 1229 | ||
1244 | if (common->state <= ATH_HW_INITIALIZED) | 1230 | if (common->state < ATH_HW_INITIALIZED) |
1245 | goto free_hw; | 1231 | goto free_hw; |
1246 | 1232 | ||
1247 | if (!AR_SREV_9100(ah)) | 1233 | if (!AR_SREV_9100(ah)) |
@@ -1252,8 +1238,6 @@ void ath9k_hw_deinit(struct ath_hw *ah) | |||
1252 | free_hw: | 1238 | free_hw: |
1253 | if (!AR_SREV_9280_10_OR_LATER(ah)) | 1239 | if (!AR_SREV_9280_10_OR_LATER(ah)) |
1254 | ath9k_hw_rf_free_ext_banks(ah); | 1240 | ath9k_hw_rf_free_ext_banks(ah); |
1255 | kfree(ah); | ||
1256 | ah = NULL; | ||
1257 | } | 1241 | } |
1258 | EXPORT_SYMBOL(ath9k_hw_deinit); | 1242 | EXPORT_SYMBOL(ath9k_hw_deinit); |
1259 | 1243 | ||
@@ -1266,26 +1250,6 @@ static void ath9k_hw_override_ini(struct ath_hw *ah, | |||
1266 | { | 1250 | { |
1267 | u32 val; | 1251 | u32 val; |
1268 | 1252 | ||
1269 | if (AR_SREV_9271(ah)) { | ||
1270 | /* | ||
1271 | * Enable spectral scan to solution for issues with stuck | ||
1272 | * beacons on AR9271 1.0. The beacon stuck issue is not seeon on | ||
1273 | * AR9271 1.1 | ||
1274 | */ | ||
1275 | if (AR_SREV_9271_10(ah)) { | ||
1276 | val = REG_READ(ah, AR_PHY_SPECTRAL_SCAN) | | ||
1277 | AR_PHY_SPECTRAL_SCAN_ENABLE; | ||
1278 | REG_WRITE(ah, AR_PHY_SPECTRAL_SCAN, val); | ||
1279 | } | ||
1280 | else if (AR_SREV_9271_11(ah)) | ||
1281 | /* | ||
1282 | * change AR_PHY_RF_CTL3 setting to fix MAC issue | ||
1283 | * present on AR9271 1.1 | ||
1284 | */ | ||
1285 | REG_WRITE(ah, AR_PHY_RF_CTL3, 0x3a020001); | ||
1286 | return; | ||
1287 | } | ||
1288 | |||
1289 | /* | 1253 | /* |
1290 | * Set the RX_ABORT and RX_DIS and clear if off only after | 1254 | * Set the RX_ABORT and RX_DIS and clear if off only after |
1291 | * RXE is set for MAC. This prevents frames with corrupted | 1255 | * RXE is set for MAC. This prevents frames with corrupted |
@@ -1294,8 +1258,10 @@ static void ath9k_hw_override_ini(struct ath_hw *ah, | |||
1294 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); | 1258 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
1295 | 1259 | ||
1296 | if (AR_SREV_9280_10_OR_LATER(ah)) { | 1260 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
1297 | val = REG_READ(ah, AR_PCU_MISC_MODE2) & | 1261 | val = REG_READ(ah, AR_PCU_MISC_MODE2); |
1298 | (~AR_PCU_MISC_MODE2_HWWAR1); | 1262 | |
1263 | if (!AR_SREV_9271(ah)) | ||
1264 | val &= ~AR_PCU_MISC_MODE2_HWWAR1; | ||
1299 | 1265 | ||
1300 | if (AR_SREV_9287_10_OR_LATER(ah)) | 1266 | if (AR_SREV_9287_10_OR_LATER(ah)) |
1301 | val = val & (~AR_PCU_MISC_MODE2_HWWAR2); | 1267 | val = val & (~AR_PCU_MISC_MODE2_HWWAR2); |
@@ -1439,7 +1405,10 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1439 | return -EINVAL; | 1405 | return -EINVAL; |
1440 | } | 1406 | } |
1441 | 1407 | ||
1408 | /* Set correct baseband to analog shift setting to access analog chips */ | ||
1442 | REG_WRITE(ah, AR_PHY(0), 0x00000007); | 1409 | REG_WRITE(ah, AR_PHY(0), 0x00000007); |
1410 | |||
1411 | /* Write ADDAC shifts */ | ||
1443 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO); | 1412 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO); |
1444 | ah->eep_ops->set_addac(ah, chan); | 1413 | ah->eep_ops->set_addac(ah, chan); |
1445 | 1414 | ||
@@ -1451,9 +1420,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1451 | sizeof(u32) * ah->iniAddac.ia_rows * | 1420 | sizeof(u32) * ah->iniAddac.ia_rows * |
1452 | ah->iniAddac.ia_columns; | 1421 | ah->iniAddac.ia_columns; |
1453 | 1422 | ||
1423 | /* For AR5416 2.0/2.1 */ | ||
1454 | memcpy(ah->addac5416_21, | 1424 | memcpy(ah->addac5416_21, |
1455 | ah->iniAddac.ia_array, addacSize); | 1425 | ah->iniAddac.ia_array, addacSize); |
1456 | 1426 | ||
1427 | /* override CLKDRV value at [row, column] = [31, 1] */ | ||
1457 | (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; | 1428 | (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; |
1458 | 1429 | ||
1459 | temp.ia_array = ah->addac5416_21; | 1430 | temp.ia_array = ah->addac5416_21; |
@@ -1485,6 +1456,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1485 | AR_SREV_9287_10_OR_LATER(ah)) | 1456 | AR_SREV_9287_10_OR_LATER(ah)) |
1486 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); | 1457 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); |
1487 | 1458 | ||
1459 | if (AR_SREV_9271_10(ah)) | ||
1460 | REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only, | ||
1461 | modesIndex, regWrites); | ||
1462 | |||
1463 | /* Write common array parameters */ | ||
1488 | for (i = 0; i < ah->iniCommon.ia_rows; i++) { | 1464 | for (i = 0; i < ah->iniCommon.ia_rows; i++) { |
1489 | u32 reg = INI_RA(&ah->iniCommon, i, 0); | 1465 | u32 reg = INI_RA(&ah->iniCommon, i, 0); |
1490 | u32 val = INI_RA(&ah->iniCommon, i, 1); | 1466 | u32 val = INI_RA(&ah->iniCommon, i, 1); |
@@ -1499,11 +1475,16 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1499 | DO_DELAY(regWrites); | 1475 | DO_DELAY(regWrites); |
1500 | } | 1476 | } |
1501 | 1477 | ||
1502 | ath9k_hw_write_regs(ah, freqIndex, regWrites); | 1478 | if (AR_SREV_9271(ah)) { |
1479 | if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1) | ||
1480 | REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271, | ||
1481 | modesIndex, regWrites); | ||
1482 | else | ||
1483 | REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, | ||
1484 | modesIndex, regWrites); | ||
1485 | } | ||
1503 | 1486 | ||
1504 | if (AR_SREV_9271_10(ah)) | 1487 | ath9k_hw_write_regs(ah, freqIndex, regWrites); |
1505 | REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only, | ||
1506 | modesIndex, regWrites); | ||
1507 | 1488 | ||
1508 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) { | 1489 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) { |
1509 | REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, | 1490 | REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, |
@@ -1517,6 +1498,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1517 | if (OLC_FOR_AR9280_20_LATER) | 1498 | if (OLC_FOR_AR9280_20_LATER) |
1518 | ath9k_olc_init(ah); | 1499 | ath9k_olc_init(ah); |
1519 | 1500 | ||
1501 | /* Set TX power */ | ||
1520 | ah->eep_ops->set_txpower(ah, chan, | 1502 | ah->eep_ops->set_txpower(ah, chan, |
1521 | ath9k_regd_get_ctl(regulatory, chan), | 1503 | ath9k_regd_get_ctl(regulatory, chan), |
1522 | channel->max_antenna_gain * 2, | 1504 | channel->max_antenna_gain * 2, |
@@ -1524,6 +1506,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah, | |||
1524 | min((u32) MAX_RATE_POWER, | 1506 | min((u32) MAX_RATE_POWER, |
1525 | (u32) regulatory->power_limit)); | 1507 | (u32) regulatory->power_limit)); |
1526 | 1508 | ||
1509 | /* Write analog registers */ | ||
1527 | if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { | 1510 | if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { |
1528 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, | 1511 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
1529 | "ar5416SetRfRegs failed\n"); | 1512 | "ar5416SetRfRegs failed\n"); |
@@ -1966,6 +1949,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1966 | 1949 | ||
1967 | ath9k_hw_mark_phy_inactive(ah); | 1950 | ath9k_hw_mark_phy_inactive(ah); |
1968 | 1951 | ||
1952 | /* Only required on the first reset */ | ||
1969 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { | 1953 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { |
1970 | REG_WRITE(ah, | 1954 | REG_WRITE(ah, |
1971 | AR9271_RESET_POWER_DOWN_CONTROL, | 1955 | AR9271_RESET_POWER_DOWN_CONTROL, |
@@ -1978,6 +1962,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1978 | return -EINVAL; | 1962 | return -EINVAL; |
1979 | } | 1963 | } |
1980 | 1964 | ||
1965 | /* Only required on the first reset */ | ||
1981 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { | 1966 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { |
1982 | ah->htc_reset_init = false; | 1967 | ah->htc_reset_init = false; |
1983 | REG_WRITE(ah, | 1968 | REG_WRITE(ah, |
@@ -2438,7 +2423,7 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) | |||
2438 | if (!AR_SREV_9100(ah)) | 2423 | if (!AR_SREV_9100(ah)) |
2439 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); | 2424 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); |
2440 | 2425 | ||
2441 | if(!AR_SREV_5416(ah)) | 2426 | if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah)) |
2442 | REG_CLR_BIT(ah, (AR_RTC_RESET), | 2427 | REG_CLR_BIT(ah, (AR_RTC_RESET), |
2443 | AR_RTC_RESET_EN); | 2428 | AR_RTC_RESET_EN); |
2444 | } | 2429 | } |
@@ -3216,7 +3201,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
3216 | else | 3201 | else |
3217 | pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD; | 3202 | pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD; |
3218 | 3203 | ||
3219 | if (AR_SREV_9285_10_OR_LATER(ah)) | 3204 | if (AR_SREV_9271(ah)) |
3205 | pCap->num_gpio_pins = AR9271_NUM_GPIO; | ||
3206 | else if (AR_SREV_9285_10_OR_LATER(ah)) | ||
3220 | pCap->num_gpio_pins = AR9285_NUM_GPIO; | 3207 | pCap->num_gpio_pins = AR9285_NUM_GPIO; |
3221 | else if (AR_SREV_9280_10_OR_LATER(ah)) | 3208 | else if (AR_SREV_9280_10_OR_LATER(ah)) |
3222 | pCap->num_gpio_pins = AR928X_NUM_GPIO; | 3209 | pCap->num_gpio_pins = AR928X_NUM_GPIO; |
@@ -3452,7 +3439,9 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio) | |||
3452 | if (gpio >= ah->caps.num_gpio_pins) | 3439 | if (gpio >= ah->caps.num_gpio_pins) |
3453 | return 0xffffffff; | 3440 | return 0xffffffff; |
3454 | 3441 | ||
3455 | if (AR_SREV_9287_10_OR_LATER(ah)) | 3442 | if (AR_SREV_9271(ah)) |
3443 | return MS_REG_READ(AR9271, gpio) != 0; | ||
3444 | else if (AR_SREV_9287_10_OR_LATER(ah)) | ||
3456 | return MS_REG_READ(AR9287, gpio) != 0; | 3445 | return MS_REG_READ(AR9287, gpio) != 0; |
3457 | else if (AR_SREV_9285_10_OR_LATER(ah)) | 3446 | else if (AR_SREV_9285_10_OR_LATER(ah)) |
3458 | return MS_REG_READ(AR9285, gpio) != 0; | 3447 | return MS_REG_READ(AR9285, gpio) != 0; |
@@ -3481,6 +3470,9 @@ EXPORT_SYMBOL(ath9k_hw_cfg_output); | |||
3481 | 3470 | ||
3482 | void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) | 3471 | void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) |
3483 | { | 3472 | { |
3473 | if (AR_SREV_9271(ah)) | ||
3474 | val = ~val; | ||
3475 | |||
3484 | REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), | 3476 | REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), |
3485 | AR_GPIO_BIT(gpio)); | 3477 | AR_GPIO_BIT(gpio)); |
3486 | } | 3478 | } |
@@ -3865,6 +3857,16 @@ void ath_gen_timer_isr(struct ath_hw *ah) | |||
3865 | } | 3857 | } |
3866 | EXPORT_SYMBOL(ath_gen_timer_isr); | 3858 | EXPORT_SYMBOL(ath_gen_timer_isr); |
3867 | 3859 | ||
3860 | /********/ | ||
3861 | /* HTC */ | ||
3862 | /********/ | ||
3863 | |||
3864 | void ath9k_hw_htc_resetinit(struct ath_hw *ah) | ||
3865 | { | ||
3866 | ah->htc_reset_init = true; | ||
3867 | } | ||
3868 | EXPORT_SYMBOL(ath9k_hw_htc_resetinit); | ||
3869 | |||
3868 | static struct { | 3870 | static struct { |
3869 | u32 version; | 3871 | u32 version; |
3870 | const char * name; | 3872 | const char * name; |