1/*
2 * Copyright 2008-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <sys/bus.h>
8#include <sys/mutex.h>
9#include <sys/systm.h>
10#include <sys/taskqueue.h>
11
12#include <machine/bus.h>
13
14#include <dev/rl/if_rlreg.h>
15
16
17extern driver_t *DRIVER_MODULE_NAME(rgephy, miibus);
18extern driver_t *DRIVER_MODULE_NAME(rlphy, miibus);
19
20
21HAIKU_FBSD_DRIVER_GLUE(rtl81xx, re, pci);
22HAIKU_DRIVER_REQUIREMENTS(FBSD_FAST_TASKQUEUE);
23
24
25driver_t *
26__haiku_select_miibus_driver(device_t dev)
27{
28	driver_t *drivers[] = {
29		DRIVER_MODULE_NAME(rgephy, miibus),
30		DRIVER_MODULE_NAME(rlphy, miibus),
31		NULL
32	};
33
34	return __haiku_probe_miibus(dev, drivers);
35}
36
37
38int
39HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
40{
41	struct rl_softc *sc = device_get_softc(dev);
42	uint16_t status;
43
44	status = CSR_READ_2(sc, RL_ISR);
45	if (status == 0xffff)
46		return 0;
47	if (status != 0 && (status & RL_INTRS) == 0) {
48		CSR_WRITE_2(sc, RL_ISR, status);
49		return 0;
50	}
51	if ((status & RL_INTRS) == 0)
52		return 0;
53
54	CSR_WRITE_2(sc, RL_IMR, 0);
55	return 1;
56}
57
58
59void
60HAIKU_REENABLE_INTERRUPTS(device_t dev)
61{
62	struct rl_softc *sc = device_get_softc(dev);
63	RL_LOCK(sc);
64	CSR_WRITE_2(sc, RL_IMR, RL_INTRS);
65	RL_UNLOCK(sc);
66}
67