/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Rafal K. Boni and Jaromir Dolecek.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/*
* 3Com 3c523 EtherLink/MC Ethernet card driver (uses i82586 Ethernet chip).
*
* The 3c523-specific hooks were derived from Linux driver (file
* drivers/net/3c523.[ch]).
*
* This driver uses generic i82586 stuff. See also ai(4), ef(4), ix(4).
*/
/* map the pio registers */
if (bus_space_map(ma->ma_iot, iobase, ELMC_IOADDR_SIZE, 0, &ioh)) {
aprint_error_dev(self, "unable to map i/o space\n");
return;
}
/*
* 3c523 has a 24K memory. The first 16K is the shared memory, while
* the last 8K is for the EtherStart BIOS ROM, which we don't care
* about. Just use the first 16K.
*/
if (bus_space_map(ma->ma_memt, pbram_addr, ELMC_MADDR_SIZE, 0, &memh)) {
aprint_error_dev(self, "unable to map memory space\n");
if (pbram_addr == 0xc0000) {
aprint_error_dev(self,
"memory space 0xc0000 may conflict with vga\n");
}
/*
* According to docs, we might need to read the interrupt number and
* write it back to the IRQ select register, since the POST might not
* configure the IRQ properly.
*/
(void) mca_conf_write(ma->ma_mc, ma->ma_slot, 3, pos3 & 0x1f);
/* reset the card first */
elmc_mca_hwreset(sc, CARD_RESET);
delay(1000000 / ( 1<< 5));
/* zero card memory */
bus_space_set_region_1(sc->bt, sc->bh, 0, 0, sc->sc_msize);
/* set card to 16-bit bus mode */
bus_space_write_1(sc->bt, sc->bh, IE_SCP_BUS_USE((u_long)sc->scp),
IE_SYSBUS_16BIT);
/* set up pointers to key structures */
elmc_mca_write_24(sc, IE_SCP_ISCP((u_long)sc->scp), (u_long) sc->iscp);
elmc_mca_write_16(sc, IE_ISCP_SCB((u_long)sc->iscp), (u_long) sc->scb);
elmc_mca_write_24(sc, IE_ISCP_BASE((u_long)sc->iscp),
(u_long) sc->iscp);
/* flush setup of pointers, check if chip answers */
if (!i82586_proberam(sc)) {
aprint_error_dev(self, "can't talk to i82586!\n");
/* revision is stored in the first 4 bits of the revision register */
revision = (int) bus_space_read_1(asc->sc_regt, asc->sc_regh,
ELMC_REVISION) & ELMC_REVISION_MASK;
/*
* Hardware ethernet address is stored in the first six bytes
* of the IO space.
*/
for(i=0; i < MIN(6, ETHER_ADDR_LEN); i++)
myaddr[i] = bus_space_read_1(asc->sc_regt, asc->sc_regh, i);