Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / isapnp / if_tr_isapnp.c
blob427ff509cc081ea8fa28e80cd3950e252be7db29
1 /* $NetBSD: if_tr_isapnp.c,v 1.19 2009/05/12 10:07:55 cegger Exp $ */
3 /*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
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
12 * are met:
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>
38 #include <sys/mbuf.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>
46 #include <net/if.h>
47 #include <net/if_dl.h>
48 #include <net/if_ether.h>
49 #include <net/if_media.h>
51 #include <sys/cpu.h>
52 #include <sys/bus.h>
53 #include <sys/intr.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);
70 int
71 tr_isapnp_match(device_t parent, cfdata_t match, void *aux)
73 int pri, variant;
75 pri = isapnp_devmatch(aux, &isapnp_tr_devinfo, &variant);
76 if (pri && variant > 0)
77 pri = 0;
78 return pri;
82 void
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;
87 int mmioidx, sramidx;
89 printf("\n");
91 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
92 aprint_error_dev(&sc->sc_dev, "error in region allocation\n");
93 return;
96 printf("%s: %s %s\n", device_xname(&sc->sc_dev), ipa->ipa_devident,
97 ipa->ipa_devclass);
99 sc->sc_piot = ipa->ipa_iot;
100 sc->sc_pioh = ipa->ipa_io[0].h;
102 if (strcmp(ipa->ipa_devlogic, "TCM3190") == 0) {
103 mmioidx = 0;
104 sramidx = 1;
106 else { /* Default */
107 mmioidx = 1;
108 sramidx = 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;
124 * Reset the card.
126 if (tr_reset(sc))
127 return;
129 sc->sc_mediastatus = NULL;
130 sc->sc_mediachange = NULL;
132 if (tr_attach(sc))
133 return;
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);