1/* 2 * Copyright (c) 1999, 2000 Matthew R. Green 3 * Copyright (c) 2001, 2003 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: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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, 2003 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: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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/isa/ofw_isa.c 128712 2004-04-28 13:06:46Z tmm $
| 31 * $FreeBSD: head/sys/sparc64/isa/ofw_isa.c 129051 2004-05-08 13:53:47Z marius $
|
32 */ 33 34/* 35 * Helper functions which can be used in both ISA and EBus code. 36 */ 37
| 32 */ 33 34/* 35 * Helper functions which can be used in both ISA and EBus code. 36 */ 37
|
38#include "opt_ofw_pci.h" 39
| |
40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/bus.h> 43 44#include <dev/ofw/openfirm.h>
| 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/bus.h> 41 42#include <dev/ofw/openfirm.h>
|
45#include <dev/ofw/ofw_pci.h>
| |
46 47#include <machine/bus.h> 48#include <machine/resource.h> 49#include <machine/ofw_bus.h> 50 51#include <sparc64/pci/ofw_pci.h> 52#include <sparc64/isa/ofw_isa.h> 53 54#include "pcib_if.h" 55 56int 57ofw_isa_range_restype(struct isa_ranges *range) 58{ 59 int ps = ISA_RANGE_PS(range); 60 61 switch (ps) { 62 case PCI_CS_IO: 63 return (SYS_RES_IOPORT); 64 case PCI_CS_MEM32: 65 return (SYS_RES_MEMORY); 66 default: 67 panic("ofw_isa_range_restype: illegal space %x", ps); 68 } 69 70} 71 72/* XXX: this only supports PCI as parent bus right now. */ 73int 74ofw_isa_range_map(struct isa_ranges *range, int nrange, u_long *start, 75 u_long *end, int *which) 76{ 77 struct isa_ranges *r; 78 u_int64_t offs, cstart, cend; 79 int i; 80 81 for (i = 0; i < nrange; i++) { 82 r = &range[i]; 83 cstart = ISA_RANGE_CHILD(r); 84 cend = cstart + r->size; 85 if (*start < cstart || *start > cend) 86 continue; 87 if (*end < cstart || *end > cend) { 88 panic("ofw_isa_map_iorange: iorange crosses pci " 89 "ranges (%#lx not in %#lx - %#lx)", *end, cstart, 90 cend); 91 } 92 offs = ISA_RANGE_PHYS(r); 93 *start = *start + offs - cstart; 94 *end = *end + offs - cstart; 95 if (which != NULL) 96 *which = i; 97 return (ofw_isa_range_restype(r)); 98 } 99 panic("ofw_isa_map_iorange: could not map range %#lx - %#lx", 100 *start, *end); 101} 102
| 43 44#include <machine/bus.h> 45#include <machine/resource.h> 46#include <machine/ofw_bus.h> 47 48#include <sparc64/pci/ofw_pci.h> 49#include <sparc64/isa/ofw_isa.h> 50 51#include "pcib_if.h" 52 53int 54ofw_isa_range_restype(struct isa_ranges *range) 55{ 56 int ps = ISA_RANGE_PS(range); 57 58 switch (ps) { 59 case PCI_CS_IO: 60 return (SYS_RES_IOPORT); 61 case PCI_CS_MEM32: 62 return (SYS_RES_MEMORY); 63 default: 64 panic("ofw_isa_range_restype: illegal space %x", ps); 65 } 66 67} 68 69/* XXX: this only supports PCI as parent bus right now. */ 70int 71ofw_isa_range_map(struct isa_ranges *range, int nrange, u_long *start, 72 u_long *end, int *which) 73{ 74 struct isa_ranges *r; 75 u_int64_t offs, cstart, cend; 76 int i; 77 78 for (i = 0; i < nrange; i++) { 79 r = &range[i]; 80 cstart = ISA_RANGE_CHILD(r); 81 cend = cstart + r->size; 82 if (*start < cstart || *start > cend) 83 continue; 84 if (*end < cstart || *end > cend) { 85 panic("ofw_isa_map_iorange: iorange crosses pci " 86 "ranges (%#lx not in %#lx - %#lx)", *end, cstart, 87 cend); 88 } 89 offs = ISA_RANGE_PHYS(r); 90 *start = *start + offs - cstart; 91 *end = *end + offs - cstart; 92 if (which != NULL) 93 *which = i; 94 return (ofw_isa_range_restype(r)); 95 } 96 panic("ofw_isa_map_iorange: could not map range %#lx - %#lx", 97 *start, *end); 98} 99
|
103#ifdef OFW_NEWPCI
| |
104ofw_pci_intr_t 105ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii, 106 ofw_isa_intr_t intr) 107{ 108 struct isa_regs reg; 109 u_int8_t maskbuf[sizeof(reg) + sizeof(intr)]; 110 device_t pbridge; 111 ofw_isa_intr_t mintr; 112 113 pbridge = device_get_parent(device_get_parent(bridge)); 114 /* 115 * If we get a match from using the map, the resulting INO is 116 * fully specified, so we may not continue to map. 117 */ 118 if (!ofw_bus_lookup_imap(node, ii, ®, sizeof(reg), 119 &intr, sizeof(intr), &mintr, sizeof(mintr), maskbuf)) { 120 /* Try routing at the parent bridge. */ 121 mintr = PCIB_ROUTE_INTERRUPT(pbridge, bridge, intr); 122 } 123 return (mintr); 124}
| 100ofw_pci_intr_t 101ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii, 102 ofw_isa_intr_t intr) 103{ 104 struct isa_regs reg; 105 u_int8_t maskbuf[sizeof(reg) + sizeof(intr)]; 106 device_t pbridge; 107 ofw_isa_intr_t mintr; 108 109 pbridge = device_get_parent(device_get_parent(bridge)); 110 /* 111 * If we get a match from using the map, the resulting INO is 112 * fully specified, so we may not continue to map. 113 */ 114 if (!ofw_bus_lookup_imap(node, ii, ®, sizeof(reg), 115 &intr, sizeof(intr), &mintr, sizeof(mintr), maskbuf)) { 116 /* Try routing at the parent bridge. */ 117 mintr = PCIB_ROUTE_INTERRUPT(pbridge, bridge, intr); 118 } 119 return (mintr); 120}
|
125#endif /* OFW_NEWPCI */
| |
| |