summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>1998-08-07 16:48:20 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>1998-08-07 16:48:20 +0000
commit53796aa2246dd1e12da7ecff86653af747b67da4 (patch)
tree0516b8d9016ab0aa8c330ec65e98f1ce26c3c285 /sys
parentc87fea89216b5ed984732ff34c2a2e8009ea517c (diff)
com.c needs to know about mem mapped ports in ppc systems.
ncr.c and if_de.c needs some hooks for systems with ncr and dec ether chips on the motherboard that runs on odd clocks and doesn't support a srom. srom is emulated in machine dependent code. big endian support for ncr and dec ether finished. the 21040 have some more coding requirements if it is to run BE since it does not have the descriptor endian swap configuration bit.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/com.c8
-rw-r--r--sys/dev/pci/if_de.c107
-rw-r--r--sys/dev/pci/if_devar.h27
-rw-r--r--sys/dev/pci/ncr.c16
4 files changed, 125 insertions, 33 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 5b614174dad..a5097188e87 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.38 1998/02/23 11:41:24 downsj Exp $ */
+/* $OpenBSD: com.c,v 1.39 1998/08/07 16:48:14 pefo Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*-
@@ -1608,7 +1608,11 @@ comcnprobe(cp)
#ifdef arc
bus_space_tag_t iot = &arc_bus_io;
#else
- bus_space_tag_t iot = 0;
+#ifdef power4e
+ bus_space_tag_t iot = &p4e_isa_io;
+#else
+ bus_space_tag_t iot = 0;
+#endif
#endif
bus_space_handle_t ioh;
int found;
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c
index b91d47b8bf0..f024447b447 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.31 1998/05/28 20:25:51 deraadt Exp $ */
+/* $OpenBSD: if_de.c,v 1.32 1998/08/07 16:48:16 pefo Exp $ */
/* $NetBSD: if_de.c,v 1.45 1997/06/09 00:34:18 thorpej Exp $ */
/*-
@@ -1048,6 +1048,16 @@ tulip_21041_mediainfo_init(
}
static void
+tulip_21041_media_noprobe(
+ tulip_softc_t * const sc)
+{
+ sc->tulip_if.if_baudrate = 10000000;
+ sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_ENHCAPTEFFCT
+ |TULIP_CMD_THRSHLD160|TULIP_CMD_BACKOFFCTR;
+ sc->tulip_intrmask |= TULIP_STS_LINKPASS;
+}
+
+static void
tulip_21041_media_probe(
tulip_softc_t * const sc)
{
@@ -1219,6 +1229,13 @@ static const tulip_boardsw_t tulip_21041_boardsw = {
tulip_21041_media_poll
};
+static const tulip_boardsw_t tulip_21041np_boardsw = {
+ TULIP_21041_GENERIC,
+ tulip_21041_media_noprobe,
+ tulip_media_select,
+ tulip_21041_media_poll
+};
+
static const tulip_phy_attr_t tulip_mii_phy_attrlist[] = {
{ 0x20005c00, 0, /* 08-00-17 */
{
@@ -2772,9 +2789,15 @@ tulip_read_macaddr(
sc->tulip_boardsw = &tulip_21140_eb_boardsw;
}
-#ifdef powerpc
-/*XXX This should be fixed in some other way. Right now we need someting. */
- pci_ether_hw_addr(sc->tulip_pc, (u_char *)(&sc->tulip_rombuf));
+#ifdef NEED_PCI_ETHER_HW_ADDR_FUNC
+ if(pci_ether_hw_addr(sc->tulip_pc, (u_char *)(&sc->tulip_rombuf),
+ sc->tulip_pci_busno, sc->tulip_pci_devno)) {
+ if(sc->tulip_boardsw == &tulip_21041_boardsw)
+ sc->tulip_boardsw = &tulip_21041np_boardsw;
+ }
+ else {
+ tulip_srom_read(sc);
+ }
#else
tulip_srom_read(sc);
#endif
@@ -3068,7 +3091,7 @@ tulip_addr_filter(
while (enm != NULL) {
if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
hash = tulip_mchash(enm->enm_addrlo);
- sp[hash >> 4] |= 1 << (hash & 0xF);
+ sp[hash >> 4] |= FILT_BO(1 << (hash & 0xF));
} else {
sc->tulip_flags |= TULIP_ALLMULTI;
sc->tulip_flags &= ~(TULIP_WANTHASHONLY|TULIP_WANTHASHPERFECT);
@@ -3082,14 +3105,14 @@ tulip_addr_filter(
*/
if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
hash = tulip_mchash(etherbroadcastaddr);
- sp[hash >> 4] |= 1 << (hash & 0xF);
+ sp[hash >> 4] |= FILT_BO(1 << (hash & 0xF));
if (sc->tulip_flags & TULIP_WANTHASHONLY) {
hash = tulip_mchash(sc->tulip_enaddr);
- sp[hash >> 4] |= 1 << (hash & 0xF);
+ sp[hash >> 4] |= FILT_BO(1 << (hash & 0xF));
} else {
- sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0];
- sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1];
- sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2];
+ sp[39] = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[0]);
+ sp[40] = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[1]);
+ sp[41] = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[2]);
}
}
}
@@ -3103,9 +3126,9 @@ tulip_addr_filter(
ETHER_FIRST_MULTI(step, TULIP_ETHERCOM(sc), enm);
for (; enm != NULL; idx++) {
if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
- *sp++ = ((u_int16_t *) enm->enm_addrlo)[0];
- *sp++ = ((u_int16_t *) enm->enm_addrlo)[1];
- *sp++ = ((u_int16_t *) enm->enm_addrlo)[2];
+ *sp++ = FILT_BO(((u_int16_t *) enm->enm_addrlo)[0]);
+ *sp++ = FILT_BO(((u_int16_t *) enm->enm_addrlo)[1]);
+ *sp++ = FILT_BO(((u_int16_t *) enm->enm_addrlo)[2]);
} else {
sc->tulip_flags |= TULIP_ALLMULTI;
break;
@@ -3116,17 +3139,17 @@ tulip_addr_filter(
* Add the broadcast address.
*/
idx++;
- *sp++ = 0xFFFF;
- *sp++ = 0xFFFF;
- *sp++ = 0xFFFF;
+ *sp++ = FILT_BO(0xFFFF);
+ *sp++ = FILT_BO(0xFFFF);
+ *sp++ = FILT_BO(0xFFFF);
}
/*
* Pad the rest with our hardware address
*/
for (; idx < 16; idx++) {
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2];
+ *sp++ = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[0]);
+ *sp++ = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[1]);
+ *sp++ = FILT_BO(((u_int16_t *) sc->tulip_enaddr)[2]);
}
}
#if defined(IFF_ALLMULTI)
@@ -3166,11 +3189,19 @@ tulip_reset(
TULIP_CSR_WRITE(sc, csr_txlist, TULIP_KVATOPHYS(sc, &sc->tulip_txinfo.ri_first[0]));
TULIP_CSR_WRITE(sc, csr_rxlist, TULIP_KVATOPHYS(sc, &sc->tulip_rxinfo.ri_first[0]));
+#ifdef powerpc
+ TULIP_CSR_WRITE(sc, csr_busmode,
+ (4 << 2) /* Descriptor skip length */
+ |TULIP_BUSMODE_CACHE_ALIGN8
+ |TULIP_BUSMODE_READMULTIPLE
+ |(BYTE_ORDER != LITTLE_ENDIAN ? (TULIP_BUSMODE_DESC_BIGENDIAN) : 0));
+#else
TULIP_CSR_WRITE(sc, csr_busmode,
(1 << (TULIP_BURSTSIZE(sc->tulip_unit) + 8))
|TULIP_BUSMODE_CACHE_ALIGN8
|TULIP_BUSMODE_READMULTIPLE
- |(BYTE_ORDER != LITTLE_ENDIAN ? TULIP_BUSMODE_BIGENDIAN : 0));
+ |(BYTE_ORDER != LITTLE_ENDIAN ? TULIP_BUSMODE_DESC_BIGENDIAN : 0));
+#endif
sc->tulip_txtimer = 0;
sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS;
@@ -3515,6 +3546,9 @@ tulip_rx_intr(
ri->ri_nextout->d_length1 = TULIP_RX_BUFLEN;
ri->ri_nextout->d_addr1 = TULIP_KVATOPHYS(sc, mtod(ms, caddr_t));
ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
+#if defined(__mips__)
+ pci_sync_cache(sc->tulip_pc, (vm_offset_t)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;
@@ -4100,6 +4134,9 @@ tulip_txput(
eop->d_addr2 = TULIP_KVATOPHYS(sc, addr);
eop->d_length2 = slen;
}
+#if defined(__mips__)
+ pci_sync_cache(sc->tulip_pc, (vm_offset_t)addr, slen);
+#endif
d_status = TULIP_DSTS_OWNER;
len -= slen;
addr += slen;
@@ -4238,6 +4275,9 @@ tulip_txput_setup(
*/
sc->tulip_flags ^= TULIP_WANTSETUP|TULIP_DOINGSETUP;
ri->ri_free--;
+#if defined(__mips__)
+ pci_sync_cache(sc->tulip_pc, (vm_offset_t)sc->tulip_setupbuf, sizeof(sc->tulip_setupbuf));
+#endif
nextout = ri->ri_nextout;
nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG
@@ -4738,6 +4778,33 @@ tulip_initring(
tulip_desc_t *descs,
int ndescs)
{
+#if defined(__mips__)
+ tulip_desc_t *xdesc = descs;
+ /*
+ * Someone moved the descriptors into the softc struct.
+ * Avoid cache line conflicts by aligning on cache line.
+ */
+ descs = (tulip_desc_t *)(roundup((int)descs, 16));
+ if(xdesc != descs) {
+ ndescs--;
+ }
+ pci_sync_cache(sc->tulip_pc, (vm_offset_t)descs, ndescs * sizeof(tulip_desc_t));
+ descs = (tulip_desc_t *)TULIP_KVATOPHYS(sc, descs);
+ descs = (tulip_desc_t *)PHYS_TO_UNCACHED((int)descs & 0x3fffffff);
+#endif
+#ifdef PPC_MPC106_BUG
+ /*
+ * This is a workaround for the powerpc MPC106 chip not snooping
+ * accesses to the descriptor area correctly.
+ */
+ tulip_desc_t *xdesc = descs;
+ xdesc = (tulip_desc_t *)(roundup((int)descs, 32) - 4);
+ if(xdesc < descs) {
+ ndescs--;
+ xdesc++;
+ }
+ descs = xdesc;
+#endif
ri->ri_max = ndescs;
ri->ri_first = descs;
ri->ri_last = ri->ri_first + ri->ri_max;
diff --git a/sys/dev/pci/if_devar.h b/sys/dev/pci/if_devar.h
index aad577054e5..c3d07c62bfa 100644
--- a/sys/dev/pci/if_devar.h
+++ b/sys/dev/pci/if_devar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_devar.h,v 1.5 1997/11/16 07:41:27 millert Exp $ */
+/* $OpenBSD: if_devar.h,v 1.6 1998/08/07 16:48:18 pefo Exp $ */
/* $NetBSD: if_devar.h,v 1.13 1997/06/08 18:46:36 thorpej Exp $ */
/*-
@@ -87,9 +87,12 @@ typedef volatile u_int32_t *tulip_csrptr_t;
/*
* Swap macro to access certain data types.
*/
-#if BYTE_ORDER == BIG_ENDIAN
+#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
+__inline__ static u_int32_t FILT_BO(u_int32_t);
+__inline__ static u_int32_t DESC_BO(u_int32_t);
+
__inline__ static u_int32_t
-FILT_SWAP(x)
+FILT_BO(x)
u_int32_t x;
{
u_int32_t s;
@@ -98,8 +101,22 @@ FILT_SWAP(x)
s = s << 16;
return s;
}
+
+__inline__ static u_int32_t
+DESC_BO(x)
+ u_int32_t x;
+{
+ u_int32_t s;
+
+ s = x;
+ x = (((s) >> 24) | (((s) >> 8) & 0xff00) |
+ ((s) << 24) | (((s) & 0xff00) << 8));
+ return x;
+}
+
#else
-#define FILT_SWAP(x) (x)
+#define FILT_BO(x) (x)
+#define DESC_BO(x) (x)
#endif
/*
@@ -178,7 +195,7 @@ typedef struct {
* architecture which can't handle unaligned accesses) because with
* 100Mb/s cards the copying is just too much of a hit.
*/
-#if defined(__alpha__)
+#if defined(__alpha__) || defined(__mips__)
#define TULIP_COPY_RXDATA 1
#endif
diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c
index 4dcb9dd84c4..9fea3bf6a75 100644
--- a/sys/dev/pci/ncr.c
+++ b/sys/dev/pci/ncr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr.c,v 1.40 1998/07/21 07:16:37 downsj Exp $ */
+/* $OpenBSD: ncr.c,v 1.41 1998/08/07 16:48:19 pefo Exp $ */
/* $NetBSD: ncr.c,v 1.63 1997/09/23 02:39:15 perry Exp $ */
/**************************************************************************
@@ -1465,7 +1465,7 @@ static void ncr_attach (pcici_t tag, int unit);
#if 0
static char ident[] =
- "\n$OpenBSD: ncr.c,v 1.40 1998/07/21 07:16:37 downsj Exp $\n";
+ "\n$OpenBSD: ncr.c,v 1.41 1998/08/07 16:48:19 pefo Exp $\n";
#endif
static const u_long ncr_version = NCR_VERSION * 11
@@ -3838,12 +3838,16 @@ static void ncr_attach (pcici_t config_id, int unit)
}
np->maxwide = np->features & FE_WIDE ? 1 : 0;
-#if defined(__mips__) /* XXX FIXME - This is gross XXX */
- np->clock_khz = 66000;
- np->clock_khz = 48000;
+#ifdef NEED_PCI_SCSI_CLOCK_FUNC
+ {
+ int b, d, f;
+ pci_decompose_tag(pc, pa->pa_tag, &b, &d, &f); \
+ if((np->clock_khz = pci_scsi_clock(pc, b, d)) == 0)
+ np->clock_khz = np->features & FE_CLK80 ? 80000 : 40000;
+ }
#else
np->clock_khz = np->features & FE_CLK80 ? 80000 : 40000;
-#endif /*__mips__*/
+#endif
if (np->features & FE_QUAD) np->multiplier = 4;
else if (np->features & FE_DBLR) np->multiplier = 2;
else np->multiplier = 1;