Deleted Added
full compact
ah_osdep.c (227309) ah_osdep.c (227410)
1/*-
2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
1/*-
2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
29 * $FreeBSD: head/sys/dev/ath/ah_osdep.c 227309 2011-11-07 15:43:11Z ed $
29 * $FreeBSD: head/sys/dev/ath/ah_osdep.c 227410 2011-11-09 22:39:44Z adrian $
30 */
31#include "opt_ah.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/sysctl.h>
38#include <sys/bus.h>
39#include <sys/malloc.h>
40#include <sys/proc.h>
30 */
31#include "opt_ah.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/sysctl.h>
38#include <sys/bus.h>
39#include <sys/malloc.h>
40#include <sys/proc.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>
41
42#include <machine/stdarg.h>
43
44#include <net/ethernet.h> /* XXX for ether_sprintf */
45
46#include <dev/ath/ath_hal/ah.h>
47
48/*

--- 5 unchanged lines hidden (view full) ---

54 */
55#ifdef AH_SUPPORT_AR5312
56#define BUSTAG(ah) \
57 ((bus_space_tag_t) ((struct ar531x_config *)((ah)->ah_st))->tag)
58#else
59#define BUSTAG(ah) ((ah)->ah_st)
60#endif
61
43
44#include <machine/stdarg.h>
45
46#include <net/ethernet.h> /* XXX for ether_sprintf */
47
48#include <dev/ath/ath_hal/ah.h>
49
50/*

--- 5 unchanged lines hidden (view full) ---

56 */
57#ifdef AH_SUPPORT_AR5312
58#define BUSTAG(ah) \
59 ((bus_space_tag_t) ((struct ar531x_config *)((ah)->ah_st))->tag)
60#else
61#define BUSTAG(ah) ((ah)->ah_st)
62#endif
63
64/*
65 * This lock is used to seralise register access for chips which have
66 * problems w/ SMP CPUs issuing concurrent PCI transactions.
67 *
68 * XXX This is a global lock for now; it should be pushed to
69 * a per-device lock in some platform-independent fashion.
70 */
71struct mtx ah_regser_mtx;
72MTX_SYSINIT(ah_regser, &ah_regser_mtx, "Atheros register access mutex",
73 MTX_SPIN);
74
62extern void ath_hal_printf(struct ath_hal *, const char*, ...)
63 __printflike(2,3);
64extern void ath_hal_vprintf(struct ath_hal *, const char*, __va_list)
65 __printflike(2, 0);
66extern const char* ath_hal_ether_sprintf(const u_int8_t *mac);
67extern void *ath_hal_malloc(size_t);
68extern void ath_hal_free(void *);
69#ifdef AH_ASSERT

--- 175 unchanged lines hidden (view full) ---

245 if (ale) {
246 struct athregrec *r = (struct athregrec *) ale->ae_data;
247 r->op = OP_WRITE;
248 r->reg = reg;
249 r->val = val;
250 alq_post(ath_hal_alq, ale);
251 }
252 }
75extern void ath_hal_printf(struct ath_hal *, const char*, ...)
76 __printflike(2,3);
77extern void ath_hal_vprintf(struct ath_hal *, const char*, __va_list)
78 __printflike(2, 0);
79extern const char* ath_hal_ether_sprintf(const u_int8_t *mac);
80extern void *ath_hal_malloc(size_t);
81extern void ath_hal_free(void *);
82#ifdef AH_ASSERT

--- 175 unchanged lines hidden (view full) ---

258 if (ale) {
259 struct athregrec *r = (struct athregrec *) ale->ae_data;
260 r->op = OP_WRITE;
261 r->reg = reg;
262 r->val = val;
263 alq_post(ath_hal_alq, ale);
264 }
265 }
266 if (ah->ah_config.ah_serialise_reg_war)
267 mtx_lock_spin(&ah_regser_mtx);
253#if _BYTE_ORDER == _BIG_ENDIAN
254 if (OS_REG_UNSWAPPED(reg))
255 bus_space_write_4(tag, h, reg, val);
256 else
257#endif
258 bus_space_write_stream_4(tag, h, reg, val);
268#if _BYTE_ORDER == _BIG_ENDIAN
269 if (OS_REG_UNSWAPPED(reg))
270 bus_space_write_4(tag, h, reg, val);
271 else
272#endif
273 bus_space_write_stream_4(tag, h, reg, val);
274 if (ah->ah_config.ah_serialise_reg_war)
275 mtx_unlock_spin(&ah_regser_mtx);
259}
260
261u_int32_t
262ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
263{
264 bus_space_tag_t tag = BUSTAG(ah);
265 bus_space_handle_t h = ah->ah_sh;
266 u_int32_t val;
267
276}
277
278u_int32_t
279ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
280{
281 bus_space_tag_t tag = BUSTAG(ah);
282 bus_space_handle_t h = ah->ah_sh;
283 u_int32_t val;
284
285 if (ah->ah_config.ah_serialise_reg_war)
286 mtx_lock_spin(&ah_regser_mtx);
268#if _BYTE_ORDER == _BIG_ENDIAN
269 if (OS_REG_UNSWAPPED(reg))
270 val = bus_space_read_4(tag, h, reg);
271 else
272#endif
273 val = bus_space_read_stream_4(tag, h, reg);
287#if _BYTE_ORDER == _BIG_ENDIAN
288 if (OS_REG_UNSWAPPED(reg))
289 val = bus_space_read_4(tag, h, reg);
290 else
291#endif
292 val = bus_space_read_stream_4(tag, h, reg);
293 if (ah->ah_config.ah_serialise_reg_war)
294 mtx_unlock_spin(&ah_regser_mtx);
274 if (ath_hal_alq) {
275 struct ale *ale = ath_hal_alq_get(ah);
276 if (ale) {
277 struct athregrec *r = (struct athregrec *) ale->ae_data;
278 r->op = OP_READ;
279 r->reg = reg;
280 r->val = val;
281 alq_post(ath_hal_alq, ale);

--- 29 unchanged lines hidden (view full) ---

311 */
312
313void
314ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val)
315{
316 bus_space_tag_t tag = BUSTAG(ah);
317 bus_space_handle_t h = ah->ah_sh;
318
295 if (ath_hal_alq) {
296 struct ale *ale = ath_hal_alq_get(ah);
297 if (ale) {
298 struct athregrec *r = (struct athregrec *) ale->ae_data;
299 r->op = OP_READ;
300 r->reg = reg;
301 r->val = val;
302 alq_post(ath_hal_alq, ale);

--- 29 unchanged lines hidden (view full) ---

332 */
333
334void
335ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val)
336{
337 bus_space_tag_t tag = BUSTAG(ah);
338 bus_space_handle_t h = ah->ah_sh;
339
340 if (ah->ah_config.ah_serialise_reg_war)
341 mtx_lock_spin(&ah_regser_mtx);
319#if _BYTE_ORDER == _BIG_ENDIAN
320 if (OS_REG_UNSWAPPED(reg))
321 bus_space_write_4(tag, h, reg, val);
322 else
323#endif
324 bus_space_write_stream_4(tag, h, reg, val);
342#if _BYTE_ORDER == _BIG_ENDIAN
343 if (OS_REG_UNSWAPPED(reg))
344 bus_space_write_4(tag, h, reg, val);
345 else
346#endif
347 bus_space_write_stream_4(tag, h, reg, val);
348 if (ah->ah_config.ah_serialise_reg_war)
349 mtx_unlock_spin(&ah_regser_mtx);
325}
326
327u_int32_t
328ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
329{
330 bus_space_tag_t tag = BUSTAG(ah);
331 bus_space_handle_t h = ah->ah_sh;
332 u_int32_t val;
333
350}
351
352u_int32_t
353ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
354{
355 bus_space_tag_t tag = BUSTAG(ah);
356 bus_space_handle_t h = ah->ah_sh;
357 u_int32_t val;
358
359 if (ah->ah_config.ah_serialise_reg_war)
360 mtx_lock_spin(&ah_regser_mtx);
334#if _BYTE_ORDER == _BIG_ENDIAN
335 if (OS_REG_UNSWAPPED(reg))
336 val = bus_space_read_4(tag, h, reg);
337 else
338#endif
339 val = bus_space_read_stream_4(tag, h, reg);
361#if _BYTE_ORDER == _BIG_ENDIAN
362 if (OS_REG_UNSWAPPED(reg))
363 val = bus_space_read_4(tag, h, reg);
364 else
365#endif
366 val = bus_space_read_stream_4(tag, h, reg);
367 if (ah->ah_config.ah_serialise_reg_war)
368 mtx_unlock_spin(&ah_regser_mtx);
340 return val;
341}
342#endif /* AH_DEBUG || AH_REGOPS_FUNC */
343
344#ifdef AH_ASSERT
345void
346ath_hal_assert_failed(const char* filename, int lineno, const char *msg)
347{
348 printf("Atheros HAL assertion failure: %s: line %u: %s\n",
349 filename, lineno, msg);
350 panic("ath_hal_assert");
351}
352#endif /* AH_ASSERT */
369 return val;
370}
371#endif /* AH_DEBUG || AH_REGOPS_FUNC */
372
373#ifdef AH_ASSERT
374void
375ath_hal_assert_failed(const char* filename, int lineno, const char *msg)
376{
377 printf("Atheros HAL assertion failure: %s: line %u: %s\n",
378 filename, lineno, msg);
379 panic("ath_hal_assert");
380}
381#endif /* AH_ASSERT */