Module Name: src Committed By: rkujawa Date: Thu Jan 19 00:14:08 UTC 2012
Modified Files: src/sys/arch/amiga/conf: DRACO GENERIC GENERIC.in INSTALL files.amiga src/sys/arch/amiga/dev: p5bus.c zbus.c src/sys/arch/amiga/include: pci_machdep.h src/sys/arch/amiga/pci: mppb.c p5membar.c p5pb.c p5pbreg.h p5pbvar.h Log Message: Tons of enchancements to MD PCI code: - The G-REX 4000 and G-REX 1200 are now really supported and working (still only 1st slot but the rest are a matter of time). - Add bridge identification to p5pb, simplifies the driver and make it more user-friendly. - Retire P5PB_GENFB and P5PB_OLD_FIRMWARE options, these are now handled automatically, depending on used hardware and firmware. - Add PCI bus reconfiguration support to p5pb (PCI_NETBSD_CONFIGURE), allows using G-REX without boot to AmigaOS. - Bring p5pb registers desription up to date with my knowledge. - Add a lot of debugging code to p5pb (enabled by P5PB_DEBUG kernel option). - Fix PCI_NETBSD_CONFIGURE in mppb (now it really works). - Fix quirk handling in zbus. - Update GENERIC.in and regen the kernel configs. - Misc cleanup. To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/sys/arch/amiga/conf/DRACO cvs rdiff -u -r1.280 -r1.281 src/sys/arch/amiga/conf/GENERIC cvs rdiff -u -r1.92 -r1.93 src/sys/arch/amiga/conf/GENERIC.in cvs rdiff -u -r1.102 -r1.103 src/sys/arch/amiga/conf/INSTALL cvs rdiff -u -r1.152 -r1.153 src/sys/arch/amiga/conf/files.amiga cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/dev/p5bus.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amiga/dev/zbus.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amiga/include/pci_machdep.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/pci/mppb.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/pci/p5membar.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amiga/pci/p5pb.c \ src/sys/arch/amiga/pci/p5pbreg.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/pci/p5pbvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/amiga/conf/DRACO diff -u src/sys/arch/amiga/conf/DRACO:1.150 src/sys/arch/amiga/conf/DRACO:1.151 --- src/sys/arch/amiga/conf/DRACO:1.150 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/conf/DRACO Thu Jan 19 00:14:08 2012 @@ -1,9 +1,9 @@ -# $NetBSD: DRACO,v 1.150 2012/01/11 17:04:29 rkujawa Exp $ +# $NetBSD: DRACO,v 1.151 2012/01/19 00:14:08 rkujawa Exp $ # # This file was automatically created. # Changes will be lost when make is run in this directory. # -# Created from: # NetBSD: GENERIC.in,v 1.91 2012/01/10 20:29:50 rkujawa Exp $ +# Created from: # NetBSD: GENERIC.in,v 1.92 2012/01/11 17:04:29 rkujawa Exp $ # ## # GENERIC machine description file @@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.150 $" +#ident "GENERIC-$Revision: 1.151 $" maxusers 8 Index: src/sys/arch/amiga/conf/GENERIC diff -u src/sys/arch/amiga/conf/GENERIC:1.280 src/sys/arch/amiga/conf/GENERIC:1.281 --- src/sys/arch/amiga/conf/GENERIC:1.280 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/conf/GENERIC Thu Jan 19 00:14:08 2012 @@ -1,9 +1,9 @@ -# $NetBSD: GENERIC,v 1.280 2012/01/11 17:04:29 rkujawa Exp $ +# $NetBSD: GENERIC,v 1.281 2012/01/19 00:14:08 rkujawa Exp $ # # This file was automatically created. # Changes will be lost when make is run in this directory. # -# Created from: # NetBSD: GENERIC.in,v 1.91 2012/01/10 20:29:50 rkujawa Exp $ +# Created from: # NetBSD: GENERIC.in,v 1.92 2012/01/11 17:04:29 rkujawa Exp $ # ## # GENERIC machine description file @@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.280 $" +#ident "GENERIC-$Revision: 1.281 $" maxusers 8 @@ -470,12 +470,10 @@ uk* at scsibus? target ? lun ? # scsi un # PCI bus support options PCIVERBOSE # verbose PCI device autoconfig messages #options PCI_CONFIG_DUMP -options PCI_NETBSD_CONFIGURE # used only by mppb(4) +options PCI_NETBSD_CONFIGURE # supported by mppb(4) and p5pb(4) p5pb0 at p5bus0 # Phase5 PCI bridge (CVPPC/BVPPC/G-REX) p5membar* at zbus0 # Phase5 PCI bridge autoconfiguring BARs -#options P5PB_OLD_FIRMWARE # enable support for p5pb with old fw -#options P5PB_GENFB # enable genfb support for CVPPC/BVPPC #options P5PB_DEBUG # enable excessive debug for p5pb pci* at p5pb0 Index: src/sys/arch/amiga/conf/GENERIC.in diff -u src/sys/arch/amiga/conf/GENERIC.in:1.92 src/sys/arch/amiga/conf/GENERIC.in:1.93 --- src/sys/arch/amiga/conf/GENERIC.in:1.92 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/conf/GENERIC.in Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC.in,v 1.92 2012/01/11 17:04:29 rkujawa Exp $ +# $NetBSD: GENERIC.in,v 1.93 2012/01/19 00:14:08 rkujawa Exp $ # ## # GENERIC machine description file @@ -52,7 +52,7 @@ include "arch/amiga/conf/std.amiga" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.92 $" +#ident "GENERIC-$Revision: 1.93 $" m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl makeoptions COPTS="-Os" @@ -557,12 +557,10 @@ m4_ifdef(`AMIGA_CONFIGURATION', `m4_dnl # PCI bus support options PCIVERBOSE # verbose PCI device autoconfig messages #options PCI_CONFIG_DUMP -options PCI_NETBSD_CONFIGURE # used only by mppb(4) +options PCI_NETBSD_CONFIGURE # supported by mppb(4) and p5pb(4) p5pb0 at p5bus0 # Phase5 PCI bridge (CVPPC/BVPPC/G-REX) p5membar* at zbus0 # Phase5 PCI bridge autoconfiguring BARs -#options P5PB_OLD_FIRMWARE # enable support for p5pb with old fw -#options P5PB_GENFB # enable genfb support for CVPPC/BVPPC #options P5PB_DEBUG # enable excessive debug for p5pb pci* at p5pb0 Index: src/sys/arch/amiga/conf/INSTALL diff -u src/sys/arch/amiga/conf/INSTALL:1.102 src/sys/arch/amiga/conf/INSTALL:1.103 --- src/sys/arch/amiga/conf/INSTALL:1.102 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/conf/INSTALL Thu Jan 19 00:14:08 2012 @@ -1,9 +1,9 @@ -# $NetBSD: INSTALL,v 1.102 2012/01/11 17:04:29 rkujawa Exp $ +# $NetBSD: INSTALL,v 1.103 2012/01/19 00:14:08 rkujawa Exp $ # # This file was automatically created. # Changes will be lost when make is run in this directory. # -# Created from: # NetBSD: GENERIC.in,v 1.91 2012/01/10 20:29:50 rkujawa Exp $ +# Created from: # NetBSD: GENERIC.in,v 1.92 2012/01/11 17:04:29 rkujawa Exp $ # ## # GENERIC machine description file @@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.102 $" +#ident "GENERIC-$Revision: 1.103 $" makeoptions COPTS="-Os" @@ -414,12 +414,10 @@ ch* at scsibus? target ? lun ? # scsi au # PCI bus support options PCIVERBOSE # verbose PCI device autoconfig messages #options PCI_CONFIG_DUMP -options PCI_NETBSD_CONFIGURE # used only by mppb(4) +options PCI_NETBSD_CONFIGURE # supported by mppb(4) and p5pb(4) p5pb0 at p5bus0 # Phase5 PCI bridge (CVPPC/BVPPC/G-REX) p5membar* at zbus0 # Phase5 PCI bridge autoconfiguring BARs -#options P5PB_OLD_FIRMWARE # enable support for p5pb with old fw -#options P5PB_GENFB # enable genfb support for CVPPC/BVPPC #options P5PB_DEBUG # enable excessive debug for p5pb pci* at p5pb0 Index: src/sys/arch/amiga/conf/files.amiga diff -u src/sys/arch/amiga/conf/files.amiga:1.152 src/sys/arch/amiga/conf/files.amiga:1.153 --- src/sys/arch/amiga/conf/files.amiga:1.152 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/conf/files.amiga Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -# $NetBSD: files.amiga,v 1.152 2012/01/11 17:04:29 rkujawa Exp $ +# $NetBSD: files.amiga,v 1.153 2012/01/19 00:14:08 rkujawa Exp $ # maxpartitions must be first item in files.${ARCH}.newconf maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL! @@ -33,8 +33,6 @@ defflag P5PPC68KBOARD defflag LEV6_DEFER defflag DEVRELOAD -defflag opt_p5pb.h P5PB_GENFB -defflag opt_p5pb.h P5PB_OLD_FIRMWARE defflag opt_p5pb.h P5PB_DEBUG defparam IOBZCLOCK Index: src/sys/arch/amiga/dev/p5bus.c diff -u src/sys/arch/amiga/dev/p5bus.c:1.1 src/sys/arch/amiga/dev/p5bus.c:1.2 --- src/sys/arch/amiga/dev/p5bus.c:1.1 Tue Jan 10 20:29:50 2012 +++ src/sys/arch/amiga/dev/p5bus.c Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: p5bus.c,v 1.1 2012/01/10 20:29:50 rkujawa Exp $ */ +/* $NetBSD: p5bus.c,v 1.2 2012/01/19 00:14:08 rkujawa Exp $ */ /*- * Copyright (c) 2011, 2012 The NetBSD Foundation, Inc. @@ -64,10 +64,6 @@ struct p5bus_softc { uint8_t sc_has_ppc; #define P5BUS_PPC_NONE 0 /* CS Mk-III only */ #define P5BUS_PPC_OK 1 /* has working PPC CPU */ - uint8_t sc_has_pci; -#define P5BUS_PCI_NONE 0 -#define P5BUS_PCI_CVPPC 1 /* CyberVisionPPC / BlizzardVisionPPC */ -#define P5BUS_PCI_GREX 2 /* G-REX (not yet) */ }; CFATTACH_DECL_NEW(p5bus, sizeof(struct p5bus_softc), @@ -126,7 +122,7 @@ p5bus_attach(device_t parent, device_t s } else if (zap->prodid == ZORRO_PRODID_BPPC) { - if (sn[0] == 'I') { /* only "+" model has SCSI */ + if (sn[0] != 'I') { /* only "+" model has SCSI */ aprint_normal_dev(sc->sc_dev, "BlizzardPPC 603e (sn %s)\n", sn); sc->sc_has_scsi = P5BUS_SCSI_NONE; @@ -141,8 +137,6 @@ p5bus_attach(device_t parent, device_t s } - sc->sc_has_pci = P5BUS_PCI_CVPPC; /* XXX: insert probe here? */ - p5baa.p5baa_cardtype = sc->sc_cardtype; /* Attach the SCSI host adapters. */ @@ -177,10 +171,9 @@ p5bus_callback(device_t self) { sc = device_private(self); p5baa.p5baa_cardtype = sc->sc_cardtype; - if (sc->sc_has_pci) { - strcpy(p5baa.p5baa_name, "p5pb"); - config_found_ia(sc->sc_dev, "p5bus", &p5baa, p5bus_print); - } + /* p5pb is always found, probe is inside of p5pb driver */ + strcpy(p5baa.p5baa_name, "p5pb"); + config_found_ia(sc->sc_dev, "p5bus", &p5baa, p5bus_print); } /* Get serial number of the card. */ Index: src/sys/arch/amiga/dev/zbus.c diff -u src/sys/arch/amiga/dev/zbus.c:1.67 src/sys/arch/amiga/dev/zbus.c:1.68 --- src/sys/arch/amiga/dev/zbus.c:1.67 Wed Sep 21 12:40:25 2011 +++ src/sys/arch/amiga/dev/zbus.c Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: zbus.c,v 1.67 2011/09/21 12:40:25 rkujawa Exp $ */ +/* $NetBSD: zbus.c,v 1.68 2012/01/19 00:14:08 rkujawa Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.67 2011/09/21 12:40:25 rkujawa Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.68 2012/01/19 00:14:08 rkujawa Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -244,6 +244,7 @@ static const char *aconflookup(int, int) * given a manufacturer id and product id, find quirks * for this board. */ + static uint8_t quirkslookup(int mid, int pid) { @@ -251,7 +252,7 @@ quirkslookup(int mid, int pid) eqdp = &quirkstab[nquirksent]; for (qdp = quirkstab; qdp < eqdp; qdp++) - if (qdp->manid == mid && qdp->prodid == pid) + if (qdp->manid == mid && qdp->prodid == pid) return(qdp->quirks); return(0); } @@ -335,6 +336,11 @@ zbusattach(device_t pdp, device_t dp, vo za.pa = cdp->addr; za.size = cdp->size; + za.manid = cdp->rom.manid; + za.prodid = cdp->rom.prodid; + za.serno = cdp->rom.serno; + za.slot = (((u_long)za.pa >> 16) & 0xF) - 0x9; + if (amiga_realconfig && pcp < epcp && pcp->vaddr) za.va = pcp->vaddr; else { @@ -349,10 +355,6 @@ zbusattach(device_t pdp, device_t dp, vo if (amiga_realconfig == 0) pcp->vaddr = za.va; } - za.manid = cdp->rom.manid; - za.prodid = cdp->rom.prodid; - za.serno = cdp->rom.serno; - za.slot = (((u_long)za.pa >> 16) & 0xF) - 0x9; amiga_config_found(early_cfdata, dp, &za, zbusprint); } } Index: src/sys/arch/amiga/include/pci_machdep.h diff -u src/sys/arch/amiga/include/pci_machdep.h:1.3 src/sys/arch/amiga/include/pci_machdep.h:1.4 --- src/sys/arch/amiga/include/pci_machdep.h:1.3 Mon Sep 19 19:15:29 2011 +++ src/sys/arch/amiga/include/pci_machdep.h Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.h,v 1.3 2011/09/19 19:15:29 rkujawa Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.4 2012/01/19 00:14:08 rkujawa Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -38,6 +38,8 @@ #include <m68k/bus_dma.h> +/* #define __HAVE_PCI_CONF_HOOK */ + /* * Forward declarations. */ Index: src/sys/arch/amiga/pci/mppb.c diff -u src/sys/arch/amiga/pci/mppb.c:1.4 src/sys/arch/amiga/pci/mppb.c:1.5 --- src/sys/arch/amiga/pci/mppb.c:1.4 Fri Jan 13 13:41:25 2012 +++ src/sys/arch/amiga/pci/mppb.c Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: mppb.c,v 1.4 2012/01/13 13:41:25 rkujawa Exp $ */ +/* $NetBSD: mppb.c,v 1.5 2012/01/19 00:14:08 rkujawa Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -55,6 +55,8 @@ #include <dev/pci/pcidevs.h> #include <dev/pci/pciconf.h> +#include "opt_pci.h" + /* Zorro IDs */ #define ZORRO_MANID_MATAY 44359 #define ZORRO_PRODID_PROMETHEUS 1 @@ -100,11 +102,6 @@ mppb_match(device_t parent, cfdata_t cf, if (zap->prodid != ZORRO_PRODID_PROMETHEUS) return 0; -#ifdef MPPB_DEBUG - aprint_normal("mppb matched by Zorro ID %d, %d\n", zap->manid, - zap->prodid); -#endif - return 1; } @@ -139,10 +136,10 @@ mppb_attach(device_t parent, device_t se sc->pci_io_area.absm = &amiga_bus_stride_1; #ifdef MPPB_DEBUG - aprint_normal("mppb mapped conf %x->%x, mem %x->%x\n, io %x->%x", - (zap->pa) + MPPB_CONF_BASE, sc->pci_conf_area.base, - (zap->pa) + MPPB_MEM_BASE, sc->pci_mem_area.base, - (zap->pa) + MPPB_IO_BASE, sc->pci_io_area.base); + aprint_normal("mppb mapped conf %x->%x, mem %x->%x\n, io %x->%x\n", + kvtop((void*) sc->pci_conf_area.base), sc->pci_conf_area.base, + kvtop((void*) sc->pci_mem_area.base), sc->pci_mem_area.base, + kvtop((void*) sc->pci_io_area.base), sc->pci_io_area.base); #endif sc->apc.pci_conf_datat = &(sc->pci_conf_area); @@ -174,7 +171,10 @@ mppb_attach(device_t parent, device_t se MPPB_IO_BASE + MPPB_IO_SIZE, M_DEVBUF, NULL, 0, EX_NOWAIT); memext = extent_create("mppbmem", MPPB_MEM_BASE, MPPB_MEM_BASE + MPPB_MEM_SIZE, M_DEVBUF, NULL, 0, EX_NOWAIT); - + +#ifdef MPPB_DEBUG + aprint_normal("mppb: reconfiguring the bus!\n"); +#endif /* MPPB_DEBUG */ pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINE_SIZE); extent_destroy(ioext); @@ -203,11 +203,11 @@ mppb_pci_conf_read(pci_chipset_tag_t pc, data = bus_space_read_4(pc->pci_conf_datat, pc->pci_conf_datah, (MPPB_CONF_STRIDE*dev) + reg); -#ifdef MPPB_DEBUG +#ifdef MPPB_DEBUG_CONF aprint_normal("mppb conf read va: %lx, bus: %d, dev: %d, " "func: %d, reg: %d -r-> data %x\n", pc->pci_conf_datah, bus, dev, func, reg, data); -#endif +#endif /* MPPB_DEBUG_CONF */ return data; } @@ -220,11 +220,11 @@ mppb_pci_conf_write(pci_chipset_tag_t pc bus_space_write_4(pc->pci_conf_datat, pc->pci_conf_datah, (MPPB_CONF_STRIDE*dev) + reg, val); -#ifdef MPPB_DEBUG +#ifdef MPPB_DEBUG_CONF aprint_normal("mppb conf write va: %lx, bus: %d, dev: %d, " "func: %d, reg: %d -w-> data %x\n", pc->pci_conf_datah, bus, dev, func, reg, val); -#endif +#endif /* MPPB_DEBUG_CONF */ } Index: src/sys/arch/amiga/pci/p5membar.c diff -u src/sys/arch/amiga/pci/p5membar.c:1.1 src/sys/arch/amiga/pci/p5membar.c:1.2 --- src/sys/arch/amiga/pci/p5membar.c:1.1 Tue Jan 10 20:29:50 2012 +++ src/sys/arch/amiga/pci/p5membar.c Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: p5membar.c,v 1.1 2012/01/10 20:29:50 rkujawa Exp $ */ +/* $NetBSD: p5membar.c,v 1.2 2012/01/19 00:14:08 rkujawa Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ p5membar_attach(device_t parent, device_ aprint_normal(": PCI I/O area, %d kB\n", zap->size / 1024); sc->sc_type = P5MEMBAR_TYPE_INTERNAL; - } else if ((bus_addr_t) zap->pa == P5BUS_PCI_BRIDGE_BASE) { + } else if ((bus_addr_t) zap->pa == P5BUS_BRIDGE_BASE) { aprint_normal(": PCI bridge, %d kB\n", zap->size / 1024); sc->sc_type = P5MEMBAR_TYPE_INTERNAL; Index: src/sys/arch/amiga/pci/p5pb.c diff -u src/sys/arch/amiga/pci/p5pb.c:1.5 src/sys/arch/amiga/pci/p5pb.c:1.6 --- src/sys/arch/amiga/pci/p5pb.c:1.5 Tue Jan 10 20:29:50 2012 +++ src/sys/arch/amiga/pci/p5pb.c Thu Jan 19 00:14:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: p5pb.c,v 1.5 2012/01/10 20:29:50 rkujawa Exp $ */ +/* $NetBSD: p5pb.c,v 1.6 2012/01/19 00:14:08 rkujawa Exp $ */ /*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. + * Copyright (c) 2011, 2012 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -36,8 +36,8 @@ #include <sys/errno.h> #include <sys/device.h> #include <sys/malloc.h> -#include <sys/extent.h> #include <sys/kmem.h> +#include <sys/extent.h> #include <uvm/uvm_extern.h> @@ -54,7 +54,12 @@ #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> #include <dev/pci/pcidevs.h> +#ifdef PCI_NETBSD_CONFIGURE #include <dev/pci/pciconf.h> +#endif /* PCI_NETBSD_CONFIGURE */ + +#include "opt_p5pb.h" +#include "opt_pci.h" /* Initial CVPPC/BVPPC resolution as configured by the firmware */ #define P5GFX_WIDTH 640 @@ -67,7 +72,9 @@ static void p5pb_attach(struct device *, void p5pb_set_props(struct p5pb_softc *sc); pcireg_t p5pb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int); void p5pb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); -int p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno); +int p5pb_pci_bus_maxdevs_cvppc(pci_chipset_tag_t pc, int busno); +int p5pb_pci_bus_maxdevs_grex1200(pci_chipset_tag_t pc, int busno); +int p5pb_pci_bus_maxdevs_grex4000(pci_chipset_tag_t pc, int busno); int p5pb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func, pcireg_t id); void p5pb_pci_attach_hook (struct device *parent, @@ -78,10 +85,21 @@ void p5pb_pci_decompose_tag(pci_chipset int *bp, int *dp, int *fp); int p5pb_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp); -bool p5pb_bus_map_cvppc(struct p5pb_softc *sc); -bool p5pb_bus_map_grex(struct p5pb_softc *sc); -bool p5pb_bus_map_common(struct p5pb_softc *sc); +bool p5pb_bus_map_memio(struct p5pb_softc *sc); +bool p5pb_bus_map_conf(struct p5pb_softc *sc); uint8_t p5pb_find_resources(struct p5pb_softc *sc); +static bool p5pb_identify_bridge(struct p5pb_softc *sc); +void p5pb_membar_grex(struct p5pb_softc *sc); +static bool p5pb_cvppc_probe(struct p5pb_softc *sc); +#ifdef PCI_NETBSD_CONFIGURE +bool p5pb_bus_reconfigure(struct p5pb_softc *sc); +#endif /* PCI_NETBSD_CONFIGURE */ +#ifdef P5PB_DEBUG +void p5pb_usable_ranges(struct p5pb_softc *sc); +void p5pb_badaddr_range(struct p5pb_softc *sc, bus_space_tag_t bust, + bus_addr_t base, size_t len); +void p5pb_conf_search(struct p5pb_softc *sc, uint16_t val); +#endif /* P5PB_DEBUG */ CFATTACH_DECL_NEW(p5pb, sizeof(struct p5pb_softc), p5pb_match, p5pb_attach, NULL, NULL); @@ -107,54 +125,69 @@ p5pb_attach(device_t parent, device_t se struct pcibus_attach_args pba; sc = device_private(self); - pci_chipset_tag_t pc = &sc->apc; sc->sc_dev = self; + sc->p5baa = (struct p5bus_attach_args *) aux; - if (p5pb_find_resources(sc) > 0) { - sc->p5pb_bus_map = &p5pb_bus_map_grex; - } else { -#ifdef P5PB_OLD_FIRMWARE - sc->p5pb_bus_map = &p5pb_bus_map_cvppc; -#else - aprint_normal(": no PCI bridges detected\n"); + pci_chipset_tag_t pc = &sc->apc; + + if (!p5pb_bus_map_conf(sc)) { + aprint_error_dev(self, + "couldn't map PCI configuration space\n"); return; -#endif /* P5PB_OLD_FIRMWARE */ } - aprint_normal(": Phase5 CVPPC/BVPPC/G-REX PCI bridge\n"); - - if(!p5pb_bus_map_common(sc)) { - aprint_error_dev(self, - "couldn't map PCI configuration and I/O spaces\n"); + if (!p5pb_identify_bridge(sc)) { return; } - if(!(sc->p5pb_bus_map(sc))) { + if (sc->bridge_type == P5PB_BRIDGE_CVPPC) { + sc->pci_mem_lowest = P5BUS_PCI_MEM_BASE; + sc->pci_mem_highest = P5BUS_PCI_MEM_BASE + P5BUS_PCI_MEM_SIZE; + } else { + p5pb_membar_grex(sc); + } + + if (!p5pb_bus_map_memio(sc)) { aprint_error_dev(self, - "couldn't map PCI memory space\n"); + "couldn't map PCI I/O and memory space\n"); return; } #ifdef P5PB_DEBUG - aprint_normal("p5pb: mapped %x -> %x, %x -> %x\n, %x -> %x\n", - P5BUS_PCI_CONF_BASE, sc->pci_conf_area.base, - P5BUS_PCI_IO_BASE, sc->pci_io_area.base, - P5BUS_PCI_MEM_BASE, sc->pci_mem_area.base ); + aprint_normal("p5pb: map conf %x -> %x, io %x -> %x, mem %x -> %x\n", + kvtop((void*) sc->pci_conf_area.base), sc->pci_conf_area.base, + kvtop((void*) sc->pci_io_area.base), sc->pci_io_area.base, + kvtop((void*) sc->pci_mem_area.base), sc->pci_mem_area.base ); #endif /* Initialize the PCI chipset tag. */ + + if (sc->bridge_type == P5PB_BRIDGE_GREX1200) + sc->apc.pc_bus_maxdevs = p5pb_pci_bus_maxdevs_grex1200; + else if (sc->bridge_type == P5PB_BRIDGE_GREX4000) + sc->apc.pc_bus_maxdevs = p5pb_pci_bus_maxdevs_grex4000; + else + sc->apc.pc_bus_maxdevs = p5pb_pci_bus_maxdevs_cvppc; + sc->apc.pc_conf_v = (void*) pc; - sc->apc.pc_bus_maxdevs = p5pb_pci_bus_maxdevs; sc->apc.pc_make_tag = amiga_pci_make_tag; sc->apc.pc_decompose_tag = amiga_pci_decompose_tag; sc->apc.pc_conf_read = p5pb_pci_conf_read; sc->apc.pc_conf_write = p5pb_pci_conf_write; + sc->apc.pc_conf_hook = p5pb_pci_conf_hook; + sc->apc.pc_conf_interrupt = amiga_pci_conf_interrupt; sc->apc.pc_attach_hook = p5pb_pci_attach_hook; sc->apc.pc_intr_map = p5pb_pci_intr_map; sc->apc.pc_intr_string = amiga_pci_intr_string; sc->apc.pc_intr_establish = amiga_pci_intr_establish; sc->apc.pc_intr_disestablish = amiga_pci_intr_disestablish; + +#ifdef PCI_NETBSD_CONFIGURE + p5pb_bus_reconfigure(sc); +#endif /* PCI_NETBSD_CONFIGURE */ + + /* Initialize the bus attachment structure. */ pba.pba_iot = &(sc->pci_io_area); pba.pba_memt = &(sc->pci_mem_area); @@ -165,15 +198,67 @@ p5pb_attach(device_t parent, device_t se pba.pba_bus = 0; pba.pba_bridgetag = NULL; -#ifdef P5PB_GENFB - p5pb_set_props(sc); -#endif /* P5PB_GENFB */ + /* If we are a CVPPC/BVPPC, set the properties needed for genfb. */ + if (sc->bridge_type == P5PB_BRIDGE_CVPPC) { + p5pb_set_props(sc); + } config_found_ia(self, "pcibus", &pba, pcibusprint); } +/* + * Try to detect what kind of bridge are we dealing with. + */ +static bool +p5pb_identify_bridge(struct p5pb_softc *sc) +{ + int pcires_count; /* Number of AutoConfig(TM) PCI resources */ + + pcires_count = p5pb_find_resources(sc); + + switch (pcires_count) { + case 0: + /* + * Zero AutoConfig(TM) PCI resources, means that there's nothing + * OR there's a CVPPC/BVPPC with a pre-44.69 firmware. + */ + if (p5pb_cvppc_probe(sc)) { + sc->bridge_type = P5PB_BRIDGE_CVPPC; + aprint_normal(": Phase5 CVPPC/BVPPC PCI bridge\n"); + } else { + aprint_normal(": no PCI bridges detected\n"); + return false; + } + break; + case 6: + /* + * We have a slight possibility, that there's a CVPPC/BVPPC with + * the new firmware. So check for it first. + */ + if (p5pb_cvppc_probe(sc)) { + /* New firmware, treat as one-slot GREX. */ + sc->bridge_type = P5PB_BRIDGE_CVPPC; + aprint_normal( + ": Phase5 CVPPC/BVPPC PCI bridge (44.69/44.71)\n"); + break; + } + default: + /* We have a G-REX surely. */ + + if (sc->p5baa->p5baa_cardtype == P5_CARDTYPE_CS) { + sc->bridge_type = P5PB_BRIDGE_GREX4000; + aprint_normal(": DCE G-REX 4000 PCI bridge\n"); + } else { + sc->bridge_type = P5PB_BRIDGE_GREX1200; + aprint_normal(": DCE G-REX 1200 PCI bridge\n"); + } + break; + } + return true; +} + /* - * Find autoconfigured resuorces (for boards running G-REX firmware). Return the + * Find AutoConfig(TM) resuorces (for boards running G-REX firmware). Return the * total number of found resources. */ uint8_t @@ -215,7 +300,7 @@ p5pb_find_resources(struct p5pb_softc *s /* * Set properties needed to support fb driver. These are read later during - * autoconfg in device_register(). + * autoconfg in device_register(). Needed for CVPPC/BVPPC. */ void p5pb_set_props(struct p5pb_softc *sc) @@ -230,12 +315,10 @@ p5pb_set_props(struct p5pb_softc *sc) prop_dictionary_set_uint32(dict, "height", P5GFX_HEIGHT); prop_dictionary_set_uint8(dict, "depth", P5GFX_DEPTH); prop_dictionary_set_uint16(dict, "linebytes", P5GFX_LINEBYTES); - prop_dictionary_set_uint64(dict, "address", P5BUS_PCI_MEM_BASE); + prop_dictionary_set_uint64(dict, "address", + kvtop((void*) sc->pci_mem_area.base)); #if (NGENFB > 0) - /* - * Framebuffer starts at P5BUS_PCI_MEM_BASE, but genfb needs virtual - * address. - */ + /* genfb needs virtual address too */ prop_dictionary_set_uint64(dict, "virtual_address", sc->pci_mem_area.base); #endif @@ -250,8 +333,8 @@ p5pb_pci_conf_read(pci_chipset_tag_t pc, pci_decompose_tag(pc, tag, &bus, &dev, &func); data = bus_space_read_4(pc->pci_conf_datat, pc->pci_conf_datah, - (func<<5) + reg); -#ifdef P5PB_DEBUG + + reg + (dev * OFF_PCI_DEVICE)); +#ifdef P5PB_DEBUG_CONF aprint_normal("p5pb conf read va: %lx, bus: %d, dev: %d, " "func: %d, reg: %d -r-> data %x\n", pc->pci_conf_datah, bus, dev, func, reg, data); @@ -267,8 +350,8 @@ p5pb_pci_conf_write(pci_chipset_tag_t pc pci_decompose_tag(pc, tag, &bus, &dev, &func); bus_space_write_4(pc->pci_conf_datat, pc->pci_conf_datah, - (func << 5) + reg, val); -#ifdef P5PB_DEBUG + + reg + (dev * OFF_PCI_DEVICE), val); +#ifdef P5PB_DEBUG_CONF aprint_normal("p5pb conf write va: %lx, bus: %d, dev: %d, " "func: %d, reg: %d -w-> data %x\n", pc->pci_conf_datah, bus, dev, func, reg, val); @@ -277,12 +360,26 @@ p5pb_pci_conf_write(pci_chipset_tag_t pc } int -p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno) +p5pb_pci_bus_maxdevs_cvppc(pci_chipset_tag_t pc, int busno) { - /* G-REX has max 5 slots. CVPPC/BVPPC has only 1. */ + /* CVPPC/BVPPC has only 1 "slot". */ return 1; } +int +p5pb_pci_bus_maxdevs_grex4000(pci_chipset_tag_t pc, int busno) +{ + /* G-REX 4000 has 4 slots. */ + return 1; /* XXX: 4 not yet! */ +} + +int +p5pb_pci_bus_maxdevs_grex1200(pci_chipset_tag_t pc, int busno) +{ + /* G-REX 1200 has 5 slots. */ + return 1; /* XXX: 5 not yet! */ +} + void p5pb_pci_attach_hook(struct device *parent, struct device *self, struct pcibus_attach_args *pba) @@ -298,82 +395,217 @@ p5pb_pci_intr_map(const struct pci_attac return 0; } -/* PCI memory mapping done G-REX-style. */ +/* Probe for CVPPC/BVPPC. */ +static bool +p5pb_cvppc_probe(struct p5pb_softc *sc) +{ + bus_space_handle_t probe_h; + uint16_t prodid, manid; + void* data; + bool rv; + + manid = 0; prodid = 0; + rv = false; + + if (bus_space_map(sc->apc.pci_conf_datat, 0, 4, 0, &probe_h)) + return rv; + + data = bus_space_vaddr(sc->apc.pci_conf_datat, probe_h); + + if (badaddr((void *)__UNVOLATILE((uint32_t) data))) { +#ifdef P5PB_DEBUG_PROBE + aprint_normal("p5pb: CVPPC configuration space not usable!\n"); +#endif /* P5PB_DEBUG_PROBE */ + } else { + prodid = bus_space_read_2(sc->apc.pci_conf_datat, probe_h, 0); + manid = bus_space_read_2(sc->apc.pci_conf_datat, probe_h, 2); + + if ((prodid == P5PB_PM2_PRODUCT_ID) && + (manid == P5PB_PM2_VENDOR_ID)) + rv = true; + } + +#ifdef P5PB_DEBUG_PROBE + aprint_normal("p5pb: CVPPC probe for PCI ID: %x, %x returns %d\n", + manid, prodid, (int) rv); +#endif /* P5PB_DEBUG_PROBE */ + + bus_space_unmap(sc->apc.pci_conf_datat, probe_h, 4); + return rv; +} + +#ifdef PCI_NETBSD_CONFIGURE +/* Reconfigure the bus. */ bool -p5pb_bus_map_grex(struct p5pb_softc *sc) +p5pb_bus_reconfigure(struct p5pb_softc *sc) { - struct p5pb_autoconf_entry *membar_entry; - bus_addr_t bar_address; - bus_addr_t pci_mem_highest; + struct extent *ioext, *memext; + pci_chipset_tag_t pc; - pci_mem_highest = P5BUS_PCI_MEM_BASE; + pc = &sc->apc; -#ifdef P5PB_DEBUG - aprint_normal("p5pb: p5pb_bus_map_grex called\n"); + ioext = extent_create("p5pbio", 0, P5BUS_PCI_IO_SIZE, M_DEVBUF, NULL, 0, + EX_NOWAIT); + + memext = extent_create("p5pbmem", sc->pci_mem_lowest, + sc->pci_mem_highest, M_DEVBUF, NULL, 0, EX_NOWAIT); + + if ( (!ioext) || (!memext) ) + return false; + +#ifdef P5PB_DEBUG + aprint_normal("p5pb: reconfiguring the bus!\n"); #endif /* P5PB_DEBUG */ + pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINE_SIZE); - /* Determine the highest address used by any PCI card. */ - TAILQ_FOREACH(membar_entry, &sc->auto_bars, entries) { + extent_destroy(ioext); + extent_destroy(memext); - bar_address = (bus_addr_t) membar_entry->base; - if ((bar_address + membar_entry->size) > pci_mem_highest) - pci_mem_highest = bar_address + membar_entry->size; + return true; /* TODO: better error handling */ +} +#endif /* PCI_NETBSD_CONFIGURE */ -#ifdef P5PB_DEBUG - aprint_normal("p5pb: memory BAR at %p, highest address %x\n", - membar_entry->base, pci_mem_highest); -#endif /* P5PB_DEBUG */ +/* Determine the PCI memory space (done G-REX-style). */ +void +p5pb_membar_grex(struct p5pb_softc *sc) +{ + struct p5pb_autoconf_entry *membar_entry; + uint32_t bar_address; + + sc->pci_mem_lowest = 0xFFFFFFFF; + sc->pci_mem_highest = 0; + + /* Iterate over membar entries to find lowest and highest address. */ + TAILQ_FOREACH(membar_entry, &sc->auto_bars, entries) { + + bar_address = (uint32_t) membar_entry->base; + if ((bar_address + membar_entry->size) > sc->pci_mem_highest) + sc->pci_mem_highest = bar_address + membar_entry->size; + if (bar_address < sc->pci_mem_lowest) + sc->pci_mem_lowest = bar_address; + +#ifdef P5PB_DEBUG_BAR + aprint_normal("p5pb: %d kB mem BAR at %p, hi = %x, lo = %x\n", + membar_entry->size / 1024, membar_entry->base, + sc->pci_mem_highest, sc->pci_mem_lowest); +#endif /* P5PB_DEBUG_BAR */ } - sc->pci_mem_area.base = (bus_addr_t) zbusmap( - (void *) P5BUS_PCI_MEM_BASE, pci_mem_highest - P5BUS_PCI_MEM_BASE); - sc->pci_mem_area.absm = &amiga_bus_stride_1swap_abs; + aprint_normal("p5pb: %d kB PCI memory space (%8p to %8p)\n", + (sc->pci_mem_highest - sc->pci_mem_lowest) / 1024, + (void*) sc->pci_mem_lowest, (void*) sc->pci_mem_highest); - return true; } -/* Map things common for all supported bridges. */ bool -p5pb_bus_map_common(struct p5pb_softc *sc) +p5pb_bus_map_conf(struct p5pb_softc *sc) { -#ifdef P5PB_DEBUG - aprint_normal("p5pb: p5pb_bus_map_common called\n"); -#endif /* P5PB_DEBUG */ - sc->pci_conf_area.base = (bus_addr_t) zbusmap( (void *) P5BUS_PCI_CONF_BASE, P5BUS_PCI_CONF_SIZE); sc->pci_conf_area.absm = &amiga_bus_stride_1; - sc->pci_io_area.base = (bus_addr_t) zbusmap( - (void *) P5BUS_PCI_IO_BASE, P5BUS_PCI_IO_SIZE); - sc->pci_io_area.absm = &amiga_bus_stride_1swap_abs; - sc->apc.pci_conf_datat = &(sc->pci_conf_area); - sc->apc.pci_conf_addresst = &(sc->pci_conf_area); if (bus_space_map(sc->apc.pci_conf_datat, OFF_PCI_CONF_DATA, 256, 0, &sc->apc.pci_conf_datah)) return false; - /* XXX */ - /* if (bus_space_map(sc->apc.pci_conf_addresst, OFF_PCI_CONF_ADDR, - 256, 0, &sc->apc.pci_conf_addressh)) - return false; */ - return true; } -/* Hard-coded memory mapping for CVPPC/BVPPC (without G-REX firmware). */ +/* Map I/O and memory space. */ bool -p5pb_bus_map_cvppc(struct p5pb_softc *sc) +p5pb_bus_map_memio(struct p5pb_softc *sc) { -#ifdef P5PB_DEBUG - aprint_normal("p5pb: p5pb_bus_map_cvppc called\n"); -#endif /* P5PB_DEBUG */ + sc->pci_io_area.base = (bus_addr_t) zbusmap( + (void *) P5BUS_PCI_IO_BASE, P5BUS_PCI_IO_SIZE); + sc->pci_io_area.absm = &amiga_bus_stride_1swap; + sc->pci_mem_area.base = (bus_addr_t) zbusmap( - (void *) P5BUS_PCI_MEM_BASE, P5BUS_PCI_MEM_SIZE); + (void *) sc->pci_mem_lowest, + sc->pci_mem_highest - sc->pci_mem_lowest); sc->pci_mem_area.absm = &amiga_bus_stride_1swap_abs; return true; } +int +p5pb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, + int func, pcireg_t id) +{ + /* XXX: What should we do on CVPPC/BVPPC? It breaks genfb. */ + + return PCI_CONF_DEFAULT; +} + +#ifdef P5PB_DEBUG +/* Check which config and I/O ranges are usable. */ +void +p5pb_usable_ranges(struct p5pb_softc *sc) +{ + p5pb_badaddr_range(sc, &(sc->pci_conf_area), 0, P5BUS_PCI_CONF_SIZE); + p5pb_badaddr_range(sc, &(sc->pci_io_area), 0, P5BUS_PCI_IO_SIZE); +} + +void +p5pb_badaddr_range(struct p5pb_softc *sc, bus_space_tag_t bust, bus_addr_t base, + size_t len) +{ + int i, state, prev_state; + bus_space_handle_t bush; + volatile void *data; + + state = -1; + prev_state = -1; + + bus_space_map(bust, base, len, 0, &bush); + + aprint_normal("p5pb: badaddr range check from %x (%x) to %x (%x)\n", + (bus_addr_t) bush, /* start VA */ + (bus_addr_t) kvtop((void*) bush), /* start PA */ + (bus_addr_t) bush + len, /* end VA */ + (bus_addr_t) kvtop((void*) (bush + len)));/* end PA */ + + data = bus_space_vaddr(bust, bush); + + for(i = 0; i < len; i++) { + state = badaddr((void *)__UNVOLATILE(((uint32_t) data + i))); + if(state != prev_state) { + aprint_normal("p5pb: badaddr %p (%x) : %d\n", + (void*) ((uint32_t) data + i), + (bus_addr_t) kvtop((void*) ((uint32_t) data + i)), + state); + prev_state = state; + } + + } + + bus_space_unmap(bust, bush, len); +} + +/* Search for 16-bit value in the configuration space. */ +void +p5pb_conf_search(struct p5pb_softc *sc, uint16_t val) +{ + int i, state; + uint16_t readv; + void *va; + + va = bus_space_vaddr(sc->apc.pci_conf_datat, sc->apc.pci_conf_datah); + + for (i = 0; i < P5BUS_PCI_CONF_SIZE; i++) { + state = badaddr((void *)__UNVOLATILE(((uint32_t) va + i))); + if(state == 0) { + readv = bus_space_read_2(sc->apc.pci_conf_datat, + sc->apc.pci_conf_datah, i); + if(readv == val) + aprint_normal("p5pb: found val %x @ %x (%x)\n", + readv, (uint32_t) sc->apc.pci_conf_datah + + i, (bus_addr_t) kvtop((void*) + ((uint32_t) sc->apc.pci_conf_datah + i))); + } + } +} + +#endif /* P5PB_DEBUG */ + Index: src/sys/arch/amiga/pci/p5pbreg.h diff -u src/sys/arch/amiga/pci/p5pbreg.h:1.5 src/sys/arch/amiga/pci/p5pbreg.h:1.6 --- src/sys/arch/amiga/pci/p5pbreg.h:1.5 Wed Jan 11 17:04:29 2012 +++ src/sys/arch/amiga/pci/p5pbreg.h Thu Jan 19 00:14:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: p5pbreg.h,v 1.5 2012/01/11 17:04:29 rkujawa Exp $ */ +/* $NetBSD: p5pbreg.h,v 1.6 2012/01/19 00:14:08 rkujawa Exp $ */ /*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. + * Copyright (c) 2011, 2012 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -34,39 +34,44 @@ * * 0xFFFA0000 - PCI register space, 64KB * 0xFFFC0000 - PCI configuration mechanism #1 data, 128KB - * 0xFFFE0000 - (unknown, maybe PCI configuration mechanism #1 address, 4KB) + * 0xFFFE0000 - (unknown, probably PCI bridge configuration registers, 4KB) * * 0xE0000000 - Permedia RAM on CVPPC/BVPPC (1st aperture), 8MB * 0xE0800000 - Permedia RAM on CVPPC/BVPPC (2nd aperture), 8MB - * 0xE1000000 - Permedia registers, 128KB + * 0xE1000000 - Permedia registers on CVPPC/BVPPC, 128KB + * + * 0x80000000 - PCI cards memory space on G-REX, variable size * * Note: this map may not look the same for every firmware revision. * - * The bridge is probably capable of DMA and interrupts, but this would - * need further reverse engineering, and is not really needed to drive - * the Permedia 2 chip on CVPPC/BVPPC cards. + * The bridge is certainly capable of DMA, but this needs further reverse + * engineering. */ #ifndef _AMIGA_P5PBREG_H_ #define P5BUS_PCI_CONF_BASE 0xFFFC0000 #define P5BUS_PCI_CONF_SIZE 0x00020000 /* up to 128kB */ -/* XXX: This is OK for CVPPC/BVPPC only! */ -#define P5BUS_PCI_MEM_BASE 0xE0000000 -#define P5BUS_PCI_MEM_SIZE 0x01010000 /* actually 0x01020000 */ +#define OFF_PCI_CONF_DATA 0x00001000 /* also 0 on CVPPC */ +#define OFF_PCI_DEVICE 0x00002000 +#define OFF_PCI_FUNCTION 0x00000100 #define P5BUS_PCI_IO_BASE 0xFFFA0000 -#define P5BUS_PCI_IO_SIZE 0x0000FFFF /* 64kB */ - -#define P5BUS_PCI_BRIDGE_BASE 0xFFFE0000 -#define P5BUS_PCI_BRIDGE_SIZE 0x0000FFFF /* 64kB, 4kB on some fw revs */ +#define P5BUS_PCI_IO_SIZE 0x00010000 /* 64kB */ -#define OFF_PCI_CONF_DATA 0x00000000 +/* Bridge configuration */ +#define P5BUS_BRIDGE_BASE 0xFFFE0000 +#define P5BUS_BRIDGE_SIZE 0x00001000 /* 64kB, 4kB on some fw revs */ + +#define OFF_BRIDGE_ENDIAN 0x0000 /* PCI_BRIDGE_BASE + offset */ +#define P5BUS_BRIDGE_ENDIAN_BIG 0x02 /* to switch into BE mode */ +#define OFF_BRIDGE_INTR 0x0010 /* ? XXX interrupt enable? */ +#define P5BUS_BRIDGE_INTR_INT2 0x01 /* ? XXX INT2? */ -#define P5BUS_CONF_ENDIAN 0x0000 /* PCI_BRIDGE_BASE + offset */ -#define P5BUS_CONF_ENDIAN_BIG 0x02 /* to switch into BE mode */ -#define P5BUS_CONF_INTR 0x0010 /* ? XXX interrupt enable? */ -#define P5BUS_CONF_INTR_INT2 0x01 /* ? XXX INT2? */ +/* CVPPC/BVPPC defaults. */ +#define P5BUS_PCI_MEM_BASE 0xE0000000 +/* #define P5BUS_PCI_MEM_BASE 0x80000000 */ /* default on G-REX */ +#define P5BUS_PCI_MEM_SIZE 0x01020000 /* typical configuration of Permedia 2 on CVPPC/BVPPC */ #define OFF_P2_APERTURE_1 0x0 @@ -74,12 +79,9 @@ #define OFF_P2_REGS 0x01000000 /* #define OFF_P2_REGS 0x0F000000 */ /* ? alt. Permedia regs */ -/* PCI configuration register on CV64/3D, base is an offset from card base */ -#define CV643D_PCI_CONF_BASE 0xC0E0000 -#define CV643D_PCI_CONF_SIZE 0xFFF -#define CV643D_PCI_MEM_BASE 0x4000000 -#define CV643D_PCI_MEM_SIZ 0x4000FFF -#define CV643D_PCI_IO_BASE 0xC000000 -#define CV643D_PCI_IO_SIZE 0xFFFF +/* Permedia 2 vendor and product IDs, for CVPPC/BVPPC probe. */ +#define P5PB_PM2_VENDOR_ID 0x104C +#define P5PB_PM2_PRODUCT_ID 0x3D07 #endif /* _AMIGA_P5PBREG_H_ */ + Index: src/sys/arch/amiga/pci/p5pbvar.h diff -u src/sys/arch/amiga/pci/p5pbvar.h:1.2 src/sys/arch/amiga/pci/p5pbvar.h:1.3 --- src/sys/arch/amiga/pci/p5pbvar.h:1.2 Tue Jan 10 20:29:50 2012 +++ src/sys/arch/amiga/pci/p5pbvar.h Thu Jan 19 00:14:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: p5pbvar.h,v 1.2 2012/01/10 20:29:50 rkujawa Exp $ */ +/* $NetBSD: p5pbvar.h,v 1.3 2012/01/19 00:14:08 rkujawa Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -45,17 +45,23 @@ struct p5pb_autoconf_entry { struct p5pb_softc { device_t sc_dev; - volatile char *ba; + struct p5bus_attach_args *p5baa; + struct bus_space_tag pci_conf_area; struct bus_space_tag pci_mem_area; struct bus_space_tag pci_io_area; struct amiga_pci_chipset apc; - /* list of preconfigured BARs */ - TAILQ_HEAD(, p5pb_autoconf_entry) auto_bars; + uint8_t bridge_type; +#define P5PB_BRIDGE_CVPPC 1 +#define P5PB_BRIDGE_GREX1200 2 +#define P5PB_BRIDGE_GREX4000 3 - bool(*p5pb_bus_map)(struct p5pb_softc *); + uint32_t pci_mem_lowest; + uint32_t pci_mem_highest; + /* list of preconfigured BARs */ + TAILQ_HEAD(, p5pb_autoconf_entry) auto_bars; }; #endif /* _AMIGA_P5PBVAR_H_ */