xref: /haiku/src/add-ons/kernel/drivers/network/ether/sis900/glue.c (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
1 /*
2  * Copyright 2018, 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/rman.h>
9 #include <sys/systm.h>
10 
11 #include <machine/bus.h>
12 
13 #include <net/if.h>
14 #include <net/if_media.h>
15 
16 #include <dev/sis/if_sisreg.h>
17 
18 
19 HAIKU_FBSD_DRIVER_GLUE(sis900, sis, pci);
20 HAIKU_DRIVER_REQUIREMENTS(0);
21 NO_HAIKU_REENABLE_INTERRUPTS();
22 
23 
24 extern driver_t* DRIVER_MODULE_NAME(icsphy, miibus);
25 extern driver_t* DRIVER_MODULE_NAME(nsphyter, miibus);
26 extern driver_t* DRIVER_MODULE_NAME(ukphy, miibus);
27 
28 
29 driver_t *
30 __haiku_select_miibus_driver(device_t dev)
31 {
32 	driver_t *drivers[] = {
33 		DRIVER_MODULE_NAME(icsphy, miibus),
34 		DRIVER_MODULE_NAME(nsphyter, miibus),
35 		DRIVER_MODULE_NAME(ukphy, miibus),
36 		NULL
37 	};
38 
39 	return __haiku_probe_miibus(dev, drivers);
40 }
41 
42 
43 int
44 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
45 {
46 	struct sis_softc *sc = device_get_softc(dev);
47 	uint32_t status;
48 
49 	/* Reading the ISR register clears all interrupts. */
50 	status = CSR_READ_4(sc, SIS_ISR);
51 	if ((status & SIS_INTRS) == 0) {
52 		/* Not ours. */
53 		return 0;
54 	}
55 
56 	/* Disable interrupts. */
57 	CSR_WRITE_4(sc, SIS_IER, 0);
58 
59 	sc->haiku_interrupt_status = status;
60 	return 1;
61 }
62