2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted (subject to the limitations in the
7 * disclaimer below) provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * * Neither the name of Qualcomm Atheros nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include "ah_internal.h"
38 #include <asf_bitmap.h>
40 extern struct ath_hal *ar5416Attach(HAL_SOFTC sc, adf_os_device_t dev,
44 ath_hal_attach_tgt(a_uint32_t devid,HAL_SOFTC sc,
46 a_uint32_t flags, HAL_STATUS *error)
48 struct ath_hal *ah = AH_NULL;
50 ah = ar5416Attach(sc, dev, error);
56 ath_hal_getcapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type)
58 const HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps;
60 case HAL_CAP_TSF_ADJUST:
62 case HAL_CAP_BSSIDMASK:
63 return pCap->halBssIdMaskSupport ? HAL_OK : HAL_ENOTSUPP;
65 return pCap->halVEOLSupport ? HAL_OK : HAL_ENOTSUPP;
71 #define CCK_SIFS_TIME 10
72 #define CCK_PREAMBLE_BITS 144
73 #define CCK_PLCP_BITS 48
75 #define OFDM_SIFS_TIME 16
76 #define OFDM_PREAMBLE_TIME 20
77 #define OFDM_PLCP_BITS 22
78 #define OFDM_SYMBOL_TIME 4
80 #define OFDM_SIFS_TIME_HALF 32
81 #define OFDM_PREAMBLE_TIME_HALF 40
82 #define OFDM_PLCP_BITS_HALF 22
83 #define OFDM_SYMBOL_TIME_HALF 8
85 #define OFDM_SIFS_TIME_QUARTER 64
86 #define OFDM_PREAMBLE_TIME_QUARTER 80
87 #define OFDM_PLCP_BITS_QUARTER 22
88 #define OFDM_SYMBOL_TIME_QUARTER 16
91 ath_hal_computetxtime(struct ath_hal *ah,
92 const HAL_RATE_TABLE *rates, a_uint32_t frameLen, a_uint16_t rateix,
93 HAL_BOOL shortPreamble)
95 a_uint32_t bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
98 kbps = rates->info[rateix].rateKbps;
101 * index can be invalid duting dynamic Turbo transitions.
103 if(kbps == 0) return 0;
104 switch (rates->info[rateix].phy) {
106 case IEEE80211_T_CCK:
107 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
108 if (shortPreamble && rates->info[rateix].shortPreamble)
110 numBits = frameLen << 3;
111 txTime = phyTime + ((numBits * 1000)/kbps);
112 /* TODO: make sure the same value of txTime can use in all device */
113 if (ath_hal_getcapability(ah, HAL_CAP_HT) != HAL_OK)
114 txTime = txTime + CCK_SIFS_TIME;
116 case IEEE80211_T_OFDM:
117 /* full rate channel */
118 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000;
119 HALASSERT(bitsPerSymbol != 0);
121 numBits = OFDM_PLCP_BITS + (frameLen << 3);
122 numSymbols = asf_howmany(numBits, bitsPerSymbol);
123 txTime = OFDM_PREAMBLE_TIME + (numSymbols * OFDM_SYMBOL_TIME);
124 /* TODO: make sure the same value of txTime can use in all device */
125 if (ath_hal_getcapability(ah, HAL_CAP_HT) != HAL_OK)
126 txTime = txTime + OFDM_SIFS_TIME;
136 #undef CCK_PREAMBLE_BITS
139 #undef OFDM_SIFS_TIME
140 #undef OFDM_PREAMBLE_TIME
141 #undef OFDM_PLCP_BITS
142 #undef OFDM_SYMBOL_TIME
146 ath_hal_get_curmode(struct ath_hal *ah, HAL_CHANNEL_INTERNAL *chan)
149 return HAL_MODE_11NG;
151 if (IS_CHAN_NA(chan))
152 return HAL_MODE_11NA;
157 if (IS_CHAN_NG(chan))
158 return HAL_MODE_11NG;
167 return HAL_MODE_11NG;
173 ath_hal_wait(struct ath_hal *ah, a_uint32_t reg, a_uint32_t mask, a_uint32_t val)
175 #define AH_TIMEOUT_11N 100000
176 #define AH_TIMEOUT_11G 1000
180 if (ath_hal_getcapability(ah, HAL_CAP_HT) == HAL_OK) {
181 for (i = 0; i < AH_TIMEOUT_11N; i++) {
182 if ((ioread32_mac(reg) & mask) == val)
187 for (i = 0; i < AH_TIMEOUT_11G; i++) {
188 if ((ioread32_mac(reg) & mask) == val)
195 #undef AH_TIMEOUT_11N
196 #undef AH_TIMEOUT_11G