xref: /haiku/src/add-ons/kernel/drivers/network/ether/marvell_yukon/glue.c (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
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/rman.h>
10 #include <sys/systm.h>
11 
12 #include <machine/bus.h>
13 
14 #include <net/if.h>
15 #include <net/if_media.h>
16 
17 #include <dev/msk/if_mskreg.h>
18 
19 
20 HAIKU_FBSD_DRIVER_GLUE(marvell_yukon, mskc, pci)
21 HAIKU_DRIVER_REQUIREMENTS(0);
22 
23 extern driver_t *DRIVER_MODULE_NAME(e1000phy, miibus);
24 extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus);
25 
26 
27 driver_t *
28 __haiku_select_miibus_driver(device_t dev)
29 {
30 	driver_t *drivers[] = {
31 		DRIVER_MODULE_NAME(e1000phy, miibus),
32 		DRIVER_MODULE_NAME(ukphy, miibus),
33 		NULL
34 	};
35 
36 	return __haiku_probe_miibus(dev, drivers);
37 }
38 
39 
40 int
41 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
42 {
43 	struct msk_softc *sc = device_get_softc(dev);
44 	uint32_t status;
45 
46 	/* Reading B0_Y2_SP_ISRC2 masks further interrupts. */
47 	status = CSR_READ_4(sc, B0_Y2_SP_ISRC2);
48 	if (status == 0 || status == 0xffffffff ||
49 	    (sc->msk_pflags & MSK_FLAG_SUSPEND) != 0 ||
50 	    (status & sc->msk_intrmask) == 0) {
51 
52 		/* Clear possibly spurious TWSI IRQ, see FreeBSD r234666. */
53 		if ((status & Y2_IS_TWSI_RDY) != 0)
54 			CSR_WRITE_4(sc, B2_I2C_IRQ, 1);
55 
56 		CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
57 		return 0;
58 	}
59 
60 	sc->haiku_interrupt_status = status;
61 	return 1;
62 }
63 
64 
65 void
66 HAIKU_REENABLE_INTERRUPTS(device_t dev)
67 {
68 	struct msk_softc *sc = device_get_softc(dev);
69 	CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
70 }
71