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