diff options
author | Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com> | 2011-11-30 00:11:23 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-30 15:08:50 -0500 |
commit | 9e25365ffaa98626bdf7e1bb5fdddf73a1c131fb (patch) | |
tree | b450cf10ff12c6dba6abec579886836801a881b3 /drivers | |
parent | f2f2185679288ade3de1052a572daf9b5d1fd324 (diff) |
ath9k: Add functions to allocate/free buffers for MCI
required buffers and dma allocation is done for GPM and SCHED
messages
Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/mci.c | 78 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/mci.h | 2 |
3 files changed, 81 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 386402c37158..afc156a0a2e3 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -647,6 +647,7 @@ struct ath_softc { | |||
647 | struct delayed_work tx_complete_work; | 647 | struct delayed_work tx_complete_work; |
648 | struct delayed_work hw_pll_work; | 648 | struct delayed_work hw_pll_work; |
649 | struct ath_btcoex btcoex; | 649 | struct ath_btcoex btcoex; |
650 | struct ath_mci_coex mci_coex; | ||
650 | 651 | ||
651 | struct ath_descdma txsdma; | 652 | struct ath_descdma txsdma; |
652 | 653 | ||
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index 0fbb141bc302..5b246766bde5 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c | |||
@@ -14,6 +14,9 @@ | |||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/dma-mapping.h> | ||
18 | #include <linux/slab.h> | ||
19 | |||
17 | #include "ath9k.h" | 20 | #include "ath9k.h" |
18 | #include "mci.h" | 21 | #include "mci.h" |
19 | 22 | ||
@@ -252,3 +255,78 @@ void ath_mci_process_status(struct ath_softc *sc, | |||
252 | if (old_num_mgmt != mci->num_mgmt) | 255 | if (old_num_mgmt != mci->num_mgmt) |
253 | ath_mci_update_scheme(sc); | 256 | ath_mci_update_scheme(sc); |
254 | } | 257 | } |
258 | |||
259 | |||
260 | static int ath_mci_buf_alloc(struct ath_softc *sc, struct ath_mci_buf *buf) | ||
261 | { | ||
262 | int error = 0; | ||
263 | |||
264 | buf->bf_addr = dma_alloc_coherent(sc->dev, buf->bf_len, | ||
265 | &buf->bf_paddr, GFP_KERNEL); | ||
266 | |||
267 | if (buf->bf_addr == NULL) { | ||
268 | error = -ENOMEM; | ||
269 | goto fail; | ||
270 | } | ||
271 | |||
272 | return 0; | ||
273 | |||
274 | fail: | ||
275 | memset(buf, 0, sizeof(*buf)); | ||
276 | return error; | ||
277 | } | ||
278 | |||
279 | static void ath_mci_buf_free(struct ath_softc *sc, struct ath_mci_buf *buf) | ||
280 | { | ||
281 | if (buf->bf_addr) { | ||
282 | dma_free_coherent(sc->dev, buf->bf_len, buf->bf_addr, | ||
283 | buf->bf_paddr); | ||
284 | memset(buf, 0, sizeof(*buf)); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | int ath_mci_setup(struct ath_softc *sc) | ||
289 | { | ||
290 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
291 | struct ath_mci_coex *mci = &sc->mci_coex; | ||
292 | int error = 0; | ||
293 | |||
294 | mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE; | ||
295 | |||
296 | if (ath_mci_buf_alloc(sc, &mci->sched_buf)) { | ||
297 | ath_dbg(common, ATH_DBG_FATAL, "MCI buffer alloc failed\n"); | ||
298 | error = -ENOMEM; | ||
299 | goto fail; | ||
300 | } | ||
301 | |||
302 | mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE; | ||
303 | |||
304 | memset(mci->sched_buf.bf_addr, MCI_GPM_RSVD_PATTERN, | ||
305 | mci->sched_buf.bf_len); | ||
306 | |||
307 | mci->gpm_buf.bf_len = ATH_MCI_GPM_BUF_SIZE; | ||
308 | mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr + | ||
309 | mci->sched_buf.bf_len; | ||
310 | mci->gpm_buf.bf_paddr = mci->sched_buf.bf_paddr + mci->sched_buf.bf_len; | ||
311 | |||
312 | /* initialize the buffer */ | ||
313 | memset(mci->gpm_buf.bf_addr, MCI_GPM_RSVD_PATTERN, mci->gpm_buf.bf_len); | ||
314 | |||
315 | ar9003_mci_setup(sc->sc_ah, mci->gpm_buf.bf_paddr, | ||
316 | mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4), | ||
317 | mci->sched_buf.bf_paddr); | ||
318 | fail: | ||
319 | return error; | ||
320 | } | ||
321 | |||
322 | void ath_mci_cleanup(struct ath_softc *sc) | ||
323 | { | ||
324 | struct ath_hw *ah = sc->sc_ah; | ||
325 | struct ath_mci_coex *mci = &sc->mci_coex; | ||
326 | |||
327 | /* | ||
328 | * both schedule and gpm buffers will be released | ||
329 | */ | ||
330 | ath_mci_buf_free(sc, &mci->sched_buf); | ||
331 | ar9003_mci_cleanup(ah); | ||
332 | } | ||
diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index 5df0d607e881..4eeb0feafc06 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h | |||
@@ -132,4 +132,6 @@ void ath_mci_process_profile(struct ath_softc *sc, | |||
132 | struct ath_mci_profile_info *info); | 132 | struct ath_mci_profile_info *info); |
133 | void ath_mci_process_status(struct ath_softc *sc, | 133 | void ath_mci_process_status(struct ath_softc *sc, |
134 | struct ath_mci_profile_status *status); | 134 | struct ath_mci_profile_status *status); |
135 | int ath_mci_setup(struct ath_softc *sc); | ||
136 | void ath_mci_cleanup(struct ath_softc *sc); | ||
135 | #endif | 137 | #endif |