FreeBSD/Linux Kernel Cross Reference
sys/mips/malta/gt.c
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2005 Olivier Houchard. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/bus.h>
33 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/module.h>
36 #include <sys/rman.h>
37 #include <sys/types.h>
38
39 #include <vm/vm.h>
40 #include <vm/vm_kern.h>
41 #include <vm/pmap.h>
42 #include <vm/vm_page.h>
43 #include <vm/vm_extern.h>
44
45 #include <dev/ic/i8259.h>
46
47 #include <machine/bus.h>
48 #include <machine/intr_machdep.h>
49
50 #include <mips/malta/gtvar.h>
51
52 static int
53 gt_probe(device_t dev)
54 {
55 device_set_desc(dev, "GT64120 chip");
56 return (BUS_PROBE_NOWILDCARD);
57 }
58
59 static void
60 gt_identify(driver_t *drv, device_t parent)
61 {
62 BUS_ADD_CHILD(parent, 0, "gt", 0);
63 }
64
65 static int
66 gt_attach(device_t dev)
67 {
68 struct gt_softc *sc = device_get_softc(dev);
69 sc->dev = dev;
70
71 device_add_child(dev, "pcib", 0);
72 bus_generic_probe(dev);
73 bus_generic_attach(dev);
74
75
76 return (0);
77 }
78
79 static struct resource *
80 gt_alloc_resource(device_t dev, device_t child, int type, int *rid,
81 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
82 {
83 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
84 type, rid, start, end, count, flags));
85
86 }
87
88 static int
89 gt_setup_intr(device_t dev, device_t child,
90 struct resource *ires, int flags, driver_filter_t *filt,
91 driver_intr_t *intr, void *arg, void **cookiep)
92 {
93 return BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags,
94 filt, intr, arg, cookiep);
95 }
96
97 static int
98 gt_teardown_intr(device_t dev, device_t child, struct resource *res,
99 void *cookie)
100 {
101 return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie));
102 }
103
104 static int
105 gt_activate_resource(device_t dev, device_t child, int type, int rid,
106 struct resource *r)
107 {
108 return (BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child,
109 type, rid, r));
110 }
111
112 static device_method_t gt_methods[] = {
113 DEVMETHOD(device_probe, gt_probe),
114 DEVMETHOD(device_identify, gt_identify),
115 DEVMETHOD(device_attach, gt_attach),
116
117 DEVMETHOD(bus_setup_intr, gt_setup_intr),
118 DEVMETHOD(bus_teardown_intr, gt_teardown_intr),
119 DEVMETHOD(bus_alloc_resource, gt_alloc_resource),
120 DEVMETHOD(bus_activate_resource, gt_activate_resource),
121
122 DEVMETHOD_END
123 };
124
125 static driver_t gt_driver = {
126 "gt",
127 gt_methods,
128 sizeof(struct gt_softc),
129 };
130 static devclass_t gt_devclass;
131
132 DRIVER_MODULE(gt, nexus, gt_driver, gt_devclass, 0, 0);
Cache object: 2c6e199e7efe47217e4efd8516ba77b8
|