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