1/*
2 * Copyright 2009, Colin G��nther, coling@gmx.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <sys/bus.h>
8#include <sys/kernel.h>
9
10#include <net/if.h>
11#include <net/if_media.h>
12
13#include <net80211/ieee80211_var.h>
14
15#include <dev/ath/if_athvar.h>
16
17
18HAIKU_FBSD_WLAN_DRIVER_GLUE(atheroswifi, if_ath_pci, pci)
19NO_HAIKU_FBSD_MII_DRIVER();
20HAIKU_DRIVER_REQUIREMENTS(FBSD_WLAN);
21
22
23int
24HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
25{
26	struct ath_softc* sc = (struct ath_softc*)device_get_softc(dev);
27	struct ath_hal* ah = sc->sc_ah;
28	HAL_INT intr_status;
29
30	if (sc->sc_invalid) {
31		// The hardware is not ready/present, don't touch anything.
32		// Note this can happen early on if the IRQ is shared.
33		return 0;
34	}
35
36	if (!ath_hal_intrpend(ah)) {
37		// shared irq, not for us
38		return 0;
39	}
40
41	 // We have to save the isr status right now.
42	 // Some devices don't like having the interrupt disabled
43	 // before accessing the isr status.
44	 //
45	 // Those devices return status 0, when status access
46	 // occurs after disabling the interrupts with ath_hal_intrset.
47	 //
48	 // Note: Haiku's pcnet driver uses the same technique of
49	 //       appending a sc_lastisr field.
50	ath_hal_getisr(ah, &intr_status);
51	atomic_set((int32*)&sc->sc_intr_status, intr_status);
52
53	ath_hal_intrset(ah, 0);
54		// disable further intr's
55
56	return 1;
57}
58
59
60void
61HAIKU_REENABLE_INTERRUPTS(device_t dev)
62{
63	struct ath_softc* sc = (struct ath_softc*)device_get_softc(dev);
64	struct ath_hal* ah = sc->sc_ah;
65
66	ath_hal_intrset(ah, sc->sc_imask);
67}
68