Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hw.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Atheros Communications Inc.
3  *
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.
7  *
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.
15  */
16 
17 #include <linux/export.h>
18 #include <asm/unaligned.h>
19 
20 #include "ath.h"
21 #include "reg.h"
22 
23 #define REG_READ (common->ops->read)
24 #define REG_WRITE (common->ops->write)
25 
119 {
120  void *ah = common->ah;
121 
123  REG_WRITE(ah, get_unaligned_le16(common->bssidmask + 4), AR_BSSMSKU);
124 }
126 
127 
137 {
138  u32 cycles, busy, rx, tx;
139  void *ah = common->ah;
140 
141  /* freeze */
143 
144  /* read */
145  cycles = REG_READ(ah, AR_CCCNT);
146  busy = REG_READ(ah, AR_RCCNT);
147  rx = REG_READ(ah, AR_RFCNT);
148  tx = REG_READ(ah, AR_TFCNT);
149 
150  /* clear */
151  REG_WRITE(ah, 0, AR_CCCNT);
152  REG_WRITE(ah, 0, AR_RFCNT);
153  REG_WRITE(ah, 0, AR_RCCNT);
154  REG_WRITE(ah, 0, AR_TFCNT);
155 
156  /* unfreeze */
157  REG_WRITE(ah, 0, AR_MIBC);
158 
159  /* update all cycle counters here */
160  common->cc_ani.cycles += cycles;
161  common->cc_ani.rx_busy += busy;
162  common->cc_ani.rx_frame += rx;
163  common->cc_ani.tx_frame += tx;
164 
165  common->cc_survey.cycles += cycles;
166  common->cc_survey.rx_busy += busy;
167  common->cc_survey.rx_frame += rx;
168  common->cc_survey.tx_frame += tx;
169 }
171 
173 {
174  struct ath_cycle_counters *cc = &common->cc_ani;
175  int32_t listen_time;
176 
177  listen_time = (cc->cycles - cc->rx_frame - cc->tx_frame) /
178  (common->clockrate * 1000);
179 
180  memset(cc, 0, sizeof(*cc));
181 
182  return listen_time;
183 }