xref: /haiku/src/add-ons/kernel/drivers/network/ether/broadcom440x/glue.c (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2  * Copyright 2008, Jérôme Duval. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <sys/bus.h>
7 #include <sys/malloc.h>
8 #include <sys/rman.h>
9 #include <sys/systm.h>
10 
11 #include <machine/bus.h>
12 
13 #include <net/if.h>
14 
15 #include "if_bfereg.h"
16 
17 
18 HAIKU_FBSD_DRIVER_GLUE(broadcom440x, bfe, pci);
19 HAIKU_DRIVER_REQUIREMENTS(0);
20 
21 extern driver_t *DRIVER_MODULE_NAME(bmtphy, miibus);
22 
23 driver_t *
24 __haiku_select_miibus_driver(device_t dev)
25 {
26 	driver_t *drivers[] = {
27 		DRIVER_MODULE_NAME(bmtphy, miibus),
28 		NULL
29 	};
30 
31 	return __haiku_probe_miibus(dev, drivers);
32 }
33 
34 
35 int
36 __haiku_disable_interrupts(device_t dev)
37 {
38 	struct bfe_softc *sc = device_get_softc(dev);
39 	uint32 istat;
40 	HAIKU_INTR_REGISTER_STATE;
41 
42 	HAIKU_INTR_REGISTER_ENTER();
43 
44 	istat = CSR_READ_4(sc, BFE_ISTAT);
45 	if (istat == 0 || (sc->bfe_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
46 		HAIKU_INTR_REGISTER_LEAVE();
47 		return 0;
48 	}
49 
50 	CSR_WRITE_4(sc, BFE_IMASK, 0);
51 	CSR_READ_4(sc, BFE_IMASK);
52 
53 	HAIKU_INTR_REGISTER_LEAVE();
54 	return 1;
55 }
56 
57 
58 void
59 __haiku_reenable_interrupts(device_t dev)
60 {
61 	struct bfe_softc *sc = device_get_softc(dev);
62 	CSR_WRITE_4(sc, BFE_IMASK, BFE_IMASK_DEF);
63 	CSR_READ_4(sc, BFE_IMASK);
64 }
65 
66 
67