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.
This commit is contained in:
garbled 2008-02-11 17:32:18 +00:00
parent 0294141b16
commit 55804a6f72
5 changed files with 82 additions and 19 deletions

View File

@ -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_ #ifndef _OFPPC_AUTOCONF_H_
#define _OFPPC_AUTOCONF_H_ #define _OFPPC_AUTOCONF_H_
@ -17,6 +17,18 @@ struct confargs {
bus_space_tag_t ca_tag; 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 int console_node;
extern char model_name[64]; extern char model_name[64];

View File

@ -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. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -36,7 +36,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/param.h> #include <sys/param.h>
#include <sys/buf.h> #include <sys/buf.h>
@ -77,6 +77,8 @@ void ofppc_bootstrap_console(void);
extern u_int l2cr_config; extern u_int l2cr_config;
extern int machine_has_rtas; extern int machine_has_rtas;
struct model_data modeldata;
void void
initppc(u_int startkernel, u_int endkernel, char *args) initppc(u_int startkernel, u_int endkernel, char *args)
{ {
@ -87,7 +89,30 @@ initppc(u_int startkernel, u_int endkernel, char *args)
void void
model_init(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 */ /* Pegasos1, Pegasos2 */
if (strncmp(model_name, "Pegasos", 7) == 0) { if (strncmp(model_name, "Pegasos", 7) == 0) {
@ -97,6 +122,10 @@ model_init(void)
char buf[32]; char buf[32];
int i; 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*/ /* the pegasos doesn't bother to set the L2 cache up*/
l2cr_config = L2CR_L2PE; l2cr_config = L2CR_L2PE;

View File

@ -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. * Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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" #include "opt_pci.h"
@ -70,6 +70,7 @@ CFATTACH_DECL(ofwpci, sizeof(struct ofwpci_softc),
ofwpci_match, ofwpci_attach, NULL, NULL); ofwpci_match, ofwpci_attach, NULL, NULL);
extern struct genppc_pci_chipset *genppc_pct; extern struct genppc_pci_chipset *genppc_pct;
extern struct model_data modeldata;
static void static void
ofwpci_get_chipset_tag(pci_chipset_tag_t pc) 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); genofw_setup_pciintr_map((void *)pc, pbi, pc->pc_node);
#ifdef PCI_NETBSD_CONFIGURE #ifdef PCI_NETBSD_CONFIGURE
ioext = extent_create("pciio", 0x00fff000, 0x00ffffff, M_DEVBUF, ioext = extent_create("pciio",
NULL, 0, EX_NOWAIT); modeldata.pciiodata[device_unit(self)].start,
memext = extent_create("pcimem", sc->sc_memt.pbs_base, sc->sc_memt.pbs_limit, M_DEVBUF, modeldata.pciiodata[device_unit(self)].limit,
NULL, 0, EX_NOWAIT); 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)) if (pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINESIZE))
aprint_error("pci_configure_bus() failed\n"); aprint_error("pci_configure_bus() failed\n");

View File

@ -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. * Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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_ppcarch.h"
#include "opt_compat_netbsd.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" #include "opt_ofwoea.h"
#ifdef ofppc
extern struct model_data modeldata;
#endif
#ifdef OFWOEA_DEBUG #ifdef OFWOEA_DEBUG
#define DPRINTF printf #define DPRINTF printf
#else #else
@ -136,7 +140,7 @@ static void set_timebase(void);
void void
ofwoea_initppc(u_int startkernel, u_int endkernel, char *args) ofwoea_initppc(u_int startkernel, u_int endkernel, char *args)
{ {
int ofmaplen, node; int ofmaplen, node, l;
register_t scratch; register_t scratch;
/* initialze bats */ /* initialze bats */
@ -156,7 +160,10 @@ ofwoea_initppc(u_int startkernel, u_int endkernel, char *args)
memset(model_name, 0, sizeof(model_name)); memset(model_name, 0, sizeof(model_name));
node = OF_finddevice("/"); node = OF_finddevice("/");
if (node >= 0) { 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(); model_init();
} }
@ -432,6 +439,10 @@ find_ranges(int base, rangemap_t *regions, int *cur, int type)
if (OF_getprop(node, "#size-cells", &scells, if (OF_getprop(node, "#size-cells", &scells,
sizeof(scells)) != sizeof(scells)) sizeof(scells)) != sizeof(scells))
scells = 1; scells = 1;
#ifdef ofppc
if (modeldata.ranges_offset == 0)
scells -= 1;
#endif
if (type == RANGE_TYPE_ISA) if (type == RANGE_TYPE_ISA)
reclen = 6; reclen = 6;
else else
@ -600,6 +611,7 @@ ofwoea_map_space(int rangetype, int iomem, int node,
} }
if (region.addr + region.size < list[range].addr) { if (region.addr + region.size < list[range].addr) {
/* allocate a hole */ /* allocate a hole */
holes[nrofholes].type = iomem;
holes[nrofholes].addr = region.size + region.addr; holes[nrofholes].addr = region.size + region.addr;
holes[nrofholes].size = list[range].addr - holes[nrofholes].size = list[range].addr -
holes[nrofholes].addr - 1; holes[nrofholes].addr - 1;
@ -643,9 +655,14 @@ ofwoea_map_space(int rangetype, int iomem, int node,
if (error) if (error)
panic("ofwoea_bus_space_init: can't init tag %s", name); panic("ofwoea_bus_space_init: can't init tag %s", name);
for (i=0; i < nrofholes; i++) { for (i=0; i < nrofholes; i++) {
error = if (holes[i].type == RANGE_IO) {
extent_alloc_region(tag->pbs_extent, 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); holes[i].addr, holes[i].size, EX_NOWAIT);
}
if (error) if (error)
panic("ofwoea_bus_space_init: can't block out" panic("ofwoea_bus_space_init: can't block out"
" reserved space 0x%x-0x%x: error=%d", " reserved space 0x%x-0x%x: error=%d",

View File

@ -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. * Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -149,6 +149,8 @@ foundic:
OF_getprop(node, "compatible", name, sizeof(name)); OF_getprop(node, "compatible", name, sizeof(name));
if (strcmp(name, "heathrow") == 0) if (strcmp(name, "heathrow") == 0)
picnodes[nrofpics].type = PICNODE_TYPE_HEATHROW; picnodes[nrofpics].type = PICNODE_TYPE_HEATHROW;
if (strcmp(name, "pnpPNP,0") == 0)
picnodes[nrofpics].type = PICNODE_TYPE_8259;
if (strcmp(name, "chrp,iic") == 0) { if (strcmp(name, "chrp,iic") == 0) {
picnodes[nrofpics].type = PICNODE_TYPE_8259; picnodes[nrofpics].type = PICNODE_TYPE_8259;
if (irgot >= 9 * sizeof(uint32_t) && if (irgot >= 9 * sizeof(uint32_t) &&