xref: /haiku/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/glue.c (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2  * Copyright 2009, Colin Günther, coling@gmx.de.
3  * All Rights Reserved. Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <sys/bus.h>
8 #include <sys/kernel.h>
9 
10 #include <machine/bus.h>
11 
12 #include <net/if.h>
13 #include <net/if_media.h>
14 
15 #include <net80211/ieee80211_var.h>
16 #include <net80211/ieee80211_amrr.h>
17 
18 #include <dev/bwi/bitops.h>
19 #include <dev/bwi/if_bwireg.h>
20 #include <dev/bwi/if_bwivar.h>
21 
22 
23 HAIKU_FBSD_WLAN_DRIVER_GLUE(broadcom43xx, bwi, pci)
24 NO_HAIKU_FBSD_MII_DRIVER();
25 NO_HAIKU_REENABLE_INTERRUPTS();
26 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN);
27 HAIKU_FIRMWARE_VERSION(0);
28 NO_HAIKU_FIRMWARE_NAME_MAP();
29 
30 
31 int
32 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
33 {
34 	struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev);
35 	struct ifnet* ifp = sc->sc_ifp;
36 	uint32 intr_status;
37 
38 	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
39 		|| (sc->sc_flags & BWI_F_STOP))
40 		return 0;
41 
42 	intr_status = CSR_READ_4(sc, BWI_MAC_INTR_STATUS);
43 	if (intr_status == 0xffffffff) {
44 		// Not for us
45 		return 0;
46 	}
47 
48 	intr_status &= CSR_READ_4(sc, BWI_MAC_INTR_MASK);
49 	if (intr_status == 0) {
50 		// nothing interesting
51 		return 0;
52 	}
53 
54 	atomic_set((int32*)&sc->sc_intr_status, intr_status);
55 
56 	CSR_CLRBITS_4(sc, BWI_MAC_INTR_MASK, BWI_ALL_INTRS);
57 		// Disable all interrupts
58 
59 	return 1;
60 }
61