/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg and Matt Fredette.
*
* 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.
*/
/*-
* Copyright (c) 1995 Charles D. Cranor
* 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.
*
* 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.
*/
/*
* Sun2 OBIO front-end for the Intel 82586 Ethernet driver
*
* Converted to SUN ie driver by Charles D. Cranor,
* October 1994, January 1995.
*/
/*
* The i82586 is a very painful chip, found in sun[23]'s, sun-4/100's
* sun-4/200's, and VME based suns. The byte order is all wrong for a
* SUN, making life difficult. Programming this chip is mostly the same,
* but certain details differ from system to system. This driver is
* written so that different "ie" interfaces can be controlled by the same
* driver.
*/
/*
* The i82586's 24-bit address space maps to all of
* KVA space (). In addition, the SCP must appear
* at IE_SCP_ADDR within the 24-bit address space,
* i.e. at KVA IEOB_ADBASE+IE_SCP_ADDR, at the very top of
* kernel space. We double-map this last page to the first
* page (starting at `maddr') of the memory we allocate to the chip.
* (a side-effect of this double-map is that the ISCP and SCB
* structures also get aliased there, but we ignore this). The
* first page at `maddr' is only used for ISCP, SCB and the aliased
* SCP; the actual buffers start at maddr+PAGE_SIZE.
*
* In a picture:
/* Map iscp at location 0 (relative to `maddr') */
sc->iscp = 0;
/* scb follows iscp */
sc->scb = IE_ISCP_SZ;
/* scp is at the fixed location IE_SCP_ADDR (modulo the page size) */
sc->scp = IE_SCP_ADDR & PGOFSET;
/* Calculate the 24-bit base of i82586 operations */
iebase = (u_long)sc->sc_dmamap->dm_segs[0].ds_addr -
(u_long)IEOB_ADBASE;
ie_obio_write16(sc, IE_ISCP_SCB(sc->iscp), sc->scb);
ie_obio_write24(sc, IE_ISCP_BASE(sc->iscp), iebase);
ie_obio_write24(sc, IE_SCP_ISCP(sc->scp), iebase + sc->iscp);
/*
* Rest of first page is unused (wasted!); the other pages
* are used for buffers.
*/
sc->buf_area = PAGE_SIZE;
sc->buf_area_sz = memsize - PAGE_SIZE;