/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* 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.
*/
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
* adapters.
*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
*
* Copyright (C) 1993, David Greenman. This software may be used, modified,
* copied, distributed, and sold, in both source and binary form provided that
* the above copyright and these terms are retained. Under no circumstances is
* the author responsible for the proper functioning of this software, nor does
* the author assume any responsibility for damages incurred with its use.
*/
/*
* Device driver for the Western Digital/SMC 8003 and 8013 series,
* and the SMC Elite Ultra (8216).
*/
/*
* Attempt to do a checksum over the station address PROM.
* If it fails, it's probably not a WD/SMC board. There is
* a problem with this, though. Some clone WD8003E boards
* (e.g. Danpex) won't pass the checksum. In this case,
* the checksum byte always seems to be 0.
*/
for (x = 0, i = 0; i < 8; i++)
x += bus_space_read_1(asict, asich, WE_PROM + i);
if (x != WE_ROM_CHECKSUM_TOTAL) {
/* Make sure it's an 8003E clone... */
if (bus_space_read_1(asict, asich, WE_CARD_ID) !=
WE_TYPE_WD8003E)
goto out;
/* Check the checksum byte. */
if (bus_space_read_1(asict, asich, WE_PROM + 7) != 0)
goto out;
}
/*
* Reset the card to force it into a known state.
*/
#ifdef TOSH_ETHER
bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST | WE_MSR_POW);
#else
bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST);
#endif
delay(100);
typestr = we_params(asict, asich, &wsc->sc_type, NULL,
&wsc->sc_flags, &sc->is790);
if (typestr == NULL) {
aprint_error_dev(self, "where did the card go?\n");
return;
}
/*
* Map memory space. Note we use the size that might have
* been overridden by the user.
*/
if (bus_space_map(memt, ia->ia_iomem[0].ir_addr,
ia->ia_iomem[0].ir_size, 0, &memh)) {
aprint_error_dev(self, "can't map shared memory\n");
return;
}
hwr = bus_space_read_1(asict, asich, WE790_HWR);
bus_space_write_1(asict, asich, WE790_HWR,
hwr | WE790_HWR_SWH);
switch (bus_space_read_1(asict, asich, WE790_RAR) &
WE790_RAR_SZ64) {
case WE790_RAR_SZ64:
memsize = 65536;
break;
case WE790_RAR_SZ32:
memsize = 32768;
break;
case WE790_RAR_SZ16:
memsize = 16384;
break;
case WE790_RAR_SZ8:
/* 8216 has 16K shared mem -- 8416 has 8K */
typestr = (type == WE_TYPE_SMC8216C) ?
"SMC8416C/SMC8416BT" : "SMC8416T";
memsize = 8192;
break;
}
bus_space_write_1(asict, asich, WE790_HWR, hwr);
is16bit = 1;
is790 = 1;
break;
}
#ifdef TOSH_ETHER
case WE_TYPE_TOSHIBA1:
typestr = "Toshiba1";
memsize = 32768;
is16bit = 1;
break;
case WE_TYPE_TOSHIBA4:
typestr = "Toshiba4";
memsize = 32768;
is16bit = 1;
break;
#endif
default:
/* Not one we recognize. */
return NULL;
}
/*
* Make some adjustments to initial values depending on what is
* found in the ICR.
*/
if (is16bit && (type != WE_TYPE_WD8013EBT) &&
#ifdef TOSH_ETHER
(type != WE_TYPE_TOSHIBA1 && type != WE_TYPE_TOSHIBA4) &&
#endif
(bus_space_read_1(asict, asich, WE_ICR) & WE_ICR_16BIT) == 0) {
is16bit = 0;
memsize = 8192;
}
#ifdef WE_DEBUG
{
int i;
printf("we_params: type = 0x%x, typestr = %s, is16bit = %d, "
"memsize = %ld\n", type, typestr, is16bit, (u_long)memsize);
for (i = 0; i < 8; i++)
printf(" %d -> 0x%x\n", i,
bus_space_read_1(asict, asich, i));
}
#endif
if (typep != NULL)
*typep = type;
if (memsizep != NULL)
*memsizep = memsize;
if (flagp != NULL && is16bit)
*flagp |= WE_16BIT_ENABLE;
if (is790p != NULL)
*is790p = is790;
return typestr;
}