psycho.c (88371) | psycho.c (88823) |
---|---|
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 * | 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 $ | 31 * $FreeBSD: head/sys/sparc64/pci/psycho.c 88823 2002-01-02 18:27:13Z 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; | 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; | 270 struct upa_regs *reg; |
271 char compat[32]; 272 char *model; 273 phandle_t node; 274 u_int64_t csr; | 271 char compat[32]; 272 char *model; 273 phandle_t node; 274 u_int64_t csr; |
275 u_long pci_ctl; | 275 u_long pci_ctl, mlen; |
276 int psycho_br[2]; | 276 int psycho_br[2]; |
277 int n, i, nreg; | 277 int n, i, nreg, rid; |
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; | 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) { | 290 sc->sc_dmatag = nexus_get_dmatag(dev); 291 292 /* 293 * call the model-specific initialisation routine. 294 */ 295 model = nexus_get_model(dev); 296 if ((model != NULL && 297 strcmp(model, OFW_SABRE_MODEL) == 0) || --- 15 unchanged lines hidden (view full) --- 313 * (2) the shared psycho configuration registers (struct psychoreg) 314 * 315 * XXX use the prom address for the psycho registers? we do so far. 316 */ 317 reg = nexus_get_reg(dev); 318 nreg = nexus_get_nreg(dev); 319 /* Register layouts are different. stuupid. */ 320 if (sc->sc_mode == PSYCHO_MODE_PSYCHO) { |
322 sc->sc_basepaddr = (vm_offset_t)reg[2].or_paddr; 323 324 if (nreg <= 2) { | 321 if (nreg <= 2) |
325 panic("psycho_attach: %d not enough registers", nreg); | 322 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; | 323 sc->sc_basepaddr = (vm_offset_t)UPA_REG_PHYS(®[2]); 324 mlen = UPA_REG_SIZE(®[2]); 325 pci_ctl = UPA_REG_PHYS(®[0]); |
331 } else { | 326 } else { |
332 sc->sc_basepaddr = (vm_offset_t)reg[0].or_paddr; 333 334 if (nreg <= 0) { | 327 if (nreg <= 0) |
335 panic("psycho_attach: %d not enough registers", nreg); | 328 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 + | 329 sc->sc_basepaddr = (vm_offset_t)UPA_REG_PHYS(®[0]); 330 mlen = UPA_REG_SIZE(reg); 331 pci_ctl = sc->sc_basepaddr + |
341 offsetof(struct psychoreg, psy_pcictl[0]); 342 } 343 | 332 offsetof(struct psychoreg, psy_pcictl[0]); 333 } 334 |
335 if (pci_ctl < sc->sc_basepaddr) 336 panic("psycho_attach: bogus pci control register location"); 337 pci_ctl -= sc->sc_basepaddr; 338 rid = 0; 339 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 340 sc->sc_basepaddr, sc->sc_basepaddr + mlen - 1, mlen, RF_ACTIVE); 341 if (sc->sc_mem_res == NULL || 342 rman_get_start(sc->sc_mem_res) != sc->sc_basepaddr) 343 panic("psycho_attach: could not allocate device memory"); 344 sc->sc_bustag = rman_get_bustag(sc->sc_mem_res); 345 sc->sc_bushandle = rman_get_bushandle(sc->sc_mem_res); 346 if (sparc64_bus_mem_map(UPA_BUS_SPACE, sc->sc_basepaddr, mlen, 0, NULL, 347 (void **)&sc->sc_regs)) 348 panic("psycho_attach: cannot map regs"); |
|
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 */ | 349 csr = sc->sc_regs->psy_csr; 350 sc->sc_ign = 0x7c0; /* APB IGN is always 0x7c */ 351 if (sc->sc_mode == PSYCHO_MODE_PSYCHO) 352 sc->sc_ign = PSYCHO_GCSR_IGN(csr) << 6; 353 354 device_printf(dev, "%s: impl %d, version %d: ign %x ", 355 model, PSYCHO_GCSR_IMPL(csr), PSYCHO_GCSR_VERS(csr), 356 sc->sc_ign); --- 18 unchanged lines hidden (view full) --- 375 /* Found partner */ 376 osc = asc; 377 break; 378 } 379 380 /* 381 * Setup the PCI control register 382 */ |
378 csr = bus_space_read_8(sc->sc_bustag, 379 (bus_space_handle_t)pci_ctl, offsetof(struct pci_ctl, pci_csr)); | 383 csr = bus_space_read_8(sc->sc_bustag, sc->sc_bushandle, 384 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); | 385 csr |= PCICTL_MRLM | 386 PCICTL_ARB_PARK | 387 PCICTL_ERRINTEN | 388 PCICTL_4ENABLE; 389 csr &= ~(PCICTL_SERR | 390 PCICTL_CPU_PRIO | 391 PCICTL_ARB_PRIO | 392 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); | 393 bus_space_write_8(sc->sc_bustag, sc->sc_bushandle, 394 pci_ctl + offsetof(struct pci_ctl, pci_csr), 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 | 395 396 /* grab the psycho ranges */ 397 psycho_get_ranges(sc->sc_node, &sc->sc_range, &sc->sc_nrange); 398 399 /* get the bus-range for the psycho */ 400 n = OF_getprop(node, "bus-range", (void *)psycho_br, sizeof(psycho_br)); 401 if (n == -1) 402 panic("could not get psycho bus-range"); --- 186 unchanged lines hidden (view full) --- 589} 590 591static void 592psycho_set_intr(struct psycho_softc *sc, int index, 593 device_t dev, u_long *map, int iflags, driver_intr_t handler) 594{ 595 int rid; 596 |
593 sc->sc_irq[index] = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, | 597 sc->sc_irq_res[index] = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, |
594 INTVEC(*map), INTVEC(*map), 1, RF_ACTIVE); | 598 INTVEC(*map), INTVEC(*map), 1, RF_ACTIVE); |
595 if (sc->sc_irq[index] == NULL) | 599 if (sc->sc_irq_res[index] == NULL) |
596 panic("psycho_set_intr: failed to get interupt"); | 600 panic("psycho_set_intr: failed to get interupt"); |
597 bus_setup_intr(dev, sc->sc_irq[index], INTR_TYPE_MISC | iflags, | 601 bus_setup_intr(dev, sc->sc_irq_res[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 --- | 602 handler, sc, &sc->sc_ihand[index]); 603 *map |= INTMAP_V; 604} 605 606static int 607psycho_find_intrmap(struct psycho_softc *sc, int ino, u_long **intrmapptr, 608 u_long **intrclrptr, u_long *intrdiagptr) 609{ --- 651 unchanged lines hidden --- |