xref: /haiku/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/glue.c (revision 508f54795f39c3e7552d87c95aae9dd8ec6f505b)
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 <dev/pci/pcivar.h>
11 
12 #include <machine/bus.h>
13 
14 #include <net/if.h>
15 #include <net/if_media.h>
16 
17 #include <net80211/ieee80211_var.h>
18 #include <net80211/ieee80211_amrr.h>
19 
20 #include <dev/ral/rt2560reg.h>
21 #include <dev/ral/rt2560var.h>
22 
23 
24 HAIKU_FBSD_WLAN_DRIVER_GLUE(ralinkwifi, ral, pci)
25 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE | FBSD_WLAN);
26 HAIKU_FIRMWARE_VERSION(0);
27 HAIKU_FIRMWARE_NAME_MAP(3) = {{"rt2561fw", "rt2561.bin"},
28 	{"rt2561sfw", "rt2561s.bin"}, {"rt2661fw", "rt2661.bin"}};
29 
30 NO_HAIKU_FBSD_MII_DRIVER();
31 NO_HAIKU_REENABLE_INTERRUPTS();
32 
33 
34 #define RT2661_INT_MASK_CSR			0x346c
35 #define RT2661_MCU_INT_MASK_CSR		0x0018
36 
37 
38 int
39 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
40 {
41 	struct rt2560_softc* sc = (struct rt2560_softc*)device_get_softc(dev);
42 		// assuming that rt2560 and rt2661 share a common context data structure
43 	struct ifnet* ifp = sc->sc_ifp;
44 
45 	if (pci_get_device(dev) == 0x0201) {
46 		// disable interrupts
47 		RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
48 	} else {
49 		// disable MAC and MCU interrupts
50 		RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
51 		RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
52 	}
53 
54 	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
55 		// don't re-enable interrupts if we're shutting down
56 		return 0;
57 	}
58 
59 	return 1;
60 }
61