Home | History | Annotate | Line # | Download | only in mca
if_we_mca.c revision 1.3.2.4
      1  1.3.2.4  nathanw /*	$NetBSD: if_we_mca.c,v 1.3.2.4 2001/11/14 19:15:01 nathanw Exp $	*/
      2  1.3.2.2  nathanw 
      3  1.3.2.2  nathanw /*-
      4  1.3.2.2  nathanw  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
      5  1.3.2.2  nathanw  * All rights reserved.
      6  1.3.2.2  nathanw  *
      7  1.3.2.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.3.2.2  nathanw  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.3.2.2  nathanw  * NASA Ames Research Center, and Jaromir Dolecek.
     10  1.3.2.2  nathanw  *
     11  1.3.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
     12  1.3.2.2  nathanw  * modification, are permitted provided that the following conditions
     13  1.3.2.2  nathanw  * are met:
     14  1.3.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     15  1.3.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     16  1.3.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.3.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     18  1.3.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     19  1.3.2.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     20  1.3.2.2  nathanw  *    must display the following acknowledgement:
     21  1.3.2.2  nathanw  *	This product includes software developed by the NetBSD
     22  1.3.2.2  nathanw  *	Foundation, Inc. and its contributors.
     23  1.3.2.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.3.2.2  nathanw  *    contributors may be used to endorse or promote products derived
     25  1.3.2.2  nathanw  *    from this software without specific prior written permission.
     26  1.3.2.2  nathanw  *
     27  1.3.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.3.2.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.3.2.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.3.2.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.3.2.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.3.2.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.3.2.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.3.2.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.3.2.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.3.2.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.3.2.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     38  1.3.2.2  nathanw  */
     39  1.3.2.2  nathanw 
     40  1.3.2.2  nathanw /*
     41  1.3.2.2  nathanw  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
     42  1.3.2.2  nathanw  * adapters.
     43  1.3.2.2  nathanw  *
     44  1.3.2.2  nathanw  * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
     45  1.3.2.2  nathanw  *
     46  1.3.2.2  nathanw  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
     47  1.3.2.2  nathanw  * copied, distributed, and sold, in both source and binary form provided that
     48  1.3.2.2  nathanw  * the above copyright and these terms are retained.  Under no circumstances is
     49  1.3.2.2  nathanw  * the author responsible for the proper functioning of this software, nor does
     50  1.3.2.2  nathanw  * the author assume any responsibility for damages incurred with its use.
     51  1.3.2.2  nathanw  */
     52  1.3.2.2  nathanw 
     53  1.3.2.2  nathanw /*
     54  1.3.2.2  nathanw  * Device driver for the Western Digital/SMC 8003 and 8013 series,
     55  1.3.2.2  nathanw  * and the SMC Elite Ultra (8216).
     56  1.3.2.2  nathanw  *
     57  1.3.2.2  nathanw  * Currently only tested with WD8003W/A. Other WD8003-based cards
     58  1.3.2.2  nathanw  * should work without problems, the SMC Elite based ones hopefully too.
     59  1.3.2.2  nathanw  */
     60  1.3.2.2  nathanw 
     61  1.3.2.4  nathanw #include <sys/cdefs.h>
     62  1.3.2.4  nathanw __KERNEL_RCSID(0, "$NetBSD: if_we_mca.c,v 1.3.2.4 2001/11/14 19:15:01 nathanw Exp $");
     63  1.3.2.4  nathanw 
     64  1.3.2.2  nathanw #include <sys/param.h>
     65  1.3.2.2  nathanw #include <sys/systm.h>
     66  1.3.2.2  nathanw #include <sys/device.h>
     67  1.3.2.2  nathanw #include <sys/socket.h>
     68  1.3.2.2  nathanw #include <sys/mbuf.h>
     69  1.3.2.2  nathanw 
     70  1.3.2.2  nathanw #include <net/if.h>
     71  1.3.2.2  nathanw #include <net/if_types.h>
     72  1.3.2.2  nathanw #include <net/if_media.h>
     73  1.3.2.2  nathanw #include <net/if_ether.h>
     74  1.3.2.2  nathanw 
     75  1.3.2.2  nathanw #include <machine/bus.h>
     76  1.3.2.2  nathanw 
     77  1.3.2.2  nathanw #include <dev/mca/mcareg.h>
     78  1.3.2.2  nathanw #include <dev/mca/mcavar.h>
     79  1.3.2.2  nathanw #include <dev/mca/mcadevs.h>
     80  1.3.2.2  nathanw 
     81  1.3.2.2  nathanw #include <dev/ic/dp8390reg.h>
     82  1.3.2.2  nathanw #include <dev/ic/dp8390var.h>
     83  1.3.2.2  nathanw #include <dev/ic/wereg.h>
     84  1.3.2.2  nathanw #include <dev/ic/wevar.h>
     85  1.3.2.2  nathanw 
     86  1.3.2.2  nathanw #define WD_8003		0x01
     87  1.3.2.2  nathanw #define WD_ELITE	0x02
     88  1.3.2.2  nathanw #define WD_MEMSIZE	16384	/* all supported cards have 16K Bytes memory */
     89  1.3.2.2  nathanw 
     90  1.3.2.2  nathanw int we_mca_probe __P((struct device *, struct cfdata *, void *));
     91  1.3.2.2  nathanw void we_mca_attach __P((struct device *, struct device *, void *));
     92  1.3.2.2  nathanw void we_mca_init_hook __P((struct we_softc *));
     93  1.3.2.2  nathanw 
     94  1.3.2.2  nathanw struct cfattach we_mca_ca = {
     95  1.3.2.2  nathanw 	sizeof(struct we_softc), we_mca_probe, we_mca_attach
     96  1.3.2.2  nathanw };
     97  1.3.2.2  nathanw 
     98  1.3.2.2  nathanw /*
     99  1.3.2.2  nathanw  * The types for some cards may not be correct; hopefully it's close
    100  1.3.2.2  nathanw  * enough.
    101  1.3.2.2  nathanw  */
    102  1.3.2.2  nathanw static const struct we_mca_product {
    103  1.3.2.2  nathanw 	u_int32_t we_id;
    104  1.3.2.2  nathanw 	const char *we_name;
    105  1.3.2.2  nathanw 	int we_flag;
    106  1.3.2.2  nathanw 	int we_type;
    107  1.3.2.2  nathanw 	const char *we_typestr;
    108  1.3.2.2  nathanw } we_mca_products[] = {
    109  1.3.2.2  nathanw 	{ MCA_PRODUCT_WD_8013EP, "EtherCard PLUS Elite/A (8013EP/A)",
    110  1.3.2.2  nathanw 		WD_ELITE,	WE_TYPE_WD8013EP, "WD8013EP/A" },
    111  1.3.2.2  nathanw 	{ MCA_PRODUCT_WD_8013WP, "EtherCard PLUS Elite 10T/A (8013WP/A)",
    112  1.3.2.2  nathanw 		WD_ELITE,	WE_TYPE_WD8013EP, "WD8013WP/A" }, /* XXX */
    113  1.3.2.2  nathanw 	{ MCA_PRODUCT_IBM_WD_2,"IBM PS/2 Adapter/A for Ethernet Networks (UTP)",
    114  1.3.2.2  nathanw 		WD_ELITE, WE_TYPE_WD8013EP, "WD8013WP/A"}, /* XXX */
    115  1.3.2.2  nathanw 	{ MCA_PRODUCT_IBM_WD_T,"IBM PS/2 Adapter/A for Ethernet Networks (BNC)",
    116  1.3.2.2  nathanw 		WD_ELITE, WE_TYPE_WD8013EP, "WD8013WP/A"}, /* XXX */
    117  1.3.2.2  nathanw 	{ MCA_PRODUCT_WD_8003E,	"WD EtherCard PLUS/A (WD8003E/A or WD8003ET/A)",
    118  1.3.2.2  nathanw 		WD_8003,	WE_TYPE_WD8003E, "WD8003E/A or WD8003ET/A" },
    119  1.3.2.2  nathanw 	{ MCA_PRODUCT_WD_8003ST,"WD StarCard PLUS/A (WD8003ST/A)",
    120  1.3.2.2  nathanw 		WD_8003,	WE_TYPE_WD8003W, "WD8003ST/A" }, /* XXX */
    121  1.3.2.2  nathanw 	{ MCA_PRODUCT_WD_8003W,	"WD EtherCard PLUS 10T/A (WD8003W/A)",
    122  1.3.2.2  nathanw 		WD_8003,	WE_TYPE_WD8003W, "WD8003W/A" },
    123  1.3.2.2  nathanw 	{ MCA_PRODUCT_IBM_WD_O, "IBM PS/2 Adapter/A for Ethernet Networks",
    124  1.3.2.2  nathanw 		WD_8003,	WE_TYPE_WD8003W, "IBM PS/2 Adapter/A" },/*XXX*/
    125  1.3.2.2  nathanw 	{ 0x0000,			NULL },
    126  1.3.2.2  nathanw };
    127  1.3.2.2  nathanw 
    128  1.3.2.2  nathanw /* see POS description in we_mca_attach() */
    129  1.3.2.2  nathanw static const int we_mca_irq[] = {
    130  1.3.2.2  nathanw 	3, 4, 10, 15,
    131  1.3.2.2  nathanw };
    132  1.3.2.2  nathanw 
    133  1.3.2.2  nathanw /* memory position and shared RAM sizes for WD8013-type of cards */
    134  1.3.2.2  nathanw static const struct {
    135  1.3.2.2  nathanw 	u_int8_t id;
    136  1.3.2.2  nathanw 	int maddr;
    137  1.3.2.2  nathanw 	int memsize;
    138  1.3.2.2  nathanw } we_mca_elite_mem[] = {
    139  1.3.2.2  nathanw 	{ 0x10,	0x0C0000, 16384 },
    140  1.3.2.2  nathanw 	{ 0x12,	0x0C4000, 16384 },
    141  1.3.2.2  nathanw 	{ 0x14,	0x0C8000, 16384 },
    142  1.3.2.2  nathanw 	{ 0x16,	0x0CC000, 16384 },
    143  1.3.2.2  nathanw 	{ 0x18,	0x0D0000, 16384 },
    144  1.3.2.2  nathanw 	{ 0x1A,	0x0D4000, 16384 },
    145  1.3.2.2  nathanw 	{ 0x1C,	0x0D8000, 16384 },
    146  1.3.2.2  nathanw 	{ 0x1E,	0x0DC000, 16384 },
    147  1.3.2.2  nathanw 	{ 0x90,	0xFC0000, 16384 },
    148  1.3.2.2  nathanw 	{ 0x94,	0xFC8000, 16384 },
    149  1.3.2.2  nathanw 	{ 0x98,	0xFD0000, 16384 },
    150  1.3.2.2  nathanw 	{ 0x9C,	0x0C0000, 16384 },
    151  1.3.2.2  nathanw 	{ 0x00,	0x0C0000, 8192 },
    152  1.3.2.2  nathanw 	{ 0x01,	0x0C2000, 8192 },
    153  1.3.2.2  nathanw 	{ 0x10,	0x0C4000, 8192 },
    154  1.3.2.2  nathanw 	{ 0x11,	0x0C6000, 8192 },
    155  1.3.2.2  nathanw 	{ 0x00, 0x000000, 0    },
    156  1.3.2.2  nathanw };
    157  1.3.2.2  nathanw 
    158  1.3.2.2  nathanw 
    159  1.3.2.2  nathanw static const struct we_mca_product *we_mca_lookup __P((int));
    160  1.3.2.2  nathanw 
    161  1.3.2.2  nathanw static const struct we_mca_product *
    162  1.3.2.2  nathanw we_mca_lookup(id)
    163  1.3.2.2  nathanw 	int id;
    164  1.3.2.2  nathanw {
    165  1.3.2.2  nathanw 	const struct we_mca_product *wep;
    166  1.3.2.2  nathanw 
    167  1.3.2.2  nathanw 	for(wep = we_mca_products; wep->we_name; wep++)
    168  1.3.2.2  nathanw 		if (wep->we_id == id)
    169  1.3.2.2  nathanw 			return (wep);
    170  1.3.2.2  nathanw 
    171  1.3.2.2  nathanw 	return (NULL);
    172  1.3.2.2  nathanw }
    173  1.3.2.2  nathanw 
    174  1.3.2.2  nathanw int
    175  1.3.2.2  nathanw we_mca_probe(parent, cf, aux)
    176  1.3.2.2  nathanw 	struct device *parent;
    177  1.3.2.2  nathanw 	struct cfdata *cf;
    178  1.3.2.2  nathanw 	void *aux;
    179  1.3.2.2  nathanw {
    180  1.3.2.2  nathanw 	struct mca_attach_args *ma = aux;
    181  1.3.2.2  nathanw 
    182  1.3.2.2  nathanw 	return (we_mca_lookup(ma->ma_id) != NULL);
    183  1.3.2.2  nathanw }
    184  1.3.2.2  nathanw 
    185  1.3.2.2  nathanw void
    186  1.3.2.2  nathanw we_mca_attach(parent, self, aux)
    187  1.3.2.2  nathanw 	struct device *parent, *self;
    188  1.3.2.2  nathanw 	void *aux;
    189  1.3.2.2  nathanw {
    190  1.3.2.2  nathanw 	struct we_softc *wsc = (struct we_softc *)self;
    191  1.3.2.2  nathanw 	struct dp8390_softc *sc = &wsc->sc_dp8390;
    192  1.3.2.2  nathanw 	struct mca_attach_args *ma = aux;
    193  1.3.2.2  nathanw 	const struct we_mca_product *wep;
    194  1.3.2.2  nathanw 	bus_space_tag_t nict, asict, memt;
    195  1.3.2.2  nathanw 	bus_space_handle_t nich, asich, memh;
    196  1.3.2.2  nathanw 	const char *typestr;
    197  1.3.2.2  nathanw 	int irq, iobase, maddr;
    198  1.3.2.2  nathanw 	int pos2, pos3, pos5;
    199  1.3.2.2  nathanw 
    200  1.3.2.2  nathanw 	pos2 = mca_conf_read(ma->ma_mc, ma->ma_slot, 2);
    201  1.3.2.2  nathanw 	pos3 = mca_conf_read(ma->ma_mc, ma->ma_slot, 3);
    202  1.3.2.2  nathanw 	pos5 = mca_conf_read(ma->ma_mc, ma->ma_slot, 5);
    203  1.3.2.2  nathanw 
    204  1.3.2.2  nathanw 	/*
    205  1.3.2.2  nathanw 	 * POS registers differ much between 8003 and 8013, so they are
    206  1.3.2.2  nathanw 	 * divided to two sections.
    207  1.3.2.2  nathanw 	 *
    208  1.3.2.2  nathanw 	 * 8003: POS register 2: (adf pos0)
    209  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    210  1.3.2.2  nathanw 	 * 0 0 1  \___/  \__ enable: 0=adapter disabled, 1=adapter enabled
    211  1.3.2.2  nathanw 	 *            \_____ Adapter IO Space: 0x200-0x29F + XX*0x20
    212  1.3.2.2  nathanw 	 *
    213  1.3.2.2  nathanw 	 * 8003: POS register 3: (adf pos1)
    214  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    215  1.3.2.2  nathanw 	 * 1 1 0  \__/ 1 X
    216  1.3.2.2  nathanw 	 *           \______ Shared Ram Space (16K Bytes):
    217  1.3.2.2  nathanw 	 *                     0xC0000-0xC3FFF + XX * 0x4000
    218  1.3.2.2  nathanw 	 *
    219  1.3.2.2  nathanw 	 * 8003: POS register 5: (adf pos3)
    220  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    221  1.3.2.2  nathanw 	 *             \_/
    222  1.3.2.2  nathanw 	 *               \__ Interrupt Level: 00=3 01=4 10=10 11=15
    223  1.3.2.2  nathanw 	 *
    224  1.3.2.2  nathanw 	 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    225  1.3.2.2  nathanw 	 *
    226  1.3.2.2  nathanw 	 * 8013: POS register 2: (adf pos0)
    227  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    228  1.3.2.2  nathanw 	 * \____/        \__ enable: 0=adapter disabled, 1=adapter enabled
    229  1.3.2.2  nathanw 	 *      \___________ Adapter I/O Space: 0x0800-0x081F + XX * 0x1000
    230  1.3.2.2  nathanw 	 *
    231  1.3.2.2  nathanw 	 * 8013: POS register 3: (adf pos1)
    232  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    233  1.3.2.2  nathanw 	 *   X 0             Shared Ram Base Address - mask 0x9f
    234  1.3.2.2  nathanw 	 *                     see wd_elite_mem[] array for details
    235  1.3.2.2  nathanw 	 *
    236  1.3.2.2  nathanw 	 * 8013: POS register 5: (adf pos3)
    237  1.3.2.2  nathanw 	 * 7 6 5 4 3 2 1 0
    238  1.3.2.2  nathanw 	 *         \_/ \_/
    239  1.3.2.2  nathanw 	 *           \   \__ Media Select: 00=TwPr (no link) 10=BNC
    240  1.3.2.2  nathanw 	 *            \          01=AUI|AUI or 10BaseT
    241  1.3.2.2  nathanw 	 *             \____ Interrupt Level: 00=3 01=4 10=10 11=14
    242  1.3.2.2  nathanw 	 */
    243  1.3.2.2  nathanw 
    244  1.3.2.2  nathanw 	wep = we_mca_lookup(ma->ma_id);
    245  1.3.2.2  nathanw #ifdef DIAGNOSTIC
    246  1.3.2.2  nathanw 	if (wep == NULL) {
    247  1.3.2.2  nathanw 		printf("\n%s: where did the card go?\n", sc->sc_dev.dv_xname);
    248  1.3.2.2  nathanw 		return;
    249  1.3.2.2  nathanw 	}
    250  1.3.2.2  nathanw #endif
    251  1.3.2.2  nathanw 
    252  1.3.2.2  nathanw 	if (wep->we_flag & WD_8003) {
    253  1.3.2.2  nathanw 		/* WD8003 based */
    254  1.3.2.2  nathanw 		iobase = 0x200 + (((pos2 & 0x0e) >> 1) * 0x020);
    255  1.3.2.2  nathanw 		maddr  = 0xC0000 + (((pos3 & 0x1c) >> 2) * 0x04000);
    256  1.3.2.2  nathanw 		irq = we_mca_irq[(pos5 & 0x03)];
    257  1.3.2.2  nathanw 		sc->mem_size = WD_MEMSIZE;
    258  1.3.2.2  nathanw 	} else {
    259  1.3.2.2  nathanw 		/* SMC Elite */
    260  1.3.2.2  nathanw 		int i, id;
    261  1.3.2.2  nathanw 
    262  1.3.2.2  nathanw 		iobase = 0x800 + (((pos2 & 0xf0) >> 4) * 0x1000);
    263  1.3.2.2  nathanw 		irq = we_mca_irq[(pos5 & 0x06) >> 2];
    264  1.3.2.2  nathanw 
    265  1.3.2.2  nathanw 		/* find location of shared mem and it's size */
    266  1.3.2.2  nathanw 		id = (pos3 & 0x9f);
    267  1.3.2.2  nathanw 		for(i=0; we_mca_elite_mem[i].maddr; i++)
    268  1.3.2.2  nathanw 			if (we_mca_elite_mem[i].id == id)
    269  1.3.2.2  nathanw 				break;
    270  1.3.2.2  nathanw 		if (we_mca_elite_mem[i].maddr == 0) {
    271  1.3.2.2  nathanw 			printf("\n%s: cannot find Shared Ram Base Address\n",
    272  1.3.2.2  nathanw 				sc->sc_dev.dv_xname);
    273  1.3.2.2  nathanw 			return;
    274  1.3.2.2  nathanw 		}
    275  1.3.2.2  nathanw 
    276  1.3.2.2  nathanw 		maddr = we_mca_elite_mem[i].maddr;
    277  1.3.2.2  nathanw 		sc->mem_size = we_mca_elite_mem[i].memsize;
    278  1.3.2.2  nathanw 	}
    279  1.3.2.2  nathanw 
    280  1.3.2.2  nathanw 	nict = asict = ma->ma_iot;
    281  1.3.2.2  nathanw 	memt = ma->ma_memt;
    282  1.3.2.2  nathanw 
    283  1.3.2.3  nathanw 	printf(" slot %d irq %d: %s\n", ma->ma_slot + 1, irq, wep->we_name);
    284  1.3.2.2  nathanw 
    285  1.3.2.2  nathanw 	/* Map the device. */
    286  1.3.2.2  nathanw 	if (bus_space_map(asict, iobase, WE_NPORTS, 0, &asich)) {
    287  1.3.2.2  nathanw 		printf("%s: can't map nic i/o space\n",
    288  1.3.2.2  nathanw 		    sc->sc_dev.dv_xname);
    289  1.3.2.2  nathanw 		return;
    290  1.3.2.2  nathanw 	}
    291  1.3.2.2  nathanw 
    292  1.3.2.2  nathanw 	if (bus_space_subregion(asict, asich, WE_NIC_OFFSET, WE_NIC_NPORTS,
    293  1.3.2.2  nathanw 	    &nich)) {
    294  1.3.2.2  nathanw 		printf("%s: can't subregion i/o space\n",
    295  1.3.2.2  nathanw 		    sc->sc_dev.dv_xname);
    296  1.3.2.2  nathanw 		return;
    297  1.3.2.2  nathanw 	}
    298  1.3.2.2  nathanw 
    299  1.3.2.2  nathanw 	wsc->sc_type = wep->we_type;
    300  1.3.2.2  nathanw 	wsc->sc_16bitp = 1;		/* all cards we support are 16bit */
    301  1.3.2.2  nathanw 	sc->is790 = 0;
    302  1.3.2.2  nathanw 	typestr = wep->we_typestr;
    303  1.3.2.2  nathanw 
    304  1.3.2.2  nathanw 	/*
    305  1.3.2.2  nathanw 	 * Map memory space.
    306  1.3.2.2  nathanw 	 */
    307  1.3.2.2  nathanw 	if (bus_space_map(memt, maddr, sc->mem_size, 0, &memh)) {
    308  1.3.2.2  nathanw 		printf("%s: can't map shared memory\n",
    309  1.3.2.2  nathanw 		    sc->sc_dev.dv_xname);
    310  1.3.2.2  nathanw 		return;
    311  1.3.2.2  nathanw 	}
    312  1.3.2.2  nathanw 
    313  1.3.2.2  nathanw 	wsc->sc_asict = asict;
    314  1.3.2.2  nathanw 	wsc->sc_asich = asich;
    315  1.3.2.2  nathanw 
    316  1.3.2.2  nathanw 	sc->sc_regt = nict;
    317  1.3.2.2  nathanw 	sc->sc_regh = nich;
    318  1.3.2.2  nathanw 
    319  1.3.2.2  nathanw 	sc->sc_buft = memt;
    320  1.3.2.2  nathanw 	sc->sc_bufh = memh;
    321  1.3.2.2  nathanw 
    322  1.3.2.2  nathanw 	wsc->sc_maddr = maddr;
    323  1.3.2.2  nathanw 
    324  1.3.2.2  nathanw 	/* Interface is always enabled. */
    325  1.3.2.2  nathanw 	sc->sc_enabled = 1;
    326  1.3.2.2  nathanw 
    327  1.3.2.2  nathanw 	wsc->sc_init_hook = we_mca_init_hook;
    328  1.3.2.2  nathanw 
    329  1.3.2.2  nathanw 	if (we_config(self, wsc, typestr))
    330  1.3.2.2  nathanw 		return;
    331  1.3.2.2  nathanw 
    332  1.3.2.2  nathanw 	/* Map and establish the interrupt. */
    333  1.3.2.2  nathanw 	wsc->sc_ih = mca_intr_establish(ma->ma_mc, irq,
    334  1.3.2.2  nathanw 			    IPL_NET, dp8390_intr, sc);
    335  1.3.2.2  nathanw 	if (wsc->sc_ih == NULL) {
    336  1.3.2.2  nathanw 		printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname);
    337  1.3.2.2  nathanw 		return;
    338  1.3.2.2  nathanw 	}
    339  1.3.2.2  nathanw }
    340  1.3.2.2  nathanw 
    341  1.3.2.2  nathanw void
    342  1.3.2.2  nathanw we_mca_init_hook(wsc)
    343  1.3.2.2  nathanw 	struct we_softc *wsc;
    344  1.3.2.2  nathanw {
    345  1.3.2.2  nathanw 	/*
    346  1.3.2.2  nathanw 	 * This quirk really needs to be here, at least for WD8003W/A. Without
    347  1.3.2.2  nathanw 	 * this, the card doesn't send any interrupts in 16bit mode. The quirk
    348  1.3.2.2  nathanw 	 * was taken from Linux smc-mca.c driver.
    349  1.3.2.2  nathanw 	 * I do not know why it's necessary. I don't want to know. It works
    350  1.3.2.2  nathanw 	 * and that is enough for me.
    351  1.3.2.2  nathanw 	 */
    352  1.3.2.2  nathanw 	bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR, 0x04);
    353  1.3.2.2  nathanw 	wsc->sc_laar_proto |= 0x04;
    354  1.3.2.2  nathanw }
    355