xsurf.c revision 1.1.4.2 1 /* $NetBSD: xsurf.c,v 1.1.4.2 2012/06/02 11:08:50 mrg 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 *
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.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: xsurf.c,v 1.1.4.2 2012/06/02 11:08:50 mrg Exp $");
34
35 /*
36 * X-Surf driver, split from ne_zbus.
37 */
38
39 #include <sys/param.h>
40 #include <sys/device.h>
41 #include <sys/malloc.h>
42 #include <sys/mbuf.h>
43 #include <sys/socket.h>
44 #include <sys/syslog.h>
45 #include <sys/systm.h>
46 #include <sys/bus.h>
47
48 #include <net/if.h>
49 #include <net/if_media.h>
50 #include <net/if_ether.h>
51
52 #include <dev/ic/dp8390reg.h>
53 #include <dev/ic/dp8390var.h>
54
55 #include <dev/ic/ne2000reg.h>
56 #include <dev/ic/ne2000var.h>
57
58 #include <dev/ic/rtl80x9reg.h>
59 #include <dev/ic/rtl80x9var.h>
60
61 #include <amiga/amiga/device.h>
62 #include <amiga/amiga/isr.h>
63
64 #include <amiga/dev/zbusvar.h>
65 #include <amiga/dev/xsurfvar.h>
66
67 //#include <amiga/clockport/clockportvar.h>
68
69 int xsurf_match(device_t, cfdata_t , void *);
70 void xsurf_attach(device_t, device_t, void *);
71 static int xsurf_print(void *aux, const char *w);
72
73 struct xsurf_softc {
74 device_t sc_dev;
75 };
76
77 CFATTACH_DECL_NEW(xsurf, sizeof(struct xsurf_softc),
78 xsurf_match, xsurf_attach, NULL, NULL);
79
80 #define XSURF_NE_OFFSET 0x8000
81
82 /*
83 * Clockport offsets.
84 */
85 #define XSURF_CP1_BASE 0xA001
86 #define XSURF_CP2_BASE 0xC000
87
88 /*
89 * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
90 * Do not attach ne driver to this fake card, otherwise kernel panic
91 * may occur.
92 */
93 #define DENEB_XSURF_SERNO 0xC0FFEE01 /* Serial of the fake card */
94
95 int
96 xsurf_match(device_t parent, cfdata_t cf, void *aux)
97 {
98 struct zbus_args *zap = aux;
99
100 /* X-surf ethernet card */
101 if (zap->manid == 4626 && zap->prodid == 23) {
102 return (1);
103 }
104
105 return (0);
106 }
107
108 /*
109 * Install interface into kernel networking data structures.
110 */
111 void
112 xsurf_attach(device_t parent, device_t self, void *aux)
113 {
114 struct xsurf_softc *sc;
115 struct xsurfbus_attach_args xaa_ne;
116 struct xsurfbus_attach_args xaa_gencp1;
117 struct xsurfbus_attach_args xaa_gencp2;
118
119 struct zbus_args *zap = aux;
120
121 sc = device_private(self);
122 sc->sc_dev = self;
123
124 aprint_normal(": Individual Computers X-Surf\n");
125
126 /* Add clockport. */
127 xaa_gencp1.xaa_base = (bus_addr_t)zap->va + XSURF_CP1_BASE;
128 strcpy(xaa_gencp1.xaa_name, "gencp_xsurf");
129 config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp1, xsurf_print);
130
131 /* Now... if we are a fake X-Surf that's enough. */
132 if (zap->serno == DENEB_XSURF_SERNO) {
133 aprint_naive_dev(sc->sc_dev, "fake X-Surf on E3B Deneb");
134 return;
135 }
136
137 /* Otherwise add one more clockport and continue... */
138 xaa_gencp2.xaa_base = (bus_addr_t)zap->va + XSURF_CP2_BASE;
139 strcpy(xaa_gencp2.xaa_name, "gencp_xsurf");
140 config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp2, xsurf_print);
141
142 /* Add ne(4). */
143 xaa_ne.xaa_base = (bus_addr_t)zap->va + XSURF_NE_OFFSET;
144 strcpy(xaa_ne.xaa_name, "ne_xsurf");
145 config_found_ia(sc->sc_dev, "xsurfbus", &xaa_ne, xsurf_print);
146 }
147
148 static int
149 xsurf_print(void *aux, const char *w)
150 {
151 if (w == NULL)
152 return 0;
153
154 return 0;
155 }
156
157