summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>1997-04-10 16:33:17 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>1997-04-10 16:33:17 +0000
commitd1c9b3622f16175a3c1add1a58e59a33311ffc90 (patch)
treef1879550c17f7dfb9899d84311372c59cad25b2c
parent4c459afa7bc75884058a78d41baa5055b46c867d (diff)
Add Matrox Mystique
-rw-r--r--sys/dev/pci/if_de.c85
-rw-r--r--sys/dev/pci/ncr.c57
-rw-r--r--sys/dev/pci/pcidevs4
-rw-r--r--sys/dev/pci/pcidevs.h2
-rw-r--r--sys/dev/pci/pcidevs_data.h12
5 files changed, 141 insertions, 19 deletions
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c
index d003209e8b9..21442f2ed15 100644
--- a/sys/dev/pci/if_de.c
+++ b/sys/dev/pci/if_de.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_de.c,v 1.16 1996/12/19 12:49:53 mickey Exp $ */
+/* $OpenBSD: if_de.c,v 1.17 1997/04/10 16:33:05 pefo Exp $ */
/* $NetBSD: if_de.c,v 1.29 1996/10/25 21:33:30 cgd Exp $ */
/*-
@@ -105,6 +105,9 @@
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <machine/bus.h>
#include <machine/intr.h>
+#if defined(__mips__)
+#include <machine/cpu.h>
+#endif
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
@@ -250,7 +253,7 @@ typedef struct {
* but we gone to directly DMA'ing into MBUFs because with 100Mb
* cards the copying is just too much of a hit.
*/
-#if defined(__alpha__)
+#if defined(__alpha__) || defined(__mips__)
#define TULIP_COPY_RXDATA 1
#endif
@@ -268,6 +271,7 @@ typedef enum {
TULIP_DC21140_COGENT_EM100,
TULIP_DC21140_ZNYX_ZX34X,
TULIP_DC21041_GENERIC,
+ TULIP_DC21041_P4032,
TULIP_DC21041_DE450
} tulip_board_t;
@@ -946,6 +950,40 @@ static const tulip_boardsw_t tulip_dc21041_de450_boardsw = {
tulip_dc21041_media_probe,
tulip_dc21041_media_select
};
+
+#if defined(__mips__)
+static void
+tulip_p4032_media_select(
+ tulip_softc_t * const sc)
+{
+ /* This board is AUI only! */
+ sc->tulip_media = TULIP_MEDIA_AUI;
+ sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
+
+ sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_ENHCAPTEFFCT
+ /* |TULIP_CMD_FULLDUPLEX */ |TULIP_CMD_THRSHLD160;
+ TULIP_WRITE_CSR(sc, csr_command, sc->tulip_cmdmode);
+
+ sc->tulip_intrmask |= TULIP_STS_NORMALINTR
+ |TULIP_STS_ABNRMLINTR|TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
+ TULIP_WRITE_CSR(sc, csr_intr, sc->tulip_intrmask);
+
+ TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
+ TULIP_WRITE_CSR(sc, csr_sia_tx_rx, TULIP_DC21041_SIATXRX_AUI);
+ TULIP_WRITE_CSR(sc, csr_sia_general, TULIP_DC21041_SIAGEN_AUI);
+ TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_DC21041_SIACONN_AUI);
+ DELAY(10000); /* Wait 10 millisecs */
+}
+
+
+static const tulip_boardsw_t tulip_p4032_boardsw = {
+ TULIP_DC21041_P4032,
+ "P4032 ",
+ tulip_dc21041_media_probe,
+ tulip_p4032_media_select
+};
+#endif
+
static void
tulip_reset(
@@ -963,11 +1001,11 @@ tulip_reset(
sc->tulip_intrmask = 0;
TULIP_WRITE_CSR(sc, csr_intr, sc->tulip_intrmask);
- TULIP_WRITE_CSR(sc, csr_txlist, vtophys(&sc->tulip_txinfo.ri_first[0]));
- TULIP_WRITE_CSR(sc, csr_rxlist, vtophys(&sc->tulip_rxinfo.ri_first[0]));
+ TULIP_WRITE_CSR(sc, csr_txlist, vtophys(&sc->tulip_txinfo.ri_first[0]) | 0xc0000000);
+ TULIP_WRITE_CSR(sc, csr_rxlist, vtophys(&sc->tulip_rxinfo.ri_first[0]) | 0xc0000000);
TULIP_WRITE_CSR(sc, csr_busmode,
(1 << (TULIP_BURSTSIZE(sc->tulip_unit) + 8))
- |TULIP_BUSMODE_CACHE_ALIGN8
+ |TULIP_BUSMODE_CACHE_ALIGN8|TULIP_BUSMODE_BURSTLEN_8LW /*XXX*/
|(BYTE_ORDER != LITTLE_ENDIAN ? TULIP_BUSMODE_BIGENDIAN : 0));
sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS;
@@ -985,8 +1023,9 @@ tulip_reset(
ri = &sc->tulip_txinfo;
ri->ri_nextin = ri->ri_nextout = ri->ri_first;
ri->ri_free = ri->ri_max;
- for (di = ri->ri_first; di < ri->ri_last; di++)
+ for (di = ri->ri_first; di < ri->ri_last; di++) {
di->d_status = 0;
+ }
/*
* We need to collect all the mbufs were on the
@@ -1069,8 +1108,9 @@ tulip_rx_intr(
if (sc->tulip_rxq.ifq_len < TULIP_RXQ_TARGET)
goto queue_mbuf;
- if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
+ if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER) {
return;
+ }
/*
* It is possible (though improbable unless the BIG_PACKET support
@@ -1080,8 +1120,9 @@ tulip_rx_intr(
while ((((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_RxLASTDESC) == 0) {
if (++eop == ri->ri_last)
eop = ri->ri_first;
- if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
+ if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER) {
return;
+ }
total_len++;
}
@@ -1204,8 +1245,11 @@ tulip_rx_intr(
*/
do {
ri->ri_nextout->d_length1 = TULIP_RX_BUFLEN;
- ri->ri_nextout->d_addr1 = vtophys(mtod(ms, caddr_t));
+ ri->ri_nextout->d_addr1 = vtophys(mtod(ms, caddr_t)) | 0xc0000000;
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
+#if defined(__mips__)
+ R4K_HitFlushDCache(mtod(ms, caddr_t),TULIP_RX_BUFLEN);
+#endif
if (++ri->ri_nextout == ri->ri_last)
ri->ri_nextout = ri->ri_first;
me = ms->m_next;
@@ -1303,10 +1347,13 @@ tulip_start(
ri->ri_nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG
|TULIP_DFLAG_TxSETUPPKT|TULIP_DFLAG_TxWANTINTR;
+#if defined(__mips__)
+ R4K_HitFlushDCache(sc->tulip_setupbuf, sizeof(sc->tulip_setupbuf));
+#endif
if (sc->tulip_flags & TULIP_WANTHASH)
ri->ri_nextout->d_flag |= TULIP_DFLAG_TxHASHFILT;
ri->ri_nextout->d_length1 = sizeof(sc->tulip_setupbuf);
- ri->ri_nextout->d_addr1 = vtophys(sc->tulip_setupbuf);
+ ri->ri_nextout->d_addr1 = vtophys(sc->tulip_setupbuf) | 0xc0000000;
ri->ri_nextout->d_length2 = 0;
ri->ri_nextout->d_addr2 = 0;
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
@@ -1383,13 +1430,16 @@ tulip_start(
nextout = ri->ri_first;
eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
eop->d_status = d_status;
- eop->d_addr1 = vtophys(addr); eop->d_length1 = slen;
+ eop->d_addr1 = vtophys(addr) | 0xc0000000; eop->d_length1 = slen;
} else {
/*
* Fill in second half of descriptor
*/
- eop->d_addr2 = vtophys(addr); eop->d_length2 = slen;
+ eop->d_addr2 = vtophys(addr) | 0xc0000000; eop->d_length2 = slen;
}
+#if defined(__mips__)
+ R4K_HitFlushDCache(addr, slen);
+#endif
d_status = TULIP_DSTS_OWNER;
len -= slen;
addr += slen;
@@ -1641,6 +1691,13 @@ tulip_read_macaddr(
unsigned char tmpbuf[8];
static const u_char testpat[] = { 0xFF, 0, 0x55, 0xAA, 0xFF, 0, 0x55, 0xAA };
+#if defined(__mips__) /* XXX Oh well */
+ if (sc->tulip_chipid == TULIP_DC21041 && sc->tulip_unit == 0 &&
+ pci_ether_hw_addr(sc->tulip_pc, (u_int8_t *)&sc->tulip_hwaddr) == 0) {
+ sc->tulip_boardsw = &tulip_p4032_boardsw;
+ return 0;
+ }
+#endif
if (sc->tulip_chipid == TULIP_DC21040) {
TULIP_WRITE_CSR(sc, csr_enetrom, 1);
for (idx = 0; idx < 32; idx++) {
@@ -2127,6 +2184,10 @@ tulip_initring(
tulip_desc_t *descs,
int ndescs)
{
+#if defined(__mips__)
+ R4K_HitFlushDCache(descs, ndescs * sizeof(tulip_desc_t));
+ descs = (tulip_desc_t *)PHYS_TO_UNCACHED(vtophys(descs));
+#endif
ri->ri_max = ndescs;
ri->ri_first = descs;
ri->ri_last = ri->ri_first + ri->ri_max;
diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c
index b6a56862a89..fda739af708 100644
--- a/sys/dev/pci/ncr.c
+++ b/sys/dev/pci/ncr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr.c,v 1.26 1997/03/03 00:25:03 millert Exp $ */
+/* $OpenBSD: ncr.c,v 1.27 1997/04/10 16:33:08 pefo Exp $ */
/* $NetBSD: ncr.c,v 1.55 1997/01/10 05:57:10 perry Exp $ */
/**************************************************************************
@@ -91,6 +91,7 @@
** (0=asynchronous)
*/
+#define SCSI_NCR_MAX_SYNC 0
#ifndef SCSI_NCR_MAX_SYNC
#define SCSI_NCR_MAX_SYNC (10000)
#endif /* SCSI_NCR_MAX_SYNC */
@@ -218,7 +219,7 @@
#include <dev/pci/ncr_reg.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
-#ifndef __alpha__
+#if !defined __alpha__ && !defined __mips__
#define DELAY(x) delay(x)
#endif
#endif /* __NetBSD__ || __OpenBSD__ */
@@ -1356,7 +1357,7 @@ static void ncr_attach (pcici_t tag, int unit);
#if 0
static char ident[] =
- "\n$OpenBSD: ncr.c,v 1.26 1997/03/03 00:25:03 millert Exp $\n";
+ "\n$OpenBSD: ncr.c,v 1.27 1997/04/10 16:33:08 pefo Exp $\n";
#endif
static const u_long ncr_version = NCR_VERSION * 11
@@ -3120,6 +3121,10 @@ static void ncr_script_copy_and_bind (struct script *script, ncb_p np)
#else /* !(__NetBSD__ || __OpenBSD__) */
np->script = (struct script *)
malloc (sizeof (struct script), M_DEVBUF, M_WAITOK);
+#if defined(__mips__)
+ R4K_HitFlushDCache(np->script, sizeof (struct script));
+ np->script = (struct script *)PHYS_TO_UNCACHED(vtophys(np->script));
+#endif /* __mips__ */
#endif /* __NetBSD__ || __OpenBSD__ */
np->p_script = vtophys(np->script);
@@ -3396,6 +3401,11 @@ ncr_attach(parent, self, aux)
int wide = 0;
u_char rev = pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG) & 0xff;
+#if defined(__mips__)
+ R4K_HitFlushDCache(np, sizeof (struct ncb));
+ np = (struct ncb *)PHYS_TO_UNCACHED(vtophys(np));
+#endif /* __mips__ */
+
printf(": NCR ");
switch (pa->pa_id) {
case NCR_810_ID:
@@ -3533,14 +3543,22 @@ static void ncr_attach (pcici_t config_id, int unit)
np->rv_dcntl = INB (nc_dcntl) | CLSE | PFEN | NOCOM;
np->rv_ctest3 = INB (nc_ctest3);
np->rv_ctest5 = 0;
+#if defined(__mips__)
+ np->rv_scntl3 = 0x24; /* default: 67MHz clock */
+#else
np->rv_scntl3 = 0x13; /* default: 40MHz clock */
+#endif
/*
** Do chip dependent initialization.
*/
np->maxwide = 0;
+#if defined(__mips__)
+ np->ns_sync = 22; /* in units of 4ns */
+#else
np->ns_sync = 25; /* in units of 4ns */
+#endif
np->maxoffs = 8;
/*
@@ -3580,7 +3598,6 @@ static void ncr_attach (pcici_t config_id, int unit)
"succeeded" : "failed");
}
#endif /* NCR_TEKRAM_EEPROM */
- ncr_getclock(np);
break;
}
@@ -3916,6 +3933,14 @@ static INT32 ncr_start (struct scsi_xfer * xp)
**----------------------------------------------------
*/
+#if defined(__mips__)
+ if (xp->data && xp->datalen) {
+ R4K_HitFlushDCache(xp->data, xp->datalen);
+ }
+ R4K_HitFlushDCache(xp->cmd, xp->cmdlen);
+ R4K_HitFlushDCache(&xp->sense, sizeof(struct scsi_sense_data));
+#endif /* __mips__ */
+
oldspl = splbio();
if (!(cp=ncr_get_ccb (np, flags, xp->sc_link->target, xp->sc_link->lun))) {
@@ -4684,11 +4709,14 @@ void ncr_init (ncb_p np, char * msg, u_long code)
OUTB (nc_scid , RRE|np->myaddr);/* host adapter SCSI address */
OUTW (nc_respid, 1ul<<np->myaddr);/* id to respond to */
OUTB (nc_istat , SIGP ); /* Signal Process */
- OUTB (nc_dmode , np->rv_dmode); /* XXX modify burstlen ??? */
+ OUTB (nc_dmode , 0x80 /*np->rv_dmode*/);/* XXX modify burstlen ??? */
OUTB (nc_dcntl , np->rv_dcntl);
OUTB (nc_ctest3, np->rv_ctest3);
OUTB (nc_ctest5, np->rv_ctest5);
OUTB (nc_ctest4, MPEE ); /* enable master parity checking */
+#if defined(__mips__)
+ OUTB (nc_stest1, 0x80 ); /* Disable external SCSI clock */
+#endif
OUTB (nc_stest2, EXT ); /* Extended Sreq/Sack filtering */
OUTB (nc_stest3, TE ); /* TolerANT enable */
OUTB (nc_stime0, 0x0b ); /* HTH = disabled, STO = 0.1 sec. */
@@ -4713,6 +4741,12 @@ void ncr_init (ncb_p np, char * msg, u_long code)
if (SCSI_NCR_MAX_SYNC) {
u_long period;
period =1000000/SCSI_NCR_MAX_SYNC; /* ns = 10e6 / kHz */
+
+ /* Don't negotiate a period that we cant't handle !!! */
+ if(period % np->ns_sync) {
+ period = ((period / np->ns_sync) + 1) * np->ns_sync;
+ }
+
if (period <= 11 * np->ns_sync) {
if (period < 4 * np->ns_sync)
usrsync = np->ns_sync;
@@ -6508,6 +6542,10 @@ static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun)
lp = (lcb_p) malloc (sizeof (struct lcb), M_DEVBUF, M_NOWAIT);
if (!lp) return;
+#if defined(__mips__)
+ R4K_HitFlushDCache(lp, sizeof (struct lcb));
+ lp = (struct lcb *)PHYS_TO_UNCACHED(vtophys(lp));
+#endif /* __mips__ */
/*
** Initialize it
*/
@@ -6546,10 +6584,14 @@ static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun)
** Allocate a ccb
*/
cp = (ccb_p) malloc (sizeof (struct ccb), M_DEVBUF, M_NOWAIT);
-
if (!cp)
return;
+#if defined(__mips__)
+ R4K_HitFlushDCache(cp, sizeof (struct ccb));
+ cp = (struct ccb *)PHYS_TO_UNCACHED(vtophys(cp));
+#endif /* __mips__ */
+
if (DEBUG_FLAGS & DEBUG_ALLOC) {
printf ("new ccb @%p.\n", cp);
}
@@ -6820,6 +6862,9 @@ static int ncr_snooptest (struct ncb* np)
** Set memory and register.
*/
ncr_cache = host_wr;
+#if defined(__mips__)
+ R4K_HitFlushDCache(&ncr_cache, sizeof (ncr_cache));
+#endif /* __mips__ */
OUTL (nc_temp, ncr_wr);
/*
** Start script (exchange values)
diff --git a/sys/dev/pci/pcidevs b/sys/dev/pci/pcidevs
index b2930eb8f0d..6cf0aa0946c 100644
--- a/sys/dev/pci/pcidevs
+++ b/sys/dev/pci/pcidevs
@@ -1,4 +1,4 @@
-$OpenBSD: pcidevs,v 1.16 1997/03/20 20:29:55 chuck Exp $
+$OpenBSD: pcidevs,v 1.17 1997/04/10 16:33:11 pefo Exp $
/* $NetBSD: pcidevs,v 1.20 1996/10/19 13:01:49 jonathan Exp $ */
@@ -543,6 +543,8 @@ product LEADTEK S3_805 0x0000 S3 805
/* Matrox products */
product MATROX ATLAS 0x0518 MGA-2 Atlas PX2085
+product MATROX MILLENIUM 0x0519 MGA-2064 Millenium
+product MATROX MYSTIQUE 0x051a MGA-1064 Mystique
product MATROX IMPRESSION 0x0d10 MGA Impression
/* Mylex products */
diff --git a/sys/dev/pci/pcidevs.h b/sys/dev/pci/pcidevs.h
index e65ced63524..19a7229f822 100644
--- a/sys/dev/pci/pcidevs.h
+++ b/sys/dev/pci/pcidevs.h
@@ -548,6 +548,8 @@
/* Matrox products */
#define PCI_PRODUCT_MATROX_ATLAS 0x0518 /* MGA-2 Atlas PX2085 */
+#define PCI_PRODUCT_MATROX_MILLENIUM 0x0519 /* MGA-2064 Millenium */
+#define PCI_PRODUCT_MATROX_MYSTIQUE 0x051a /* MGA-1064 Mystique */
#define PCI_PRODUCT_MATROX_IMPRESSION 0x0d10 /* MGA Impression */
/* Mylex products */
diff --git a/sys/dev/pci/pcidevs_data.h b/sys/dev/pci/pcidevs_data.h
index bdc50c77fba..3dc89ebd061 100644
--- a/sys/dev/pci/pcidevs_data.h
+++ b/sys/dev/pci/pcidevs_data.h
@@ -531,6 +531,18 @@ struct pci_knowndev pci_knowndevs[] = {
"MGA-2 Atlas PX2085",
},
{
+ PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILLENIUM,
+ 0,
+ "Matrox",
+ "MGA-2064 Millenium",
+ },
+ {
+ PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MYSTIQUE,
+ 0,
+ "Matrox",
+ "MGA-1064 Mystique",
+ },
+ {
PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_IMPRESSION,
0,
"Matrox",