psycho.c (220039) | psycho.c (220147) |
---|---|
1/*- 2 * Copyright (c) 1999, 2000 Matthew R. Green 3 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org> 4 * Copyright (c) 2005 - 2006 Marius Strobl <marius@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999, 2000 Matthew R. Green 3 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org> 4 * Copyright (c) 2005 - 2006 Marius Strobl <marius@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/sparc64/pci/psycho.c 220039 2011-03-26 16:52:31Z marius $"); | 34__FBSDID("$FreeBSD: head/sys/sparc64/pci/psycho.c 220147 2011-03-29 19:48:03Z marius $"); |
35 36/* 37 * Support for `Hummingbird' (UltraSPARC IIe), `Psycho' and `Psycho+' 38 * (UltraSPARC II) and `Sabre' (UltraSPARC IIi) UPA to PCI bridges. 39 */ 40 41#include "opt_ofw_pci.h" 42#include "opt_psycho.h" --- 481 unchanged lines hidden (view full) --- 524 * or Sabre. 525 * 526 * We should calculate a TSB size based on amount of RAM 527 * and number of bus controllers and number and type of 528 * child devices. 529 * 530 * For the moment, 32KB should be more than enough. 531 */ | 35 36/* 37 * Support for `Hummingbird' (UltraSPARC IIe), `Psycho' and `Psycho+' 38 * (UltraSPARC II) and `Sabre' (UltraSPARC IIi) UPA to PCI bridges. 39 */ 40 41#include "opt_ofw_pci.h" 42#include "opt_psycho.h" --- 481 unchanged lines hidden (view full) --- 524 * or Sabre. 525 * 526 * We should calculate a TSB size based on amount of RAM 527 * and number of bus controllers and number and type of 528 * child devices. 529 * 530 * For the moment, 32KB should be more than enough. 531 */ |
532 memcpy(&sc->sc_dma_methods, &iommu_dma_methods, 533 sizeof(sc->sc_dma_methods)); 534 sc->sc_is = malloc(sizeof(struct iommu_state), M_DEVBUF, 535 M_NOWAIT | M_ZERO); | 532 sc->sc_is = malloc(sizeof(*sc->sc_is), M_DEVBUF, M_NOWAIT | 533 M_ZERO); |
536 if (sc->sc_is == NULL) | 534 if (sc->sc_is == NULL) |
537 panic("%s: malloc iommu_state failed", __func__); | 535 panic("%s: could not malloc IOMMU state", __func__); |
538 sc->sc_is->is_flags = IOMMU_PRESERVE_PROM; 539 if (sc->sc_mode == PSYCHO_MODE_SABRE) { | 536 sc->sc_is->is_flags = IOMMU_PRESERVE_PROM; 537 if (sc->sc_mode == PSYCHO_MODE_SABRE) { |
540 sc->sc_dma_methods.dm_dmamap_sync = | 538 sc->sc_dma_methods = 539 malloc(sizeof(*sc->sc_dma_methods), M_DEVBUF, 540 M_NOWAIT); 541 if (sc->sc_dma_methods == NULL) 542 panic("%s: could not malloc DMA methods", 543 __func__); 544 memcpy(sc->sc_dma_methods, &iommu_dma_methods, 545 sizeof(*sc->sc_dma_methods)); 546 sc->sc_dma_methods->dm_dmamap_sync = |
541 sabre_dmamap_sync; 542 sc->sc_is->is_pmaxaddr = 543 IOMMU_MAXADDR(SABRE_IOMMU_BITS); | 547 sabre_dmamap_sync; 548 sc->sc_is->is_pmaxaddr = 549 IOMMU_MAXADDR(SABRE_IOMMU_BITS); |
544 } else | 550 } else { 551 sc->sc_dma_methods = &iommu_dma_methods; |
545 sc->sc_is->is_pmaxaddr = 546 IOMMU_MAXADDR(PSYCHO_IOMMU_BITS); | 552 sc->sc_is->is_pmaxaddr = 553 IOMMU_MAXADDR(PSYCHO_IOMMU_BITS); |
554 } |
|
547 sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = 0; 548 if (OF_getproplen(node, "no-streaming-cache") < 0) 549 sc->sc_is->is_sb[0] = sc->sc_pcictl + PCR_STRBUF; 550 sc->sc_is->is_flags |= (rerun != 1) ? IOMMU_RERUN_DISABLE : 0; 551 psycho_iommu_init(sc, 3, dvmabase); 552 } else { 553 /* Just copy IOMMU state, config tag and address. */ | 555 sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = 0; 556 if (OF_getproplen(node, "no-streaming-cache") < 0) 557 sc->sc_is->is_sb[0] = sc->sc_pcictl + PCR_STRBUF; 558 sc->sc_is->is_flags |= (rerun != 1) ? IOMMU_RERUN_DISABLE : 0; 559 psycho_iommu_init(sc, 3, dvmabase); 560 } else { 561 /* Just copy IOMMU state, config tag and address. */ |
562 sc->sc_dma_methods = &iommu_dma_methods; |
|
554 sc->sc_is = osc->sc_is; 555 if (OF_getproplen(node, "no-streaming-cache") < 0) 556 sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF; 557 iommu_reset(sc->sc_is); 558 } 559 560 /* Allocate our tags. */ 561 sc->sc_pci_memt = psycho_alloc_bus_tag(sc, PCI_MEMORY_BUS_SPACE); 562 sc->sc_pci_iot = psycho_alloc_bus_tag(sc, PCI_IO_BUS_SPACE); 563 sc->sc_pci_cfgt = psycho_alloc_bus_tag(sc, PCI_CONFIG_BUS_SPACE); 564 if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, 565 sc->sc_is->is_pmaxaddr, ~0, NULL, NULL, sc->sc_is->is_pmaxaddr, 566 0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0) 567 panic("%s: bus_dma_tag_create failed", __func__); 568 /* Customize the tag. */ 569 sc->sc_pci_dmat->dt_cookie = sc->sc_is; | 563 sc->sc_is = osc->sc_is; 564 if (OF_getproplen(node, "no-streaming-cache") < 0) 565 sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF; 566 iommu_reset(sc->sc_is); 567 } 568 569 /* Allocate our tags. */ 570 sc->sc_pci_memt = psycho_alloc_bus_tag(sc, PCI_MEMORY_BUS_SPACE); 571 sc->sc_pci_iot = psycho_alloc_bus_tag(sc, PCI_IO_BUS_SPACE); 572 sc->sc_pci_cfgt = psycho_alloc_bus_tag(sc, PCI_CONFIG_BUS_SPACE); 573 if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, 574 sc->sc_is->is_pmaxaddr, ~0, NULL, NULL, sc->sc_is->is_pmaxaddr, 575 0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0) 576 panic("%s: bus_dma_tag_create failed", __func__); 577 /* Customize the tag. */ 578 sc->sc_pci_dmat->dt_cookie = sc->sc_is; |
570 sc->sc_pci_dmat->dt_mt = &sc->sc_dma_methods; | 579 sc->sc_pci_dmat->dt_mt = sc->sc_dma_methods; |
571 572 i = OF_getprop(node, "bus-range", (void *)prop_array, 573 sizeof(prop_array)); 574 if (i == -1) 575 panic("%s: could not get bus-range", __func__); 576 if (i != sizeof(prop_array)) 577 panic("%s: broken bus-range (%d)", __func__, i); 578 sc->sc_pci_secbus = prop_array[0]; --- 743 unchanged lines hidden --- | 580 581 i = OF_getprop(node, "bus-range", (void *)prop_array, 582 sizeof(prop_array)); 583 if (i == -1) 584 panic("%s: could not get bus-range", __func__); 585 if (i != sizeof(prop_array)) 586 panic("%s: broken bus-range (%d)", __func__, i); 587 sc->sc_pci_secbus = prop_array[0]; --- 743 unchanged lines hidden --- |