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_
#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];

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.
* All rights reserved.
@ -36,7 +36,7 @@
*/
#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/buf.h>
@ -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;

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.
@ -37,7 +37,7 @@
*/
#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"
@ -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");

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.
@ -37,7 +37,7 @@
*/
#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_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",

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.
@ -41,7 +41,7 @@
*/
#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/param.h>
@ -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) &&