Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / amiga / dev / if_ne_zbus.c
blobbd8b868260f6eec5639be177cd430dc4a9286d0b
1 /* $NetBSD: if_ne_zbus.c,v 1.12 2008/03/12 14:31:11 cube Exp $ */
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Bernd Ernesti.
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_ne_zbus.c,v 1.12 2008/03/12 14:31:11 cube Exp $");
36 * Thanks to Village Tronic for giving me a card.
37 * Bernd Ernesti
40 #include <sys/param.h>
41 #include <sys/device.h>
42 #include <sys/malloc.h>
43 #include <sys/mbuf.h>
44 #include <sys/socket.h>
45 #include <sys/syslog.h>
46 #include <sys/systm.h>
48 #include <net/if.h>
49 #include <net/if_media.h>
50 #include <net/if_ether.h>
52 #include <machine/bus.h>
54 #include <dev/ic/dp8390reg.h>
55 #include <dev/ic/dp8390var.h>
57 #include <dev/ic/ne2000reg.h>
58 #include <dev/ic/ne2000var.h>
60 #include <dev/ic/rtl80x9reg.h>
61 #include <dev/ic/rtl80x9var.h>
63 #include <amiga/amiga/device.h>
64 #include <amiga/amiga/isr.h>
66 #include <amiga/dev/zbusvar.h>
68 int ne_zbus_match(device_t, cfdata_t , void *);
69 void ne_zbus_attach(device_t, device_t, void *);
71 struct ne_zbus_softc {
72 struct ne2000_softc sc_ne2000;
73 struct bus_space_tag sc_bst;
74 struct isr sc_isr;
77 CFATTACH_DECL_NEW(ne_zbus, sizeof(struct ne_zbus_softc),
78 ne_zbus_match, ne_zbus_attach, NULL, NULL);
81 * The Amiga address are shifted by one bit to the ISA-Bus, but
82 * this is handled by the bus_space functions.
84 #define NE_ARIADNE_II_NPORTS 0x20
85 #define NE_ARIADNE_II_NICBASE 0x0300 /* 0x0600 */
86 #define NE_ARIADNE_II_NICSIZE 0x10
87 #define NE_ARIADNE_II_ASICBASE 0x0310 /* 0x0620 */
88 #define NE_ARIADNE_II_ASICSIZE 0x10
90 int
91 ne_zbus_match(device_t parent, cfdata_t cf, void *aux)
93 struct zbus_args *zap = aux;
95 /* Ariadne II ethernet card */
96 if (zap->manid == 2167 && zap->prodid == 202)
97 return (1);
99 /* X-surf ethernet card */
100 if (zap->manid == 4626 && zap->prodid == 23)
101 return (1);
103 return (0);
107 * Install interface into kernel networking data structures
109 void
110 ne_zbus_attach(device_t parent, device_t self, void *aux)
112 struct ne_zbus_softc *zsc = device_private(self);
113 struct ne2000_softc *nsc = &zsc->sc_ne2000;
114 struct dp8390_softc *dsc = &nsc->sc_dp8390;
115 struct zbus_args *zap = aux;
116 bus_space_tag_t nict = &zsc->sc_bst;
117 bus_space_handle_t nich;
118 bus_space_tag_t asict = nict;
119 bus_space_handle_t asich;
121 dsc->sc_dev = self;
122 dsc->sc_mediachange = rtl80x9_mediachange;
123 dsc->sc_mediastatus = rtl80x9_mediastatus;
124 dsc->init_card = rtl80x9_init_card;
125 dsc->sc_media_init = rtl80x9_media_init;
127 zsc->sc_bst.base = (u_long)zap->va + 0;
128 if (zap->manid == 4626)
129 zsc->sc_bst.base += 0x8000;
131 zsc->sc_bst.absm = &amiga_bus_stride_2;
133 aprint_normal("\n");
135 /* Map i/o space. */
136 if (bus_space_map(nict, NE_ARIADNE_II_NICBASE, NE_ARIADNE_II_NPORTS, 0, &nich)) {
137 aprint_error_dev(self, "can't map nic i/o space\n");
138 return;
141 if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, NE_ARIADNE_II_ASICSIZE,
142 &asich)) {
143 aprint_error_dev(self, "can't map asic i/o space\n");
144 return;
147 dsc->sc_regt = nict;
148 dsc->sc_regh = nich;
150 nsc->sc_asict = asict;
151 nsc->sc_asich = asich;
153 /* This interface is always enabled. */
154 dsc->sc_enabled = 1;
157 * Do generic NE2000 attach. This will read the station address
158 * from the EEPROM.
160 ne2000_attach(nsc, NULL);
162 zsc->sc_isr.isr_intr = dp8390_intr;
163 zsc->sc_isr.isr_arg = dsc;
164 zsc->sc_isr.isr_ipl = 2;
165 add_isr(&zsc->sc_isr);