2 * Copyright (c) 2008-2009 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 static void ar9002_hw_rx_enable(struct ath_hw *ah)
21 REG_WRITE(ah, AR_CR, AR_CR_RXE);
24 static void ar9002_hw_set_desc_link(void *ds, u32 ds_link)
26 ((struct ath_desc *) ds)->ds_link = ds_link;
29 static void ar9002_hw_get_desc_link(void *ds, u32 **ds_link)
31 *ds_link = &((struct ath_desc *)ds)->ds_link;
34 static bool ar9002_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
38 struct ath9k_hw_capabilities *pCap = &ah->caps;
40 bool fatal_int = false;
41 struct ath_common *common = ath9k_hw_common(ah);
43 if (!AR_SREV_9100(ah)) {
44 if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) {
45 if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M)
46 == AR_RTC_STATUS_ON) {
47 isr = REG_READ(ah, AR_ISR);
51 sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) &
56 if (!isr && !sync_cause)
60 isr = REG_READ(ah, AR_ISR);
64 if (isr & AR_ISR_BCNMISC) {
66 isr2 = REG_READ(ah, AR_ISR_S2);
67 if (isr2 & AR_ISR_S2_TIM)
68 mask2 |= ATH9K_INT_TIM;
69 if (isr2 & AR_ISR_S2_DTIM)
70 mask2 |= ATH9K_INT_DTIM;
71 if (isr2 & AR_ISR_S2_DTIMSYNC)
72 mask2 |= ATH9K_INT_DTIMSYNC;
73 if (isr2 & (AR_ISR_S2_CABEND))
74 mask2 |= ATH9K_INT_CABEND;
75 if (isr2 & AR_ISR_S2_GTT)
76 mask2 |= ATH9K_INT_GTT;
77 if (isr2 & AR_ISR_S2_CST)
78 mask2 |= ATH9K_INT_CST;
79 if (isr2 & AR_ISR_S2_TSFOOR)
80 mask2 |= ATH9K_INT_TSFOOR;
83 isr = REG_READ(ah, AR_ISR_RAC);
84 if (isr == 0xffffffff) {
89 *masked = isr & ATH9K_INT_COMMON;
91 if (ah->config.rx_intr_mitigation) {
92 if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
93 *masked |= ATH9K_INT_RX;
96 if (isr & (AR_ISR_RXOK | AR_ISR_RXERR))
97 *masked |= ATH9K_INT_RX;
99 (AR_ISR_TXOK | AR_ISR_TXDESC | AR_ISR_TXERR |
103 *masked |= ATH9K_INT_TX;
105 s0_s = REG_READ(ah, AR_ISR_S0_S);
106 ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXOK);
107 ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXDESC);
109 s1_s = REG_READ(ah, AR_ISR_S1_S);
110 ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXERR);
111 ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXEOL);
114 if (isr & AR_ISR_RXORN) {
115 ath_print(common, ATH_DBG_INTERRUPT,
116 "receive FIFO overrun interrupt\n");
119 if (!AR_SREV_9100(ah)) {
120 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
121 u32 isr5 = REG_READ(ah, AR_ISR_S5_S);
122 if (isr5 & AR_ISR_S5_TIM_TIMER)
123 *masked |= ATH9K_INT_TIM_TIMER;
130 if (AR_SREV_9100(ah))
133 if (isr & AR_ISR_GENTMR) {
136 s5_s = REG_READ(ah, AR_ISR_S5_S);
137 if (isr & AR_ISR_GENTMR) {
138 ah->intr_gen_timer_trigger =
139 MS(s5_s, AR_ISR_S5_GENTIMER_TRIG);
141 ah->intr_gen_timer_thresh =
142 MS(s5_s, AR_ISR_S5_GENTIMER_THRESH);
144 if (ah->intr_gen_timer_trigger)
145 *masked |= ATH9K_INT_GENTIMER;
153 (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR))
157 if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) {
158 ath_print(common, ATH_DBG_ANY,
159 "received PCI FATAL interrupt\n");
161 if (sync_cause & AR_INTR_SYNC_HOST1_PERR) {
162 ath_print(common, ATH_DBG_ANY,
163 "received PCI PERR interrupt\n");
165 *masked |= ATH9K_INT_FATAL;
167 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) {
168 ath_print(common, ATH_DBG_INTERRUPT,
169 "AR_INTR_SYNC_RADM_CPL_TIMEOUT\n");
170 REG_WRITE(ah, AR_RC, AR_RC_HOSTIF);
171 REG_WRITE(ah, AR_RC, 0);
172 *masked |= ATH9K_INT_FATAL;
174 if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) {
175 ath_print(common, ATH_DBG_INTERRUPT,
176 "AR_INTR_SYNC_LOCAL_TIMEOUT\n");
179 REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause);
180 (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR);
186 void ar9002_hw_attach_mac_ops(struct ath_hw *ah)
188 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
190 ops->rx_enable = ar9002_hw_rx_enable;
191 ops->set_desc_link = ar9002_hw_set_desc_link;
192 ops->get_desc_link = ar9002_hw_get_desc_link;
193 ops->get_isr = ar9002_hw_get_isr;
196 static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,
197 struct ath9k_tx_queue_info *qi)
199 ath_print(ath9k_hw_common(ah), ATH_DBG_INTERRUPT,
200 "tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n",
201 ah->txok_interrupt_mask, ah->txerr_interrupt_mask,
202 ah->txdesc_interrupt_mask, ah->txeol_interrupt_mask,
203 ah->txurn_interrupt_mask);
205 REG_WRITE(ah, AR_IMR_S0,
206 SM(ah->txok_interrupt_mask, AR_IMR_S0_QCU_TXOK)
207 | SM(ah->txdesc_interrupt_mask, AR_IMR_S0_QCU_TXDESC));
208 REG_WRITE(ah, AR_IMR_S1,
209 SM(ah->txerr_interrupt_mask, AR_IMR_S1_QCU_TXERR)
210 | SM(ah->txeol_interrupt_mask, AR_IMR_S1_QCU_TXEOL));
212 ah->imrs2_reg &= ~AR_IMR_S2_QCU_TXURN;
213 ah->imrs2_reg |= (ah->txurn_interrupt_mask & AR_IMR_S2_QCU_TXURN);
214 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
217 u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q)
219 return REG_READ(ah, AR_QTXDP(q));
221 EXPORT_SYMBOL(ath9k_hw_gettxbuf);
223 void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp)
225 REG_WRITE(ah, AR_QTXDP(q), txdp);
227 EXPORT_SYMBOL(ath9k_hw_puttxbuf);
229 void ath9k_hw_txstart(struct ath_hw *ah, u32 q)
231 ath_print(ath9k_hw_common(ah), ATH_DBG_QUEUE,
232 "Enable TXE on queue: %u\n", q);
233 REG_WRITE(ah, AR_Q_TXE, 1 << q);
235 EXPORT_SYMBOL(ath9k_hw_txstart);
237 u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q)
241 npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT;
244 if (REG_READ(ah, AR_Q_TXE) & (1 << q))
250 EXPORT_SYMBOL(ath9k_hw_numtxpending);
253 * ath9k_hw_updatetxtriglevel - adjusts the frame trigger level
255 * @ah: atheros hardware struct
256 * @bIncTrigLevel: whether or not the frame trigger level should be updated
258 * The frame trigger level specifies the minimum number of bytes,
259 * in units of 64 bytes, that must be DMA'ed into the PCU TX FIFO
260 * before the PCU will initiate sending the frame on the air. This can
261 * mean we initiate transmit before a full frame is on the PCU TX FIFO.
262 * Resets to 0x1 (meaning 64 bytes or a full frame, whichever occurs
265 * Caution must be taken to ensure to set the frame trigger level based
266 * on the DMA request size. For example if the DMA request size is set to
267 * 128 bytes the trigger level cannot exceed 6 * 64 = 384. This is because
268 * there need to be enough space in the tx FIFO for the requested transfer
269 * size. Hence the tx FIFO will stop with 512 - 128 = 384 bytes. If we set
270 * the threshold to a value beyond 6, then the transmit will hang.
272 * Current dual stream devices have a PCU TX FIFO size of 8 KB.
273 * Current single stream devices have a PCU TX FIFO size of 4 KB, however,
274 * there is a hardware issue which forces us to use 2 KB instead so the
275 * frame trigger level must not exceed 2 KB for these chipsets.
277 bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel)
279 u32 txcfg, curLevel, newLevel;
280 enum ath9k_int omask;
282 if (ah->tx_trig_level >= ah->config.max_txtrig_level)
285 omask = ath9k_hw_set_interrupts(ah, ah->imask & ~ATH9K_INT_GLOBAL);
287 txcfg = REG_READ(ah, AR_TXCFG);
288 curLevel = MS(txcfg, AR_FTRIG);
291 if (curLevel < ah->config.max_txtrig_level)
293 } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
295 if (newLevel != curLevel)
296 REG_WRITE(ah, AR_TXCFG,
297 (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG));
299 ath9k_hw_set_interrupts(ah, omask);
301 ah->tx_trig_level = newLevel;
303 return newLevel != curLevel;
305 EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel);
307 bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
309 #define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
310 #define ATH9K_TIME_QUANTUM 100 /* usec */
311 struct ath_common *common = ath9k_hw_common(ah);
312 struct ath9k_hw_capabilities *pCap = &ah->caps;
313 struct ath9k_tx_queue_info *qi;
315 u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
317 if (q >= pCap->total_queues) {
318 ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, "
319 "invalid queue: %u\n", q);
324 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
325 ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, "
326 "inactive queue: %u\n", q);
330 REG_WRITE(ah, AR_Q_TXD, 1 << q);
332 for (wait = wait_time; wait != 0; wait--) {
333 if (ath9k_hw_numtxpending(ah, q) == 0)
335 udelay(ATH9K_TIME_QUANTUM);
338 if (ath9k_hw_numtxpending(ah, q)) {
339 ath_print(common, ATH_DBG_QUEUE,
340 "%s: Num of pending TX Frames %d on Q %d\n",
341 __func__, ath9k_hw_numtxpending(ah, q), q);
343 for (j = 0; j < 2; j++) {
344 tsfLow = REG_READ(ah, AR_TSF_L32);
345 REG_WRITE(ah, AR_QUIET2,
346 SM(10, AR_QUIET2_QUIET_DUR));
347 REG_WRITE(ah, AR_QUIET_PERIOD, 100);
348 REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
349 REG_SET_BIT(ah, AR_TIMER_MODE,
352 if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
355 ath_print(common, ATH_DBG_QUEUE,
356 "TSF has moved while trying to set "
357 "quiet time TSF: 0x%08x\n", tsfLow);
360 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
363 REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
366 while (ath9k_hw_numtxpending(ah, q)) {
368 ath_print(common, ATH_DBG_FATAL,
369 "Failed to stop TX DMA in 100 "
370 "msec after killing last frame\n");
373 udelay(ATH9K_TIME_QUANTUM);
376 REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
379 REG_WRITE(ah, AR_Q_TXD, 0);
382 #undef ATH9K_TX_STOP_DMA_TIMEOUT
383 #undef ATH9K_TIME_QUANTUM
385 EXPORT_SYMBOL(ath9k_hw_stoptxdma);
387 void ath9k_hw_filltxdesc(struct ath_hw *ah, struct ath_desc *ds,
388 u32 segLen, bool firstSeg,
389 bool lastSeg, const struct ath_desc *ds0,
392 struct ar5416_desc *ads = AR5416DESC(ds);
394 ads->ds_data = buf_addr;
397 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore);
398 } else if (lastSeg) {
400 ads->ds_ctl1 = segLen;
401 ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2;
402 ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3;
405 ads->ds_ctl1 = segLen | AR_TxMore;
409 ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
410 ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
411 ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
412 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
413 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
415 EXPORT_SYMBOL(ath9k_hw_filltxdesc);
417 void ath9k_hw_cleartxdesc(struct ath_hw *ah, struct ath_desc *ds)
419 struct ar5416_desc *ads = AR5416DESC(ds);
421 ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
422 ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
423 ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
424 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
425 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
427 EXPORT_SYMBOL(ath9k_hw_cleartxdesc);
429 int ath9k_hw_txprocdesc(struct ath_hw *ah, struct ath_desc *ds,
430 struct ath_tx_status *ts)
432 struct ar5416_desc *ads = AR5416DESC(ds);
434 if ((ads->ds_txstatus9 & AR_TxDone) == 0)
437 ts->ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum);
438 ts->ts_tstamp = ads->AR_SendTimestamp;
442 if (ads->ds_txstatus1 & AR_FrmXmitOK)
443 ts->ts_status |= ATH9K_TX_ACKED;
444 if (ads->ds_txstatus1 & AR_ExcessiveRetries)
445 ts->ts_status |= ATH9K_TXERR_XRETRY;
446 if (ads->ds_txstatus1 & AR_Filtered)
447 ts->ts_status |= ATH9K_TXERR_FILT;
448 if (ads->ds_txstatus1 & AR_FIFOUnderrun) {
449 ts->ts_status |= ATH9K_TXERR_FIFO;
450 ath9k_hw_updatetxtriglevel(ah, true);
452 if (ads->ds_txstatus9 & AR_TxOpExceeded)
453 ts->ts_status |= ATH9K_TXERR_XTXOP;
454 if (ads->ds_txstatus1 & AR_TxTimerExpired)
455 ts->ts_status |= ATH9K_TXERR_TIMER_EXPIRED;
457 if (ads->ds_txstatus1 & AR_DescCfgErr)
458 ts->ts_flags |= ATH9K_TX_DESC_CFG_ERR;
459 if (ads->ds_txstatus1 & AR_TxDataUnderrun) {
460 ts->ts_flags |= ATH9K_TX_DATA_UNDERRUN;
461 ath9k_hw_updatetxtriglevel(ah, true);
463 if (ads->ds_txstatus1 & AR_TxDelimUnderrun) {
464 ts->ts_flags |= ATH9K_TX_DELIM_UNDERRUN;
465 ath9k_hw_updatetxtriglevel(ah, true);
467 if (ads->ds_txstatus0 & AR_TxBaStatus) {
468 ts->ts_flags |= ATH9K_TX_BA;
469 ts->ba_low = ads->AR_BaBitmapLow;
470 ts->ba_high = ads->AR_BaBitmapHigh;
473 ts->ts_rateindex = MS(ads->ds_txstatus9, AR_FinalTxIdx);
474 switch (ts->ts_rateindex) {
476 ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate0);
479 ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate1);
482 ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate2);
485 ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate3);
489 ts->ts_rssi = MS(ads->ds_txstatus5, AR_TxRSSICombined);
490 ts->ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00);
491 ts->ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01);
492 ts->ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02);
493 ts->ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10);
494 ts->ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11);
495 ts->ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12);
496 ts->evm0 = ads->AR_TxEVM0;
497 ts->evm1 = ads->AR_TxEVM1;
498 ts->evm2 = ads->AR_TxEVM2;
499 ts->ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt);
500 ts->ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt);
501 ts->ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt);
506 EXPORT_SYMBOL(ath9k_hw_txprocdesc);
508 void ath9k_hw_set11n_txdesc(struct ath_hw *ah, struct ath_desc *ds,
509 u32 pktLen, enum ath9k_pkt_type type, u32 txPower,
510 u32 keyIx, enum ath9k_key_type keyType, u32 flags)
512 struct ar5416_desc *ads = AR5416DESC(ds);
514 txPower += ah->txpower_indexoffset;
518 ads->ds_ctl0 = (pktLen & AR_FrameLen)
519 | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
520 | SM(txPower, AR_XmitPower)
521 | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
522 | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
523 | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
524 | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
527 (keyIx != ATH9K_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0)
528 | SM(type, AR_FrameType)
529 | (flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0)
530 | (flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
531 | (flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
533 ads->ds_ctl6 = SM(keyType, AR_EncrType);
535 if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) {
542 EXPORT_SYMBOL(ath9k_hw_set11n_txdesc);
544 void ath9k_hw_set11n_ratescenario(struct ath_hw *ah, struct ath_desc *ds,
545 struct ath_desc *lastds,
546 u32 durUpdateEn, u32 rtsctsRate,
548 struct ath9k_11n_rate_series series[],
549 u32 nseries, u32 flags)
551 struct ar5416_desc *ads = AR5416DESC(ds);
552 struct ar5416_desc *last_ads = AR5416DESC(lastds);
555 if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) {
556 ds_ctl0 = ads->ds_ctl0;
558 if (flags & ATH9K_TXDESC_RTSENA) {
559 ds_ctl0 &= ~AR_CTSEnable;
560 ds_ctl0 |= AR_RTSEnable;
562 ds_ctl0 &= ~AR_RTSEnable;
563 ds_ctl0 |= AR_CTSEnable;
566 ads->ds_ctl0 = ds_ctl0;
569 (ads->ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable));
572 ads->ds_ctl2 = set11nTries(series, 0)
573 | set11nTries(series, 1)
574 | set11nTries(series, 2)
575 | set11nTries(series, 3)
576 | (durUpdateEn ? AR_DurUpdateEna : 0)
577 | SM(0, AR_BurstDur);
579 ads->ds_ctl3 = set11nRate(series, 0)
580 | set11nRate(series, 1)
581 | set11nRate(series, 2)
582 | set11nRate(series, 3);
584 ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
585 | set11nPktDurRTSCTS(series, 1);
587 ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
588 | set11nPktDurRTSCTS(series, 3);
590 ads->ds_ctl7 = set11nRateFlags(series, 0)
591 | set11nRateFlags(series, 1)
592 | set11nRateFlags(series, 2)
593 | set11nRateFlags(series, 3)
594 | SM(rtsctsRate, AR_RTSCTSRate);
595 last_ads->ds_ctl2 = ads->ds_ctl2;
596 last_ads->ds_ctl3 = ads->ds_ctl3;
598 EXPORT_SYMBOL(ath9k_hw_set11n_ratescenario);
600 void ath9k_hw_set11n_aggr_first(struct ath_hw *ah, struct ath_desc *ds,
603 struct ar5416_desc *ads = AR5416DESC(ds);
605 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
606 ads->ds_ctl6 &= ~AR_AggrLen;
607 ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen);
609 EXPORT_SYMBOL(ath9k_hw_set11n_aggr_first);
611 void ath9k_hw_set11n_aggr_middle(struct ath_hw *ah, struct ath_desc *ds,
614 struct ar5416_desc *ads = AR5416DESC(ds);
617 ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
620 ctl6 &= ~AR_PadDelim;
621 ctl6 |= SM(numDelims, AR_PadDelim);
624 EXPORT_SYMBOL(ath9k_hw_set11n_aggr_middle);
626 void ath9k_hw_set11n_aggr_last(struct ath_hw *ah, struct ath_desc *ds)
628 struct ar5416_desc *ads = AR5416DESC(ds);
630 ads->ds_ctl1 |= AR_IsAggr;
631 ads->ds_ctl1 &= ~AR_MoreAggr;
632 ads->ds_ctl6 &= ~AR_PadDelim;
634 EXPORT_SYMBOL(ath9k_hw_set11n_aggr_last);
636 void ath9k_hw_clr11n_aggr(struct ath_hw *ah, struct ath_desc *ds)
638 struct ar5416_desc *ads = AR5416DESC(ds);
640 ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr);
642 EXPORT_SYMBOL(ath9k_hw_clr11n_aggr);
644 void ath9k_hw_set11n_burstduration(struct ath_hw *ah, struct ath_desc *ds,
647 struct ar5416_desc *ads = AR5416DESC(ds);
649 ads->ds_ctl2 &= ~AR_BurstDur;
650 ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur);
652 EXPORT_SYMBOL(ath9k_hw_set11n_burstduration);
654 void ath9k_hw_set11n_virtualmorefrag(struct ath_hw *ah, struct ath_desc *ds,
657 struct ar5416_desc *ads = AR5416DESC(ds);
660 ads->ds_ctl0 |= AR_VirtMoreFrag;
662 ads->ds_ctl0 &= ~AR_VirtMoreFrag;
665 void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
667 *txqs &= ah->intr_txqs;
668 ah->intr_txqs &= ~(*txqs);
670 EXPORT_SYMBOL(ath9k_hw_gettxintrtxqs);
672 bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
673 const struct ath9k_tx_queue_info *qinfo)
676 struct ath_common *common = ath9k_hw_common(ah);
677 struct ath9k_hw_capabilities *pCap = &ah->caps;
678 struct ath9k_tx_queue_info *qi;
680 if (q >= pCap->total_queues) {
681 ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, "
682 "invalid queue: %u\n", q);
687 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
688 ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, "
689 "inactive queue: %u\n", q);
693 ath_print(common, ATH_DBG_QUEUE, "Set queue properties for: %u\n", q);
695 qi->tqi_ver = qinfo->tqi_ver;
696 qi->tqi_subtype = qinfo->tqi_subtype;
697 qi->tqi_qflags = qinfo->tqi_qflags;
698 qi->tqi_priority = qinfo->tqi_priority;
699 if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
700 qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
702 qi->tqi_aifs = INIT_AIFS;
703 if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
704 cw = min(qinfo->tqi_cwmin, 1024U);
706 while (qi->tqi_cwmin < cw)
707 qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
709 qi->tqi_cwmin = qinfo->tqi_cwmin;
710 if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
711 cw = min(qinfo->tqi_cwmax, 1024U);
713 while (qi->tqi_cwmax < cw)
714 qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
716 qi->tqi_cwmax = INIT_CWMAX;
718 if (qinfo->tqi_shretry != 0)
719 qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
721 qi->tqi_shretry = INIT_SH_RETRY;
722 if (qinfo->tqi_lgretry != 0)
723 qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U);
725 qi->tqi_lgretry = INIT_LG_RETRY;
726 qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
727 qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
728 qi->tqi_burstTime = qinfo->tqi_burstTime;
729 qi->tqi_readyTime = qinfo->tqi_readyTime;
731 switch (qinfo->tqi_subtype) {
733 if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
734 qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
742 EXPORT_SYMBOL(ath9k_hw_set_txq_props);
744 bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q,
745 struct ath9k_tx_queue_info *qinfo)
747 struct ath_common *common = ath9k_hw_common(ah);
748 struct ath9k_hw_capabilities *pCap = &ah->caps;
749 struct ath9k_tx_queue_info *qi;
751 if (q >= pCap->total_queues) {
752 ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, "
753 "invalid queue: %u\n", q);
758 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
759 ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, "
760 "inactive queue: %u\n", q);
764 qinfo->tqi_qflags = qi->tqi_qflags;
765 qinfo->tqi_ver = qi->tqi_ver;
766 qinfo->tqi_subtype = qi->tqi_subtype;
767 qinfo->tqi_qflags = qi->tqi_qflags;
768 qinfo->tqi_priority = qi->tqi_priority;
769 qinfo->tqi_aifs = qi->tqi_aifs;
770 qinfo->tqi_cwmin = qi->tqi_cwmin;
771 qinfo->tqi_cwmax = qi->tqi_cwmax;
772 qinfo->tqi_shretry = qi->tqi_shretry;
773 qinfo->tqi_lgretry = qi->tqi_lgretry;
774 qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
775 qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
776 qinfo->tqi_burstTime = qi->tqi_burstTime;
777 qinfo->tqi_readyTime = qi->tqi_readyTime;
781 EXPORT_SYMBOL(ath9k_hw_get_txq_props);
783 int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type,
784 const struct ath9k_tx_queue_info *qinfo)
786 struct ath_common *common = ath9k_hw_common(ah);
787 struct ath9k_tx_queue_info *qi;
788 struct ath9k_hw_capabilities *pCap = &ah->caps;
792 case ATH9K_TX_QUEUE_BEACON:
793 q = pCap->total_queues - 1;
795 case ATH9K_TX_QUEUE_CAB:
796 q = pCap->total_queues - 2;
798 case ATH9K_TX_QUEUE_PSPOLL:
801 case ATH9K_TX_QUEUE_UAPSD:
802 q = pCap->total_queues - 3;
804 case ATH9K_TX_QUEUE_DATA:
805 for (q = 0; q < pCap->total_queues; q++)
806 if (ah->txq[q].tqi_type ==
807 ATH9K_TX_QUEUE_INACTIVE)
809 if (q == pCap->total_queues) {
810 ath_print(common, ATH_DBG_FATAL,
811 "No available TX queue\n");
816 ath_print(common, ATH_DBG_FATAL,
817 "Invalid TX queue type: %u\n", type);
821 ath_print(common, ATH_DBG_QUEUE, "Setup TX queue: %u\n", q);
824 if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
825 ath_print(common, ATH_DBG_FATAL,
826 "TX queue: %u already active\n", q);
829 memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
833 TXQ_FLAG_TXOKINT_ENABLE
834 | TXQ_FLAG_TXERRINT_ENABLE
835 | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
836 qi->tqi_aifs = INIT_AIFS;
837 qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
838 qi->tqi_cwmax = INIT_CWMAX;
839 qi->tqi_shretry = INIT_SH_RETRY;
840 qi->tqi_lgretry = INIT_LG_RETRY;
841 qi->tqi_physCompBuf = 0;
843 qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
844 (void) ath9k_hw_set_txq_props(ah, q, qinfo);
849 EXPORT_SYMBOL(ath9k_hw_setuptxqueue);
851 bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
853 struct ath9k_hw_capabilities *pCap = &ah->caps;
854 struct ath_common *common = ath9k_hw_common(ah);
855 struct ath9k_tx_queue_info *qi;
857 if (q >= pCap->total_queues) {
858 ath_print(common, ATH_DBG_QUEUE, "Release TXQ, "
859 "invalid queue: %u\n", q);
863 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
864 ath_print(common, ATH_DBG_QUEUE, "Release TXQ, "
865 "inactive queue: %u\n", q);
869 ath_print(common, ATH_DBG_QUEUE, "Release TX queue: %u\n", q);
871 qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
872 ah->txok_interrupt_mask &= ~(1 << q);
873 ah->txerr_interrupt_mask &= ~(1 << q);
874 ah->txdesc_interrupt_mask &= ~(1 << q);
875 ah->txeol_interrupt_mask &= ~(1 << q);
876 ah->txurn_interrupt_mask &= ~(1 << q);
877 ath9k_hw_set_txq_interrupts(ah, qi);
881 EXPORT_SYMBOL(ath9k_hw_releasetxqueue);
883 bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q)
885 struct ath9k_hw_capabilities *pCap = &ah->caps;
886 struct ath_common *common = ath9k_hw_common(ah);
887 struct ath9k_channel *chan = ah->curchan;
888 struct ath9k_tx_queue_info *qi;
889 u32 cwMin, chanCwMin, value;
891 if (q >= pCap->total_queues) {
892 ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, "
893 "invalid queue: %u\n", q);
898 if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
899 ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, "
900 "inactive queue: %u\n", q);
904 ath_print(common, ATH_DBG_QUEUE, "Reset TX queue: %u\n", q);
906 if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
907 if (chan && IS_CHAN_B(chan))
908 chanCwMin = INIT_CWMIN_11B;
910 chanCwMin = INIT_CWMIN;
912 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
914 cwMin = qi->tqi_cwmin;
916 REG_WRITE(ah, AR_DLCL_IFS(q),
917 SM(cwMin, AR_D_LCL_IFS_CWMIN) |
918 SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) |
919 SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
921 REG_WRITE(ah, AR_DRETRY_LIMIT(q),
922 SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) |
923 SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) |
924 SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
926 REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
927 REG_WRITE(ah, AR_DMISC(q),
928 AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
930 if (qi->tqi_cbrPeriod) {
931 REG_WRITE(ah, AR_QCBRCFG(q),
932 SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
933 SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH));
934 REG_WRITE(ah, AR_QMISC(q),
935 REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR |
936 (qi->tqi_cbrOverflowLimit ?
937 AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
939 if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
940 REG_WRITE(ah, AR_QRDYTIMECFG(q),
941 SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
945 REG_WRITE(ah, AR_DCHNTIME(q),
946 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
947 (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
949 if (qi->tqi_burstTime
950 && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
951 REG_WRITE(ah, AR_QMISC(q),
952 REG_READ(ah, AR_QMISC(q)) |
953 AR_Q_MISC_RDYTIME_EXP_POLICY);
957 if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
958 REG_WRITE(ah, AR_DMISC(q),
959 REG_READ(ah, AR_DMISC(q)) |
960 AR_D_MISC_POST_FR_BKOFF_DIS);
962 if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
963 REG_WRITE(ah, AR_DMISC(q),
964 REG_READ(ah, AR_DMISC(q)) |
965 AR_D_MISC_FRAG_BKOFF_EN);
967 switch (qi->tqi_type) {
968 case ATH9K_TX_QUEUE_BEACON:
969 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
970 | AR_Q_MISC_FSP_DBA_GATED
971 | AR_Q_MISC_BEACON_USE
972 | AR_Q_MISC_CBR_INCR_DIS1);
974 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
975 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
976 AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
977 | AR_D_MISC_BEACON_USE
978 | AR_D_MISC_POST_FR_BKOFF_DIS);
980 case ATH9K_TX_QUEUE_CAB:
981 REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
982 | AR_Q_MISC_FSP_DBA_GATED
983 | AR_Q_MISC_CBR_INCR_DIS1
984 | AR_Q_MISC_CBR_INCR_DIS0);
985 value = (qi->tqi_readyTime -
986 (ah->config.sw_beacon_response_time -
987 ah->config.dma_beacon_response_time) -
988 ah->config.additional_swba_backoff) * 1024;
989 REG_WRITE(ah, AR_QRDYTIMECFG(q),
990 value | AR_Q_RDYTIMECFG_EN);
991 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
992 | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
993 AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
995 case ATH9K_TX_QUEUE_PSPOLL:
996 REG_WRITE(ah, AR_QMISC(q),
997 REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
999 case ATH9K_TX_QUEUE_UAPSD:
1000 REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
1001 AR_D_MISC_POST_FR_BKOFF_DIS);
1007 if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
1008 REG_WRITE(ah, AR_DMISC(q),
1009 REG_READ(ah, AR_DMISC(q)) |
1010 SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
1011 AR_D_MISC_ARB_LOCKOUT_CNTRL) |
1012 AR_D_MISC_POST_FR_BKOFF_DIS);
1015 if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
1016 ah->txok_interrupt_mask |= 1 << q;
1018 ah->txok_interrupt_mask &= ~(1 << q);
1019 if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
1020 ah->txerr_interrupt_mask |= 1 << q;
1022 ah->txerr_interrupt_mask &= ~(1 << q);
1023 if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
1024 ah->txdesc_interrupt_mask |= 1 << q;
1026 ah->txdesc_interrupt_mask &= ~(1 << q);
1027 if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
1028 ah->txeol_interrupt_mask |= 1 << q;
1030 ah->txeol_interrupt_mask &= ~(1 << q);
1031 if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
1032 ah->txurn_interrupt_mask |= 1 << q;
1034 ah->txurn_interrupt_mask &= ~(1 << q);
1035 ath9k_hw_set_txq_interrupts(ah, qi);
1039 EXPORT_SYMBOL(ath9k_hw_resettxqueue);
1041 int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
1042 struct ath_rx_status *rs, u64 tsf)
1044 struct ar5416_desc ads;
1045 struct ar5416_desc *adsp = AR5416DESC(ds);
1048 if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
1049 return -EINPROGRESS;
1051 ads.u.rx = adsp->u.rx;
1056 rs->rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
1057 rs->rs_tstamp = ads.AR_RcvTimestamp;
1059 if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
1060 rs->rs_rssi = ATH9K_RSSI_BAD;
1061 rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD;
1062 rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD;
1063 rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD;
1064 rs->rs_rssi_ext0 = ATH9K_RSSI_BAD;
1065 rs->rs_rssi_ext1 = ATH9K_RSSI_BAD;
1066 rs->rs_rssi_ext2 = ATH9K_RSSI_BAD;
1068 rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
1069 rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0,
1071 rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0,
1073 rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0,
1075 rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4,
1077 rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4,
1079 rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4,
1082 if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
1083 rs->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
1085 rs->rs_keyix = ATH9K_RXKEYIX_INVALID;
1087 rs->rs_rate = RXSTATUS_RATE(ah, (&ads));
1088 rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
1090 rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
1092 (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
1093 rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
1095 (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
1097 (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
1099 if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
1100 rs->rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
1101 if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
1102 rs->rs_flags |= ATH9K_RX_DELIM_CRC_POST;
1103 if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
1104 rs->rs_flags |= ATH9K_RX_DECRYPT_BUSY;
1106 if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
1107 if (ads.ds_rxstatus8 & AR_CRCErr)
1108 rs->rs_status |= ATH9K_RXERR_CRC;
1109 else if (ads.ds_rxstatus8 & AR_PHYErr) {
1110 rs->rs_status |= ATH9K_RXERR_PHY;
1111 phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
1112 rs->rs_phyerr = phyerr;
1113 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
1114 rs->rs_status |= ATH9K_RXERR_DECRYPT;
1115 else if (ads.ds_rxstatus8 & AR_MichaelErr)
1116 rs->rs_status |= ATH9K_RXERR_MIC;
1121 EXPORT_SYMBOL(ath9k_hw_rxprocdesc);
1123 void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds,
1124 u32 size, u32 flags)
1126 struct ar5416_desc *ads = AR5416DESC(ds);
1127 struct ath9k_hw_capabilities *pCap = &ah->caps;
1129 ads->ds_ctl1 = size & AR_BufLen;
1130 if (flags & ATH9K_RXDESC_INTREQ)
1131 ads->ds_ctl1 |= AR_RxIntrReq;
1133 ads->ds_rxstatus8 &= ~AR_RxDone;
1134 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
1135 memset(&(ads->u), 0, sizeof(ads->u));
1137 EXPORT_SYMBOL(ath9k_hw_setuprxdesc);
1140 * This can stop or re-enables RX.
1142 * If bool is set this will kill any frame which is currently being
1143 * transferred between the MAC and baseband and also prevent any new
1144 * frames from getting started.
1146 bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
1151 REG_SET_BIT(ah, AR_DIAG_SW,
1152 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1154 if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE,
1155 0, AH_WAIT_TIMEOUT)) {
1156 REG_CLR_BIT(ah, AR_DIAG_SW,
1160 reg = REG_READ(ah, AR_OBS_BUS_1);
1161 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
1162 "RX failed to go idle in 10 ms RXSM=0x%x\n",
1168 REG_CLR_BIT(ah, AR_DIAG_SW,
1169 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1174 EXPORT_SYMBOL(ath9k_hw_setrxabort);
1176 void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp)
1178 REG_WRITE(ah, AR_RXDP, rxdp);
1180 EXPORT_SYMBOL(ath9k_hw_putrxbuf);
1182 void ath9k_hw_startpcureceive(struct ath_hw *ah)
1184 ath9k_enable_mib_counters(ah);
1186 ath9k_ani_reset(ah);
1188 REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1190 EXPORT_SYMBOL(ath9k_hw_startpcureceive);
1192 void ath9k_hw_stoppcurecv(struct ath_hw *ah)
1194 REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
1196 ath9k_hw_disable_mib_counters(ah);
1198 EXPORT_SYMBOL(ath9k_hw_stoppcurecv);
1200 bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
1202 #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
1203 #define AH_RX_TIME_QUANTUM 100 /* usec */
1204 struct ath_common *common = ath9k_hw_common(ah);
1207 REG_WRITE(ah, AR_CR, AR_CR_RXD);
1209 /* Wait for rx enable bit to go low */
1210 for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
1211 if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
1213 udelay(AH_TIME_QUANTUM);
1217 ath_print(common, ATH_DBG_FATAL,
1218 "DMA failed to stop in %d ms "
1219 "AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
1220 AH_RX_STOP_DMA_TIMEOUT / 1000,
1221 REG_READ(ah, AR_CR),
1222 REG_READ(ah, AR_DIAG_SW));
1228 #undef AH_RX_TIME_QUANTUM
1229 #undef AH_RX_STOP_DMA_TIMEOUT
1231 EXPORT_SYMBOL(ath9k_hw_stopdmarecv);
1233 int ath9k_hw_beaconq_setup(struct ath_hw *ah)
1235 struct ath9k_tx_queue_info qi;
1237 memset(&qi, 0, sizeof(qi));
1241 /* NB: don't enable any interrupts */
1242 return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
1244 EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
1246 bool ath9k_hw_intrpend(struct ath_hw *ah)
1250 if (AR_SREV_9100(ah))
1253 host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE);
1254 if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS))
1257 host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE);
1258 if ((host_isr & AR_INTR_SYNC_DEFAULT)
1259 && (host_isr != AR_INTR_SPURIOUS))
1264 EXPORT_SYMBOL(ath9k_hw_intrpend);
1266 enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah,
1267 enum ath9k_int ints)
1269 enum ath9k_int omask = ah->imask;
1271 struct ath9k_hw_capabilities *pCap = &ah->caps;
1272 struct ath_common *common = ath9k_hw_common(ah);
1274 ath_print(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints);
1276 if (omask & ATH9K_INT_GLOBAL) {
1277 ath_print(common, ATH_DBG_INTERRUPT, "disable IER\n");
1278 REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
1279 (void) REG_READ(ah, AR_IER);
1280 if (!AR_SREV_9100(ah)) {
1281 REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0);
1282 (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE);
1284 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
1285 (void) REG_READ(ah, AR_INTR_SYNC_ENABLE);
1289 /* TODO: global int Ref count */
1290 mask = ints & ATH9K_INT_COMMON;
1293 if (ints & ATH9K_INT_TX) {
1294 if (ah->config.tx_intr_mitigation)
1295 mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM;
1296 if (ah->txok_interrupt_mask)
1297 mask |= AR_IMR_TXOK;
1298 if (ah->txdesc_interrupt_mask)
1299 mask |= AR_IMR_TXDESC;
1300 if (ah->txerr_interrupt_mask)
1301 mask |= AR_IMR_TXERR;
1302 if (ah->txeol_interrupt_mask)
1303 mask |= AR_IMR_TXEOL;
1305 if (ints & ATH9K_INT_RX) {
1306 if (AR_SREV_9300_20_OR_LATER(ah)) {
1307 mask |= AR_IMR_RXERR | AR_IMR_RXOK_HP;
1308 if (ah->config.rx_intr_mitigation) {
1309 mask &= ~AR_IMR_RXOK_LP;
1310 mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
1312 mask |= AR_IMR_RXOK_LP;
1315 if (ah->config.rx_intr_mitigation)
1316 mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM;
1318 mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
1320 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
1321 mask |= AR_IMR_GENTMR;
1324 if (ints & (ATH9K_INT_BMISC)) {
1325 mask |= AR_IMR_BCNMISC;
1326 if (ints & ATH9K_INT_TIM)
1327 mask2 |= AR_IMR_S2_TIM;
1328 if (ints & ATH9K_INT_DTIM)
1329 mask2 |= AR_IMR_S2_DTIM;
1330 if (ints & ATH9K_INT_DTIMSYNC)
1331 mask2 |= AR_IMR_S2_DTIMSYNC;
1332 if (ints & ATH9K_INT_CABEND)
1333 mask2 |= AR_IMR_S2_CABEND;
1334 if (ints & ATH9K_INT_TSFOOR)
1335 mask2 |= AR_IMR_S2_TSFOOR;
1338 if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) {
1339 mask |= AR_IMR_BCNMISC;
1340 if (ints & ATH9K_INT_GTT)
1341 mask2 |= AR_IMR_S2_GTT;
1342 if (ints & ATH9K_INT_CST)
1343 mask2 |= AR_IMR_S2_CST;
1346 ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask);
1347 REG_WRITE(ah, AR_IMR, mask);
1348 ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC |
1349 AR_IMR_S2_CABEND | AR_IMR_S2_CABTO |
1350 AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST);
1351 ah->imrs2_reg |= mask2;
1352 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
1354 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
1355 if (ints & ATH9K_INT_TIM_TIMER)
1356 REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
1358 REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER);
1361 if (ints & ATH9K_INT_GLOBAL) {
1362 ath_print(common, ATH_DBG_INTERRUPT, "enable IER\n");
1363 REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
1364 if (!AR_SREV_9100(ah)) {
1365 REG_WRITE(ah, AR_INTR_ASYNC_ENABLE,
1367 REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ);
1370 REG_WRITE(ah, AR_INTR_SYNC_ENABLE,
1371 AR_INTR_SYNC_DEFAULT);
1372 REG_WRITE(ah, AR_INTR_SYNC_MASK,
1373 AR_INTR_SYNC_DEFAULT);
1375 ath_print(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
1376 REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
1381 EXPORT_SYMBOL(ath9k_hw_set_interrupts);