xref: /haiku/src/add-ons/kernel/drivers/network/ether/3com/glue.c (revision 97f11716bfaa0f385eb0e28a52bf56a5023b9e99)
1cbe0a0c4SAugustin Cavalier /*
2cbe0a0c4SAugustin Cavalier  * Copyright 2007, Hugo Santos. All Rights Reserved.
3cbe0a0c4SAugustin Cavalier  * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved.
4cbe0a0c4SAugustin Cavalier  * Distributed under the terms of the MIT License.
5cbe0a0c4SAugustin Cavalier  */
6cbe0a0c4SAugustin Cavalier 
7cbe0a0c4SAugustin Cavalier #include <sys/bus.h>
8cbe0a0c4SAugustin Cavalier #include <sys/systm.h>
9cbe0a0c4SAugustin Cavalier 
10cbe0a0c4SAugustin Cavalier #include <machine/bus.h>
11cbe0a0c4SAugustin Cavalier 
12cbe0a0c4SAugustin Cavalier #include <net/if.h>
13cbe0a0c4SAugustin Cavalier #include <net/if_media.h>
14cbe0a0c4SAugustin Cavalier 
15cbe0a0c4SAugustin Cavalier #include "if_xlreg.h"
16cbe0a0c4SAugustin Cavalier 
17cbe0a0c4SAugustin Cavalier 
18cbe0a0c4SAugustin Cavalier HAIKU_FBSD_DRIVER_GLUE(3com, xl, pci);
19*b0719130SAugustin Cavalier HAIKU_DRIVER_REQUIREMENTS(FBSD_SWI_TASKQUEUE);
20cbe0a0c4SAugustin Cavalier 
21cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(bmtphy, miibus);
22cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus);
23cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(xlphy, miibus);
24cbe0a0c4SAugustin Cavalier 
25cbe0a0c4SAugustin Cavalier 
26cbe0a0c4SAugustin Cavalier driver_t *
__haiku_select_miibus_driver(device_t dev)27cbe0a0c4SAugustin Cavalier __haiku_select_miibus_driver(device_t dev)
28cbe0a0c4SAugustin Cavalier {
29cbe0a0c4SAugustin Cavalier 	driver_t *drivers[] = {
30cbe0a0c4SAugustin Cavalier 		DRIVER_MODULE_NAME(bmtphy, miibus),
31cbe0a0c4SAugustin Cavalier 		DRIVER_MODULE_NAME(ukphy, miibus),
32cbe0a0c4SAugustin Cavalier 		DRIVER_MODULE_NAME(xlphy, miibus),
33cbe0a0c4SAugustin Cavalier 		NULL
34cbe0a0c4SAugustin Cavalier 	};
35cbe0a0c4SAugustin Cavalier 
36cbe0a0c4SAugustin Cavalier 	return __haiku_probe_miibus(dev, drivers);
37cbe0a0c4SAugustin Cavalier }
38cbe0a0c4SAugustin Cavalier 
39cbe0a0c4SAugustin Cavalier 
40cbe0a0c4SAugustin Cavalier int
HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)41cbe0a0c4SAugustin Cavalier HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
42cbe0a0c4SAugustin Cavalier {
43cbe0a0c4SAugustin Cavalier 	struct xl_softc *sc = device_get_softc(dev);
44cbe0a0c4SAugustin Cavalier 	u_int16_t status = CSR_READ_2(sc, XL_STATUS);
45cbe0a0c4SAugustin Cavalier 
46cbe0a0c4SAugustin Cavalier 	if (status == 0xffff || (status & XL_INTRS) == 0)
47cbe0a0c4SAugustin Cavalier 		return 0;
48cbe0a0c4SAugustin Cavalier 
49cbe0a0c4SAugustin Cavalier 	CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB);
50cbe0a0c4SAugustin Cavalier 	CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK | (status & XL_INTRS));
51cbe0a0c4SAugustin Cavalier 	atomic_set((int32 *)&sc->xl_intr_status, status);
52cbe0a0c4SAugustin Cavalier 	return 1;
53cbe0a0c4SAugustin Cavalier }
54cbe0a0c4SAugustin Cavalier 
55cbe0a0c4SAugustin Cavalier 
56cbe0a0c4SAugustin Cavalier void
HAIKU_REENABLE_INTERRUPTS(device_t dev)57cbe0a0c4SAugustin Cavalier HAIKU_REENABLE_INTERRUPTS(device_t dev)
58cbe0a0c4SAugustin Cavalier {
59cbe0a0c4SAugustin Cavalier 	struct xl_softc *sc = device_get_softc(dev);
60cbe0a0c4SAugustin Cavalier 	CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB | XL_INTRS);
61cbe0a0c4SAugustin Cavalier }
62