From 55804a6f72e443838c48b1c71f9904d50f03e04f Mon Sep 17 00:00:00 2001 From: garbled Date: Mon, 11 Feb 2008 17:32:18 +0000 Subject: [PATCH] Use model_init to clean up how we decide the ranges for PCI_NETBSD_CONFIGURE. Add some code to hopefully better handle the firepower and powerstackII, based on the OFW dumps from those machines. Untested on those machines, but doesn't break anything on pegasos/7044. --- sys/arch/ofppc/include/autoconf.h | 14 ++++++++++- sys/arch/ofppc/ofppc/machdep.c | 35 +++++++++++++++++++++++--- sys/arch/ofppc/pci/ofwpci.c | 15 ++++++----- sys/arch/powerpc/oea/ofwoea_machdep.c | 31 +++++++++++++++++------ sys/arch/powerpc/pci/pci_machdep_ofw.c | 6 +++-- 5 files changed, 82 insertions(+), 19 deletions(-) diff --git a/sys/arch/ofppc/include/autoconf.h b/sys/arch/ofppc/include/autoconf.h index e6e17d5aca11..9d75c7614765 100644 --- a/sys/arch/ofppc/include/autoconf.h +++ b/sys/arch/ofppc/include/autoconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.11 2008/01/17 23:42:57 garbled Exp $ */ +/* $NetBSD: autoconf.h,v 1.12 2008/02/11 17:32:18 garbled Exp $ */ #ifndef _OFPPC_AUTOCONF_H_ #define _OFPPC_AUTOCONF_H_ @@ -17,6 +17,18 @@ struct confargs { bus_space_tag_t ca_tag; }; +struct pciio_info { + uint32_t start; + uint32_t limit; +}; + +/* to support machines with more than 4 busses, change the below */ +#define MAX_PCI_BUSSES 4 +struct model_data { + int ranges_offset; + struct pciio_info pciiodata[MAX_PCI_BUSSES]; +}; + extern int console_node; extern char model_name[64]; diff --git a/sys/arch/ofppc/ofppc/machdep.c b/sys/arch/ofppc/ofppc/machdep.c index 5338417fc471..81ad33af0c34 100644 --- a/sys/arch/ofppc/ofppc/machdep.c +++ b/sys/arch/ofppc/ofppc/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.104 2008/01/17 23:42:58 garbled Exp $ */ +/* $NetBSD: machdep.c,v 1.105 2008/02/11 17:32:18 garbled Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.104 2008/01/17 23:42:58 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.105 2008/02/11 17:32:18 garbled Exp $"); #include #include @@ -77,6 +77,8 @@ void ofppc_bootstrap_console(void); extern u_int l2cr_config; extern int machine_has_rtas; +struct model_data modeldata; + void initppc(u_int startkernel, u_int endkernel, char *args) { @@ -87,7 +89,30 @@ initppc(u_int startkernel, u_int endkernel, char *args) void model_init(void) { - int qhandle, phandle; + int qhandle, phandle, j; + + memset(&modeldata, 0, sizeof(struct model_data)); + /* provide sane defaults */ + for (j=0; j < MAX_PCI_BUSSES; j++) { + modeldata.pciiodata[j].start = 0x00008000; + modeldata.pciiodata[j].limit = 0x0000ffff; + } + modeldata.ranges_offset = 1; + + if (strncmp(model_name, "FirePower,", 10) == 0) { + modeldata.ranges_offset = 0; + } + if (strcmp(model_name, "MOT,PowerStack_II_Pro4000") == 0) { + modeldata.ranges_offset = 0; + } + + /* 7044-270 and 7044-170 */ + if (strncmp(model_name, "IBM,7044", 8) == 0) { + for (j=0; j < MAX_PCI_BUSSES; j++) { + modeldata.pciiodata[j].start = 0x00fff000; + modeldata.pciiodata[j].limit = 0x00ffffff; + } + } /* Pegasos1, Pegasos2 */ if (strncmp(model_name, "Pegasos", 7) == 0) { @@ -97,6 +122,10 @@ model_init(void) char buf[32]; int i; + modeldata.ranges_offset = 1; + modeldata.pciiodata[0].start = 0x00001400; + modeldata.pciiodata[0].limit = 0x0000ffff; + /* the pegasos doesn't bother to set the L2 cache up*/ l2cr_config = L2CR_L2PE; diff --git a/sys/arch/ofppc/pci/ofwpci.c b/sys/arch/ofppc/pci/ofwpci.c index 8fe81458d1b5..b69b60dcf8e0 100644 --- a/sys/arch/ofppc/pci/ofwpci.c +++ b/sys/arch/ofppc/pci/ofwpci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofwpci.c,v 1.5 2008/01/17 23:42:58 garbled Exp $ */ +/* $NetBSD: ofwpci.c,v 1.6 2008/02/11 17:32:18 garbled Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ofwpci.c,v 1.5 2008/01/17 23:42:58 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofwpci.c,v 1.6 2008/02/11 17:32:18 garbled Exp $"); #include "opt_pci.h" @@ -70,6 +70,7 @@ CFATTACH_DECL(ofwpci, sizeof(struct ofwpci_softc), ofwpci_match, ofwpci_attach, NULL, NULL); extern struct genppc_pci_chipset *genppc_pct; +extern struct model_data modeldata; static void ofwpci_get_chipset_tag(pci_chipset_tag_t pc) @@ -204,10 +205,12 @@ ofwpci_attach(struct device *parent, struct device *self, void *aux) genofw_setup_pciintr_map((void *)pc, pbi, pc->pc_node); #ifdef PCI_NETBSD_CONFIGURE - ioext = extent_create("pciio", 0x00fff000, 0x00ffffff, M_DEVBUF, - NULL, 0, EX_NOWAIT); - memext = extent_create("pcimem", sc->sc_memt.pbs_base, sc->sc_memt.pbs_limit, M_DEVBUF, - NULL, 0, EX_NOWAIT); + ioext = extent_create("pciio", + modeldata.pciiodata[device_unit(self)].start, + modeldata.pciiodata[device_unit(self)].limit, + M_DEVBUF, NULL, 0, EX_NOWAIT); + memext = extent_create("pcimem", sc->sc_memt.pbs_base, + sc->sc_memt.pbs_limit-1, M_DEVBUF, NULL, 0, EX_NOWAIT); if (pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINESIZE)) aprint_error("pci_configure_bus() failed\n"); diff --git a/sys/arch/powerpc/oea/ofwoea_machdep.c b/sys/arch/powerpc/oea/ofwoea_machdep.c index d55f3df0a41a..b1522828e769 100644 --- a/sys/arch/powerpc/oea/ofwoea_machdep.c +++ b/sys/arch/powerpc/oea/ofwoea_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofwoea_machdep.c,v 1.10 2008/02/05 18:10:47 garbled Exp $ */ +/* $NetBSD: ofwoea_machdep.c,v 1.11 2008/02/11 17:32:18 garbled Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.10 2008/02/05 18:10:47 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.11 2008/02/11 17:32:18 garbled Exp $"); #include "opt_ppcarch.h" #include "opt_compat_netbsd.h" @@ -86,6 +86,10 @@ __KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.10 2008/02/05 18:10:47 garbled #include "opt_ofwoea.h" +#ifdef ofppc +extern struct model_data modeldata; +#endif + #ifdef OFWOEA_DEBUG #define DPRINTF printf #else @@ -136,7 +140,7 @@ static void set_timebase(void); void ofwoea_initppc(u_int startkernel, u_int endkernel, char *args) { - int ofmaplen, node; + int ofmaplen, node, l; register_t scratch; /* initialze bats */ @@ -156,7 +160,10 @@ ofwoea_initppc(u_int startkernel, u_int endkernel, char *args) memset(model_name, 0, sizeof(model_name)); node = OF_finddevice("/"); if (node >= 0) { - OF_getprop(node, "model", model_name, sizeof(model_name)); + l = OF_getprop(node, "model", model_name, sizeof(model_name)); + if (l == -1) + OF_getprop(node, "name", model_name, + sizeof(model_name)); model_init(); } @@ -432,6 +439,10 @@ find_ranges(int base, rangemap_t *regions, int *cur, int type) if (OF_getprop(node, "#size-cells", &scells, sizeof(scells)) != sizeof(scells)) scells = 1; +#ifdef ofppc + if (modeldata.ranges_offset == 0) + scells -= 1; +#endif if (type == RANGE_TYPE_ISA) reclen = 6; else @@ -600,6 +611,7 @@ ofwoea_map_space(int rangetype, int iomem, int node, } if (region.addr + region.size < list[range].addr) { /* allocate a hole */ + holes[nrofholes].type = iomem; holes[nrofholes].addr = region.size + region.addr; holes[nrofholes].size = list[range].addr - holes[nrofholes].addr - 1; @@ -643,9 +655,14 @@ ofwoea_map_space(int rangetype, int iomem, int node, if (error) panic("ofwoea_bus_space_init: can't init tag %s", name); for (i=0; i < nrofholes; i++) { - error = - extent_alloc_region(tag->pbs_extent, - holes[i].addr, holes[i].size, EX_NOWAIT); + if (holes[i].type == RANGE_IO) { + error = extent_alloc_region(tag->pbs_extent, + holes[i].addr - tag->pbs_offset, + holes[i].size, EX_NOWAIT); + } else { + error = extent_alloc_region(tag->pbs_extent, + holes[i].addr, holes[i].size, EX_NOWAIT); + } if (error) panic("ofwoea_bus_space_init: can't block out" " reserved space 0x%x-0x%x: error=%d", diff --git a/sys/arch/powerpc/pci/pci_machdep_ofw.c b/sys/arch/powerpc/pci/pci_machdep_ofw.c index 61e238dec53d..c05dfd25bc1e 100644 --- a/sys/arch/powerpc/pci/pci_machdep_ofw.c +++ b/sys/arch/powerpc/pci/pci_machdep_ofw.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep_ofw.c,v 1.9 2008/01/28 18:24:22 garbled Exp $ */ +/* $NetBSD: pci_machdep_ofw.c,v 1.10 2008/02/11 17:32:18 garbled Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_machdep_ofw.c,v 1.9 2008/01/28 18:24:22 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep_ofw.c,v 1.10 2008/02/11 17:32:18 garbled Exp $"); #include #include @@ -149,6 +149,8 @@ foundic: OF_getprop(node, "compatible", name, sizeof(name)); if (strcmp(name, "heathrow") == 0) picnodes[nrofpics].type = PICNODE_TYPE_HEATHROW; + if (strcmp(name, "pnpPNP,0") == 0) + picnodes[nrofpics].type = PICNODE_TYPE_8259; if (strcmp(name, "chrp,iic") == 0) { picnodes[nrofpics].type = PICNODE_TYPE_8259; if (irgot >= 9 * sizeof(uint32_t) &&