xref: /haiku/src/add-ons/kernel/drivers/network/wlan/iprowifi3945/glue.c (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
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 #include <net80211/ieee80211_ratectl.h>
18 
19 #include <dev/wpi/if_wpireg.h>
20 #include <dev/wpi/if_wpivar.h>
21 
22 
23 HAIKU_FBSD_WLAN_DRIVER_GLUE(iprowifi3945, wpi, pci)
24 NO_HAIKU_FBSD_MII_DRIVER();
25 NO_HAIKU_REENABLE_INTERRUPTS();
26 HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN);
27 HAIKU_FIRMWARE_VERSION(2144);
28 HAIKU_FIRMWARE_NAME_MAP({{"wpifw", "iwlwifi-3945-15.ucode"}});
29 
30 
31 int
32 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
33 {
34 	struct wpi_softc* sc = (struct wpi_softc*)device_get_softc(dev);
35 	uint32 r1, r2;
36 
37 	r1 = WPI_READ(sc, WPI_INT);
38 
39 	if (__predict_false(r1 == 0xffffffff ||
40 			(r1 & 0xfffffff0) == 0xa5a5a5a0))
41 		return 0;	/* Hardware gone! */
42 
43 	r2 = WPI_READ(sc, WPI_FH_INT);
44 
45 	if (r1 == 0 && r2 == 0)
46 		return 0;	/* Interrupt not for us. */
47 
48 	/* Disable interrupts. */
49 	WPI_WRITE(sc, WPI_INT_MASK, 0);
50 
51 	atomic_set((int32*)&sc->sc_intr_status_1, r1);
52 	atomic_set((int32*)&sc->sc_intr_status_2, r2);
53 
54 	return 1;
55 }
56