aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/ar9003_phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/ar9003_phy.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c190
1 files changed, 128 insertions, 62 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 1f694ab3cc78..e897648d3233 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -632,6 +632,22 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
632 632
633 REG_SET_BIT(ah, AR_PHY_CCK_DETECT, 633 REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
634 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); 634 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
635
636 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
637 REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
638 AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
639
640 if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
641 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
642 ah->enabled_cals |= TX_IQ_CAL;
643 else
644 ah->enabled_cals &= ~TX_IQ_CAL;
645
646 if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
647 ah->enabled_cals |= TX_CL_CAL;
648 else
649 ah->enabled_cals &= ~TX_CL_CAL;
650 }
635} 651}
636 652
637static void ar9003_hw_prog_ini(struct ath_hw *ah, 653static void ar9003_hw_prog_ini(struct ath_hw *ah,
@@ -814,29 +830,12 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
814 if (chan->channel == 2484) 830 if (chan->channel == 2484)
815 ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1); 831 ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
816 832
817 if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
818 REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
819 AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
820
821 ah->modes_index = modesIndex; 833 ah->modes_index = modesIndex;
822 ar9003_hw_override_ini(ah); 834 ar9003_hw_override_ini(ah);
823 ar9003_hw_set_channel_regs(ah, chan); 835 ar9003_hw_set_channel_regs(ah, chan);
824 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); 836 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
825 ath9k_hw_apply_txpower(ah, chan, false); 837 ath9k_hw_apply_txpower(ah, chan, false);
826 838
827 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
828 if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
829 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
830 ah->enabled_cals |= TX_IQ_CAL;
831 else
832 ah->enabled_cals &= ~TX_IQ_CAL;
833
834 if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
835 ah->enabled_cals |= TX_CL_CAL;
836 else
837 ah->enabled_cals &= ~TX_CL_CAL;
838 }
839
840 return 0; 839 return 0;
841} 840}
842 841
@@ -1173,6 +1172,10 @@ skip_ws_det:
1173 * is_on == 0 means MRC CCK is OFF (more noise imm) 1172 * is_on == 0 means MRC CCK is OFF (more noise imm)
1174 */ 1173 */
1175 bool is_on = param ? 1 : 0; 1174 bool is_on = param ? 1 : 0;
1175
1176 if (ah->caps.rx_chainmask == 1)
1177 break;
1178
1176 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, 1179 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
1177 AR_PHY_MRC_CCK_ENABLE, is_on); 1180 AR_PHY_MRC_CCK_ENABLE, is_on);
1178 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, 1181 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
@@ -1190,8 +1193,6 @@ skip_ws_det:
1190 } 1193 }
1191 break; 1194 break;
1192 } 1195 }
1193 case ATH9K_ANI_PRESENT:
1194 break;
1195 default: 1196 default:
1196 ath_dbg(common, ANI, "invalid cmd %u\n", cmd); 1197 ath_dbg(common, ANI, "invalid cmd %u\n", cmd);
1197 return false; 1198 return false;
@@ -1413,65 +1414,111 @@ static void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah,
1413 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); 1414 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1414} 1415}
1415 1416
1416static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah, 1417#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1417 bool enable) 1418
1419static void ar9003_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
1418{ 1420{
1421 struct ath9k_hw_capabilities *pCap = &ah->caps;
1419 u8 ant_div_ctl1; 1422 u8 ant_div_ctl1;
1420 u32 regval; 1423 u32 regval;
1421 1424
1422 if (!AR_SREV_9565(ah)) 1425 if (!AR_SREV_9485(ah) && !AR_SREV_9565(ah))
1423 return; 1426 return;
1424 1427
1425 ah->shared_chain_lnadiv = enable; 1428 if (AR_SREV_9485(ah)) {
1429 regval = ar9003_hw_ant_ctrl_common_2_get(ah,
1430 IS_CHAN_2GHZ(ah->curchan));
1431 if (enable) {
1432 regval &= ~AR_SWITCH_TABLE_COM2_ALL;
1433 regval |= ah->config.ant_ctrl_comm2g_switch_enable;
1434 }
1435 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2,
1436 AR_SWITCH_TABLE_COM2_ALL, regval);
1437 }
1438
1426 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); 1439 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
1427 1440
1441 /*
1442 * Set MAIN/ALT LNA conf.
1443 * Set MAIN/ALT gain_tb.
1444 */
1428 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); 1445 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1429 regval &= (~AR_ANT_DIV_CTRL_ALL); 1446 regval &= (~AR_ANT_DIV_CTRL_ALL);
1430 regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S; 1447 regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
1431 regval &= ~AR_PHY_ANT_DIV_LNADIV;
1432 regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
1433
1434 if (enable)
1435 regval |= AR_ANT_DIV_ENABLE;
1436
1437 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); 1448 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1438 1449
1439 regval = REG_READ(ah, AR_PHY_CCK_DETECT); 1450 if (AR_SREV_9485_11_OR_LATER(ah)) {
1440 regval &= ~AR_FAST_DIV_ENABLE; 1451 /*
1441 regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; 1452 * Enable LNA diversity.
1442 1453 */
1443 if (enable)
1444 regval |= AR_FAST_DIV_ENABLE;
1445
1446 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
1447
1448 if (enable) {
1449 REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1450 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1451 if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
1452 REG_SET_BIT(ah, AR_PHY_RESTART,
1453 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
1454 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
1455 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1456 } else {
1457 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
1458 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1459 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1460 REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
1461 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
1462 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1463
1464 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); 1454 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1465 regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF | 1455 regval &= ~AR_PHY_ANT_DIV_LNADIV;
1466 AR_PHY_ANT_DIV_ALT_LNACONF | 1456 regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
1467 AR_PHY_ANT_DIV_MAIN_GAINTB | 1457 if (enable)
1468 AR_PHY_ANT_DIV_ALT_GAINTB); 1458 regval |= AR_ANT_DIV_ENABLE;
1469 regval |= (AR_PHY_ANT_DIV_LNA1 << AR_PHY_ANT_DIV_MAIN_LNACONF_S); 1459
1470 regval |= (AR_PHY_ANT_DIV_LNA2 << AR_PHY_ANT_DIV_ALT_LNACONF_S);
1471 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); 1460 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1461
1462 /*
1463 * Enable fast antenna diversity.
1464 */
1465 regval = REG_READ(ah, AR_PHY_CCK_DETECT);
1466 regval &= ~AR_FAST_DIV_ENABLE;
1467 regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
1468 if (enable)
1469 regval |= AR_FAST_DIV_ENABLE;
1470
1471 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
1472
1473 if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
1474 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1475 regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
1476 AR_PHY_ANT_DIV_ALT_LNACONF |
1477 AR_PHY_ANT_DIV_ALT_GAINTB |
1478 AR_PHY_ANT_DIV_MAIN_GAINTB));
1479 /*
1480 * Set MAIN to LNA1 and ALT to LNA2 at the
1481 * beginning.
1482 */
1483 regval |= (ATH_ANT_DIV_COMB_LNA1 <<
1484 AR_PHY_ANT_DIV_MAIN_LNACONF_S);
1485 regval |= (ATH_ANT_DIV_COMB_LNA2 <<
1486 AR_PHY_ANT_DIV_ALT_LNACONF_S);
1487 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1488 }
1489 } else if (AR_SREV_9565(ah)) {
1490 if (enable) {
1491 REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1492 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1493 if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
1494 REG_SET_BIT(ah, AR_PHY_RESTART,
1495 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
1496 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
1497 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1498 } else {
1499 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
1500 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1501 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1502 REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
1503 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
1504 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1505
1506 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
1507 regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF |
1508 AR_PHY_ANT_DIV_ALT_LNACONF |
1509 AR_PHY_ANT_DIV_MAIN_GAINTB |
1510 AR_PHY_ANT_DIV_ALT_GAINTB);
1511 regval |= (ATH_ANT_DIV_COMB_LNA1 <<
1512 AR_PHY_ANT_DIV_MAIN_LNACONF_S);
1513 regval |= (ATH_ANT_DIV_COMB_LNA2 <<
1514 AR_PHY_ANT_DIV_ALT_LNACONF_S);
1515 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
1516 }
1472 } 1517 }
1473} 1518}
1474 1519
1520#endif
1521
1475static int ar9003_hw_fast_chan_change(struct ath_hw *ah, 1522static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
1476 struct ath9k_channel *chan, 1523 struct ath9k_channel *chan,
1477 u8 *ini_reloaded) 1524 u8 *ini_reloaded)
@@ -1518,6 +1565,18 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
1518 1565
1519 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); 1566 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
1520 1567
1568 if (AR_SREV_9462_20_OR_LATER(ah)) {
1569 /*
1570 * CUS217 mix LNA mode.
1571 */
1572 if (ar9003_hw_get_rx_gain_idx(ah) == 2) {
1573 REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_core,
1574 1, regWrites);
1575 REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
1576 modesIndex, regWrites);
1577 }
1578 }
1579
1521 /* 1580 /*
1522 * For 5GHz channels requiring Fast Clock, apply 1581 * For 5GHz channels requiring Fast Clock, apply
1523 * different modal values. 1582 * different modal values.
@@ -1528,7 +1587,11 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
1528 if (AR_SREV_9565(ah)) 1587 if (AR_SREV_9565(ah))
1529 REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites); 1588 REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites);
1530 1589
1531 REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites); 1590 /*
1591 * JAPAN regulatory.
1592 */
1593 if (chan->channel == 2484)
1594 ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
1532 1595
1533 ah->modes_index = modesIndex; 1596 ah->modes_index = modesIndex;
1534 *ini_reloaded = true; 1597 *ini_reloaded = true;
@@ -1631,11 +1694,14 @@ void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
1631 1694
1632 ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get; 1695 ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get;
1633 ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set; 1696 ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set;
1634 ops->antctrl_shared_chain_lnadiv = ar9003_hw_antctrl_shared_chain_lnadiv;
1635 ops->spectral_scan_config = ar9003_hw_spectral_scan_config; 1697 ops->spectral_scan_config = ar9003_hw_spectral_scan_config;
1636 ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger; 1698 ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger;
1637 ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait; 1699 ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait;
1638 1700
1701#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1702 ops->set_bt_ant_diversity = ar9003_hw_set_bt_ant_diversity;
1703#endif
1704
1639 ar9003_hw_set_nf_limits(ah); 1705 ar9003_hw_set_nf_limits(ah);
1640 ar9003_hw_set_radar_conf(ah); 1706 ar9003_hw_set_radar_conf(ah);
1641 memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs)); 1707 memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs));