summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2001-04-09 05:36:18 +0000
committerJason Wright <jason@cvs.openbsd.org>2001-04-09 05:36:18 +0000
commite03c39280d31c393d167185608d8bdfcdbf7f51e (patch)
tree1b14ffab1bdca4f1cfe756c05bb9e6310c49dfad /sys/dev/pci
parent382a77afe89d4cf7d0d3374edcf0a516a0dc467f (diff)
partial mii support (commented out because the response queue freaks out)
get link status via media status query (unclear how to get speed/duplex this way) fix media command definitions to match documentation update the hostvar index for response queue on successful query
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_txp.c59
-rw-r--r--sys/dev/pci/if_txpreg.h23
2 files changed, 71 insertions, 11 deletions
diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c
index e9628c3cb7a..19cd7e04c5d 100644
--- a/sys/dev/pci/if_txp.c
+++ b/sys/dev/pci/if_txp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_txp.c,v 1.7 2001/04/09 04:09:17 jason Exp $ */
+/* $OpenBSD: if_txp.c,v 1.8 2001/04/09 05:36:16 jason Exp $ */
/*
* Copyright (c) 2001
@@ -112,6 +112,8 @@ int txp_response __P((struct txp_softc *, u_int32_t, u_int16_t,
void txp_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
int txp_ifmedia_upd __P((struct ifnet *));
+int txp_miibus_readreg __P((struct device *, int, int));
+void txp_miibus_writereg __P((struct device *, int, int, int));
struct cfattach txp_ca = {
sizeof(struct txp_softc), txp_probe, txp_attach,
@@ -232,6 +234,12 @@ txp_attach(parent, self, aux)
txp_command(sc, TXP_CMD_XCVR_SELECT, TXP_XCVR_AUTO, 0, 0,
NULL, NULL, NULL, 0);
+#if 0
+ sc->sc_mii.mii_ifp = ifp;
+ sc->sc_mii.mii_readreg = txp_miibus_readreg;
+ sc->sc_mii.mii_writereg = txp_miibus_writereg;
+ mii_phy_probe(self, &sc->sc_mii, 0xffffffff);
+#endif
ifp->if_softc = sc;
ifp->if_mtu = ETHERMTU;
@@ -904,6 +912,11 @@ txp_command(sc, id, in1, in2, in3, out1, out2, out3, wait)
if (out3 != NULL)
*out3 = rsp->rsp_par3;
+ idx += sizeof(struct txp_rsp_desc);
+ if (idx == sc->sc_rspring.size)
+ idx = 0;
+ sc->sc_rspring.lastwrite = hv->hv_resp_read_idx = idx;
+
return (0);
}
@@ -1035,6 +1048,7 @@ txp_ifmedia_sts(ifp, ifmr)
struct ifmediareq *ifmr;
{
struct txp_softc *sc = ifp->if_softc;
+ u_int16_t p1;
switch (sc->sc_xcvr) {
case TXP_XCVR_10_HDX:
@@ -1057,6 +1071,45 @@ txp_ifmedia_sts(ifp, ifmr)
break;
}
- /* XXX determine real speed/duplex/link status */
- ifmr->ifm_status &= ~IFM_AVALID;
+ /* XXX determine real speed/duplex status */
+
+ if (txp_command(sc, TXP_CMD_MEDIA_STATUS_READ, 0, 0, 0,
+ &p1, NULL, NULL, 1))
+ ifmr->ifm_status &= ~IFM_AVALID;
+ else {
+ ifmr->ifm_status |= IFM_AVALID;
+ if ((p1 & TXP_MEDIA_NOLINK) == 0)
+ ifmr->ifm_status |= IFM_ACTIVE;
+ }
+}
+
+void
+txp_miibus_writereg(self, phy, reg, val)
+ struct device *self;
+ int phy, reg, val;
+{
+ struct txp_softc *sc = (struct txp_softc *)self;
+
+ if (phy != 0)
+ return;
+
+ txp_command(sc, TXP_CMD_PHY_MGMT_WRITE, val, reg, 0,
+ NULL, NULL, NULL, 0);
+}
+
+int
+txp_miibus_readreg(self, phy, reg)
+ struct device *self;
+ int phy, reg;
+{
+ struct txp_softc *sc = (struct txp_softc *)self;
+ u_int16_t dat;
+
+ if (phy != 0)
+ return (0);
+
+ if (txp_command(sc, TXP_CMD_PHY_MGMT_READ, 0, reg, 0,
+ &dat, NULL, NULL, 1))
+ return (0);
+ return (dat);
}
diff --git a/sys/dev/pci/if_txpreg.h b/sys/dev/pci/if_txpreg.h
index e08c578b472..23d072d9a9a 100644
--- a/sys/dev/pci/if_txpreg.h
+++ b/sys/dev/pci/if_txpreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_txpreg.h,v 1.8 2001/04/09 04:09:18 jason Exp $ */
+/* $OpenBSD: if_txpreg.h,v 1.9 2001/04/09 05:36:17 jason Exp $ */
/*
* Copyright (c) 2001 Aaron Campbell <aaron@monkey.org>.
@@ -126,8 +126,8 @@
#define TXP_CMD_MEDIA_STATUS_WRITE 0x1c
#define TXP_CMD_NETWORK_DIAGS_READ 0x1d
#define TXP_CMD_NETWORK_DIAGS_WRITE 0x1e
-#define TXP_CMD_POWER_MGMT_EVENT_READ 0x1f
-#define TXP_CMD_POWER_MGMT_EVENT_WRITE 0x20
+#define TXP_CMD_PHY_MGMT_READ 0x1f
+#define TXP_CMD_PHY_MGMT_WRITE 0x20
#define TXP_CMD_VARIABLE_PARAMETER_READ 0x21
#define TXP_CMD_VARIABLE_PARAMETER_WRITE 0x22
#define TXP_CMD_GOTO_SLEEP 0x23
@@ -352,6 +352,12 @@ struct txp_tcpseg_desc {
#define TXP_XCVR_100_FDX 3
#define TXP_XCVR_AUTO 4
+#define TXP_MEDIA_CRC 0x0004 /* crc strip disable */
+#define TXP_MEDIA_CD 0x0010 /* collision detection */
+#define TXP_MEDIA_CS 0x0020 /* carrier sense */
+#define TXP_MEDIA_POL 0x0400 /* polarity reversed */
+#define TXP_MEDIA_NOLINK 0x0800 /* 0 = link, 1 = no link */
+
/*
* boot record (pointers to rings)
*/
@@ -439,18 +445,19 @@ struct txp_rsp_ring {
};
struct txp_softc {
- struct device sc_dev;
- struct arpcom sc_arpcom;
+ struct device sc_dev; /* base device */
+ struct arpcom sc_arpcom; /* ethernet common */
struct txp_hostvar *sc_hostvar;
struct txp_boot_record *sc_boot;
- bus_space_handle_t sc_bh;
- bus_space_tag_t sc_bt;
- bus_dma_tag_t sc_dmat;
+ bus_space_handle_t sc_bh; /* bus handle (regs) */
+ bus_space_tag_t sc_bt; /* bus tag (regs) */
+ bus_dma_tag_t sc_dmat; /* dma tag */
struct txp_cmd_ring sc_cmdring;
struct txp_rsp_ring sc_rspring;
void * sc_ih;
struct timeout sc_tick_tmo;
struct ifmedia sc_ifmedia;
+ mii_data_t sc_mii; /* mii bus */
u_int16_t sc_xcvr;
struct txp_dma_alloc sc_boot_dma, sc_host_dma, sc_zero_dma;
struct txp_dma_alloc sc_rxhiring_dma, sc_rxloring_dma;