xref: /haiku/src/add-ons/kernel/drivers/network/wlan/iprowifi3945/glue.c (revision 6ec69f4426d9d171c683124d62cfbd7762a37f27)
1 /*
2  * Copyright 2009, Colin Günther, coling@gmx.de.
3  * Copyright 2018, Haiku, Inc.
4  * All rights reserved. Distributed under the terms of the MIT license.
5  */
6 
7 
8 #include <sys/bus.h>
9 #include <sys/kernel.h>
10 
11 #include <machine/bus.h>
12 
13 #include <net/if.h>
14 #include <net/if_media.h>
15 
16 #include <net80211/ieee80211_var.h>
17 
18 #include <dev/wpi/if_wpireg.h>
19 #include <dev/wpi/if_wpivar.h>
20 
21 
22 HAIKU_FBSD_WLAN_DRIVER_GLUE(iprowifi3945, wpi, pci)
23 NO_HAIKU_FBSD_MII_DRIVER();
24 NO_HAIKU_REENABLE_INTERRUPTS();
25 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN);
26 HAIKU_FIRMWARE_VERSION(2144);
27 HAIKU_FIRMWARE_NAME_MAP(1) = {{"wpifw", "iwlwifi-3945-2.ucode"}};
28 
29 
30 int
31 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
32 {
33 	struct wpi_softc* sc = (struct wpi_softc*)device_get_softc(dev);
34 	uint32 r1, r2;
35 
36 	r1 = WPI_READ(sc, WPI_INT);
37 
38 	if (__predict_false(r1 == 0xffffffff ||
39 			(r1 & 0xfffffff0) == 0xa5a5a5a0))
40 		return 0;	/* Hardware gone! */
41 
42 	r2 = WPI_READ(sc, WPI_FH_INT);
43 
44 	if (r1 == 0 && r2 == 0)
45 		return 0;	/* Interrupt not for us. */
46 
47 	/* Disable interrupts. */
48 	WPI_WRITE(sc, WPI_INT_MASK, 0);
49 
50 	atomic_set((int32*)&sc->sc_intr_status_1, r1);
51 	atomic_set((int32*)&sc->sc_intr_status_2, r2);
52 
53 	return 1;
54 }
55