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
8cbe0a0c4SAugustin Cavalier #include <sys/bus.h>
9cbe0a0c4SAugustin Cavalier #include <sys/mutex.h>
10cbe0a0c4SAugustin Cavalier #include <sys/rman.h>
11cbe0a0c4SAugustin Cavalier #include <sys/systm.h>
12cbe0a0c4SAugustin Cavalier
13cbe0a0c4SAugustin Cavalier #include <machine/bus.h>
14cbe0a0c4SAugustin Cavalier
15*1454f3c2SAugustin Cavalier #include <net/if.h>
16*1454f3c2SAugustin Cavalier #include <net/if_var.h>
17cbe0a0c4SAugustin Cavalier
18*1454f3c2SAugustin Cavalier #include "if_skreg.h"
19cbe0a0c4SAugustin Cavalier #include "xmaciireg.h"
20cbe0a0c4SAugustin Cavalier
21cbe0a0c4SAugustin Cavalier HAIKU_FBSD_DRIVER_GLUE(syskonnect, skc, pci)
22cbe0a0c4SAugustin Cavalier
23cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(e1000phy, miibus);
24cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus);
25cbe0a0c4SAugustin Cavalier extern driver_t *DRIVER_MODULE_NAME(xmphy, miibus);
26cbe0a0c4SAugustin Cavalier
27cbe0a0c4SAugustin Cavalier HAIKU_DRIVER_REQUIREMENTS(0);
28cbe0a0c4SAugustin Cavalier
29cbe0a0c4SAugustin Cavalier driver_t *
__haiku_select_miibus_driver(device_t dev)30cbe0a0c4SAugustin Cavalier __haiku_select_miibus_driver(device_t dev)
31cbe0a0c4SAugustin Cavalier {
32cbe0a0c4SAugustin Cavalier driver_t *drivers[] = {
33cbe0a0c4SAugustin Cavalier DRIVER_MODULE_NAME(xmphy, miibus),
34cbe0a0c4SAugustin Cavalier DRIVER_MODULE_NAME(e1000phy, miibus),
35cbe0a0c4SAugustin Cavalier DRIVER_MODULE_NAME(ukphy, miibus),
36cbe0a0c4SAugustin Cavalier NULL
37cbe0a0c4SAugustin Cavalier };
38cbe0a0c4SAugustin Cavalier
39cbe0a0c4SAugustin Cavalier return __haiku_probe_miibus(dev, drivers);
40cbe0a0c4SAugustin Cavalier }
41cbe0a0c4SAugustin Cavalier
42cbe0a0c4SAugustin Cavalier
43cbe0a0c4SAugustin Cavalier int
__haiku_disable_interrupts(device_t dev)44cbe0a0c4SAugustin Cavalier __haiku_disable_interrupts(device_t dev)
45cbe0a0c4SAugustin Cavalier {
46cbe0a0c4SAugustin Cavalier struct sk_softc* sc = device_get_softc(dev);
47cbe0a0c4SAugustin Cavalier u_int32_t status;
48cbe0a0c4SAugustin Cavalier u_int32_t mask;
49cbe0a0c4SAugustin Cavalier HAIKU_INTR_REGISTER_STATE;
50cbe0a0c4SAugustin Cavalier
51cbe0a0c4SAugustin Cavalier mask = sc->sk_intrmask;
52cbe0a0c4SAugustin Cavalier HAIKU_INTR_REGISTER_ENTER();
53cbe0a0c4SAugustin Cavalier
54cbe0a0c4SAugustin Cavalier status = CSR_READ_4(sc, SK_ISSR);
55cbe0a0c4SAugustin Cavalier if (status == 0 || status == 0xffffffff || sc->sk_suspended)
56cbe0a0c4SAugustin Cavalier {
57cbe0a0c4SAugustin Cavalier HAIKU_INTR_REGISTER_LEAVE();
58cbe0a0c4SAugustin Cavalier return 0;
59cbe0a0c4SAugustin Cavalier }
60cbe0a0c4SAugustin Cavalier
61cbe0a0c4SAugustin Cavalier if (sc->sk_if[SK_PORT_A] != NULL)
62cbe0a0c4SAugustin Cavalier {
63cbe0a0c4SAugustin Cavalier mask &= ~SK_INTRS1;
64cbe0a0c4SAugustin Cavalier }
65cbe0a0c4SAugustin Cavalier
66cbe0a0c4SAugustin Cavalier if (sc->sk_if[SK_PORT_B] != NULL)
67cbe0a0c4SAugustin Cavalier {
68cbe0a0c4SAugustin Cavalier mask &= ~SK_INTRS2;
69cbe0a0c4SAugustin Cavalier }
70cbe0a0c4SAugustin Cavalier
71cbe0a0c4SAugustin Cavalier mask &= ~SK_ISR_EXTERNAL_REG;
72cbe0a0c4SAugustin Cavalier CSR_WRITE_4(sc, SK_IMR, mask);
73cbe0a0c4SAugustin Cavalier
74cbe0a0c4SAugustin Cavalier HAIKU_INTR_REGISTER_LEAVE();
75cbe0a0c4SAugustin Cavalier
76cbe0a0c4SAugustin Cavalier atomic_set((int32 *)&sc->sk_intstatus, status);
77cbe0a0c4SAugustin Cavalier return status & sc->sk_intrmask;
78cbe0a0c4SAugustin Cavalier }
79cbe0a0c4SAugustin Cavalier
80cbe0a0c4SAugustin Cavalier void
__haiku_reenable_interrupts(device_t dev)81cbe0a0c4SAugustin Cavalier __haiku_reenable_interrupts(device_t dev)
82cbe0a0c4SAugustin Cavalier {
83cbe0a0c4SAugustin Cavalier struct sk_softc *sc = device_get_softc(dev);
84cbe0a0c4SAugustin Cavalier
85cbe0a0c4SAugustin Cavalier CSR_READ_4(sc, SK_ISSR);
86cbe0a0c4SAugustin Cavalier CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
87cbe0a0c4SAugustin Cavalier }
88cbe0a0c4SAugustin Cavalier
89cbe0a0c4SAugustin Cavalier
90