Style(9) cleanup. There was no consistent style in this driver, and
The next round of commits will be to fix up locking in it. This lot is to at least give a consistent base to work off. OK'ed by: imp, mdodd
This commit is contained in:
parent
9e66b98a4a
commit
5146af6d82
@ -26,8 +26,6 @@
|
||||
* 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.
|
||||
*
|
||||
* if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -38,8 +36,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* Promiscuous mode added and interrupt logic slightly changed
|
||||
* to reduce the number of adapter failures. Transceiver select
|
||||
* logic changed to use value from EEPROM. Autoconfiguration
|
||||
@ -61,12 +57,14 @@
|
||||
* <mdodd@FreeBSD.org>
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
@ -79,18 +77,12 @@
|
||||
#include <net/ethernet.h>
|
||||
#include <net/bpf.h>
|
||||
|
||||
|
||||
#include <dev/ep/if_epreg.h>
|
||||
#include <dev/ep/if_epvar.h>
|
||||
|
||||
/* Exported variables */
|
||||
devclass_t ep_devclass;
|
||||
|
||||
#if 0
|
||||
static char * ep_conn_type[] = {"UTP", "AUI", "???", "BNC"};
|
||||
static int if_media2ep_media[] = { 0, 0, 0, UTP, BNC, AUI };
|
||||
#endif
|
||||
|
||||
static int ep_media2if_media[] =
|
||||
{IFM_10_T, IFM_10_5, IFM_NONE, IFM_10_2, IFM_NONE};
|
||||
|
||||
@ -113,18 +105,18 @@ static int eeprom_rdy (struct ep_softc *);
|
||||
#define EP_FRST(sc, f) (sc->stat &= ~(f))
|
||||
|
||||
static int
|
||||
eeprom_rdy(sc)
|
||||
struct ep_softc *sc;
|
||||
eeprom_rdy(struct ep_softc *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
|
||||
for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++)
|
||||
DELAY(100);
|
||||
}
|
||||
|
||||
if (i >= MAX_EEPROMBUSY) {
|
||||
printf("ep%d: eeprom failed to come ready.\n", sc->unit);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -133,27 +125,25 @@ eeprom_rdy(sc)
|
||||
* before
|
||||
*/
|
||||
int
|
||||
get_e(sc, offset, result)
|
||||
struct ep_softc *sc;
|
||||
u_int16_t offset;
|
||||
u_int16_t *result;
|
||||
get_e(struct ep_softc *sc, u_int16_t offset, u_int16_t *result)
|
||||
{
|
||||
|
||||
if (eeprom_rdy(sc))
|
||||
return (ENXIO);
|
||||
|
||||
outw(BASE + EP_W0_EEPROM_COMMAND,
|
||||
(EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
|
||||
|
||||
if (eeprom_rdy(sc))
|
||||
return (ENXIO);
|
||||
|
||||
(*result) = inw(BASE + EP_W0_EEPROM_DATA);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ep_get_macaddr(sc, addr)
|
||||
struct ep_softc * sc;
|
||||
u_char * addr;
|
||||
ep_get_macaddr(struct ep_softc *sc, u_char *addr)
|
||||
{
|
||||
int i;
|
||||
u_int16_t result;
|
||||
@ -189,7 +179,6 @@ ep_alloc(device_t dev)
|
||||
error = ENXIO;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
rid = 0;
|
||||
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
|
||||
0, ~0, 1, RF_ACTIVE);
|
||||
@ -198,7 +187,6 @@ ep_alloc(device_t dev)
|
||||
error = ENXIO;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sc->dev = dev;
|
||||
sc->unit = device_get_unit(dev);
|
||||
sc->stat = 0; /* 16 bit access */
|
||||
@ -229,8 +217,7 @@ ep_alloc(device_t dev)
|
||||
}
|
||||
|
||||
void
|
||||
ep_get_media(sc)
|
||||
struct ep_softc * sc;
|
||||
ep_get_media(struct ep_softc *sc)
|
||||
{
|
||||
u_int16_t config;
|
||||
|
||||
@ -243,10 +230,9 @@ ep_get_media(sc)
|
||||
if (config & IS_UTP)
|
||||
sc->ep_connectors |= UTP;
|
||||
|
||||
if (!(sc->ep_connectors & 7)) {
|
||||
if (!(sc->ep_connectors & 7))
|
||||
if (bootverbose)
|
||||
device_printf(sc->dev, "no connectors!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* This works for most of the cards so we'll do it here.
|
||||
@ -254,8 +240,6 @@ ep_get_media(sc)
|
||||
* this later on.
|
||||
*/
|
||||
sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
@ -269,13 +253,10 @@ ep_free(device_t dev)
|
||||
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
|
||||
if (sc->irq)
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
ep_attach(sc)
|
||||
struct ep_softc * sc;
|
||||
ep_attach(struct ep_softc *sc)
|
||||
{
|
||||
struct ifnet *ifp = NULL;
|
||||
struct ifmedia *ifm = NULL;
|
||||
@ -291,15 +272,13 @@ ep_attach(sc)
|
||||
device_printf(sc->dev, "Unable to retrieve Ethernet address!\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the station address
|
||||
*/
|
||||
p = (u_short *)&sc->arpcom.ac_enaddr;
|
||||
GO_WINDOW(2);
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 0; i < 3; i++)
|
||||
outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
|
||||
}
|
||||
|
||||
device_printf(sc->dev, "Ethernet address %6D\n",
|
||||
sc->arpcom.ac_enaddr, ":");
|
||||
@ -337,7 +316,6 @@ ep_attach(sc)
|
||||
ifm->ifm_media = ifm->ifm_cur->ifm_media;
|
||||
ep_ifmedia_upd(ifp);
|
||||
}
|
||||
|
||||
if (!attached)
|
||||
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
|
||||
|
||||
@ -350,7 +328,7 @@ ep_attach(sc)
|
||||
|
||||
epstop(sc);
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -366,7 +344,6 @@ ep_detach(device_t dev)
|
||||
device_printf(dev, "already unloaded\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
epstop(sc);
|
||||
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
@ -383,21 +360,15 @@ ep_detach(device_t dev)
|
||||
* interrupts. ?!
|
||||
*/
|
||||
static void
|
||||
ep_if_init(xsc)
|
||||
void *xsc;
|
||||
ep_if_init(void *xsc)
|
||||
{
|
||||
struct ep_softc *sc = xsc;
|
||||
register struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
int s, i;
|
||||
|
||||
if (sc->gone)
|
||||
return;
|
||||
|
||||
/*
|
||||
if (ifp->if_addrlist == (struct ifaddr *) 0)
|
||||
return;
|
||||
*/
|
||||
|
||||
s = splimp();
|
||||
while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
|
||||
|
||||
@ -442,9 +413,8 @@ ep_if_init(xsc)
|
||||
outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
|
||||
FIL_GROUP | FIL_BRDCST);
|
||||
|
||||
if (!sc->epb.mii_trans) {
|
||||
if (!sc->epb.mii_trans)
|
||||
ep_ifmedia_upd(ifp);
|
||||
}
|
||||
|
||||
outw(BASE + EP_COMMAND, RX_ENABLE);
|
||||
outw(BASE + EP_COMMAND, TX_ENABLE);
|
||||
@ -477,8 +447,7 @@ ep_if_init(xsc)
|
||||
}
|
||||
|
||||
static void
|
||||
ep_if_start(ifp)
|
||||
struct ifnet *ifp;
|
||||
ep_if_start(struct ifnet *ifp)
|
||||
{
|
||||
struct ep_softc *sc;
|
||||
u_int len;
|
||||
@ -523,9 +492,8 @@ ep_if_start(ifp)
|
||||
IF_PREPEND(&ifp->if_snd, m0);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | EP_THRESH_DISABLE);
|
||||
}
|
||||
|
||||
s = splhigh();
|
||||
|
||||
@ -581,11 +549,10 @@ ep_if_start(ifp)
|
||||
}
|
||||
|
||||
void
|
||||
ep_intr(arg)
|
||||
void *arg;
|
||||
ep_intr(void *arg)
|
||||
{
|
||||
struct ep_softc *sc;
|
||||
register int status;
|
||||
int status;
|
||||
struct ifnet *ifp;
|
||||
int x;
|
||||
|
||||
@ -600,7 +567,6 @@ ep_intr(arg)
|
||||
splx(x);
|
||||
return;
|
||||
}
|
||||
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
|
||||
outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
|
||||
@ -664,7 +630,8 @@ ep_intr(arg)
|
||||
#endif
|
||||
} else {
|
||||
if (status & TXS_JABBER);
|
||||
else /* TXS_MAX_COLLISION - we shouldn't get here */
|
||||
else /* TXS_MAX_COLLISION -
|
||||
* we shouldn't get here */
|
||||
++ifp->if_collisions;
|
||||
}
|
||||
++ifp->if_oerrors;
|
||||
@ -673,10 +640,9 @@ ep_intr(arg)
|
||||
* To have a tx_avail_int but giving the chance to the
|
||||
* Reception
|
||||
*/
|
||||
if (ifp->if_snd.ifq_head) {
|
||||
if (ifp->if_snd.ifq_head)
|
||||
outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
|
||||
}
|
||||
}
|
||||
outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next
|
||||
* status */
|
||||
} /* while */
|
||||
@ -699,15 +665,14 @@ ep_intr(arg)
|
||||
}
|
||||
|
||||
static void
|
||||
epread(sc)
|
||||
register struct ep_softc *sc;
|
||||
epread(struct ep_softc *sc)
|
||||
{
|
||||
struct mbuf *top, *mcur, *m;
|
||||
struct ifnet *ifp;
|
||||
int lenthisone;
|
||||
|
||||
short rx_fifo2, status;
|
||||
register short rx_fifo;
|
||||
short rx_fifo;
|
||||
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
status = inw(BASE + EP_W1_RX_STATUS);
|
||||
@ -770,7 +735,8 @@ epread(sc)
|
||||
mcur->m_next = m;
|
||||
lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
|
||||
}
|
||||
if (EP_FTST(sc, F_ACCESS_32_BITS)) { /* default for EISA configured cards*/
|
||||
if (EP_FTST(sc, F_ACCESS_32_BITS)) { /* default for EISA
|
||||
* configured cards */
|
||||
insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t)+m->m_len,
|
||||
lenthisone / 4);
|
||||
m->m_len += (lenthisone & ~3);
|
||||
@ -789,15 +755,18 @@ epread(sc)
|
||||
rx_fifo -= lenthisone;
|
||||
}
|
||||
|
||||
if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete
|
||||
* packet */
|
||||
if (status & ERR_RX_INCOMPLETE) { /* we haven't received the
|
||||
* complete packet */
|
||||
sc->mcur = m;
|
||||
#ifdef EP_LOCAL_STATS
|
||||
sc->rx_no_first++; /* to know how often we come here */
|
||||
#endif
|
||||
EP_FRST(sc, F_RX_FIRST);
|
||||
if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) {
|
||||
/* we see if by now, the packet has completly arrived */
|
||||
/*
|
||||
* we see if by now, the packet has completly
|
||||
* arrived
|
||||
*/
|
||||
goto read_again;
|
||||
}
|
||||
outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH);
|
||||
@ -830,8 +799,7 @@ epread(sc)
|
||||
}
|
||||
|
||||
static int
|
||||
ep_ifmedia_upd(ifp)
|
||||
struct ifnet * ifp;
|
||||
ep_ifmedia_upd(struct ifnet *ifp)
|
||||
{
|
||||
struct ep_softc *sc = ifp->if_softc;
|
||||
int i = 0, j;
|
||||
@ -875,22 +843,15 @@ ep_ifmedia_upd(ifp)
|
||||
}
|
||||
|
||||
static void
|
||||
ep_ifmedia_sts(ifp, ifmr)
|
||||
struct ifnet * ifp;
|
||||
struct ifmediareq * ifmr;
|
||||
ep_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
{
|
||||
struct ep_softc *sc = ifp->if_softc;
|
||||
|
||||
ifmr->ifm_active = sc->ifmedia.ifm_media;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
ep_if_ioctl(ifp, cmd, data)
|
||||
struct ifnet * ifp;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
ep_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
struct ep_softc *sc = ifp->if_softc;
|
||||
struct ifreq *ifr = (struct ifreq *) data;
|
||||
@ -904,10 +865,9 @@ ep_if_ioctl(ifp, cmd, data)
|
||||
(ifp->if_flags & IFF_RUNNING)) {
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
epstop(sc);
|
||||
} else {
|
||||
} else
|
||||
/* reinitialize card on any parameter change */
|
||||
ep_if_init(sc);
|
||||
}
|
||||
break;
|
||||
#ifdef notdef
|
||||
case SIOCGHWADDR:
|
||||
@ -928,11 +888,10 @@ ep_if_ioctl(ifp, cmd, data)
|
||||
break;
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCGIFMEDIA:
|
||||
if (!sc->epb.mii_trans) {
|
||||
if (!sc->epb.mii_trans)
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
|
||||
} else {
|
||||
else
|
||||
error = EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = ether_ioctl(ifp, cmd, data);
|
||||
@ -945,8 +904,7 @@ ep_if_ioctl(ifp, cmd, data)
|
||||
}
|
||||
|
||||
static void
|
||||
ep_if_watchdog(ifp)
|
||||
struct ifnet *ifp;
|
||||
ep_if_watchdog(struct ifnet *ifp)
|
||||
{
|
||||
struct ep_softc *sc = ifp->if_softc;
|
||||
|
||||
@ -957,23 +915,18 @@ ep_if_watchdog(ifp)
|
||||
ifp->if_oerrors++;
|
||||
*/
|
||||
|
||||
if (sc->gone) {
|
||||
if (sc->gone)
|
||||
return;
|
||||
}
|
||||
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
ep_if_start(ifp);
|
||||
ep_intr(ifp->if_softc);
|
||||
}
|
||||
|
||||
static void
|
||||
epstop(sc)
|
||||
struct ep_softc *sc;
|
||||
epstop(struct ep_softc *sc)
|
||||
{
|
||||
if (sc->gone) {
|
||||
if (sc->gone)
|
||||
return;
|
||||
}
|
||||
|
||||
outw(BASE + EP_COMMAND, RX_DISABLE);
|
||||
outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
|
||||
while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
|
||||
|
@ -18,15 +18,15 @@
|
||||
* Justin T. Gibbs.
|
||||
* 4. Modifications may be freely made to this file if the above conditions
|
||||
* are met.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
|
||||
#include <dev/eisa/eisaconf.h>
|
||||
|
||||
#include <dev/ep/if_epreg.h>
|
||||
@ -77,28 +76,21 @@ ep_match(eisa_id_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case EISA_DEVICE_ID_3COM_3C509_TP:
|
||||
return "3Com 3C509-TP Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C509-TP Network Adapter");
|
||||
case EISA_DEVICE_ID_3COM_3C509_BNC:
|
||||
return "3Com 3C509-BNC Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C509-BNC Network Adapter");
|
||||
case EISA_DEVICE_ID_3COM_3C579_TP:
|
||||
return "3Com 3C579-TP EISA Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C579-TP EISA Network Adapter");
|
||||
case EISA_DEVICE_ID_3COM_3C579_BNC:
|
||||
return "3Com 3C579-BNC EISA Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C579-BNC EISA Network Adapter");
|
||||
case EISA_DEVICE_ID_3COM_3C509_COMBO:
|
||||
return "3Com 3C509-Combo Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C509-Combo Network Adapter");
|
||||
case EISA_DEVICE_ID_3COM_3C509_TPO:
|
||||
return "3Com 3C509-TPO Network Adapter";
|
||||
break;
|
||||
return ("3Com 3C509-TPO Network Adapter");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ep_eisa_probe(device_t dev)
|
||||
@ -158,7 +150,7 @@ ep_eisa_probe(device_t dev)
|
||||
"slot %d has its IRQ disabled. "
|
||||
"Probe failed.\n",
|
||||
eisa_get_slot(dev));
|
||||
return ENXIO;
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
switch (eisa_get_id(dev)) {
|
||||
@ -173,7 +165,7 @@ ep_eisa_probe(device_t dev)
|
||||
|
||||
eisa_add_intr(dev, irq, int_trig);
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -206,14 +198,11 @@ ep_eisa_attach(device_t dev)
|
||||
device_printf(dev, "ep_alloc() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
switch (eisa_get_id(dev)) {
|
||||
case EISA_DEVICE_ID_3COM_3C579_BNC:
|
||||
case EISA_DEVICE_ID_3COM_3C579_TP:
|
||||
sc->stat = F_ACCESS_32_BITS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ep_get_media(sc);
|
||||
@ -229,13 +218,11 @@ ep_eisa_attach(device_t dev)
|
||||
device_printf(dev, "ep_attach() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
|
||||
sc, &sc->ep_intrhand))) {
|
||||
device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
|
@ -26,15 +26,15 @@
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
@ -59,6 +59,7 @@
|
||||
static u_int16_t get_eeprom_data(int, int);
|
||||
static void ep_isa_identify(driver_t *, device_t);
|
||||
#endif
|
||||
|
||||
static int ep_isa_probe(device_t);
|
||||
static int ep_isa_attach(device_t);
|
||||
static int ep_eeprom_cksum(struct ep_softc *);
|
||||
@ -119,9 +120,7 @@ static struct isa_pnp_id ep_ids[] = {
|
||||
*/
|
||||
#ifdef __i386__
|
||||
static u_int16_t
|
||||
get_eeprom_data(id_port, offset)
|
||||
int id_port;
|
||||
int offset;
|
||||
get_eeprom_data(int id_port, int offset)
|
||||
{
|
||||
int i;
|
||||
u_int16_t data = 0;
|
||||
@ -137,11 +136,10 @@ get_eeprom_data(id_port, offset)
|
||||
#endif
|
||||
|
||||
const char *
|
||||
ep_isa_match_id (id, isa_devs)
|
||||
u_int32_t id;
|
||||
struct isa_ident * isa_devs;
|
||||
ep_isa_match_id(u_int32_t id, struct isa_ident *isa_devs)
|
||||
{
|
||||
struct isa_ident *i = isa_devs;
|
||||
|
||||
while (i->name != NULL) {
|
||||
if (id == i->id)
|
||||
return (i->name);
|
||||
@ -152,9 +150,8 @@ ep_isa_match_id (id, isa_devs)
|
||||
* return something so that it will work; be annoying
|
||||
* so that the user will tell us about it though.
|
||||
*/
|
||||
if ((id >> 4) == ISA_ID_3C509_XXX) {
|
||||
if ((id >> 4) == ISA_ID_3C509_XXX)
|
||||
return ("Unknown 3c509; notify maintainer!");
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -187,27 +184,22 @@ ep_isa_identify (driver_t *driver, device_t parent)
|
||||
elink_idseq(ELINK_509_POLY);
|
||||
DELAY(400);
|
||||
|
||||
/* For the first probe, clear all
|
||||
* board's tag registers.
|
||||
* Otherwise kill off already-found
|
||||
* boards. -- linux 3c509.c
|
||||
/*
|
||||
* For the first probe, clear all board's tag registers.
|
||||
* Otherwise kill off already-found boards. -- linux 3c509.c
|
||||
*/
|
||||
if (i == 0) {
|
||||
if (i == 0)
|
||||
outb(ELINK_ID_PORT, 0xd0);
|
||||
} else {
|
||||
else
|
||||
outb(ELINK_ID_PORT, 0xd8);
|
||||
}
|
||||
|
||||
/* Get out of loop if we're out of cards. */
|
||||
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_MFG_ID);
|
||||
if (data != MFG_ID) {
|
||||
if (data != MFG_ID)
|
||||
break;
|
||||
}
|
||||
|
||||
/* resolve contention using the Ethernet address */
|
||||
for (j = 0; j < 3; j++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
(void)get_eeprom_data(ELINK_ID_PORT, j);
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct an 'isa_id' in 'EISA'
|
||||
@ -221,13 +213,11 @@ ep_isa_identify (driver_t *driver, device_t parent)
|
||||
/* Find known ISA boards */
|
||||
desc = ep_isa_match_id(isa_id, ep_isa_devs);
|
||||
if (!desc) {
|
||||
if (bootverbose) {
|
||||
if (bootverbose)
|
||||
device_printf(parent, "if_ep: unknown ID 0x%08x\n",
|
||||
isa_id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Retreive IRQ */
|
||||
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_RESOURCE_CFG);
|
||||
irq = (data >> 12);
|
||||
@ -243,26 +233,29 @@ ep_isa_identify (driver_t *driver, device_t parent)
|
||||
if ((data & ADDR_CFG_MASK) == ADDR_CFG_EISA) {
|
||||
device_printf(parent, "if_ep: <%s> at port 0x%03x in EISA mode!\n",
|
||||
desc, ioport);
|
||||
/* Set the adaptor tag so that the next card can be found. */
|
||||
/*
|
||||
* Set the adaptor tag so that the next card can be
|
||||
* found.
|
||||
*/
|
||||
outb(ELINK_ID_PORT, tag--);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Test for an adapter with PnP support. */
|
||||
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_CAP);
|
||||
if (data == CAP_ISA) {
|
||||
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_INT_CONFIG_1);
|
||||
if (data & ICW1_IAS_PNP) {
|
||||
if (bootverbose) {
|
||||
if (bootverbose)
|
||||
device_printf(parent, "if_ep: <%s> at 0x%03x in PnP mode!\n",
|
||||
desc, ioport);
|
||||
}
|
||||
/* Set the adaptor tag so that the next card can be found. */
|
||||
/*
|
||||
* Set the adaptor tag so that the next card
|
||||
* can be found.
|
||||
*/
|
||||
outb(ELINK_ID_PORT, tag--);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the adaptor tag so that the next card can be found. */
|
||||
outb(ELINK_ID_PORT, tag--);
|
||||
|
||||
@ -277,22 +270,17 @@ ep_isa_identify (driver_t *driver, device_t parent)
|
||||
desc, ioport);
|
||||
continue;
|
||||
}
|
||||
|
||||
child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ep", -1);
|
||||
device_set_desc_copy(child, desc);
|
||||
device_set_driver(child, driver);
|
||||
bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
|
||||
bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EP_IOSIZE);
|
||||
|
||||
if (bootverbose) {
|
||||
if (bootverbose)
|
||||
device_printf(parent, "if_ep: <%s> at port 0x%03x-0x%03x irq %d\n",
|
||||
desc, ioport, ioport + EP_IOSIZE, irq);
|
||||
}
|
||||
|
||||
found++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -305,20 +293,17 @@ ep_isa_probe (device_t dev)
|
||||
error = ISA_PNP_PROBE(device_get_parent(dev), dev, ep_ids);
|
||||
|
||||
/* If the card had a PnP ID that didn't match any we know about */
|
||||
if (error == ENXIO) {
|
||||
if (error == ENXIO)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* If we had some other problem. */
|
||||
if (!(error == 0 || error == ENOENT)) {
|
||||
if (!(error == 0 || error == ENOENT))
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* If we have the resources we need then we're good to go. */
|
||||
if ((bus_get_resource_start(dev, SYS_RES_IOPORT, 0) != 0) &&
|
||||
(bus_get_resource_start(dev, SYS_RES_IRQ, 0) != 0)) {
|
||||
(bus_get_resource_start(dev, SYS_RES_IRQ, 0) != 0))
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
}
|
||||
@ -333,7 +318,6 @@ ep_isa_attach (device_t dev)
|
||||
device_printf(dev, "ep_alloc() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
ep_get_media(sc);
|
||||
|
||||
GO_WINDOW(0);
|
||||
@ -343,19 +327,16 @@ ep_isa_attach (device_t dev)
|
||||
device_printf(dev, "ep_attach() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
error = ep_eeprom_cksum(sc);
|
||||
if (error) {
|
||||
device_printf(sc->dev, "Invalid EEPROM checksum!\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
|
||||
sc, &sc->ep_intrhand))) {
|
||||
device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
ep_free(dev);
|
||||
@ -363,8 +344,7 @@ ep_isa_attach (device_t dev)
|
||||
}
|
||||
|
||||
static int
|
||||
ep_eeprom_cksum (sc)
|
||||
struct ep_softc * sc;
|
||||
ep_eeprom_cksum(struct ep_softc *sc)
|
||||
{
|
||||
int i;
|
||||
int error;
|
||||
|
@ -22,14 +22,14 @@
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
@ -132,13 +132,11 @@ ep_mca_attach (device_t dev)
|
||||
device_printf(dev, "ep_attach() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
|
||||
sc, &sc->ep_intrhand))) {
|
||||
device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
ep_free(dev);
|
||||
|
@ -26,8 +26,6 @@
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -36,11 +34,13 @@
|
||||
* nao@tom-yam.or.jp
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
@ -52,12 +52,12 @@
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
|
||||
#include <dev/ep/if_epreg.h>
|
||||
#include <dev/ep/if_epvar.h>
|
||||
|
||||
#include <dev/pccard/pccardvar.h>
|
||||
#include <dev/pccard/pccarddevs.h>
|
||||
|
||||
#include "card_if.h"
|
||||
|
||||
static const char *ep_pccard_identify(u_short id);
|
||||
@ -76,7 +76,7 @@ ep_pccard_probe(device_t dev)
|
||||
|
||||
error = ep_alloc(dev);
|
||||
if (error)
|
||||
return error;
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* XXX - Certain (newer?) 3Com cards need epb->cmd_off ==
|
||||
@ -136,9 +136,10 @@ ep_pccard_identify(u_short id)
|
||||
return ("3Com 3C562D/3C563D");
|
||||
case 0x0010: /* 3C1 */
|
||||
return ("3Com Megahertz C1");
|
||||
}
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ep_pccard_card_attach(struct ep_board * epb)
|
||||
@ -156,9 +157,10 @@ ep_pccard_card_attach(struct ep_board *epb)
|
||||
case 0x9058: /* 3C589 */
|
||||
epb->mii_trans = 0;
|
||||
return (1);
|
||||
}
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ep_pccard_attach(device_t dev)
|
||||
@ -171,7 +173,6 @@ ep_pccard_attach(device_t dev)
|
||||
device_printf(dev, "ep_alloc() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sc->epb.cmd_off = 0;
|
||||
|
||||
error = get_e(sc, EEPROM_PROD_ID, &result); /* XXX check return */
|
||||
@ -190,7 +191,6 @@ ep_pccard_attach(device_t dev)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
error = get_e(sc, EEPROM_ADDR_CFG, &result);
|
||||
|
||||
/* ROM size = 0, ROM base = 0 */
|
||||
@ -215,21 +215,18 @@ ep_pccard_attach(device_t dev)
|
||||
while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
|
||||
DELAY(1000);
|
||||
outw(BASE + EP_W3_OPTIONS, 0x8040);
|
||||
} else {
|
||||
} else
|
||||
ep_get_media(sc);
|
||||
}
|
||||
|
||||
if ((error = ep_attach(sc))) {
|
||||
device_printf(dev, "ep_attach() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
|
||||
sc, &sc->ep_intrhand))) {
|
||||
device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
ep_free(dev);
|
||||
|
@ -115,8 +115,10 @@
|
||||
#define EEPROM_INT_CONFIG_1 0x13
|
||||
/* RAM Partition TX FIFO/RX FIFO */
|
||||
#define ICW1_RAM_PART_MASK 0x03
|
||||
# define ICW1_RAM_PART_35 0x00 /* 2:5 (only legal if RAM size == 000b default power-up/reset */
|
||||
# define ICW1_RAM_PART_13 0x01 /* 1:3 (only legal if RAM size == 000b) */
|
||||
#define ICW1_RAM_PART_35 0x00 /* 2:5 (only legal if RAM size == 000b
|
||||
* default power-up/reset */
|
||||
#define ICW1_RAM_PART_13 0x01 /* 1:3 (only legal if RAM size ==
|
||||
* 000b) */
|
||||
#define ICW1_RAM_PART_11 0x10 /* 1:1 */
|
||||
#define ICW1_RAM_PART_RESV 0x11 /* Reserved */
|
||||
/* ISA Adapter Selection */
|
||||
@ -419,7 +421,8 @@
|
||||
* Misc defines for various things.
|
||||
*/
|
||||
#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
|
||||
#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
|
||||
#define MFG_ID 0x6d50 /* in EEPROM and W0
|
||||
* ADDR_CONFIG */
|
||||
#define PROD_ID 0x9150
|
||||
|
||||
#define AUI 0x1
|
||||
|
Loading…
Reference in New Issue
Block a user