1 /* 2 * Copyright 2007, Hugo Santos. All Rights Reserved. 3 * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 8 #include <sys/bus.h> 9 #include <sys/mutex.h> 10 #include <sys/rman.h> 11 #include <sys/systm.h> 12 13 #include <machine/bus.h> 14 15 #include <net/if.h> 16 #include <net/if_var.h> 17 18 #include "if_skreg.h" 19 #include "xmaciireg.h" 20 21 HAIKU_FBSD_DRIVER_GLUE(syskonnect, skc, pci) 22 23 extern driver_t *DRIVER_MODULE_NAME(e1000phy, miibus); 24 extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus); 25 extern driver_t *DRIVER_MODULE_NAME(xmphy, miibus); 26 27 HAIKU_DRIVER_REQUIREMENTS(0); 28 29 driver_t * 30 __haiku_select_miibus_driver(device_t dev) 31 { 32 driver_t *drivers[] = { 33 DRIVER_MODULE_NAME(xmphy, miibus), 34 DRIVER_MODULE_NAME(e1000phy, 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_disable_interrupts(device_t dev) 45 { 46 struct sk_softc* sc = device_get_softc(dev); 47 u_int32_t status; 48 u_int32_t mask; 49 HAIKU_INTR_REGISTER_STATE; 50 51 mask = sc->sk_intrmask; 52 HAIKU_INTR_REGISTER_ENTER(); 53 54 status = CSR_READ_4(sc, SK_ISSR); 55 if (status == 0 || status == 0xffffffff || sc->sk_suspended) 56 { 57 HAIKU_INTR_REGISTER_LEAVE(); 58 return 0; 59 } 60 61 if (sc->sk_if[SK_PORT_A] != NULL) 62 { 63 mask &= ~SK_INTRS1; 64 } 65 66 if (sc->sk_if[SK_PORT_B] != NULL) 67 { 68 mask &= ~SK_INTRS2; 69 } 70 71 mask &= ~SK_ISR_EXTERNAL_REG; 72 CSR_WRITE_4(sc, SK_IMR, mask); 73 74 HAIKU_INTR_REGISTER_LEAVE(); 75 76 atomic_set((int32 *)&sc->sk_intstatus, status); 77 return status & sc->sk_intrmask; 78 } 79 80 void 81 __haiku_reenable_interrupts(device_t dev) 82 { 83 struct sk_softc *sc = device_get_softc(dev); 84 85 CSR_READ_4(sc, SK_ISSR); 86 CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask); 87 } 88 89 90