Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 12:03 PM
Martin Reindl
 
Posts: n/a
Default Re: MII sm(4)

Martin Reindl <mreindl@catai.org> wrote:

> Anyone still using sm(4)/SMC91C9x-based ethernet cards out there? I'm
> also interested if the sm(4) ISA attachment works, see sm(4) (add 'sm0
> at isa? port 0x300 irq 10 ' to GENERIC if you happen to have one).
>
> Regardless if ISA or PCMCIA, i would appreciate feedback on this diff
> adding support for MII to sm(4). Reports can go directly to me, thanks.


Better diff. No one running sm(4) these days?

Index: arch/i386/conf/GENERIC
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.464
diff -u -p -r1.464 GENERIC
--- arch/i386/conf/GENERIC 16 Jan 2006 20:26:46 -0000 1.464
+++ arch/i386/conf/GENERIC 19 Jan 2006 13:03:19 -0000
@@ -417,6 +417,7 @@ lc0 at isa? port 0x200 # DEC EtherWork
lc1 at isa? port 0x280 # DEC EtherWorks
le0 at isa? port 0x360 irq 15 drq 6 # IsoLan, NE2100, and DEPCA
ex0 at isa? port 0x320 irq 5 # Intel EtherExpress PRO/10
+sm0 at isa? port 0x300 irq 10 # SMC 91cxx-based ethernet
#tr0 at isa? port 0xa20 iomem 0xd8000 # IBM TROPIC based Token-Ring
#tr1 at isa? port 0xa24 iomem 0xd0000 # IBM TROPIC based Token-Ring
#tr* at isa? # 3COM TROPIC based Token-Ring
Index: conf/files
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/conf/files,v
retrieving revision 1.362
diff -u -p -r1.362 files
--- conf/files 14 Jan 2006 19:04:14 -0000 1.362
+++ conf/files 19 Jan 2006 13:03:23 -0000
@@ -256,7 +256,7 @@ device dc: ether, ifnet, ifmedia, mii
file dev/ic/dc.c dc

# SMC 91Cxx Ethernet Controller
-device sm: ether, ifnet, ifmedia
+device sm: ether, ifnet, ifmedia, mii, mii_bitbang
file dev/ic/smc91cxx.c sm

# SMC 83C170 EPIC/100 Fast Ethernet Controller
Index: dev/ic/smc91cxx.c
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/dev/ic/smc91cxx.c,v
retrieving revision 1.21
diff -u -p -r1.21 smc91cxx.c
--- dev/ic/smc91cxx.c 8 Jun 2005 17:03:00 -0000 1.21
+++ dev/ic/smc91cxx.c 19 Jan 2006 13:03:24 -0000
@@ -86,6 +86,7 @@
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/device.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
@@ -112,9 +113,20 @@
#include <net/bpf.h>
#endif

+#include <dev/mii/mii.h>
+#include <dev/mii/miivar.h>
+#include <dev/mii/mii_bitbang.h>
+
#include <dev/ic/smc91cxxreg.h>
#include <dev/ic/smc91cxxvar.h>

+#ifndef __BUS_SPACE_HAS_STREAM_METHODS
+#define bus_space_write_multi_stream_2 bus_space_write_multi_2
+#define bus_space_write_multi_stream_4 bus_space_write_multi_4
+#define bus_space_read_multi_stream_2 bus_space_read_multi_2
+#define bus_space_read_multi_stream_4 bus_space_read_multi_4
+#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
+
/* XXX Hardware padding doesn't work yet(?) */
#define SMC91CXX_SW_PAD

@@ -123,11 +135,11 @@ const char *smc91cxx_idstrs[] = {
NULL, /* 1 */
NULL, /* 2 */
"SMC91C90/91C92", /* 3 */
- "SMC91C94", /* 4 */
+ "SMC91C94/91C96", /* 4 */
"SMC91C95", /* 5 */
NULL, /* 6 */
"SMC91C100", /* 7 */
- NULL, /* 8 */
+ "SMC91C100FD", /* 8 */
NULL, /* 9 */
NULL, /* 10 */
NULL, /* 11 */
@@ -144,10 +156,34 @@ const int smc91cxx_media[] = {
};
#define NSMC91CxxMEDIA (sizeof(smc91cxx_media) / sizeof(smc91cxx_media[0]))

+/*
+ * MII bit-bang glue.
+ */
+u_int32_t smc91cxx_mii_bitbang_read(struct device *);
+void smc91cxx_mii_bitbang_write(struct device *, u_int32_t);
+
+const struct mii_bitbang_ops smc91cxx_mii_bitbang_ops = {
+ smc91cxx_mii_bitbang_read,
+ smc91cxx_mii_bitbang_write,
+ {
+ MR_MDO, /* MII_BIT_MDO */
+ MR_MDI, /* MII_BIT_MDI */
+ MR_MCLK, /* MII_BIT_MDC */
+ MR_MDOE, /* MII_BIT_DIR_HOST_PHY */
+ 0, /* MII_BIT_DIR_PHY_HOST */
+ }
+};
+
struct cfdriver sm_cd = {
NULL, "sm", DV_IFNET
};

+/* MII callbacks */
+int smc91cxx_mii_readreg(struct device *, int, int);
+void smc91cxx_mii_writereg(struct device *, int, int, int);
+void smc91cxx_statchg(struct device *);
+void smc91cxx_tick(void *);
+
int smc91cxx_mediachange(struct ifnet *);
void smc91cxx_mediastatus(struct ifnet *, struct ifmediareq *);

@@ -160,9 +196,6 @@ void smc91cxx_resume(struct smc91cxx_sof
void smc91cxx_watchdog(struct ifnet *);
int smc91cxx_ioctl(struct ifnet *, u_long, caddr_t);

-int smc91cxx_enable(struct smc91cxx_softc *);
-void smc91cxx_disable(struct smc91cxx_softc *);
-
static __inline int ether_cmp(void *, void *);
static __inline int
ether_cmp(va, vb)
@@ -183,25 +216,31 @@ smc91cxx_attach(sc, myea)
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
+ struct ifmedia *ifm = &sc->sc_mii.mii_media;
+ u_int32_t miicapabilities;
u_int16_t tmp;
int i, aui;
-#ifdef SMC_DEBUG
const char *idstr;
-#endif

/* Make sure the chip is stopped. */
smc91cxx_stop(sc);

-#ifdef SMC_DEBUG
SMC_SELECT_BANK(sc, 3);
tmp = bus_space_read_2(bst, bsh, REVISION_REG_W);
- idstr = smc91cxx_idstrs[RR_ID(tmp)];
- printf("%s: ", sc->sc_dev.dv_xname);
+ sc->sc_chipid = RR_ID(tmp);
+ /* check magic number */
+ if ((tmp & BSR_DETECT_MASK) != BSR_DETECT_VALUE) {
+ idstr = NULL;
+ printf("%s: invalid BSR 0x%04x\n", sc->sc_dev.dv_xname, tmp);
+ } else
+ idstr = smc91cxx_idstrs[RR_ID(tmp)];
+#ifdef SMC_DEBUG
+ printf("\n%s: ", sc->sc_dev.dv_xname);
if (idstr != NULL)
printf("%s, ", idstr);
else
- printf("unknown chip id %d, ", RR_ID(tmp));
- printf("revision %d\n", RR_REV(tmp));
+ printf("unknown chip id %d, ", sc->sc_chipid);
+ printf("revision %d", RR_REV(tmp));
#endif

/* Read the station address from the chip. */
@@ -216,13 +255,7 @@ smc91cxx_attach(sc, myea)
bcopy(myea, sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN);
}

- printf(": address %s, ",
- ether_sprintf(sc->sc_arpcom.ac_enaddr));
-
- /* ..and default media. */
- tmp = bus_space_read_2(bst, bsh, CONFIG_REG_W);
- printf("utp/aui (default %s)\n", (aui = (tmp & CR_AUI_SELECT)) ?
- "aui" : "utp");
+ printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));

/* Initialize the ifnet structure. */
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
@@ -238,16 +271,67 @@ smc91cxx_attach(sc, myea)
if_attach(ifp);
ether_ifattach(ifp);

- /* Initialize the media structures. */
- ifmedia_init(&sc->sc_media, 0, smc91cxx_mediachange,
- smc91cxx_mediastatus);
- for (i = 0; i < NSMC91CxxMEDIA; i++)
- ifmedia_add(&sc->sc_media, smc91cxx_media[i], 0, NULL);
- ifmedia_set(&sc->sc_media, IFM_ETHER | (aui ? IFM_10_5 : IFM_10_T));
+ /*
+ * Initialize our media structures and MII info. We will
+ * probe the MII if we are on the SMC91Cxx
+ */
+ sc->sc_mii.mii_ifp = ifp;
+ sc->sc_mii.mii_readreg = smc91cxx_mii_readreg;
+ sc->sc_mii.mii_writereg = smc91cxx_mii_writereg;
+ sc->sc_mii.mii_statchg = smc91cxx_statchg;
+ ifmedia_init(ifm, 0, smc91cxx_mediachange, smc91cxx_mediastatus);
+
+ SMC_SELECT_BANK(sc, 1);
+ tmp = bus_space_read_2(bst, bsh, CONFIG_REG_W);
+
+ miicapabilities = BMSR_MEDIAMASK|BMSR_ANEG;
+ switch (sc->sc_chipid) {
+ case CHIP_91100:
+ /*
+ * The 91100 does not have full-duplex capabilities,
+ * even if the PHY does.
+ */
+ miicapabilities &= ~(BMSR_100TXFDX | BMSR_10TFDX);
+ case CHIP_91100FD:
+ if (tmp & CR_MII_SELECT) {
+#ifdef SMC_DEBUG
+ printf("%s: default media MII\n",
+ sc->sc_dev.dv_xname);
+#endif
+ mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff,
+ MII_PHY_ANY, MII_OFFSET_ANY, 0);
+ if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+ ifmedia_add(&sc->sc_mii.mii_media,
+ IFM_ETHER|IFM_NONE, 0, NULL);
+ ifmedia_set(&sc->sc_mii.mii_media,
+ IFM_ETHER|IFM_NONE);
+ } else {
+ ifmedia_set(&sc->sc_mii.mii_media,
+ IFM_ETHER|IFM_AUTO);
+ }
+ sc->sc_flags |= SMC_FLAGS_HAS_MII;
+ break;
+ }
+ /*FALLTHROUGH*/
+ default:
+ aui = tmp & CR_AUI_SELECT;
+#ifdef SMC_DEBUG
+ printf("%s: default media %s\n", sc->sc_dev.dv_xname,
+ aui ? "AUI" : "UTP");
+#endif
+ for (i = 0; i < NSMC91CxxMEDIA; i++)
+ ifmedia_add(ifm, smc91cxx_media[i], 0, NULL);
+ ifmedia_set(ifm, IFM_ETHER | (aui ? IFM_10_5 : IFM_10_T));
+ break;
+ }

#if NRND > 0
- rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
+ rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
+ RND_TYPE_NET, 0);
#endif
+
+ /* The attach is successful. */
+ sc->sc_flags |= SMC_FLAGS_ATTACHED;
}

/*
@@ -259,7 +343,7 @@ smc91cxx_mediachange(ifp)
{
struct smc91cxx_softc *sc = ifp->if_softc;

- return (smc91cxx_set_media(sc, sc->sc_media.ifm_media));
+ return (smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_media));
}

int
@@ -276,12 +360,15 @@ smc91cxx_set_media(sc, media)
* When it is enabled later, smc91cxx_init() will properly set
* up the media for us.
*/
- if (sc->sc_enabled == 0)
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0)
return (0);

if (IFM_TYPE(media) != IFM_ETHER)
return (EINVAL);

+ if (sc->sc_flags & SMC_FLAGS_HAS_MII)
+ return (mii_mediachg(&sc->sc_mii));
+
switch (IFM_SUBTYPE(media)) {
case IFM_10_T:
case IFM_10_5:
@@ -315,12 +402,22 @@ smc91cxx_mediastatus(ifp, ifmr)
bus_space_handle_t bsh = sc->sc_bsh;
u_int16_t tmp;

- if (sc->sc_enabled == 0) {
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0) {
ifmr->ifm_active = IFM_ETHER | IFM_NONE;
ifmr->ifm_status = 0;
return;
}

+ /*
+ * If we have MII, go ask the PHY what's going on.
+ */
+ if (sc->sc_flags & SMC_FLAGS_HAS_MII) {
+ mii_pollstat(&sc->sc_mii);
+ ifmr->ifm_active = sc->sc_mii.mii_media_active;
+ ifmr->ifm_status = sc->sc_mii.mii_media_status;
+ return;
+ }
+
SMC_SELECT_BANK(sc, 1);
tmp = bus_space_read_2(bst, bsh, CONFIG_REG_W);
ifmr->ifm_active =
@@ -387,7 +484,7 @@ smc91cxx_init(sc)
/*
* Set current media.
*/
- smc91cxx_set_media(sc, sc->sc_media.ifm_cur->ifm_media);
+ smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_cur->ifm_media);

/*
* Set the receive filter. We want receive enable and auto
@@ -432,6 +529,12 @@ smc91cxx_init(sc)
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;

+ if (sc->sc_flags & SMC_FLAGS_HAS_MII) {
+ /* Start the one second clock. */
+ timeout_set(&sc->sc_mii_timeout, smc91cxx_tick, sc);
+ timeout_add(&sc->sc_mii_timeout, hz);
+ }
+
/*
* Attempt to start any pending transmission.
*/
@@ -568,8 +671,9 @@ smc91cxx_start(ifp)
*/
for (top = m; m != NULL; m = m->m_next) {
/* Words... */
- bus_space_write_multi_2(bst, bsh, DATA_REG_W,
- mtod(m, u_int16_t *), m->m_len >> 1);
+ if (m->m_len > 1)
+ bus_space_write_multi_stream_2(bst, bsh, DATA_REG_W,
+ mtod(m, u_int16_t *), m->m_len >> 1);

/* ...and the remaining byte, if any. */
if (m->m_len & 1)
@@ -641,7 +745,8 @@ smc91cxx_intr(arg)
u_int8_t mask, interrupts, status;
u_int16_t packetno, tx_status, card_stats;

- if (sc->sc_enabled == 0)
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 ||
+ (sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
return (0);

SMC_SELECT_BANK(sc, 2);
@@ -681,10 +786,11 @@ smc91cxx_intr(arg)
if (status & IM_RCV_INT) {
#if 1 /* DIAGNOSTIC */
packetno = bus_space_read_2(bst, bsh, FIFO_PORTS_REG_W);
- if (packetno & FIFO_REMPTY)
+ if (packetno & FIFO_REMPTY) {
printf("%s: receive interrupt on empty fifo\n",
sc->sc_dev.dv_xname);
- else
+ goto out;
+ } else
#endif
smc91cxx_read(sc);
}
@@ -805,6 +911,7 @@ smc91cxx_intr(arg)
*/
smc91cxx_start(ifp);

+out:
/*
* Reenable the interrupts we wish to receive now that processing
* is complete.
@@ -876,9 +983,8 @@ smc91cxx_read(sc)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
goto out;
-
m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = m->m_len = packetlen;
+ m->m_pkthdr.len = packetlen;

/*
* Always put the packet in a cluster.
@@ -894,11 +1000,16 @@ smc91cxx_read(sc)
}

/*
- * Pull the packet off the interface.
+ * Pull the packet off the interface. Make sure the payload
+ * is aligned.
*/
+ m->m_data = (caddr_t) ALIGN(mtod(m, caddr_t) +
+ sizeof(struct ether_header)) - sizeof(struct ether_header);
+
data = mtod(m, u_int8_t *);
- bus_space_read_multi_2(bst, bsh, DATA_REG_W, (u_int16_t *)data,
- packetlen >> 1);
+ if (packetlen > 1)
+ bus_space_read_multi_stream_2(bst, bsh, DATA_REG_W,
+ (u_int16_t *)data, packetlen >> 1);
if (packetlen & 1) {
data += packetlen & ~1;
*data = bus_space_read_1(bst, bsh, DATA_REG_B);
@@ -988,7 +1099,7 @@ smc91cxx_ioctl(ifp, cmd, data)
if ((error = smc91cxx_enable(sc)) != 0)
break;
smc91cxx_init(sc);
- } else if (sc->sc_enabled) {
+ } else if ((ifp->if_flags & IFF_UP) != 0) {
/*
* Reset the interface to pick up changes in any
* other flags that affect hardware registers.
@@ -999,7 +1110,7 @@ smc91cxx_ioctl(ifp, cmd, data)

case SIOCADDMULTI:
case SIOCDELMULTI:
- if (sc->sc_enabled == 0) {
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0) {
error = EIO;
break;
}
@@ -1020,7 +1131,7 @@ smc91cxx_ioctl(ifp, cmd, data)

case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
+ error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
break;

default:
@@ -1098,8 +1209,7 @@ int
smc91cxx_enable(sc)
struct smc91cxx_softc *sc;
{
-
- if (sc->sc_enabled == 0 && sc->sc_enable != NULL) {
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 && sc->sc_enable != NULL) {
if ((*sc->sc_enable)(sc) != 0) {
printf("%s: device enable failed\n",
sc->sc_dev.dv_xname);
@@ -1107,7 +1217,7 @@ smc91cxx_enable(sc)
}
}

- sc->sc_enabled = 1;
+ sc->sc_flags |= SMC_FLAGS_ENABLED;
return (0);
}

@@ -1118,9 +1228,162 @@ void
smc91cxx_disable(sc)
struct smc91cxx_softc *sc;
{
-
- if (sc->sc_enabled != 0 && sc->sc_disable != NULL) {
+ if ((sc->sc_flags & SMC_FLAGS_ENABLED) != 0 && sc->sc_disable != NULL) {
(*sc->sc_disable)(sc);
- sc->sc_enabled = 0;
+ sc->sc_flags &= ~SMC_FLAGS_ENABLED;
}
+}
+
+int
+smc91cxx_activate(self, act)
+ struct device *self;
+ enum devact act;
+{
+#if 0
+ struct smc91cxx_softc *sc = (struct smc91cxx_softc *)self;
+#endif
+ int rv = 0, s;
+
+ s = splnet();
+ switch (act) {
+ case DVACT_ACTIVATE:
+ rv = EOPNOTSUPP;
+ break;
+
+ case DVACT_DEACTIVATE:
+#if 0
+ if_deactivate(&sc->sc_ic.ic_if);
+#endif
+ break;
+ }
+ splx(s);
+ return(rv);
+}
+
+int
+smc91cxx_detach(self, flags)
+ struct device *self;
+ int flags;
+{
+ struct smc91cxx_softc *sc = (struct smc91cxx_softc *)self;
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+
+ /* Succeed now if there's no work to do. */
+ if ((sc->sc_flags & SMC_FLAGS_ATTACHED) == 0)
+ return(0);
+
+ /* smc91cxx_disable() checks SMC_FLAGS_ENABLED */
+ smc91cxx_disable(sc);
+
+ /* smc91cxx_attach() never fails */
+
+ /* Delete all media. */
+ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
+
+#if NRND > 0
+ rnd_detach_source(&sc->rnd_source);
+#endif
+#if NBPFILTER > 0
+ bpfdetach(ifp);
+#endif
+ ether_ifdetach(ifp);
+ if_detach(ifp);
+
+ return (0);
+}
+
+u_int32_t
+smc91cxx_mii_bitbang_read(self)
+ struct device *self;
+{
+ struct smc91cxx_softc *sc = (void *) self;
+
+ /* We're already in bank 3. */
+ return (bus_space_read_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W));
+}
+
+void
+smc91cxx_mii_bitbang_write(self, val)
+ struct device *self;
+ u_int32_t val;
+{
+ struct smc91cxx_softc *sc = (void *) self;
+
+ /* We're already in bank 3. */
+ bus_space_write_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W, val);
+}
+
+int
+smc91cxx_mii_readreg(self, phy, reg)
+ struct device *self;
+ int phy, reg;
+{
+ struct smc91cxx_softc *sc = (void *) self;
+ int val;
+
+ SMC_SELECT_BANK(sc, 3);
+
+ val = mii_bitbang_readreg(self, &smc91cxx_mii_bitbang_ops, phy, reg);
+
+ SMC_SELECT_BANK(sc, 2);
+
+ return (val);
+}
+
+void
+smc91cxx_mii_writereg(self, phy, reg, val)
+ struct device *self;
+ int phy, reg, val;
+{
+ struct smc91cxx_softc *sc = (void *) self;
+
+ SMC_SELECT_BANK(sc, 3);
+
+ mii_bitbang_writereg(self, &smc91cxx_mii_bitbang_ops, phy, reg, val);
+
+ SMC_SELECT_BANK(sc, 2);
+}
+
+void
+smc91cxx_statchg(self)
+ struct device *self;
+{
+ struct smc91cxx_softc *sc = (struct smc91cxx_softc *)self;
+ bus_space_tag_t bst = sc->sc_bst;
+ bus_space_handle_t bsh = sc->sc_bsh;
+ int mctl;
+
+ SMC_SELECT_BANK(sc, 0);
+ mctl = bus_space_read_2(bst, bsh, TXMIT_CONTROL_REG_W);
+ if (sc->sc_mii.mii_media_active & IFM_FDX)
+ mctl |= TCR_SWFDUP;
+ else
+ mctl &= ~TCR_SWFDUP;
+ bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, mctl);
+ SMC_SELECT_BANK(sc, 2); /* back to operating window */
+}
+
+/*
+ * One second timer, used to tick the MII.
+ */
+void
+smc91cxx_tick(arg)
+ void *arg;
+{
+ struct smc91cxx_softc *sc = arg;
+ int s;
+
+#ifdef DIAGNOSTIC
+ if ((sc->sc_flags & SMC_FLAGS_HAS_MII) == 0)
+ panic("smc91cxx_tick");
+#endif
+
+ if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
+ return;
+
+ s = splnet();
+ mii_tick(&sc->sc_mii);
+ splx(s);
+
+ timeout_add(&sc->sc_mii_timeout, hz);
}
Index: dev/ic/smc91cxxreg.h
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/dev/ic/smc91cxxreg.h,v
retrieving revision 1.2
diff -u -p -r1.2 smc91cxxreg.h
--- dev/ic/smc91cxxreg.h 27 Jun 2001 05:44:52 -0000 1.2
+++ dev/ic/smc91cxxreg.h 19 Jan 2006 13:03:24 -0000
@@ -109,6 +109,7 @@
#define TCR_FDUPLX 0x0800 /* receive packets sent out */
#define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */
#define TCR_EPH_LOOP 0x2000 /* Enable internal digital loopback */
+#define TCR_SWFDUP 0x8000 /* FEAST: Switched full-duplex (only w/ MII) */


/*
@@ -179,6 +180,7 @@
*/
#define MEM_CFG_REG_W 0x0a

+#define MCR_MEM_MULT(x) (((x)>>9)&7) /* Memory size multiplier */
#define MCR_TXRSV_MASK 0x001f /* Count of pages reserved for transmit */


@@ -204,6 +206,7 @@
#define CR_SET_SQLCH 0x0200 /* Squelch level */
#define CR_FULL_STEP 0x0400 /* AUI signalling mode */
#define CR_NOW_WAIT_ST 0x1000 /* Disable bus wait states */
+#define CR_MII_SELECT 0x8000 /* FEAST: MII port selected */


/*
@@ -367,10 +370,18 @@
/*
* These registers do not exist on SMC9192, or at least
* are not documented in the SMC91C92 data sheet.
+ *
* The REVISION_REG_W register does however seem to work.
+ *
+ * On the FEAST, the low nibble controls the MII interface.
*/
#define MGMT_REG_W 0x08

+#define MR_MDOE 0x08
+#define MR_MCLK 0x04
+#define MR_MDI 0x02
+#define MR_MDO 0x01
+
#define REVISION_REG_W 0x0a /* (hi: chip id low: rev #) */
#define RR_REV(x) ((x) & 0x0f)
#define RR_ID(x) (((x) >> 4) & 0x0f)
@@ -385,6 +396,7 @@
#define CHIP_9194 4
#define CHIP_9195 5
#define CHIP_91100 7
+#define CHIP_91100FD 8


/*
Index: dev/ic/smc91cxxvar.h
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/dev/ic/smc91cxxvar.h,v
retrieving revision 1.4
diff -u -p -r1.4 smc91cxxvar.h
--- dev/ic/smc91cxxvar.h 14 Mar 2002 01:26:55 -0000 1.4
+++ dev/ic/smc91cxxvar.h 19 Jan 2006 13:03:24 -0000
@@ -49,15 +49,24 @@ struct smc91cxx_softc {
#endif
struct arpcom sc_arpcom; /* ethernet common glue */

+ struct mii_data sc_mii; /* MII/media control */
+ struct timeout sc_mii_timeout; /* MII callout handle */
+
bus_space_tag_t sc_bst; /* bus space */
bus_space_handle_t sc_bsh;

- struct ifmedia sc_media; /* our media info */
-
/* Power management hooks and state. */
int (*sc_enable)(struct smc91cxx_softc *);
void (*sc_disable)(struct smc91cxx_softc *);
int sc_enabled;
+ u_int32_t sc_flags; /* misc. flags*/
+#define SMC_FLAGS_ENABLED 0x0001
+#define SMC_FLAGS_ATTACHED 0x0002 /* attach was successful */
+#define SMC_FLAGS_HAS_MII 0x0004 /* Has MII (FEAST) */
+#define SMC_FLAGS_32BIT_READ 0x0008 /* reads are always 32-bits */
+
+ u_int8_t sc_chipid;
+ u_int8_t sc_internal_phy; /* 91C111 only */

#if NRND > 0
rndsource_element_t rnd_source;
@@ -72,3 +81,7 @@ void smc91cxx_attach(struct smc91cxx_sof
int smc91cxx_intr(void *);
void smc91cxx_init(struct smc91cxx_softc *);
void smc91cxx_stop(struct smc91cxx_softc *);
+int smc91cxx_enable(struct smc91cxx_softc *);
+void smc91cxx_disable(struct smc91cxx_softc *);
+int smc91cxx_activate(struct device *, enum devact);
+int smc91cxx_detach(struct device *, int);
Index: dev/isa/if_sm_isa.c
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/dev/isa/if_sm_isa.c,v
retrieving revision 1.6
diff -u -p -r1.6 if_sm_isa.c
--- dev/isa/if_sm_isa.c 21 Nov 2005 18:16:40 -0000 1.6
+++ dev/isa/if_sm_isa.c 19 Jan 2006 13:03:24 -0000
@@ -76,6 +76,11 @@
#include <machine/intr.h>
#include <machine/bus.h>

+#include <net/if_media.h>
+
+#include <dev/mii/mii.h>
+#include <dev/mii/miivar.h>
+
#include <dev/ic/smc91cxxreg.h>
#include <dev/ic/smc91cxxvar.h>

Index: dev/pcmcia/if_sm_pcmcia.c
================================================== =================
RCS file: /data/cvs/openbsd/src/sys/dev/pcmcia/if_sm_pcmcia.c,v
retrieving revision 1.24
diff -u -p -r1.24 if_sm_pcmcia.c
--- dev/pcmcia/if_sm_pcmcia.c 21 Nov 2005 18:16:42 -0000 1.24
+++ dev/pcmcia/if_sm_pcmcia.c 19 Jan 2006 13:03:25 -0000
@@ -69,6 +69,11 @@
#include <machine/intr.h>
#include <machine/bus.h>

+#include <net/if_media.h>
+
+#include <dev/mii/mii.h>
+#include <dev/mii/miivar.h>
+
#include <dev/ic/smc91cxxreg.h>
#include <dev/ic/smc91cxxvar.h>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934