/* * Copyright (c) 2012 Qualcomm Atheros, Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
staticvoid ath9k_hw_set_sta_powersave(struct ath_hw *ah)
{ if (!ath9k_hw_mci_is_enabled(ah)) goto set; /* * If MCI is being used, set PWR_SAV only when MCI's * PS state is disabled.
*/ if (ar9003_mci_state(ah, MCI_STATE_GET_WLAN_PS_STATE) != MCI_PS_DISABLE) return;
set:
REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
}
if (AR_SREV_9462_20_OR_LATER(ah) || AR_SREV_9565(ah)) { /* * AR9462 2.0 and AR9565 have an extra descriptor word * (time based discard) compared to other chips.
*/
REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0);
wow_ka_data_word0 = AR_WOW_TXBUF(13);
} else {
wow_ka_data_word0 = AR_WOW_TXBUF(12);
}
for (i = 0; i < KAL_NUM_DATA_WORDS; i++)
REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]);
}
int ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
u8 *user_mask, int pattern_count, int pattern_len)
{ int i;
u32 pattern_val, mask_val;
u32 set, clr;
if (pattern_count >= ah->wow.max_patterns) return -ENOSPC;
/* * Read the WoW status register to know * the wakeup reason.
*/
rval = REG_READ(ah, AR_WOW_PATTERN);
val = AR_WOW_STATUS(rval);
/* * Mask only the WoW events that we have enabled. Sometimes * we have spurious WoW events from the AR_WOW_PATTERN * register. This mask will clean it up.
*/
val &= ah->wow.wow_event_mask;
if (val) { if (val & AR_WOW_MAGIC_PAT_FOUND)
wow_status |= AH_WOW_MAGIC_PATTERN_EN; if (AR_WOW_PATTERN_FOUND(val))
wow_status |= AH_WOW_USER_PATTERN_EN; if (val & AR_WOW_KEEP_ALIVE_FAIL)
wow_status |= AH_WOW_LINK_CHANGE; if (val & AR_WOW_BEACON_FAIL)
wow_status |= AH_WOW_BEACON_MISS;
}
rval = REG_READ(ah, AR_MAC_PCU_WOW4);
val = AR_WOW_STATUS2(rval);
val &= ah->wow.wow_event_mask2;
if (val) { if (AR_WOW2_PATTERN_FOUND(val))
wow_status |= AH_WOW_USER_PATTERN_EN;
}
/* * set and clear WOW_PME_CLEAR registers for the chip to * generate next wow signal. * disable D3 before accessing other registers ?
*/
/* do we need to check the bit value 0x01000000 (7-10) ?? */
REG_RMW(ah, AR_PCIE_PM_CTRL(ah), AR_PMCTRL_WOW_PME_CLR,
AR_PMCTRL_PWR_STATE_D1D3);
/* * restore the beacon threshold to init value
*/
REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
/* * Restore the way the PCI-E reset, Power-On-Reset, external * PCIE_POR_SHORT pins are tied to its original value. * Previously just before WoW sleep, we untie the PCI-E * reset to our Chip's Power On Reset so that any PCI-E * reset from the bus will not reset our chip
*/ if (ah->is_pciexpress)
ath9k_hw_configpcipowersave(ah, false);
if (AR_SREV_9462(ah) || AR_SREV_9565(ah) || AR_SREV_9485(ah)) {
u32 dc = REG_READ(ah, AR_DIRECT_CONNECT);
if (!(dc & AR_DC_TSF2_ENABLE))
ath9k_hw_gen_timer_start_tsf2(ah);
}
/* * We need to untie the internal POR (power-on-reset) * to the external PCI-E reset. We also need to tie * the PCI-E Phy reset to the PCI-E reset.
*/
wa_reg = REG_READ(ah, AR_WA(ah));
wa_reg &= ~AR_WA_UNTIE_RESET_EN;
wa_reg |= AR_WA_RESET_EN;
wa_reg |= AR_WA_POR_SHORT;
/* * AR_PMCTRL_HOST_PME_EN - Override PME enable in configuration * space and allow MAC to generate WoW anyway. * * AR_PMCTRL_PWR_PM_CTRL_ENA - ??? * * AR_PMCTRL_AUX_PWR_DET - PCI core SYS_AUX_PWR_DET signal, * needs to be set for WoW in PCI mode. * * AR_PMCTRL_WOW_PME_CLR - WoW Clear Signal going to the MAC. * * Set the power states appropriately and enable PME. * * Set and clear WOW_PME_CLEAR for the chip * to generate next wow signal.
*/
REG_SET_BIT(ah, AR_PCIE_PM_CTRL(ah), AR_PMCTRL_HOST_PME_EN |
AR_PMCTRL_PWR_PM_CTRL_ENA |
AR_PMCTRL_AUX_PWR_DET |
AR_PMCTRL_WOW_PME_CLR);
REG_CLR_BIT(ah, AR_PCIE_PM_CTRL(ah), AR_PMCTRL_WOW_PME_CLR);
/* * Random Backoff. * * 31:28 in AR_WOW_PATTERN : Indicates the number of bits used in the * contention window. For value N, * the random backoff will be selected between * 0 and (2 ^ N) - 1.
*/
REG_SET_BIT(ah, AR_WOW_PATTERN,
AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF));
/* * We are relying on a bmiss failure, ensure we have * enough threshold to prevent false positives.
*/
REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,
AR_WOW_BMISSTHRESHOLD);
/* * Enable pattern matching for packets which are less * than 256 bytes.
*/
REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,
AR_WOW_PATTERN_SUPPORTED);
/* * Set the power states appropriately and enable PME.
*/
host_pm_ctrl = REG_READ(ah, AR_PCIE_PM_CTRL(ah));
host_pm_ctrl |= AR_PMCTRL_PWR_STATE_D1D3 |
AR_PMCTRL_HOST_PME_EN |
AR_PMCTRL_PWR_PM_CTRL_ENA;
host_pm_ctrl &= ~AR_PCIE_PM_CTRL_ENA;
if (AR_SREV_9462(ah)) { /* * This is needed to prevent the chip waking up * the host within 3-4 seconds with certain * platform/BIOS.
*/
host_pm_ctrl &= ~AR_PMCTRL_PWR_STATE_D1D3;
host_pm_ctrl |= AR_PMCTRL_PWR_STATE_D1D3_REAL;
}
REG_WRITE(ah, AR_PCIE_PM_CTRL(ah), host_pm_ctrl);
/* * Enable sequence number generation when asleep.
*/
REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
/* To bring down WOW power low margin */
REG_SET_BIT(ah, AR_PCIE_PHY_REG3, BIT(13));
ath9k_hw_wow_set_arwr_reg(ah);
if (ath9k_hw_mci_is_enabled(ah))
REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.