aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2e767cf22f1e..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
993static 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
1009static void ath9k_hw_init_pll(struct ath_hw *ah, 1009static 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);
@@ -1151,7 +1137,8 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
1151 ah->mask_reg |= AR_IMR_MIB; 1137 ah->mask_reg |= AR_IMR_MIB;
1152 1138
1153 REG_WRITE(ah, AR_IMR, ah->mask_reg); 1139 REG_WRITE(ah, AR_IMR, ah->mask_reg);
1154 REG_WRITE(ah, AR_IMR_S2, REG_READ(ah, AR_IMR_S2) | AR_IMR_S2_GTT); 1140 ah->imrs2_reg |= AR_IMR_S2_GTT;
1141 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
1155 1142
1156 if (!AR_SREV_9100(ah)) { 1143 if (!AR_SREV_9100(ah)) {
1157 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF); 1144 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF);
@@ -1240,7 +1227,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
1240{ 1227{
1241 struct ath_common *common = ath9k_hw_common(ah); 1228 struct ath_common *common = ath9k_hw_common(ah);
1242 1229
1243 if (common->state <= ATH_HW_INITIALIZED) 1230 if (common->state < ATH_HW_INITIALIZED)
1244 goto free_hw; 1231 goto free_hw;
1245 1232
1246 if (!AR_SREV_9100(ah)) 1233 if (!AR_SREV_9100(ah))
@@ -1251,8 +1238,6 @@ void ath9k_hw_deinit(struct ath_hw *ah)
1251free_hw: 1238free_hw:
1252 if (!AR_SREV_9280_10_OR_LATER(ah)) 1239 if (!AR_SREV_9280_10_OR_LATER(ah))
1253 ath9k_hw_rf_free_ext_banks(ah); 1240 ath9k_hw_rf_free_ext_banks(ah);
1254 kfree(ah);
1255 ah = NULL;
1256} 1241}
1257EXPORT_SYMBOL(ath9k_hw_deinit); 1242EXPORT_SYMBOL(ath9k_hw_deinit);
1258 1243
@@ -1265,26 +1250,6 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
1265{ 1250{
1266 u32 val; 1251 u32 val;
1267 1252
1268 if (AR_SREV_9271(ah)) {
1269 /*
1270 * Enable spectral scan to solution for issues with stuck
1271 * beacons on AR9271 1.0. The beacon stuck issue is not seeon on
1272 * AR9271 1.1
1273 */
1274 if (AR_SREV_9271_10(ah)) {
1275 val = REG_READ(ah, AR_PHY_SPECTRAL_SCAN) |
1276 AR_PHY_SPECTRAL_SCAN_ENABLE;
1277 REG_WRITE(ah, AR_PHY_SPECTRAL_SCAN, val);
1278 }
1279 else if (AR_SREV_9271_11(ah))
1280 /*
1281 * change AR_PHY_RF_CTL3 setting to fix MAC issue
1282 * present on AR9271 1.1
1283 */
1284 REG_WRITE(ah, AR_PHY_RF_CTL3, 0x3a020001);
1285 return;
1286 }
1287
1288 /* 1253 /*
1289 * 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
1290 * RXE is set for MAC. This prevents frames with corrupted 1255 * RXE is set for MAC. This prevents frames with corrupted
@@ -1293,8 +1258,10 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
1293 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));
1294 1259
1295 if (AR_SREV_9280_10_OR_LATER(ah)) { 1260 if (AR_SREV_9280_10_OR_LATER(ah)) {
1296 val = REG_READ(ah, AR_PCU_MISC_MODE2) & 1261 val = REG_READ(ah, AR_PCU_MISC_MODE2);
1297 (~AR_PCU_MISC_MODE2_HWWAR1); 1262
1263 if (!AR_SREV_9271(ah))
1264 val &= ~AR_PCU_MISC_MODE2_HWWAR1;
1298 1265
1299 if (AR_SREV_9287_10_OR_LATER(ah)) 1266 if (AR_SREV_9287_10_OR_LATER(ah))
1300 val = val & (~AR_PCU_MISC_MODE2_HWWAR2); 1267 val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
@@ -1438,7 +1405,10 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1438 return -EINVAL; 1405 return -EINVAL;
1439 } 1406 }
1440 1407
1408 /* Set correct baseband to analog shift setting to access analog chips */
1441 REG_WRITE(ah, AR_PHY(0), 0x00000007); 1409 REG_WRITE(ah, AR_PHY(0), 0x00000007);
1410
1411 /* Write ADDAC shifts */
1442 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);
1443 ah->eep_ops->set_addac(ah, chan); 1413 ah->eep_ops->set_addac(ah, chan);
1444 1414
@@ -1450,9 +1420,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1450 sizeof(u32) * ah->iniAddac.ia_rows * 1420 sizeof(u32) * ah->iniAddac.ia_rows *
1451 ah->iniAddac.ia_columns; 1421 ah->iniAddac.ia_columns;
1452 1422
1423 /* For AR5416 2.0/2.1 */
1453 memcpy(ah->addac5416_21, 1424 memcpy(ah->addac5416_21,
1454 ah->iniAddac.ia_array, addacSize); 1425 ah->iniAddac.ia_array, addacSize);
1455 1426
1427 /* override CLKDRV value at [row, column] = [31, 1] */
1456 (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; 1428 (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0;
1457 1429
1458 temp.ia_array = ah->addac5416_21; 1430 temp.ia_array = ah->addac5416_21;
@@ -1484,6 +1456,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1484 AR_SREV_9287_10_OR_LATER(ah)) 1456 AR_SREV_9287_10_OR_LATER(ah))
1485 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); 1457 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
1486 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 */
1487 for (i = 0; i < ah->iniCommon.ia_rows; i++) { 1464 for (i = 0; i < ah->iniCommon.ia_rows; i++) {
1488 u32 reg = INI_RA(&ah->iniCommon, i, 0); 1465 u32 reg = INI_RA(&ah->iniCommon, i, 0);
1489 u32 val = INI_RA(&ah->iniCommon, i, 1); 1466 u32 val = INI_RA(&ah->iniCommon, i, 1);
@@ -1498,11 +1475,16 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1498 DO_DELAY(regWrites); 1475 DO_DELAY(regWrites);
1499 } 1476 }
1500 1477
1501 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 }
1502 1486
1503 if (AR_SREV_9271_10(ah)) 1487 ath9k_hw_write_regs(ah, freqIndex, regWrites);
1504 REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only,
1505 modesIndex, regWrites);
1506 1488
1507 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)) {
1508 REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, 1490 REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex,
@@ -1516,6 +1498,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1516 if (OLC_FOR_AR9280_20_LATER) 1498 if (OLC_FOR_AR9280_20_LATER)
1517 ath9k_olc_init(ah); 1499 ath9k_olc_init(ah);
1518 1500
1501 /* Set TX power */
1519 ah->eep_ops->set_txpower(ah, chan, 1502 ah->eep_ops->set_txpower(ah, chan,
1520 ath9k_regd_get_ctl(regulatory, chan), 1503 ath9k_regd_get_ctl(regulatory, chan),
1521 channel->max_antenna_gain * 2, 1504 channel->max_antenna_gain * 2,
@@ -1523,6 +1506,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1523 min((u32) MAX_RATE_POWER, 1506 min((u32) MAX_RATE_POWER,
1524 (u32) regulatory->power_limit)); 1507 (u32) regulatory->power_limit));
1525 1508
1509 /* Write analog registers */
1526 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { 1510 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
1527 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, 1511 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
1528 "ar5416SetRfRegs failed\n"); 1512 "ar5416SetRfRegs failed\n");
@@ -1965,6 +1949,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1965 1949
1966 ath9k_hw_mark_phy_inactive(ah); 1950 ath9k_hw_mark_phy_inactive(ah);
1967 1951
1952 /* Only required on the first reset */
1968 if (AR_SREV_9271(ah) && ah->htc_reset_init) { 1953 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1969 REG_WRITE(ah, 1954 REG_WRITE(ah,
1970 AR9271_RESET_POWER_DOWN_CONTROL, 1955 AR9271_RESET_POWER_DOWN_CONTROL,
@@ -1977,6 +1962,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1977 return -EINVAL; 1962 return -EINVAL;
1978 } 1963 }
1979 1964
1965 /* Only required on the first reset */
1980 if (AR_SREV_9271(ah) && ah->htc_reset_init) { 1966 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1981 ah->htc_reset_init = false; 1967 ah->htc_reset_init = false;
1982 REG_WRITE(ah, 1968 REG_WRITE(ah,
@@ -2437,7 +2423,7 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip)
2437 if (!AR_SREV_9100(ah)) 2423 if (!AR_SREV_9100(ah))
2438 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); 2424 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
2439 2425
2440 if(!AR_SREV_5416(ah)) 2426 if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah))
2441 REG_CLR_BIT(ah, (AR_RTC_RESET), 2427 REG_CLR_BIT(ah, (AR_RTC_RESET),
2442 AR_RTC_RESET_EN); 2428 AR_RTC_RESET_EN);
2443 } 2429 }
@@ -2920,14 +2906,11 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
2920 2906
2921 ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask); 2907 ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask);
2922 REG_WRITE(ah, AR_IMR, mask); 2908 REG_WRITE(ah, AR_IMR, mask);
2923 mask = REG_READ(ah, AR_IMR_S2) & ~(AR_IMR_S2_TIM | 2909 ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC |
2924 AR_IMR_S2_DTIM | 2910 AR_IMR_S2_CABEND | AR_IMR_S2_CABTO |
2925 AR_IMR_S2_DTIMSYNC | 2911 AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST);
2926 AR_IMR_S2_CABEND | 2912 ah->imrs2_reg |= mask2;
2927 AR_IMR_S2_CABTO | 2913 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
2928 AR_IMR_S2_TSFOOR |
2929 AR_IMR_S2_GTT | AR_IMR_S2_CST);
2930 REG_WRITE(ah, AR_IMR_S2, mask | mask2);
2931 ah->mask_reg = ints; 2914 ah->mask_reg = ints;
2932 2915
2933 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { 2916 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
@@ -3218,7 +3201,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
3218 else 3201 else
3219 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD; 3202 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD;
3220 3203
3221 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))
3222 pCap->num_gpio_pins = AR9285_NUM_GPIO; 3207 pCap->num_gpio_pins = AR9285_NUM_GPIO;
3223 else if (AR_SREV_9280_10_OR_LATER(ah)) 3208 else if (AR_SREV_9280_10_OR_LATER(ah))
3224 pCap->num_gpio_pins = AR928X_NUM_GPIO; 3209 pCap->num_gpio_pins = AR928X_NUM_GPIO;
@@ -3454,7 +3439,9 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
3454 if (gpio >= ah->caps.num_gpio_pins) 3439 if (gpio >= ah->caps.num_gpio_pins)
3455 return 0xffffffff; 3440 return 0xffffffff;
3456 3441
3457 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))
3458 return MS_REG_READ(AR9287, gpio) != 0; 3445 return MS_REG_READ(AR9287, gpio) != 0;
3459 else if (AR_SREV_9285_10_OR_LATER(ah)) 3446 else if (AR_SREV_9285_10_OR_LATER(ah))
3460 return MS_REG_READ(AR9285, gpio) != 0; 3447 return MS_REG_READ(AR9285, gpio) != 0;
@@ -3483,6 +3470,9 @@ EXPORT_SYMBOL(ath9k_hw_cfg_output);
3483 3470
3484void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) 3471void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val)
3485{ 3472{
3473 if (AR_SREV_9271(ah))
3474 val = ~val;
3475
3486 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), 3476 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio),
3487 AR_GPIO_BIT(gpio)); 3477 AR_GPIO_BIT(gpio));
3488} 3478}
@@ -3867,6 +3857,16 @@ void ath_gen_timer_isr(struct ath_hw *ah)
3867} 3857}
3868EXPORT_SYMBOL(ath_gen_timer_isr); 3858EXPORT_SYMBOL(ath_gen_timer_isr);
3869 3859
3860/********/
3861/* HTC */
3862/********/
3863
3864void ath9k_hw_htc_resetinit(struct ath_hw *ah)
3865{
3866 ah->htc_reset_init = true;
3867}
3868EXPORT_SYMBOL(ath9k_hw_htc_resetinit);
3869
3870static struct { 3870static struct {
3871 u32 version; 3871 u32 version;
3872 const char * name; 3872 const char * name;