BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / drivers / network / wlan / ralinkwifi / glue.c
blobe07c1b438a73f605104129baf70466d540c57c13
1 /*
2 * Copyright 2009, Colin Günther, coling@gmx.de.
3 * All Rights Reserved. Distributed under the terms of the MIT License.
4 */
7 #include <sys/bus.h>
8 #include <sys/kernel.h>
10 #include <dev/pci/pcivar.h>
12 #include <machine/bus.h>
14 #include <net/if.h>
15 #include <net/if_media.h>
17 #include <net80211/ieee80211_var.h>
18 #include <net80211/ieee80211_amrr.h>
20 #include <dev/ral/rt2560reg.h>
21 #include <dev/ral/rt2560var.h>
22 #include <dev/ral/rt2860reg.h>
23 #include <dev/ral/rt2860var.h>
26 HAIKU_FBSD_WLAN_DRIVER_GLUE(ralinkwifi, ral, pci)
27 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE | FBSD_WLAN);
28 HAIKU_FIRMWARE_VERSION(0);
29 HAIKU_FIRMWARE_NAME_MAP(4) = {{"rt2561fw", "rt2561.bin"},
30 {"rt2561sfw", "rt2561s.bin"}, {"rt2661fw", "rt2661.bin"},
31 {"rt2860fw", "rt2860.bin"}};
33 NO_HAIKU_FBSD_MII_DRIVER();
34 NO_HAIKU_REENABLE_INTERRUPTS();
37 #define RT2661_INT_MASK_CSR 0x346c
38 #define RT2661_MCU_INT_MASK_CSR 0x0018
41 int
42 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
44 struct rt2560_softc* sc = (struct rt2560_softc*)device_get_softc(dev);
45 // sc_ifp is common between context data structures
46 struct ifnet* ifp = sc->sc_ifp;
48 switch (pci_get_device(dev)) {
49 case 0x0201:
50 // disable interrupts
51 RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
53 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
54 // don't re-enable interrupts if we're shutting down
55 return 0;
57 break;
58 case 0x0301:
59 case 0x0302:
60 case 0x0401:
61 // disable MAC and MCU interrupts
62 RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
63 RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
65 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
66 // don't re-enable interrupts if we're shutting down
67 return 0;
69 break;
70 default:
72 uint32 r;
73 struct rt2860_softc* sc =
74 (struct rt2860_softc*)device_get_softc(dev);
75 r = RAL_READ(sc, RT2860_INT_STATUS);
76 if (r == 0 || r == 0xffffffff)
77 return 0;
79 atomic_set((int32*)&sc->sc_intr_status, r);
80 break;
84 return 1;