1 /* $NetBSD: if_tr_isapnp.c,v 1.19 2009/05/12 10:07:55 cegger Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Onno van der Linden.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: if_tr_isapnp.c,v 1.19 2009/05/12 10:07:55 cegger Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/callout.h>
39 #include <sys/socket.h>
40 #include <sys/ioctl.h>
41 #include <sys/errno.h>
42 #include <sys/syslog.h>
43 #include <sys/select.h>
44 #include <sys/device.h>
47 #include <net/if_dl.h>
48 #include <net/if_ether.h>
49 #include <net/if_media.h>
55 #include <dev/ic/tropicreg.h>
56 #include <dev/ic/tropicvar.h>
58 #include <dev/isa/isavar.h>
60 #include <dev/isapnp/isapnpreg.h>
61 #include <dev/isapnp/isapnpvar.h>
62 #include <dev/isapnp/isapnpdevs.h>
64 int tr_isapnp_match(device_t
, cfdata_t
, void *);
65 void tr_isapnp_attach(device_t
, device_t
, void *);
67 CFATTACH_DECL(tr_isapnp
, sizeof(struct tr_softc
),
68 tr_isapnp_match
, tr_isapnp_attach
, NULL
, NULL
);
71 tr_isapnp_match(device_t parent
, cfdata_t match
, void *aux
)
75 pri
= isapnp_devmatch(aux
, &isapnp_tr_devinfo
, &variant
);
76 if (pri
&& variant
> 0)
83 tr_isapnp_attach(device_t parent
, device_t self
, void *aux
)
85 struct tr_softc
*sc
= device_private(self
);
86 struct isapnp_attach_args
*ipa
= aux
;
91 if (isapnp_config(ipa
->ipa_iot
, ipa
->ipa_memt
, ipa
)) {
92 aprint_error_dev(&sc
->sc_dev
, "error in region allocation\n");
96 printf("%s: %s %s\n", device_xname(&sc
->sc_dev
), ipa
->ipa_devident
,
99 sc
->sc_piot
= ipa
->ipa_iot
;
100 sc
->sc_pioh
= ipa
->ipa_io
[0].h
;
102 if (strcmp(ipa
->ipa_devlogic
, "TCM3190") == 0) {
110 sc
->sc_memt
= ipa
->ipa_memt
;
111 sc
->sc_mmioh
= ipa
->ipa_mem
[mmioidx
].h
;
112 sc
->sc_sramh
= ipa
->ipa_mem
[sramidx
].h
;
113 sc
->sc_memwinsz
= ipa
->ipa_mem
[sramidx
].length
;
115 * Determine total RAM on adapter and decide how much to use.
116 * XXX Since we don't use RAM paging, use sc_memwinsz for now.
118 sc
->sc_memsize
= sc
->sc_memwinsz
;
119 sc
->sc_memreserved
= 0;
121 sc
->sc_aca
= TR_ACA_OFFSET
;
122 sc
->sc_maddr
= ipa
->ipa_mem
[sramidx
].base
;
129 sc
->sc_mediastatus
= NULL
;
130 sc
->sc_mediachange
= NULL
;
135 sc
->sc_ih
= isa_intr_establish(ipa
->ipa_ic
, ipa
->ipa_irq
[0].num
,
136 ipa
->ipa_irq
[0].type
, IPL_NET
, tr_intr
, sc
);