Deleted Added
full compact
ebus.c (128775) ebus.c (129051)
1/*
2 * Copyright (c) 1999, 2000 Matthew R. Green
3 * Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
4 * 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:

--- 14 unchanged lines hidden (view full) ---

23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * from: NetBSD: ebus.c,v 1.26 2001/09/10 16:27:53 eeh Exp
30 *
1/*
2 * Copyright (c) 1999, 2000 Matthew R. Green
3 * Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
4 * 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:

--- 14 unchanged lines hidden (view full) ---

23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * from: NetBSD: ebus.c,v 1.26 2001/09/10 16:27:53 eeh Exp
30 *
31 * $FreeBSD: head/sys/sparc64/ebus/ebus.c 128775 2004-04-30 19:19:55Z tmm $
31 * $FreeBSD: head/sys/sparc64/ebus/ebus.c 129051 2004-05-08 13:53:47Z marius $
32 */
33
34/*
35 * UltraSPARC 5 and beyond ebus support.
36 *
37 * note that this driver is not complete:
38 * - ebus2 dma code is completely unwritten
39 * - interrupt establish is written and appears to work
40 * - bus map code is written and appears to work
41 * XXX: This is PCI specific, however, there exist SBus-to-EBus bridges...
42 * XXX: The EBus was designed to allow easy adaption of ISA devices to it - a
43 * compatability layer for ISA devices might be nice, although probably not
44 * easily possible because of some cruft (like in[bwl]/out[bwl] and friends).
45 * Additionally, the existing ISA code is limited to one ISA bus, however,
46 * there are machines with both ISA and EBus.
47 */
48
32 */
33
34/*
35 * UltraSPARC 5 and beyond ebus support.
36 *
37 * note that this driver is not complete:
38 * - ebus2 dma code is completely unwritten
39 * - interrupt establish is written and appears to work
40 * - bus map code is written and appears to work
41 * XXX: This is PCI specific, however, there exist SBus-to-EBus bridges...
42 * XXX: The EBus was designed to allow easy adaption of ISA devices to it - a
43 * compatability layer for ISA devices might be nice, although probably not
44 * easily possible because of some cruft (like in[bwl]/out[bwl] and friends).
45 * Additionally, the existing ISA code is limited to one ISA bus, however,
46 * there are machines with both ISA and EBus.
47 */
48
49#include "opt_ofw_pci.h"
50
51#include <sys/param.h>
52#include <sys/systm.h>
53#include <sys/bus.h>
54#include <sys/kernel.h>
55#include <sys/malloc.h>
56
57#include <machine/bus.h>
58
59#include <sys/rman.h>
60
61#include <dev/ofw/openfirm.h>
49#include <sys/param.h>
50#include <sys/systm.h>
51#include <sys/bus.h>
52#include <sys/kernel.h>
53#include <sys/malloc.h>
54
55#include <machine/bus.h>
56
57#include <sys/rman.h>
58
59#include <dev/ofw/openfirm.h>
62#include <dev/ofw/ofw_pci.h>
63
64#include <machine/ofw_bus.h>
65#include <machine/resource.h>
66
67#include <dev/pci/pcireg.h>
68#include <dev/pci/pcivar.h>
69
70#include <sparc64/pci/ofw_pci.h>

--- 23 unchanged lines hidden (view full) ---

94 phandle_t sc_node;
95
96 struct isa_ranges *sc_range;
97 struct ebus_rinfo *sc_rinfo;
98
99 int sc_nrange;
100 int sc_nimap;
101
60
61#include <machine/ofw_bus.h>
62#include <machine/resource.h>
63
64#include <dev/pci/pcireg.h>
65#include <dev/pci/pcivar.h>
66
67#include <sparc64/pci/ofw_pci.h>

--- 23 unchanged lines hidden (view full) ---

91 phandle_t sc_node;
92
93 struct isa_ranges *sc_range;
94 struct ebus_rinfo *sc_rinfo;
95
96 int sc_nrange;
97 int sc_nimap;
98
102#ifdef OFW_NEWPCI
103 struct ofw_bus_iinfo sc_iinfo;
99 struct ofw_bus_iinfo sc_iinfo;
104#endif
105};
106
107static device_probe_t ebus_probe;
108static device_attach_t ebus_attach;
109static bus_print_child_t ebus_print_child;
110static bus_probe_nomatch_t ebus_probe_nomatch;
111static bus_read_ivar_t ebus_read_ivar;
112static bus_write_ivar_t ebus_write_ivar;

--- 33 unchanged lines hidden (view full) ---

146 ebus_methods,
147 sizeof(struct ebus_softc),
148};
149
150static devclass_t ebus_devclass;
151
152DRIVER_MODULE(ebus, pci, ebus_driver, ebus_devclass, 0, 0);
153
100};
101
102static device_probe_t ebus_probe;
103static device_attach_t ebus_attach;
104static bus_print_child_t ebus_print_child;
105static bus_probe_nomatch_t ebus_probe_nomatch;
106static bus_read_ivar_t ebus_read_ivar;
107static bus_write_ivar_t ebus_write_ivar;

--- 33 unchanged lines hidden (view full) ---

141 ebus_methods,
142 sizeof(struct ebus_softc),
143};
144
145static devclass_t ebus_devclass;
146
147DRIVER_MODULE(ebus, pci, ebus_driver, ebus_devclass, 0, 0);
148
154static phandle_t
155ebus_get_busnode(device_t dev)
156{
157
158#ifdef OFW_NEWPCI
159 return (ofw_pci_get_node(dev));
160#else
161 return (ofw_pci_find_node(pci_get_bus(dev), pci_get_slot(dev),
162 pci_get_function(dev)));
163#endif
164}
165
166static int
167ebus_probe(device_t dev)
168{
169 char name[10];
170 phandle_t node;
171
149static int
150ebus_probe(device_t dev)
151{
152 char name[10];
153 phandle_t node;
154
172 if ((node = ebus_get_busnode(dev)) == 0)
155 if ((node = ofw_pci_get_node(dev)) == 0)
173 return (ENXIO);
174
175 OF_getprop(node, "name", &name, sizeof(name));
176 if (pci_get_class(dev) != PCIC_BRIDGE ||
177 pci_get_vendor(dev) != 0x108e ||
178 strcmp(name, "ebus") != 0)
179 return (ENXIO);
180

--- 14 unchanged lines hidden (view full) ---

195 struct ebus_rinfo *eri;
196 struct resource *res;
197 device_t cdev;
198 phandle_t node;
199 char *cname;
200 int i, rnum, rid;
201
202 sc = device_get_softc(dev);
156 return (ENXIO);
157
158 OF_getprop(node, "name", &name, sizeof(name));
159 if (pci_get_class(dev) != PCIC_BRIDGE ||
160 pci_get_vendor(dev) != 0x108e ||
161 strcmp(name, "ebus") != 0)
162 return (ENXIO);
163

--- 14 unchanged lines hidden (view full) ---

178 struct ebus_rinfo *eri;
179 struct resource *res;
180 device_t cdev;
181 phandle_t node;
182 char *cname;
183 int i, rnum, rid;
184
185 sc = device_get_softc(dev);
203 sc->sc_node = node = ebus_get_busnode(dev);
186 sc->sc_node = node = ofw_pci_get_node(dev);
204
205 sc->sc_nrange = OF_getprop_alloc(node, "ranges",
206 sizeof(*sc->sc_range), (void **)&sc->sc_range);
207 if (sc->sc_nrange == -1) {
208 printf("ebus_attach: could not get ranges property\n");
209 return (ENXIO);
210 }
211

--- 22 unchanged lines hidden (view full) ---

234 if (rman_manage_region(&eri->eri_rman, rman_get_start(res),
235 rman_get_end(res)) != 0) {
236 printf("ebus_attach: failed to register region!");
237 rman_fini(&eri->eri_rman);
238 goto fail;
239 }
240 }
241
187
188 sc->sc_nrange = OF_getprop_alloc(node, "ranges",
189 sizeof(*sc->sc_range), (void **)&sc->sc_range);
190 if (sc->sc_nrange == -1) {
191 printf("ebus_attach: could not get ranges property\n");
192 return (ENXIO);
193 }
194

--- 22 unchanged lines hidden (view full) ---

217 if (rman_manage_region(&eri->eri_rman, rman_get_start(res),
218 rman_get_end(res)) != 0) {
219 printf("ebus_attach: failed to register region!");
220 rman_fini(&eri->eri_rman);
221 goto fail;
222 }
223 }
224
242#ifdef OFW_NEWPCI
243 ofw_bus_setup_iinfo(node, &sc->sc_iinfo, sizeof(ofw_isa_intr_t));
225 ofw_bus_setup_iinfo(node, &sc->sc_iinfo, sizeof(ofw_isa_intr_t));
244#endif
245
246 /*
247 * Now attach our children.
248 */
249 for (node = OF_child(node); node > 0; node = OF_peer(node)) {
250 if ((OF_getprop_alloc(node, "name", 1, (void **)&cname)) == -1)
251 continue;
252

--- 232 unchanged lines hidden (view full) ---

485 resource_list_add(&edi->edi_rl, SYS_RES_IOPORT, i,
486 start, start + reg[i].size - 1, reg[i].size);
487 }
488 free(reg, M_OFWPROP);
489
490 nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs),
491 (void **)&intrs);
492 for (i = 0; i < nintr; i++) {
226
227 /*
228 * Now attach our children.
229 */
230 for (node = OF_child(node); node > 0; node = OF_peer(node)) {
231 if ((OF_getprop_alloc(node, "name", 1, (void **)&cname)) == -1)
232 continue;
233

--- 232 unchanged lines hidden (view full) ---

466 resource_list_add(&edi->edi_rl, SYS_RES_IOPORT, i,
467 start, start + reg[i].size - 1, reg[i].size);
468 }
469 free(reg, M_OFWPROP);
470
471 nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs),
472 (void **)&intrs);
473 for (i = 0; i < nintr; i++) {
493#ifdef OFW_NEWPCI
494 rintr = ofw_isa_route_intr(dev, node, &sc->sc_iinfo, intrs[i]);
474 rintr = ofw_isa_route_intr(dev, node, &sc->sc_iinfo, intrs[i]);
495 if (rintr == PCI_INVALID_IRQ) {
496#else
497 rintr = ofw_bus_route_intr(node, intrs[i], ofw_pci_orb_callback,
498 dev);
499 if (rintr == ORIR_NOTFOUND) {
500#endif
475 if (rintr == PCI_INVALID_IRQ)
501 panic("ebus_setup_dinfo: could not map ebus "
502 "interrupt %d", intrs[i]);
476 panic("ebus_setup_dinfo: could not map ebus "
477 "interrupt %d", intrs[i]);
503 }
504 resource_list_add(&edi->edi_rl, SYS_RES_IRQ, i,
505 rintr, rintr, 1);
506 }
507 free(intrs, M_OFWPROP);
508
509 return (edi);
510}
511

--- 24 unchanged lines hidden ---
478 resource_list_add(&edi->edi_rl, SYS_RES_IRQ, i,
479 rintr, rintr, 1);
480 }
481 free(intrs, M_OFWPROP);
482
483 return (edi);
484}
485

--- 24 unchanged lines hidden ---