btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / add-ons / kernel / drivers / network / wlan / ralink2860 / glue.c
blob37b7b7ddb7f38ff66b370ad4810a77b2f1507ab1
1 /*
2 * Copyright 2010, 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>
19 #include "dev/rt2860/rt2860_io.h"
20 #include "dev/rt2860/rt2860_reg.h"
21 #include "dev/rt2860/rt2860_softc.h"
24 HAIKU_FBSD_WLAN_DRIVER_GLUE(ralink2860, rt2860, pci)
25 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN);
27 HAIKU_FIRMWARE_VERSION(0);
28 NO_HAIKU_FIRMWARE_NAME_MAP();
30 NO_HAIKU_FBSD_MII_DRIVER();
33 static void rt2860_intr_enable(struct rt2860_softc* sc, uint32_t intr_mask)
35 uint32_t tmp;
37 sc->intr_disable_mask &= ~intr_mask;
39 tmp = sc->intr_enable_mask & ~sc->intr_disable_mask;
41 rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, tmp);
45 int
46 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
48 struct rt2860_softc* sc = (struct rt2860_softc*)device_get_softc(dev);
49 struct ifnet* ifp = sc->ifp;
51 // acknowledge interrupts
52 uint32_t status = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_INT_STATUS);
53 rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_STATUS, status);
55 if (status == 0xffffffff || status == 0)
56 // device likely went away || not for us
57 return 0;
59 sc->interrupts++;
61 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
62 return 0;
64 rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, 0);
65 // Disable interrupts
67 sc->interrupt_status = status;
69 return 1;
73 void
74 HAIKU_REENABLE_INTERRUPTS(device_t dev)
76 struct rt2860_softc* sc = (struct rt2860_softc*)device_get_softc(dev);
78 rt2860_intr_enable(sc, 0);