if_ne_zbus.c revision 1.1 1 /* $NetBSD: if_ne_zbus.c,v 1.1 1998/11/11 22:26:27 veego Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Bernd Ernesti.
9 *
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.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Thanks to Village Tronic for giving me a card.
41 * Bernd Ernesti
42 */
43
44 #include <sys/param.h>
45 #include <sys/device.h>
46 #include <sys/malloc.h>
47 #include <sys/mbuf.h>
48 #include <sys/socket.h>
49 #include <sys/syslog.h>
50 #include <sys/systm.h>
51
52 #include <net/if.h>
53 #include <net/if_media.h>
54 #include <net/if_ether.h>
55
56 #include <machine/bus.h>
57
58 #include <dev/ic/dp8390reg.h>
59 #include <dev/ic/dp8390var.h>
60
61 #include <dev/ic/ne2000reg.h>
62 #include <dev/ic/ne2000var.h>
63
64 #include <dev/ic/rtl80x9reg.h>
65 #include <dev/ic/rtl80x9var.h>
66
67 #include <amiga/amiga/device.h>
68 #include <amiga/amiga/isr.h>
69
70 #include <amiga/dev/zbusvar.h>
71
72 int ne_zbus_match __P((struct device *, struct cfdata *, void *));
73 void ne_zbus_attach __P((struct device *, struct device *, void *));
74
75 struct ne_zbus_softc {
76 struct ne2000_softc sc_ne2000;
77 struct bus_space_tag sc_bst;
78 struct isr sc_isr;
79 };
80
81 struct cfattach ne_zbus_ca = {
82 sizeof(struct ne_zbus_softc), ne_zbus_match, ne_zbus_attach
83 };
84
85 /* The amiga address are shifted by one bit to the ISA-Bus. */
86 #define NE_ARIADNE_II_NPORTS 0x40
87 #define NE_ARIADNE_II_NICBASE 0x0300 /* 0x0600 */
88 #define NE_ARIADNE_II_NICSIZE 0x20
89 #define NE_ARIADNE_II_ASICBASE 0x0310 /* 0x0620 */
90 #define NE_ARIADNE_II_ASICSIZE 0x20
91
92
93 int
94 ne_zbus_match(parent, cf, aux)
95 struct device *parent;
96 struct cfdata *cf;
97 void *aux;
98 {
99 struct zbus_args *zap = aux;
100
101 /* Ariadne II ethernet card */
102 if (zap->manid == 2167 && zap->prodid == 202)
103 return (1);
104
105 return (0);
106 }
107
108 /*
109 * Install interface into kernel networking data structures
110 */
111 void
112 ne_zbus_attach(parent, self, aux)
113 struct device *parent, *self;
114 void *aux;
115 {
116 struct ne_zbus_softc *zsc = (struct ne_zbus_softc *)self;
117 struct ne2000_softc *nsc = &zsc->sc_ne2000;
118 struct dp8390_softc *dsc = &nsc->sc_dp8390;
119 struct zbus_args *zap = aux;
120 bus_space_tag_t nict = &zsc->sc_bst;
121 bus_space_handle_t nich;
122 bus_space_tag_t asict = nict;
123 bus_space_handle_t asich;
124 int *media, nmedia, defmedia;
125
126 media = NULL;
127 nmedia = defmedia = 0;
128
129 dsc->sc_mediachange = rtl80x9_mediachange;
130 dsc->sc_mediastatus = rtl80x9_mediastatus;
131 dsc->init_card = rtl80x9_init_card;
132
133 zsc->sc_bst.base = (u_long)zap->va + 0;
134 zsc->sc_bst.stride = 1;
135 zsc->sc_bst.absm = &amiga_interleaved_wordaccess_methods;
136
137 printf("\n");
138
139 /* Map i/o space. */
140 if (bus_space_map(nict, NE_ARIADNE_II_NICBASE, NE_ARIADNE_II_NPORTS, 0, &nich)) {
141 printf("%s: can't map nic i/o space\n", dsc->sc_dev.dv_xname);
142 return;
143 }
144
145 if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, NE_ARIADNE_II_ASICSIZE,
146 &asich)) {
147 printf("%s: can't map asic i/o space\n", dsc->sc_dev.dv_xname);
148 return;
149 }
150
151 dsc->sc_regt = nict;
152 dsc->sc_regh = nich;
153
154 nsc->sc_asict = asict;
155 nsc->sc_asich = asich;
156
157 /* Initialize media. */
158 rtl80x9_init_media(dsc, &media, &nmedia, &defmedia);
159
160 /* This interface is always enabled. */
161 dsc->sc_enabled = 1;
162
163 /*
164 * Do generic NE2000 attach. This will read the station address
165 * from the EEPROM.
166 */
167 ne2000_attach(nsc, NULL, media, nmedia, defmedia);
168
169 zsc->sc_isr.isr_intr = dp8390_intr;
170 zsc->sc_isr.isr_arg = dsc;
171 zsc->sc_isr.isr_ipl = 2;
172 add_isr(&zsc->sc_isr);
173 }
174