aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/ar5008_phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/ar5008_phy.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c81
1 files changed, 9 insertions, 72 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 48c5a5f38ca..4a910b78de5 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -1516,77 +1516,6 @@ static void ar5008_hw_do_getnf(struct ath_hw *ah,
1516 nfarray[5] = sign_extend(nf, 9); 1516 nfarray[5] = sign_extend(nf, 9);
1517} 1517}
1518 1518
1519static void ar5008_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
1520{
1521 struct ath9k_nfcal_hist *h;
1522 int i, j;
1523 int32_t val;
1524 const u32 ar5416_cca_regs[6] = {
1525 AR_PHY_CCA,
1526 AR_PHY_CH1_CCA,
1527 AR_PHY_CH2_CCA,
1528 AR_PHY_EXT_CCA,
1529 AR_PHY_CH1_EXT_CCA,
1530 AR_PHY_CH2_EXT_CCA
1531 };
1532 u8 chainmask, rx_chain_status;
1533
1534 rx_chain_status = REG_READ(ah, AR_PHY_RX_CHAINMASK);
1535 if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
1536 chainmask = 0x9;
1537 else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) {
1538 if ((rx_chain_status & 0x2) || (rx_chain_status & 0x4))
1539 chainmask = 0x1B;
1540 else
1541 chainmask = 0x09;
1542 } else {
1543 if (rx_chain_status & 0x4)
1544 chainmask = 0x3F;
1545 else if (rx_chain_status & 0x2)
1546 chainmask = 0x1B;
1547 else
1548 chainmask = 0x09;
1549 }
1550
1551 h = ah->nfCalHist;
1552
1553 for (i = 0; i < NUM_NF_READINGS; i++) {
1554 if (chainmask & (1 << i)) {
1555 val = REG_READ(ah, ar5416_cca_regs[i]);
1556 val &= 0xFFFFFE00;
1557 val |= (((u32) (h[i].privNF) << 1) & 0x1ff);
1558 REG_WRITE(ah, ar5416_cca_regs[i], val);
1559 }
1560 }
1561
1562 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
1563 AR_PHY_AGC_CONTROL_ENABLE_NF);
1564 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
1565 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
1566 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
1567
1568 for (j = 0; j < 5; j++) {
1569 if ((REG_READ(ah, AR_PHY_AGC_CONTROL) &
1570 AR_PHY_AGC_CONTROL_NF) == 0)
1571 break;
1572 udelay(50);
1573 }
1574
1575 ENABLE_REGWRITE_BUFFER(ah);
1576
1577 for (i = 0; i < NUM_NF_READINGS; i++) {
1578 if (chainmask & (1 << i)) {
1579 val = REG_READ(ah, ar5416_cca_regs[i]);
1580 val &= 0xFFFFFE00;
1581 val |= (((u32) (-50) << 1) & 0x1ff);
1582 REG_WRITE(ah, ar5416_cca_regs[i], val);
1583 }
1584 }
1585
1586 REGWRITE_BUFFER_FLUSH(ah);
1587 DISABLE_REGWRITE_BUFFER(ah);
1588}
1589
1590/* 1519/*
1591 * Initialize the ANI register values with default (ini) values. 1520 * Initialize the ANI register values with default (ini) values.
1592 * This routine is called during a (full) hardware reset after 1521 * This routine is called during a (full) hardware reset after
@@ -1664,6 +1593,14 @@ static void ar5008_hw_set_nf_limits(struct ath_hw *ah)
1664void ar5008_hw_attach_phy_ops(struct ath_hw *ah) 1593void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
1665{ 1594{
1666 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); 1595 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1596 const u32 ar5416_cca_regs[6] = {
1597 AR_PHY_CCA,
1598 AR_PHY_CH1_CCA,
1599 AR_PHY_CH2_CCA,
1600 AR_PHY_EXT_CCA,
1601 AR_PHY_CH1_EXT_CCA,
1602 AR_PHY_CH2_EXT_CCA
1603 };
1667 1604
1668 priv_ops->rf_set_freq = ar5008_hw_set_channel; 1605 priv_ops->rf_set_freq = ar5008_hw_set_channel;
1669 priv_ops->spur_mitigate_freq = ar5008_hw_spur_mitigate; 1606 priv_ops->spur_mitigate_freq = ar5008_hw_spur_mitigate;
@@ -1683,7 +1620,6 @@ void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
1683 priv_ops->restore_chainmask = ar5008_restore_chainmask; 1620 priv_ops->restore_chainmask = ar5008_restore_chainmask;
1684 priv_ops->set_diversity = ar5008_set_diversity; 1621 priv_ops->set_diversity = ar5008_set_diversity;
1685 priv_ops->do_getnf = ar5008_hw_do_getnf; 1622 priv_ops->do_getnf = ar5008_hw_do_getnf;
1686 priv_ops->loadnf = ar5008_hw_loadnf;
1687 1623
1688 if (modparam_force_new_ani) { 1624 if (modparam_force_new_ani) {
1689 priv_ops->ani_control = ar5008_hw_ani_control_new; 1625 priv_ops->ani_control = ar5008_hw_ani_control_new;
@@ -1699,4 +1635,5 @@ void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
1699 priv_ops->compute_pll_control = ar5008_hw_compute_pll_control; 1635 priv_ops->compute_pll_control = ar5008_hw_compute_pll_control;
1700 1636
1701 ar5008_hw_set_nf_limits(ah); 1637 ar5008_hw_set_nf_limits(ah);
1638 memcpy(ah->nf_regs, ar5416_cca_regs, sizeof(ah->nf_regs));
1702} 1639}