/*-
* Copyright (c) 1997, 1998, 2010 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 SMC Elite Ultra (8216) with SMC_TT VME-ISA bridge.
* Based on:
* NetBSD: if_we_isa.c,v 1.20 2008/04/28 20:23:52 martin Exp
*/
/* VME space mapped by SMC_TT VME-ISA bridge */
#define SMCTT_MEM_BASE 0xFE000000 /* base for shared memory space */
#define SMCTT_IOE_BASE 0xFE200000 /* base for I/O ports at even address */
#define SMCTT_IOO_BASE 0xFE300000 /* base for I/O ports at odd address */
/* SMC_TT has a bit weird I/O address mappings */
asict = beb_alloc_bus_space_tag(&t);
/* XXX setup only simple byte functions used in MI we(4) driver */
asict->abs_r_1 = smctt_bus_space_read_1;
asict->abs_w_1 = smctt_bus_space_write_1;
asict->abs_p_1 = smctt_bus_space_peek_1;
/*
* Only 16 bit accesses are allowed for memory space on SMC_TT,
* but MI we(4) uses them on 16 bit mode.
*/
memt = va->va_memt;
/* Attempt to map the device. */
if (bus_space_map(asict, SMCTT_IOE_BASE + SMCTT_IO_ADDR, WE_NPORTS,
0, &asich) != 0) {
DPRINTF(("%s: failed to map even I/O space", __func__));
goto out;
}
asich_valid = true;
/* XXX abuse stride for offset of odd ports from even ones */
asict->stride =
(vaddr_t)bus_space_vaddr(asict, asich1) -
(vaddr_t)bus_space_vaddr(asict, asich);
/* check if register regions are valid */
if (bus_space_peek_1(asict, asich, WE_PROM + 0) == 0 ||
bus_space_peek_1(asict, asich, WE_PROM + 1) == 0)
goto out;
/*
* Attempt to do a checksum over the station address PROM.
* If it fails, it's probably not an SMC_TT board.
*/
DPRINTF(("%s: WE_PROM: ", __func__));
sum = 0;
for (i = 0; i < 8; i++) {
reg = bus_space_read_1(asict, asich, WE_PROM + i);
DPRINTF(("%02x ", reg));
sum += reg;
}
DPRINTF(("\n"));
DPRINTF(("%s: WE_ROM_SUM: 0x%02x\n", __func__, sum));
if (sum != WE_ROM_CHECKSUM_TOTAL)
goto out;
/*
* Reset the card to force it into a known state.
*/
bus_space_write_1(asict, asich, WE_MSR, WE_MSR_RST);
delay(100);