Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/dev Add ofppb to match ofpci.
details: https://anonhg.NetBSD.org/src/rev/04ebf969b1d3
branches: trunk
changeset: 526588:04ebf969b1d3
user: eeh <eeh%NetBSD.org@localhost>
date: Mon May 06 19:40:20 2002 +0000
description:
Add ofppb to match ofpci.
diffstat:
sys/arch/sparc64/dev/ofppb.c | 143 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 143 insertions(+), 0 deletions(-)
diffs (147 lines):
diff -r 124c272b76fd -r 04ebf969b1d3 sys/arch/sparc64/dev/ofppb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc64/dev/ofppb.c Mon May 06 19:40:20 2002 +0000
@@ -0,0 +1,143 @@
+/* $NetBSD: ofppb.c,v 1.1 2002/05/06 19:40:20 eeh Exp $ */
+
+/*
+ * Copyright (c) 2002 Eduardo Horvath. All rights reserved.
+ * Copyright (c) 1996, 1998 Christopher G. Demetriou. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ofppb.c,v 1.1 2002/05/06 19:40:20 eeh Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
+
+#include <sparc64/dev/ofpcivar.h>
+
+int ofppbmatch __P((struct device *, struct cfdata *, void *));
+void ofppbattach __P((struct device *, struct device *, void *));
+
+struct cfattach ofppb_ca = {
+ sizeof(struct device), ofppbmatch, ofppbattach
+};
+
+int ofppbprint __P((void *, const char *pnp));
+
+int
+ofppbmatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct pci_attach_args *pa = aux;
+
+ /*
+ * Check the ID register to see that it's a PCI bridge.
+ * If it is, we assume that we can deal with it; it _should_
+ * work in a standardized way...
+ */
+ if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
+ PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_PCI)
+ return (1);
+
+ return (0);
+}
+
+void
+ofppbattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct pci_attach_args *pa = aux;
+ pci_chipset_tag_t pc = pa->pa_pc;
+ struct ofpcibus_attach_args pba;
+ pcireg_t busdata;
+ char devinfo[256];
+
+ pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
+ printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
+
+ busdata = pci_conf_read(pc, pa->pa_tag, PPB_REG_BUSINFO);
+
+ if (PPB_BUSINFO_SECONDARY(busdata) == 0) {
+ printf("%s: not configured by system firmware\n",
+ self->dv_xname);
+ return;
+ }
+
+#if 0
+ /*
+ * XXX can't do this, because we're not given our bus number
+ * (we shouldn't need it), and because we've no way to
+ * decompose our tag.
+ */
+ /* sanity check. */
+ if (pa->pa_bus != PPB_BUSINFO_PRIMARY(busdata))
+ panic("ofppbattach: bus in tag (%d) != bus in reg (%d)",
+ pa->pa_bus, PPB_BUSINFO_PRIMARY(busdata));
+#endif
+
+ /*
+ * Attach the PCI bus than hangs off of it.
+ *
+ * XXX Don't pass-through Memory Read Multiple. Should we?
+ * XXX Consult the spec...
+ */
+ pba.opba_pba.pba_busname = "ofpci"; /* XXX should be pci_ppb attachment */
+ pba.opba_pba.pba_iot = pa->pa_iot;
+ pba.opba_pba.pba_memt = pa->pa_memt;
+ pba.opba_pba.pba_dmat = pa->pa_dmat;
+ pba.opba_pba.pba_pc = pc;
+ pba.opba_pba.pba_flags = pa->pa_flags & ~PCI_FLAGS_MRM_OKAY;
+ pba.opba_pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata);
+ pba.opba_pba.pba_intrswiz = pa->pa_intrswiz;
+ pba.opba_pba.pba_intrtag = pa->pa_intrtag;
+ pba.opba_node = PCITAG_NODE(pa->pa_tag);
+
+ config_found(self, &pba, ofppbprint);
+}
+
+int
+ofppbprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct pcibus_attach_args *pba = aux;
+
+ /* only PCIs can attach to PPBs; easy. */
+ if (pnp)
+ printf("pci at %s", pnp);
+ printf(" bus %d", pba->pba_bus);
+ return (UNCONF);
+}
Home |
Main Index |
Thread Index |
Old Index