From 1d6b36aa0dd019dcef375fb6a67c10243c8957d0 Mon Sep 17 00:00:00 2001 From: mrg Date: Wed, 10 Dec 2008 03:31:51 +0000 Subject: [PATCH] ofpci_make_tag(): don't write PCI_COMMAND_STATUS_REG with PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in. sparc_pci_childspace(): move psycho.c:get_childspace() into pci_machdep.c but rename it psycho_alloc_bus_tag(): use M_ZERO --- sys/arch/sparc64/dev/pci_machdep.c | 46 +++++++++++++++++++++++--- sys/arch/sparc64/dev/psycho.c | 44 ++++-------------------- sys/arch/sparc64/include/pci_machdep.h | 5 ++- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/sys/arch/sparc64/dev/pci_machdep.c b/sys/arch/sparc64/dev/pci_machdep.c index b1e094cb5d2c..4e465f5c7033 100644 --- a/sys/arch/sparc64/dev/pci_machdep.c +++ b/sys/arch/sparc64/dev/pci_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.60 2008/12/07 21:03:57 mrg Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.61 2008/12/10 03:31:51 mrg Exp $ */ /* * Copyright (c) 1999, 2000 Matthew R. Green @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.60 2008/12/07 21:03:57 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.61 2008/12/10 03:31:51 mrg Exp $"); #include #include @@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.60 2008/12/07 21:03:57 mrg Exp $") #define SPDB_INTR 0x04 #define SPDB_INTMAP 0x08 #define SPDB_PROBE 0x20 +#define SPDB_TAG 0x40 int sparc_pci_debug = 0x0; #define DPRINTF(l, s) do { if (sparc_pci_debug & l) printf s; } while (0) #else @@ -78,13 +79,20 @@ static pcitag_t ofpci_make_tag(pci_chipset_tag_t pc, int node, int b, int d, int f) { pcitag_t tag; + pcireg_t reg; tag = PCITAG_CREATE(node, b, d, f); + DPRINTF(SPDB_TAG, + ("%s: creating tag for node %d bus %d dev %d fn %d\n", + __func__, node, b, d, f)); + /* Enable all the different spaces for this device */ - pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, - PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE| - PCI_COMMAND_IO_ENABLE); + reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); + reg |= PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE| + PCI_COMMAND_IO_ENABLE; + pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, reg); + return (tag); } @@ -449,3 +457,31 @@ pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) /* XXX */ /* panic("can't disestablish PCI interrupts yet"); */ } + +int +sparc_pci_childspace(int type) +{ + int ss; + + switch (type) { + case PCI_CONFIG_BUS_SPACE: + ss = 0x00; + break; + case PCI_IO_BUS_SPACE: + ss = 0x01; + break; + case PCI_MEMORY_BUS_SPACE: + ss = 0x02; + break; +#if 0 + /* we don't do 64 bit memory space */ + case PCI_MEMORY64_BUS_SPACE: + ss = 0x03; + break; +#endif + default: + panic("get_childspace: unknown bus type"); + } + + return (ss); +} diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index 1c826b9b2534..320fcdf94a03 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $NetBSD: psycho.c,v 1.93 2008/12/09 13:14:38 nakayama Exp $ */ +/* $NetBSD: psycho.c,v 1.94 2008/12/10 03:31:51 mrg Exp $ */ /* * Copyright (c) 1999, 2000 Matthew R. Green @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.93 2008/12/09 13:14:38 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.94 2008/12/10 03:31:51 mrg Exp $"); #include "opt_ddb.h" @@ -138,7 +138,6 @@ static void psycho_iommu_init(struct psycho_softc *, int); * bus space and bus DMA support for UltraSPARC `psycho'. note that most * of the bus DMA support is provided by the iommu dvma controller. */ -static int get_childspace(int); static struct psycho_ranges *get_psychorange(struct psycho_pbm *, int); static paddr_t psycho_bus_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int); @@ -1039,12 +1038,11 @@ psycho_alloc_bus_tag(struct psycho_pbm *pp, int type) struct psycho_softc *sc = pp->pp_sc; bus_space_tag_t bt; - bt = (bus_space_tag_t) - malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT); + bt = (bus_space_tag_t) malloc(sizeof(struct sparc_bus_space_tag), + M_DEVBUF, M_NOWAIT | M_ZERO); if (bt == NULL) panic("could not allocate psycho bus tag"); - memset(bt, 0, sizeof *bt); bt->cookie = pp; bt->parent = sc->sc_bustag; bt->type = type; @@ -1094,34 +1092,6 @@ psycho_alloc_dma_tag(struct psycho_pbm *pp) * PCI physical addresses. */ -static int -get_childspace(int type) -{ - int ss; - - switch (type) { - case PCI_CONFIG_BUS_SPACE: - ss = 0x00; - break; - case PCI_IO_BUS_SPACE: - ss = 0x01; - break; - case PCI_MEMORY_BUS_SPACE: - ss = 0x02; - break; -#if 0 - /* we don't do 64 bit memory space */ - case PCI_MEMORY64_BUS_SPACE: - ss = 0x03; - break; -#endif - default: - panic("get_childspace: unknown bus type"); - } - - return (ss); -} - static struct psycho_ranges * get_psychorange(struct psycho_pbm *pp, int ss) { @@ -1150,7 +1120,7 @@ _psycho_bus_map(bus_space_tag_t t, bus_addr_t offset, bus_size_t size, t->type, (unsigned long long)offset, (unsigned long long)size, flags)); - ss = get_childspace(t->type); + ss = sparc_pci_childspace(t->type); DPRINTF(PDB_BUSMAP, (" cspace %d", ss)); pr = get_psychorange(pp, ss); @@ -1177,7 +1147,7 @@ psycho_bus_mmap(bus_space_tag_t t, bus_addr_t paddr, off_t off, int prot, struct psycho_ranges *pr; int ss; - ss = get_childspace(t->type); + ss = sparc_pci_childspace(t->type); DPRINTF(PDB_BUSMAP, ("_psycho_bus_mmap: prot %x flags %d pa %qx\n", prot, flags, (unsigned long long)paddr)); @@ -1209,7 +1179,7 @@ psycho_bus_offset(bus_space_tag_t t, bus_space_handle_t *hp) int ss; addr = hp->_ptr; - ss = get_childspace(t->type); + ss = sparc_pci_childspace(t->type); DPRINTF(PDB_BUSMAP, ("psycho_bus_offset: type %d addr %" PRIx64 " cspace %d", t->type, addr, ss)); diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h index ecfa381eb60d..d091c2ed7133 100644 --- a/sys/arch/sparc64/include/pci_machdep.h +++ b/sys/arch/sparc64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.h,v 1.21 2008/12/09 13:14:38 nakayama Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.22 2008/12/10 03:31:51 mrg Exp $ */ /* * Copyright (c) 1999 Matthew R. Green @@ -104,4 +104,7 @@ int sparc64_pci_enumerate_bus(struct pci_softc *, const int *, #define pci_intr_establish(pc, handle, level, func, arg) \ ((pc)->spc_intr_establish(pc, handle, level, func, arg)) +/* SPARC specific PCI interfaces */ +int sparc_pci_childspace(int); + #endif /* _MACHINE_PCI_MACHDEP_H_ */