2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
1999-09-26 06:42:36 +00:00
|
|
|
* Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Herb Peyerl.
|
|
|
|
* 4. The name of Herb Peyerl may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-07-17 19:37:56 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-09-26 06:42:36 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1999-10-27 06:25:16 +00:00
|
|
|
#include <sys/kernel.h>
|
1999-09-26 06:42:36 +00:00
|
|
|
#include <sys/socket.h>
|
1999-10-27 06:25:16 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
2003-07-17 19:37:56 +00:00
|
|
|
#include <sys/rman.h>
|
1999-10-27 06:25:16 +00:00
|
|
|
|
1999-09-26 06:42:36 +00:00
|
|
|
#include <net/if.h>
|
1999-10-27 06:25:16 +00:00
|
|
|
#include <net/if_arp.h>
|
2003-07-17 19:37:56 +00:00
|
|
|
#include <net/if_media.h>
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
#include <isa/isavar.h>
|
1999-09-26 06:42:36 +00:00
|
|
|
|
|
|
|
#include <dev/ep/if_epreg.h>
|
|
|
|
#include <dev/ep/if_epvar.h>
|
2003-02-13 23:01:59 +00:00
|
|
|
|
|
|
|
#ifdef __i386__
|
1999-09-26 06:42:36 +00:00
|
|
|
#include <i386/isa/elink.h>
|
2003-02-13 23:01:59 +00:00
|
|
|
#endif
|
1999-09-26 06:42:36 +00:00
|
|
|
|
2003-02-13 23:01:59 +00:00
|
|
|
#ifdef __i386__
|
2005-01-20 19:39:33 +00:00
|
|
|
static uint16_t get_eeprom_data(int, int);
|
2003-07-17 19:37:56 +00:00
|
|
|
static void ep_isa_identify(driver_t *, device_t);
|
2003-02-13 23:01:59 +00:00
|
|
|
#endif
|
2003-07-17 19:37:56 +00:00
|
|
|
|
|
|
|
static int ep_isa_probe(device_t);
|
|
|
|
static int ep_isa_attach(device_t);
|
|
|
|
static int ep_eeprom_cksum(struct ep_softc *);
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
struct isa_ident {
|
2005-01-20 19:39:33 +00:00
|
|
|
uint32_t id;
|
2003-07-17 19:37:56 +00:00
|
|
|
char *name;
|
1999-10-27 06:25:16 +00:00
|
|
|
};
|
2005-01-20 19:39:33 +00:00
|
|
|
const char *ep_isa_match_id(uint32_t, struct isa_ident *);
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2000-01-23 08:23:38 +00:00
|
|
|
#define ISA_ID_3C509_XXX 0x0506d509
|
1999-10-27 06:25:16 +00:00
|
|
|
#define ISA_ID_3C509_TP 0x506d5090
|
|
|
|
#define ISA_ID_3C509_BNC 0x506d5091
|
|
|
|
#define ISA_ID_3C509_COMBO 0x506d5094
|
|
|
|
#define ISA_ID_3C509_TPO 0x506d5095
|
2000-01-23 08:23:38 +00:00
|
|
|
#define ISA_ID_3C509_TPC 0x506d5098
|
2000-12-09 04:25:07 +00:00
|
|
|
#ifdef PC98
|
|
|
|
#define ISA_ID_3C569B_COMBO 0x506d5694
|
|
|
|
#define ISA_ID_3C569B_TPO 0x506d5695
|
|
|
|
#endif
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2003-02-23 03:39:22 +00:00
|
|
|
#ifdef __i386__
|
1999-10-27 06:25:16 +00:00
|
|
|
static struct isa_ident ep_isa_devs[] = {
|
2003-07-17 19:37:56 +00:00
|
|
|
{ISA_ID_3C509_TP, "3Com 3C509-TP EtherLink III"},
|
|
|
|
{ISA_ID_3C509_BNC, "3Com 3C509-BNC EtherLink III"},
|
|
|
|
{ISA_ID_3C509_COMBO, "3Com 3C509-Combo EtherLink III"},
|
|
|
|
{ISA_ID_3C509_TPO, "3Com 3C509-TPO EtherLink III"},
|
|
|
|
{ISA_ID_3C509_TPC, "3Com 3C509-TPC EtherLink III"},
|
2000-12-09 04:25:07 +00:00
|
|
|
#ifdef PC98
|
2003-07-17 19:37:56 +00:00
|
|
|
{ISA_ID_3C569B_COMBO, "3Com 3C569B-J-Combo EtherLink III"},
|
|
|
|
{ISA_ID_3C569B_TPO, "3Com 3C569B-J-TPO EtherLink III"},
|
2000-12-09 04:25:07 +00:00
|
|
|
#endif
|
2003-07-17 19:37:56 +00:00
|
|
|
{0, NULL},
|
1999-09-26 06:42:36 +00:00
|
|
|
};
|
2003-02-23 03:39:22 +00:00
|
|
|
#endif
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
static struct isa_pnp_id ep_ids[] = {
|
2003-07-17 19:37:56 +00:00
|
|
|
{0x90506d50, "3Com 3C509B-TP EtherLink III (PnP)"}, /* TCM5090 */
|
|
|
|
{0x91506d50, "3Com 3C509B-BNC EtherLink III (PnP)"}, /* TCM5091 */
|
|
|
|
{0x94506d50, "3Com 3C509B-Combo EtherLink III (PnP)"}, /* TCM5094 */
|
|
|
|
{0x95506d50, "3Com 3C509B-TPO EtherLink III (PnP)"}, /* TCM5095 */
|
|
|
|
{0x98506d50, "3Com 3C509B-TPC EtherLink III (PnP)"}, /* TCM5098 */
|
|
|
|
{0xf780d041, NULL}, /* PNP80f7 */
|
|
|
|
{0, NULL},
|
1999-10-27 06:25:16 +00:00
|
|
|
};
|
1999-09-26 06:42:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We get eeprom data from the id_port given an offset into the eeprom.
|
|
|
|
* Basically; after the ID_sequence is sent to all of the cards; they enter
|
|
|
|
* the ID_CMD state where they will accept command requests. 0x80-0xbf loads
|
|
|
|
* the eeprom data. We then read the port 16 times and with every read; the
|
|
|
|
* cards check for contention (ie: if one card writes a 0 bit and another
|
|
|
|
* writes a 1 bit then the host sees a 0. At the end of the cycle; each card
|
|
|
|
* compares the data on the bus; if there is a difference then that card goes
|
|
|
|
* into ID_WAIT state again). In the meantime; one bit of data is returned in
|
|
|
|
* the AX register which is conveniently returned to us by inb(). Hence; we
|
|
|
|
* read 16 times getting one bit of data with each read.
|
|
|
|
*/
|
2003-02-23 03:39:22 +00:00
|
|
|
#ifdef __i386__
|
2005-01-20 19:39:33 +00:00
|
|
|
static uint16_t
|
2003-07-17 19:37:56 +00:00
|
|
|
get_eeprom_data(int id_port, int offset)
|
1999-09-26 06:42:36 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
int i;
|
2005-01-20 19:39:33 +00:00
|
|
|
uint16_t data = 0;
|
1999-12-06 08:59:52 +00:00
|
|
|
|
2003-07-17 19:37:56 +00:00
|
|
|
outb(id_port, EEPROM_CMD_RD | offset);
|
1999-10-27 06:25:16 +00:00
|
|
|
DELAY(BIT_DELAY_MULTIPLE * 1000);
|
1999-12-06 08:59:52 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
DELAY(50);
|
|
|
|
data = (data << 1) | (inw(id_port) & 1);
|
|
|
|
}
|
|
|
|
return (data);
|
1999-09-26 06:42:36 +00:00
|
|
|
}
|
2003-02-23 03:39:22 +00:00
|
|
|
#endif
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
const char *
|
2005-01-20 19:39:33 +00:00
|
|
|
ep_isa_match_id(uint32_t id, struct isa_ident *isa_devs)
|
1999-10-27 06:25:16 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
struct isa_ident *i = isa_devs;
|
|
|
|
|
|
|
|
while (i->name != NULL) {
|
|
|
|
if (id == i->id)
|
|
|
|
return (i->name);
|
|
|
|
i++;
|
1999-10-27 06:25:16 +00:00
|
|
|
}
|
2000-01-23 08:23:38 +00:00
|
|
|
/*
|
|
|
|
* If we see a card that is likely to be a 3c509
|
|
|
|
* return something so that it will work; be annoying
|
|
|
|
* so that the user will tell us about it though.
|
|
|
|
*/
|
2003-07-17 19:37:56 +00:00
|
|
|
if ((id >> 4) == ISA_ID_3C509_XXX)
|
2000-01-23 08:23:38 +00:00
|
|
|
return ("Unknown 3c509; notify maintainer!");
|
1999-10-27 06:25:16 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2003-02-13 23:01:59 +00:00
|
|
|
#ifdef __i386__
|
1999-10-27 06:25:16 +00:00
|
|
|
static void
|
2003-07-17 19:37:56 +00:00
|
|
|
ep_isa_identify(driver_t * driver, device_t parent)
|
1999-09-26 06:42:36 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
int tag = EP_LAST_TAG;
|
|
|
|
int found = 0;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
const char *desc;
|
2005-01-20 19:39:33 +00:00
|
|
|
uint16_t data;
|
|
|
|
uint32_t irq;
|
|
|
|
uint32_t ioport;
|
|
|
|
uint32_t isa_id;
|
2003-07-17 19:37:56 +00:00
|
|
|
device_t child;
|
1999-10-27 06:25:16 +00:00
|
|
|
|
|
|
|
outb(ELINK_ID_PORT, 0);
|
|
|
|
outb(ELINK_ID_PORT, 0);
|
|
|
|
elink_idseq(ELINK_509_POLY);
|
|
|
|
elink_reset();
|
|
|
|
|
|
|
|
DELAY(DELAY_MULTIPLE * 10000);
|
|
|
|
|
|
|
|
for (i = 0; i < EP_MAX_BOARDS; i++) {
|
|
|
|
|
|
|
|
outb(ELINK_ID_PORT, 0);
|
|
|
|
outb(ELINK_ID_PORT, 0);
|
1999-12-06 08:31:47 +00:00
|
|
|
elink_idseq(ELINK_509_POLY);
|
|
|
|
DELAY(400);
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2003-07-17 19:37:56 +00:00
|
|
|
/*
|
|
|
|
* For the first probe, clear all board's tag registers.
|
|
|
|
* Otherwise kill off already-found boards. -- linux 3c509.c
|
1999-10-27 06:25:16 +00:00
|
|
|
*/
|
2003-07-17 19:37:56 +00:00
|
|
|
if (i == 0)
|
1999-10-27 06:25:16 +00:00
|
|
|
outb(ELINK_ID_PORT, 0xd0);
|
2003-07-17 19:37:56 +00:00
|
|
|
else
|
1999-10-27 06:25:16 +00:00
|
|
|
outb(ELINK_ID_PORT, 0xd8);
|
|
|
|
|
1999-12-06 08:31:47 +00:00
|
|
|
/* Get out of loop if we're out of cards. */
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_MFG_ID);
|
2003-07-17 19:37:56 +00:00
|
|
|
if (data != MFG_ID)
|
1999-12-06 08:31:47 +00:00
|
|
|
break;
|
|
|
|
/* resolve contention using the Ethernet address */
|
2003-07-17 19:37:56 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
1999-12-06 08:31:47 +00:00
|
|
|
(void)get_eeprom_data(ELINK_ID_PORT, j);
|
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
/*
|
|
|
|
* Construct an 'isa_id' in 'EISA'
|
|
|
|
* format.
|
|
|
|
*/
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_MFG_ID);
|
|
|
|
isa_id = (htons(data) << 16);
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_PROD_ID);
|
|
|
|
isa_id |= htons(data);
|
|
|
|
|
|
|
|
/* Find known ISA boards */
|
|
|
|
desc = ep_isa_match_id(isa_id, ep_isa_devs);
|
|
|
|
if (!desc) {
|
2003-07-17 19:37:56 +00:00
|
|
|
if (bootverbose)
|
2003-08-30 08:10:58 +00:00
|
|
|
device_printf(parent,
|
2005-07-01 05:31:23 +00:00
|
|
|
"unknown ID 0x%08x\n", isa_id);
|
2000-01-23 08:46:21 +00:00
|
|
|
continue;
|
1999-10-27 06:25:16 +00:00
|
|
|
}
|
|
|
|
/* Retreive IRQ */
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_RESOURCE_CFG);
|
|
|
|
irq = (data >> 12);
|
|
|
|
|
|
|
|
/* Retreive IOPORT */
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_ADDR_CFG);
|
|
|
|
#ifdef PC98
|
2000-07-18 06:37:08 +00:00
|
|
|
ioport = (((data & ADDR_CFG_MASK) * 0x100) + 0x40d0);
|
1999-10-27 06:25:16 +00:00
|
|
|
#else
|
2000-07-18 06:37:08 +00:00
|
|
|
ioport = (((data & ADDR_CFG_MASK) << 4) + 0x200);
|
1999-10-27 06:25:16 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-18 06:37:08 +00:00
|
|
|
if ((data & ADDR_CFG_MASK) == ADDR_CFG_EISA) {
|
2003-08-30 08:10:58 +00:00
|
|
|
device_printf(parent,
|
2005-07-01 05:31:23 +00:00
|
|
|
"<%s> at port 0x%03x in EISA mode!\n",
|
2003-07-17 19:37:56 +00:00
|
|
|
desc, ioport);
|
|
|
|
/*
|
|
|
|
* Set the adaptor tag so that the next card can be
|
|
|
|
* found.
|
|
|
|
*/
|
2000-07-18 06:37:08 +00:00
|
|
|
outb(ELINK_ID_PORT, tag--);
|
|
|
|
continue;
|
|
|
|
}
|
1999-12-06 08:31:47 +00:00
|
|
|
/* Test for an adapter with PnP support. */
|
|
|
|
data = get_eeprom_data(ELINK_ID_PORT, EEPROM_CAP);
|
|
|
|
if (data == CAP_ISA) {
|
2003-08-30 08:10:58 +00:00
|
|
|
data = get_eeprom_data(ELINK_ID_PORT,
|
|
|
|
EEPROM_INT_CONFIG_1);
|
1999-12-06 08:31:47 +00:00
|
|
|
if (data & ICW1_IAS_PNP) {
|
2003-07-17 19:37:56 +00:00
|
|
|
if (bootverbose)
|
2003-08-30 08:10:58 +00:00
|
|
|
device_printf(parent,
|
2005-07-01 05:31:23 +00:00
|
|
|
"<%s> at 0x%03x "
|
2003-08-30 08:10:58 +00:00
|
|
|
"in PnP mode!\n",
|
2003-07-17 19:37:56 +00:00
|
|
|
desc, ioport);
|
|
|
|
/*
|
|
|
|
* Set the adaptor tag so that the next card
|
|
|
|
* can be found.
|
|
|
|
*/
|
1999-12-06 08:31:47 +00:00
|
|
|
outb(ELINK_ID_PORT, tag--);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
1999-10-27 06:25:16 +00:00
|
|
|
/* Set the adaptor tag so that the next card can be found. */
|
|
|
|
outb(ELINK_ID_PORT, tag--);
|
|
|
|
|
|
|
|
/* Activate the adaptor at the EEPROM location. */
|
1999-12-06 08:31:47 +00:00
|
|
|
outb(ELINK_ID_PORT, ACTIVATE_ADAPTER_TO_CONFIG);
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-12-06 08:31:47 +00:00
|
|
|
/* Test for an adapter in TEST mode. */
|
|
|
|
outw(ioport + EP_COMMAND, WINDOW_SELECT | 0);
|
1999-10-27 06:25:16 +00:00
|
|
|
data = inw(ioport + EP_W0_EEPROM_COMMAND);
|
|
|
|
if (data & EEPROM_TST_MODE) {
|
2003-08-30 08:10:58 +00:00
|
|
|
device_printf(parent,
|
2005-07-01 05:31:23 +00:00
|
|
|
"<%s> at port 0x%03x in TEST mode!"
|
2003-08-30 08:10:58 +00:00
|
|
|
" Erase pencil mark.\n",
|
2003-07-17 19:37:56 +00:00
|
|
|
desc, ioport);
|
1999-10-27 06:25:16 +00:00
|
|
|
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);
|
|
|
|
|
2003-07-17 19:37:56 +00:00
|
|
|
if (bootverbose)
|
2003-08-30 08:10:58 +00:00
|
|
|
device_printf(parent,
|
2005-07-01 05:31:23 +00:00
|
|
|
"<%s>"
|
2003-08-30 08:10:58 +00:00
|
|
|
" at port 0x%03x-0x%03x irq %d\n",
|
2003-07-17 19:37:56 +00:00
|
|
|
desc, ioport, ioport + EP_IOSIZE, irq);
|
1999-10-27 06:25:16 +00:00
|
|
|
found++;
|
|
|
|
}
|
1999-09-26 06:42:36 +00:00
|
|
|
}
|
2003-02-13 23:01:59 +00:00
|
|
|
#endif
|
1999-09-26 06:42:36 +00:00
|
|
|
|
|
|
|
static int
|
2003-07-17 19:37:56 +00:00
|
|
|
ep_isa_probe(device_t dev)
|
1999-09-26 06:42:36 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
int error = 0;
|
1999-09-26 06:42:36 +00:00
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
/* Check isapnp ids */
|
|
|
|
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 */
|
2003-07-17 19:37:56 +00:00
|
|
|
if (error == ENXIO)
|
|
|
|
return (error);
|
1999-10-27 06:25:16 +00:00
|
|
|
|
|
|
|
/* If we had some other problem. */
|
2003-07-17 19:37:56 +00:00
|
|
|
if (!(error == 0 || error == ENOENT))
|
1999-10-27 06:25:16 +00:00
|
|
|
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) &&
|
2003-07-17 19:37:56 +00:00
|
|
|
(bus_get_resource_start(dev, SYS_RES_IRQ, 0) != 0))
|
1999-10-27 06:25:16 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (ENXIO);
|
1999-09-26 06:42:36 +00:00
|
|
|
}
|
1999-10-27 06:25:16 +00:00
|
|
|
|
|
|
|
static int
|
2003-07-17 19:37:56 +00:00
|
|
|
ep_isa_attach(device_t dev)
|
1999-10-27 06:25:16 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
struct ep_softc *sc = device_get_softc(dev);
|
|
|
|
int error = 0;
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2005-07-01 05:31:23 +00:00
|
|
|
if ((error = ep_alloc(dev)))
|
1999-10-27 06:25:16 +00:00
|
|
|
goto bad;
|
|
|
|
ep_get_media(sc);
|
|
|
|
|
2003-10-26 22:28:20 +00:00
|
|
|
GO_WINDOW(sc, 0);
|
2003-10-18 15:22:43 +00:00
|
|
|
SET_IRQ(sc, rman_get_start(sc->irq));
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2005-07-01 05:31:23 +00:00
|
|
|
if ((error = ep_attach(sc)))
|
1999-10-27 06:25:16 +00:00
|
|
|
goto bad;
|
2003-03-29 21:57:32 +00:00
|
|
|
error = ep_eeprom_cksum(sc);
|
|
|
|
if (error) {
|
|
|
|
device_printf(sc->dev, "Invalid EEPROM checksum!\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
2003-10-25 04:09:49 +00:00
|
|
|
if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, ep_intr,
|
2003-07-17 19:37:56 +00:00
|
|
|
sc, &sc->ep_intrhand))) {
|
1999-10-27 06:25:16 +00:00
|
|
|
device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
bad:
|
|
|
|
ep_free(dev);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2003-03-29 21:57:32 +00:00
|
|
|
static int
|
2003-07-17 19:37:56 +00:00
|
|
|
ep_eeprom_cksum(struct ep_softc *sc)
|
2003-03-29 21:57:32 +00:00
|
|
|
{
|
2003-07-17 19:37:56 +00:00
|
|
|
int i;
|
|
|
|
int error;
|
2005-01-20 19:39:33 +00:00
|
|
|
uint16_t val;
|
|
|
|
uint16_t cksum;
|
|
|
|
uint8_t cksum_high = 0;
|
|
|
|
uint8_t cksum_low = 0;
|
2003-03-29 21:57:32 +00:00
|
|
|
|
2005-06-26 04:19:45 +00:00
|
|
|
error = ep_get_e(sc, 0x0f, &val);
|
2003-03-29 21:57:32 +00:00
|
|
|
if (error)
|
2003-07-17 19:37:56 +00:00
|
|
|
return (ENXIO);
|
2003-03-29 21:57:32 +00:00
|
|
|
cksum = val;
|
|
|
|
|
|
|
|
for (i = 0; i < 0x0f; i++) {
|
2005-06-26 04:19:45 +00:00
|
|
|
error = ep_get_e(sc, i, &val);
|
2003-03-29 21:57:32 +00:00
|
|
|
if (error)
|
|
|
|
return (ENXIO);
|
|
|
|
switch (i) {
|
2003-07-17 19:37:56 +00:00
|
|
|
case 0x08:
|
|
|
|
case 0x09:
|
|
|
|
case 0x0d:
|
2005-01-20 19:39:33 +00:00
|
|
|
cksum_low ^= (uint8_t) (val & 0x00ff) ^
|
|
|
|
(uint8_t)((val & 0xff00) >> 8);
|
2003-07-17 19:37:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-01-20 19:39:33 +00:00
|
|
|
cksum_high ^= (uint8_t) (val & 0x00ff) ^
|
|
|
|
(uint8_t)((val & 0xff00) >> 8);
|
2003-07-17 19:37:56 +00:00
|
|
|
break;
|
2003-03-29 21:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-20 19:39:33 +00:00
|
|
|
return (cksum != ((uint16_t)cksum_low | (uint16_t)(cksum_high << 8)));
|
2003-03-29 21:57:32 +00:00
|
|
|
}
|
|
|
|
|
1999-10-27 06:25:16 +00:00
|
|
|
static device_method_t ep_isa_methods[] = {
|
|
|
|
/* Device interface */
|
2003-02-13 23:01:59 +00:00
|
|
|
#ifdef __i386__
|
2003-07-17 19:37:56 +00:00
|
|
|
DEVMETHOD(device_identify, ep_isa_identify),
|
2003-02-13 23:01:59 +00:00
|
|
|
#endif
|
2003-07-17 19:37:56 +00:00
|
|
|
DEVMETHOD(device_probe, ep_isa_probe),
|
|
|
|
DEVMETHOD(device_attach, ep_isa_attach),
|
|
|
|
DEVMETHOD(device_detach, ep_detach),
|
1999-10-27 06:25:16 +00:00
|
|
|
|
2003-07-17 19:37:56 +00:00
|
|
|
{0, 0}
|
1999-10-27 06:25:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ep_isa_driver = {
|
|
|
|
"ep",
|
|
|
|
ep_isa_methods,
|
|
|
|
sizeof(struct ep_softc),
|
|
|
|
};
|
|
|
|
|
|
|
|
extern devclass_t ep_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(ep, isa, ep_isa_driver, ep_devclass, 0, 0);
|
2003-03-29 13:45:17 +00:00
|
|
|
#ifdef __i386__
|
|
|
|
MODULE_DEPEND(ep, elink, 1, 1, 1);
|
|
|
|
#endif
|