xref: /haiku/src/add-ons/kernel/drivers/network/ether/rtl81xx/glue.c (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 /*
2  * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <sys/bus.h>
8 #include <sys/mutex.h>
9 #include <sys/systm.h>
10 #include <sys/taskqueue.h>
11 
12 #include <machine/bus.h>
13 
14 #include <net/if.h>
15 #include <net/if_var.h>
16 
17 #include <dev/rl/if_rlreg.h>
18 
19 
20 extern driver_t *DRIVER_MODULE_NAME(rgephy, miibus);
21 extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus);
22 
23 
24 HAIKU_FBSD_DRIVER_GLUE(rtl81xx, re, pci);
25 HAIKU_DRIVER_REQUIREMENTS(FBSD_FAST_TASKQUEUE);
26 
27 
28 driver_t *
29 __haiku_select_miibus_driver(device_t dev)
30 {
31 	driver_t *drivers[] = {
32 		DRIVER_MODULE_NAME(rgephy, miibus),
33 		DRIVER_MODULE_NAME(rlphy, miibus),
34 		NULL
35 	};
36 
37 	return __haiku_probe_miibus(dev, drivers);
38 }
39 
40 
41 int
42 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
43 {
44 	struct rl_softc *sc = device_get_softc(dev);
45 	uint16_t status;
46 
47 	status = CSR_READ_2(sc, RL_ISR);
48 	if (status == 0xffff)
49 		return 0;
50 	if (status != 0 && (status & RL_INTRS) == 0) {
51 		CSR_WRITE_2(sc, RL_ISR, status);
52 		return 0;
53 	}
54 	if ((status & RL_INTRS) == 0)
55 		return 0;
56 
57 	CSR_WRITE_2(sc, RL_IMR, 0);
58 	return 1;
59 }
60 
61 
62 void
63 HAIKU_REENABLE_INTERRUPTS(device_t dev)
64 {
65 	struct rl_softc *sc = device_get_softc(dev);
66 	RL_LOCK(sc);
67 	CSR_WRITE_2(sc, RL_IMR, RL_INTRS);
68 	RL_UNLOCK(sc);
69 }
70