xref: /haiku/src/add-ons/kernel/drivers/network/wlan/atheroswifi/glue.c (revision ab3e2cf4bc58c8cb63a554448b8df14a52869172)
189ee864aSColin Günther /*
2*ab3e2cf4SAugustin Cavalier  * Copyright 2009, Colin Günther, coling@gmx.de. All rights reserved.
3*ab3e2cf4SAugustin Cavalier  * Distributed under the terms of the MIT License.
489ee864aSColin Günther  */
589ee864aSColin Günther 
689ee864aSColin Günther 
789ee864aSColin Günther #include <sys/bus.h>
889ee864aSColin Günther #include <sys/kernel.h>
989ee864aSColin Günther 
1089ee864aSColin Günther #include <net/if.h>
1189ee864aSColin Günther #include <net/if_media.h>
1289ee864aSColin Günther 
1389ee864aSColin Günther #include <net80211/ieee80211_var.h>
1489ee864aSColin Günther 
1589ee864aSColin Günther #include <dev/ath/if_athvar.h>
1689ee864aSColin Günther 
1789ee864aSColin Günther 
18*ab3e2cf4SAugustin Cavalier HAIKU_FBSD_WLAN_DRIVER_GLUE(atheroswifi, if_ath_pci, pci)
1989ee864aSColin Günther NO_HAIKU_FBSD_MII_DRIVER();
20a052f480SAugustin Cavalier HAIKU_DRIVER_REQUIREMENTS(FBSD_WLAN);
2189ee864aSColin Günther 
2289ee864aSColin Günther 
2389ee864aSColin Günther int
HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)2489ee864aSColin Günther HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
2589ee864aSColin Günther {
26168aaf2fSColin Günther 	struct ath_softc* sc = (struct ath_softc*)device_get_softc(dev);
27168aaf2fSColin Günther 	struct ath_hal* ah = sc->sc_ah;
28168aaf2fSColin Günther 	HAL_INT intr_status;
2989ee864aSColin Günther 
30f8762ee7SColin Günther 	if (sc->sc_invalid) {
31097be0a8SColin Günther 		// The hardware is not ready/present, don't touch anything.
32097be0a8SColin Günther 		// Note this can happen early on if the IRQ is shared.
3389ee864aSColin Günther 		return 0;
34f8762ee7SColin Günther 	}
3589ee864aSColin Günther 
36f8762ee7SColin Günther 	if (!ath_hal_intrpend(ah)) {
37097be0a8SColin Günther 		// shared irq, not for us
3889ee864aSColin Günther 		return 0;
39f8762ee7SColin Günther 	}
4089ee864aSColin Günther 
41097be0a8SColin Günther 	 // We have to save the isr status right now.
42097be0a8SColin Günther 	 // Some devices don't like having the interrupt disabled
43097be0a8SColin Günther 	 // before accessing the isr status.
44097be0a8SColin Günther 	 //
45097be0a8SColin Günther 	 // Those devices return status 0, when status access
46097be0a8SColin Günther 	 // occurs after disabling the interrupts with ath_hal_intrset.
47097be0a8SColin Günther 	 //
48097be0a8SColin Günther 	 // Note: Haiku's pcnet driver uses the same technique of
49097be0a8SColin Günther 	 //       appending a sc_lastisr field.
50168aaf2fSColin Günther 	ath_hal_getisr(ah, &intr_status);
510e39b0b7SColin Günther 	atomic_set((int32*)&sc->sc_intr_status, intr_status);
52097be0a8SColin Günther 
53097be0a8SColin Günther 	ath_hal_intrset(ah, 0);
54097be0a8SColin Günther 		// disable further intr's
5589ee864aSColin Günther 
5689ee864aSColin Günther 	return 1;
5789ee864aSColin Günther }
5889ee864aSColin Günther 
5989ee864aSColin Günther 
6089ee864aSColin Günther void
HAIKU_REENABLE_INTERRUPTS(device_t dev)6189ee864aSColin Günther HAIKU_REENABLE_INTERRUPTS(device_t dev)
6289ee864aSColin Günther {
63168aaf2fSColin Günther 	struct ath_softc* sc = (struct ath_softc*)device_get_softc(dev);
64168aaf2fSColin Günther 	struct ath_hal* ah = sc->sc_ah;
6589ee864aSColin Günther 
66168aaf2fSColin Günther 	ath_hal_intrset(ah, sc->sc_imask);
6789ee864aSColin Günther }
68