Deleted Added
sdiff udiff text old ( 88371 ) new ( 88823 )
full compact
1/*
2 * Copyright (c) 1999, 2000 Matthew R. Green
3 * All rights reserved.
4 * Copyright 2001 by Thomas Moestl <tmm@FreeBSD.org>. 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: psycho.c,v 1.35 2001/09/10 16:17:06 eeh Exp
30 *
31 * $FreeBSD: head/sys/sparc64/pci/psycho.c 88371 2001-12-21 21:35:47Z tmm $
32 */
33
34/*
35 * Support for `psycho' and `psycho+' UPA to PCI bridge and
36 * UltraSPARC IIi and IIe `sabre' PCI controllers.
37 */
38
39#include "opt_psycho.h"

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

262 * just copy it's tags and addresses.
263 */
264static int
265psycho_attach(device_t dev)
266{
267 struct psycho_softc *sc;
268 struct psycho_softc *osc = NULL;
269 struct psycho_softc *asc;
270 struct ofw_nexus_reg *reg;
271 char compat[32];
272 char *model;
273 phandle_t node;
274 u_int64_t csr;
275 u_long pci_ctl;
276 int psycho_br[2];
277 int n, i, nreg;
278#if defined(PSYCHO_DEBUG) || defined(PSYCHO_STRAY)
279 u_long *map, *clr;
280#endif
281
282 bootverbose = 1;
283 node = nexus_get_node(dev);
284 sc = device_get_softc(dev);
285 if (OF_getprop(node, "compatible", compat, sizeof(compat)) == -1)
286 compat[0] = '\0';
287
288 sc->sc_node = node;
289 sc->sc_dev = dev;
290 sc->sc_bustag = nexus_get_bustag(dev);
291 sc->sc_dmatag = nexus_get_dmatag(dev);
292
293 /*
294 * call the model-specific initialisation routine.
295 */
296 model = nexus_get_model(dev);
297 if ((model != NULL &&
298 strcmp(model, OFW_SABRE_MODEL) == 0) ||

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

314 * (2) the shared psycho configuration registers (struct psychoreg)
315 *
316 * XXX use the prom address for the psycho registers? we do so far.
317 */
318 reg = nexus_get_reg(dev);
319 nreg = nexus_get_nreg(dev);
320 /* Register layouts are different. stuupid. */
321 if (sc->sc_mode == PSYCHO_MODE_PSYCHO) {
322 sc->sc_basepaddr = (vm_offset_t)reg[2].or_paddr;
323
324 if (nreg <= 2) {
325 panic("psycho_attach: %d not enough registers", nreg);
326 }
327 if (sparc64_bus_mem_map(UPA_BUS_SPACE, reg[2].or_paddr,
328 reg[2].or_len, 0, NULL, (void **)&sc->sc_regs))
329 panic("psycho_attach: cannot map regs");
330 pci_ctl = reg[0].or_paddr;
331 } else {
332 sc->sc_basepaddr = (vm_offset_t)reg[0].or_paddr;
333
334 if (nreg <= 0) {
335 panic("psycho_attach: %d not enough registers", nreg);
336 }
337 if (sparc64_bus_mem_map(UPA_BUS_SPACE, reg[0].or_paddr,
338 reg[0].or_len, 0, NULL, (void **)&sc->sc_regs))
339 panic("psycho_attach: cannot map regs");
340 pci_ctl = reg[0].or_paddr +
341 offsetof(struct psychoreg, psy_pcictl[0]);
342 }
343
344 csr = sc->sc_regs->psy_csr;
345 sc->sc_ign = 0x7c0; /* APB IGN is always 0x7c */
346 if (sc->sc_mode == PSYCHO_MODE_PSYCHO)
347 sc->sc_ign = PSYCHO_GCSR_IGN(csr) << 6;
348
349 device_printf(dev, "%s: impl %d, version %d: ign %x ",
350 model, PSYCHO_GCSR_IMPL(csr), PSYCHO_GCSR_VERS(csr),
351 sc->sc_ign);

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

370 /* Found partner */
371 osc = asc;
372 break;
373 }
374
375 /*
376 * Setup the PCI control register
377 */
378 csr = bus_space_read_8(sc->sc_bustag,
379 (bus_space_handle_t)pci_ctl, offsetof(struct pci_ctl, pci_csr));
380 csr |= PCICTL_MRLM |
381 PCICTL_ARB_PARK |
382 PCICTL_ERRINTEN |
383 PCICTL_4ENABLE;
384 csr &= ~(PCICTL_SERR |
385 PCICTL_CPU_PRIO |
386 PCICTL_ARB_PRIO |
387 PCICTL_RTRYWAIT);
388 bus_space_write_8(sc->sc_bustag,
389 (bus_space_handle_t)pci_ctl, offsetof(struct pci_ctl, pci_csr),
390 csr);
391
392 /* grab the psycho ranges */
393 psycho_get_ranges(sc->sc_node, &sc->sc_range, &sc->sc_nrange);
394
395 /* get the bus-range for the psycho */
396 n = OF_getprop(node, "bus-range", (void *)psycho_br, sizeof(psycho_br));
397 if (n == -1)
398 panic("could not get psycho bus-range");

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

585}
586
587static void
588psycho_set_intr(struct psycho_softc *sc, int index,
589 device_t dev, u_long *map, int iflags, driver_intr_t handler)
590{
591 int rid;
592
593 sc->sc_irq[index] = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
594 INTVEC(*map), INTVEC(*map), 1, RF_ACTIVE);
595 if (sc->sc_irq[index] == NULL)
596 panic("psycho_set_intr: failed to get interupt");
597 bus_setup_intr(dev, sc->sc_irq[index], INTR_TYPE_MISC | iflags,
598 handler, sc, &sc->sc_ihand[index]);
599 *map |= INTMAP_V;
600}
601
602static int
603psycho_find_intrmap(struct psycho_softc *sc, int ino, u_long **intrmapptr,
604 u_long **intrclrptr, u_long *intrdiagptr)
605{

--- 651 unchanged lines hidden ---