xref: /haiku/src/add-ons/kernel/drivers/network/wlan/iprowifi4965/glue.c (revision 6490c5b6211c94ec48c03c12b90e8603fe268d1b)
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/iwn/if_iwnreg.h>
19 #include <dev/iwn/if_iwnvar.h>
20 
21 
22 HAIKU_FBSD_WLAN_DRIVER_GLUE(iprowifi4965, iwn, pci)
23 NO_HAIKU_FBSD_MII_DRIVER();
24 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES|FBSD_WLAN);
25 HAIKU_FIRMWARE_VERSION(44417);
26 
27 
28 int
29 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
30 {
31 	struct iwn_softc* sc = (struct iwn_softc*)device_get_softc(dev);
32 	uint32 r1, r2;
33 	HAIKU_INTR_REGISTER_STATE;
34 
35 	HAIKU_INTR_REGISTER_ENTER();
36 	r1 = IWN_READ(sc, IWN_INTR);
37 	r2 = IWN_READ(sc, IWN_INTR_STATUS);
38 
39 	if (r1 == 0 && r2 == 0) {
40 		/* not for us */
41 		IWN_WRITE(sc, IWN_MASK, IWN_INTR_MASK);
42 		HAIKU_INTR_REGISTER_LEAVE();
43 		return 0;
44 	}
45 
46 	if (r1 == 0xffffffff) {
47 		/* hardware gone */
48 		HAIKU_INTR_REGISTER_LEAVE();
49 		return 0;
50 	}
51 
52 	/* disable interrupts */
53 	IWN_WRITE(sc, IWN_MASK, 0);
54 
55 	HAIKU_INTR_REGISTER_LEAVE();
56 
57 	return 1;
58 }
59 
60 
61 void
62 HAIKU_REENABLE_INTERRUPTS(device_t dev)
63 {
64 	struct iwn_softc* sc = (struct iwn_softc*)device_get_softc(dev);
65 
66 	/* enable interrupts */
67 	IWN_WRITE(sc, IWN_MASK, IWN_INTR_MASK);
68 }
69