Newbusify ed driver.

Partly submitted by:	alex
This commit is contained in:
Seigo Tanimura 2000-08-14 04:31:07 +00:00
parent 4bcefa9655
commit 8f4fec9c36
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64630
3 changed files with 482 additions and 389 deletions

File diff suppressed because it is too large Load Diff

View File

@ -130,13 +130,19 @@ ed_pccard_probe(device_t dev)
u_char rdbuf[4];
int iobase;
int attr_ioport;
/* XXX Allocate the port resource during setup. */
error = ed_alloc_port(dev, 0, ED_NOVELL_IO_PORTS);
if (error != 0)
return (error);
sc->chip_type = ED_CHIP_TYPE_AX88190;
/*
* Check & Set Attribute Memory IOBASE Register
*/
ed_pccard_memread(dev,ED_AX88190_IOBASE0,rdbuf,4);
attr_ioport = rdbuf[2] << 8 | rdbuf[0];
iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
iobase = rman_get_start(sc->port_res);
if (attr_ioport != iobase) {
#if notdef
printf("AX88190 IOBASE MISMATCH %04x -> %04x Setting\n",attr_ioport,iobase);
@ -144,7 +150,9 @@ ed_pccard_probe(device_t dev)
ed_pccard_memwrite(dev,ED_AX88190_IOBASE0,iobase & 0xff);
ed_pccard_memwrite(dev,ED_AX88190_IOBASE1,(iobase >> 8) & 0xff);
}
ax88190_geteprom(dev);
ed_ax88190_geteprom(sc);
ed_release_resources(dev);
}
error = ed_probe_Novell(dev);
@ -201,73 +209,6 @@ ed_pccard_attach(device_t dev)
return (error);
}
static void
ax88190_geteprom(device_t dev)
{
int prom[16],i;
u_char tmp;
struct ed_softc *sc;
struct pccard_devinfo *devi;
int iobase;
struct {
unsigned char offset,value;
} pg_seq[]={
{ED_P0_CR ,ED_CR_RD2|ED_CR_STP}, /* Select Page0 */
{ED_P0_DCR,0x01},
{ED_P0_RBCR0, 0x00}, /* Clear the count regs. */
{ED_P0_RBCR1, 0x00},
{ED_P0_IMR, 0x00}, /* Mask completion irq. */
{ED_P0_ISR, 0xff},
{ED_P0_RCR, ED_RCR_MON|ED_RCR_INTT}, /* Set To Monitor */
{ED_P0_TCR, ED_TCR_LB0}, /* loopback mode. */
{ED_P0_RBCR0,32},
{ED_P0_RBCR1,0x00},
{ED_P0_RSAR0,0x00},
{ED_P0_RSAR1,0x04},
{ED_P0_CR ,ED_CR_RD0|ED_CR_STA},
};
sc = device_get_softc(dev);
devi = device_get_ivars(dev);
iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
/* XXX: no bus_space_*()? */
/* Default Set */
sc->asic_addr = iobase + ED_NOVELL_ASIC_OFFSET;
sc->nic_addr = iobase + ED_NOVELL_NIC_OFFSET;
/* Reset Card */
tmp = inb(sc->asic_addr + ED_NOVELL_RESET);
outb(sc->asic_addr + ED_NOVELL_RESET, tmp);
DELAY(5000);
outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_STP);
DELAY(5000);
/* Card Settings */
for(i=0;i<sizeof(pg_seq)/sizeof(pg_seq[0]);i++) {
outb(sc->nic_addr + pg_seq[i].offset , pg_seq[i].value);
}
/* Get Data */
for(i=0;i<16;i++) {
prom[i] = inw(sc->asic_addr);
}
/*
for(i=0;i<16;i++) {
printf("ax88190 eprom [%02d] %02x %02x\n",
i,prom[i] & 0xff,prom[i] >> 8);
}
*/
sc->arpcom.ac_enaddr[0] = prom[0] & 0xff;
sc->arpcom.ac_enaddr[1] = prom[0] >> 8;
sc->arpcom.ac_enaddr[2] = prom[1] & 0xff;
sc->arpcom.ac_enaddr[3] = prom[1] >> 8;
sc->arpcom.ac_enaddr[4] = prom[2] & 0xff;
sc->arpcom.ac_enaddr[5] = prom[2] >> 8;
return;
}
/* XXX: Warner-san, any plan to provide access to the attribute memory? */
static int
ed_pccard_memwrite(device_t dev, off_t offset, u_char byte)

View File

@ -48,8 +48,16 @@ struct ed_softc {
struct resource* irq_res; /* resource for irq */
void* irq_handle; /* handle for irq handler */
bus_space_tag_t bst; /* Bus Space tag */
bus_space_handle_t bsh; /* Bus Space handle */
#ifdef __alpha__
u_int asic_addr; /* ASIC I/O bus address */
u_int nic_addr; /* NIC (DS8390) I/O bus address */
#else
u_short asic_addr; /* ASIC I/O bus address */
u_short nic_addr; /* NIC (DS8390) I/O bus address */
#endif
/*
* The following 'proto' variable is part of a work-around for 8013EBT asics
@ -66,12 +74,12 @@ struct ed_softc {
u_short hpp_options; /* flags controlling behaviour of the HP card */
u_short hpp_id; /* software revision and other fields */
caddr_t hpp_mem_start; /* Memory-mapped IO register address */
u_long hpp_mem_start; /* Memory-mapped IO register address */
caddr_t mem_start; /* NIC memory start address */
caddr_t mem_end; /* NIC memory end address */
u_long mem_size; /* total NIC memory size */
caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */
u_long mem_start; /* NIC memory start address */
u_long mem_end; /* NIC memory end address */
u_int32_t mem_size; /* total NIC memory size */
u_long mem_ring; /* start of RX ring-buffer (in NIC mem) */
u_char mem_shared; /* NIC memory is shared with host */
u_char xmit_busy; /* transmitter is busy */
@ -100,6 +108,7 @@ int ed_probe_Novell __P((device_t));
int ed_probe_Novell_generic __P((device_t, int, int));
int ed_probe_HP_pclanp __P((device_t));
int ed_get_Linksys __P((struct ed_softc *));
void ed_ax88190_geteprom __P((struct ed_softc *));
int ed_attach __P((struct ed_softc *, int, int));
void ed_stop __P((struct ed_softc *));