Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/pci Initial commit.
details: https://anonhg.NetBSD.org/src/rev/f13dfda60ed5
branches: trunk
changeset: 487896:f13dfda60ed5
user: soren <soren%NetBSD.org@localhost>
date: Wed Jun 14 16:06:57 2000 +0000
description:
Initial commit.
diffstat:
sys/arch/sgimips/pci/macepci.c | 213 ++++++++++++++++++++++++++++++++++
sys/arch/sgimips/pci/macepcireg.h | 40 ++++++
sys/arch/sgimips/pci/pci_machdep.c | 200 +++++++++++++++++++++++++++++++
sys/arch/sgimips/pci/pciide_machdep.c | 53 ++++++++
4 files changed, 506 insertions(+), 0 deletions(-)
diffs (truncated from 522 to 300 lines):
diff -r 1368318701a3 -r f13dfda60ed5 sys/arch/sgimips/pci/macepci.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sgimips/pci/macepci.c Wed Jun 14 16:06:57 2000 +0000
@@ -0,0 +1,213 @@
+/* $NetBSD: macepci.c,v 1.1 2000/06/14 16:06:57 soren Exp $ */
+
+/*
+ * Copyright (c) 2000 Soren S. Jorvang
+ * 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 for the
+ * NetBSD Project. See http://www.netbsd.org/ for
+ * information about NetBSD.
+ * 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/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/locore.h>
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+
+#include <dev/pci/pcivar.h>
+
+#include <sgimips/dev/macereg.h>
+#include <sgimips/dev/macevar.h>
+
+#ifdef notyet
+#include <sgimips/pci/macepcireg.h>
+#endif
+
+#include "pci.h"
+
+struct macepci_softc {
+ struct device sc_dev;
+
+ struct sgimips_pci_chipset sc_pc;
+};
+
+static int macepci_match(struct device *, struct cfdata *, void *);
+static void macepci_attach(struct device *, struct device *, void *);
+static int macepci_print(void *, const char *);
+pcireg_t macepci_conf_read(pci_chipset_tag_t, pcitag_t, int);
+void macepci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
+int macepci_intr(void *);
+
+struct cfattach macepci_ca = {
+ sizeof(struct macepci_softc), macepci_match, macepci_attach
+};
+
+static int
+macepci_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ return 1;
+}
+
+static void
+macepci_attach(parent, self, aux)
+ struct device *parent;
+ struct device *self;
+ void *aux;
+{
+ struct macepci_softc *sc = (struct macepci_softc *)self;
+ pci_chipset_tag_t pc = &sc->sc_pc;
+ struct mace_attach_args *maa = aux;
+ struct pcibus_attach_args pba;
+ pcitag_t devtag;
+ int rev;
+
+ rev = bus_space_read_4(maa->maa_st, maa->maa_sh, PCI_REV_INFO_R);
+ printf(": rev %d\n", rev);
+
+#if 0
+ mace_intr_establish(maa->maa_intr, IPL_NONE , macepci_intr, sc);
+#endif
+
+ pc->pc_conf_read = macepci_conf_read;
+ pc->pc_conf_write = macepci_conf_write;
+
+ /*
+ * Fixup O2 PCI slot.
+ */
+ devtag = pci_make_tag(0, 0, 3, 0);
+#if 1
+ macepci_conf_write(0, devtag, 0x4, 0x00000007);
+#endif
+#if 1 /* 1 for canuck */
+ macepci_conf_write(0, devtag, 0x10, 0x00001000);
+#endif
+#if 0 /* 1 for hut */
+ macepci_conf_write(0, devtag, 0x18, 0x00000000);
+#endif
+
+#if 1
+ printf("macepci0: ctrl %x\n", *(volatile u_int32_t *)0xbf080008);
+ *(volatile u_int32_t *)0xbf080008 |= 0x000000ff;
+ printf("macepci0: ctrl %x\n", *(volatile u_int32_t *)0xbf080008);
+#endif
+
+#if NPCI > 0
+ memset(&pba, 0, sizeof pba);
+ pba.pba_busname = "pci";
+/*XXX*/ pba.pba_iot = 4;
+/*XXX*/ pba.pba_memt = 2;
+ pba.pba_dmat = &pci_bus_dma_tag;
+ pba.pba_bus = 0;
+ pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
+ PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
+ pba.pba_pc = pc;
+
+ if (rev == 0)
+ pba.pba_flags &= ~PCI_FLAGS_IO_ENABLED; /* Buggy? */
+
+ config_found(self, &pba, macepci_print);
+#endif
+}
+
+
+static int
+macepci_print(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct pcibus_attach_args *pba = aux;
+
+ if (pnp != 0)
+ printf("%s at %s", pba->pba_busname, pnp);
+ else
+ printf(" bus %d", pba->pba_bus);
+
+ return UNCONF;
+}
+
+#define PCI_CFG_ADDR ((volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1f080cf8))
+#define PCI_CFG_DATA ((volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1f080cfc))
+
+pcireg_t
+macepci_conf_read(pc, tag, reg)
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
+ int reg;
+{
+ pcireg_t data;
+
+ /* XXX more generic pci error checking */
+#if 1
+ if ((*(volatile u_int32_t *)0xbf080004 & ~0x00100000) != 6)
+ panic("pcierr: %x %x", *(volatile u_int32_t *)0xbf080004,
+ *(volatile u_int32_t *)0xbf080000);
+#endif
+ *PCI_CFG_ADDR = 0x80000000 | tag | reg;
+ data = *PCI_CFG_DATA;
+ *PCI_CFG_ADDR = 0;
+
+ if (*(volatile u_int32_t *)0xbf080004 & 0xf0000000) {
+ *(volatile u_int32_t *)0xbf080004 = 0;
+ return (pcireg_t)-1;
+ }
+
+ return data;
+}
+
+void
+macepci_conf_write(pc, tag, reg, data)
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
+ int reg;
+ pcireg_t data;
+{
+ /* XXX O2 soren */
+ if (tag == 0)
+ return;
+
+ *PCI_CFG_ADDR = 0x80000000 | tag | reg;
+ *PCI_CFG_DATA = data;
+ *PCI_CFG_ADDR = 0;
+}
+
+
+/*
+ * Handle PCI error interrupts.
+ */
+int
+macepci_intr(arg)
+ void *arg;
+{
+
+ return 0;
+}
diff -r 1368318701a3 -r f13dfda60ed5 sys/arch/sgimips/pci/macepcireg.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sgimips/pci/macepcireg.h Wed Jun 14 16:06:57 2000 +0000
@@ -0,0 +1,40 @@
+/* $NetBSD: macepcireg.h,v 1.1 2000/06/14 16:06:58 soren Exp $ */
+
+/*
+ * Copyright (c) 2000 Soren S. Jorvang. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+#define PCI_ERROR_ADDR 0x0000
+#define PCI_ERROR_FLAGS 0x0004
+#define PCI_CONTROL 0x0008
+#define PCI_REV_INFO_R 0x000c
+#define PCI_FLUSH_W 0x000c
+#define PCI_CONFIG_ADDR 0x0cf8
+#define PCI_CONFIG_DATA 0x0cfc
+#define PCI_LOW_MEMORY 0x1a000000
+#define PCI_LOW_IO 0x18000000
+#define PCI_NATIVE_VIEW 0x40000000
+#define PCI_IO 0x80000000
+#define PCI_HI_MEMORY 0x280000000
+#define PCI_HI_IO 0x100000000
diff -r 1368318701a3 -r f13dfda60ed5 sys/arch/sgimips/pci/pci_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sgimips/pci/pci_machdep.c Wed Jun 14 16:06:57 2000 +0000
@@ -0,0 +1,200 @@
+/* $NetBSD: pci_machdep.c,v 1.1 2000/06/14 16:06:59 soren Exp $ */
+
+/*
+ * Copyright (c) 2000 Soren S. Jorvang
+ * 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 for the
+ * NetBSD Project. See http://www.netbsd.org/ for
+ * information about NetBSD.
+ * 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/types.h>
Home |
Main Index |
Thread Index |
Old Index