xsurf.c revision 1.1.2.2 1 1.1.2.2 yamt /* $NetBSD: xsurf.c,v 1.1.2.2 2012/05/23 10:07:40 yamt Exp $ */
2 1.1.2.2 yamt
3 1.1.2.2 yamt /*-
4 1.1.2.2 yamt * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1.2.2 yamt * All rights reserved.
6 1.1.2.2 yamt *
7 1.1.2.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 yamt * by Bernd Ernesti.
9 1.1.2.2 yamt *
10 1.1.2.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.1.2.2 yamt * modification, are permitted provided that the following conditions
12 1.1.2.2 yamt * are met:
13 1.1.2.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.1.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.1.2.2 yamt * documentation and/or other materials provided with the distribution.
18 1.1.2.2 yamt *
19 1.1.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.2 yamt * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.2 yamt */
31 1.1.2.2 yamt
32 1.1.2.2 yamt #include <sys/cdefs.h>
33 1.1.2.2 yamt __KERNEL_RCSID(0, "$NetBSD: xsurf.c,v 1.1.2.2 2012/05/23 10:07:40 yamt Exp $");
34 1.1.2.2 yamt
35 1.1.2.2 yamt /*
36 1.1.2.2 yamt * X-Surf driver, split from ne_zbus.
37 1.1.2.2 yamt */
38 1.1.2.2 yamt
39 1.1.2.2 yamt #include <sys/param.h>
40 1.1.2.2 yamt #include <sys/device.h>
41 1.1.2.2 yamt #include <sys/malloc.h>
42 1.1.2.2 yamt #include <sys/mbuf.h>
43 1.1.2.2 yamt #include <sys/socket.h>
44 1.1.2.2 yamt #include <sys/syslog.h>
45 1.1.2.2 yamt #include <sys/systm.h>
46 1.1.2.2 yamt #include <sys/bus.h>
47 1.1.2.2 yamt
48 1.1.2.2 yamt #include <net/if.h>
49 1.1.2.2 yamt #include <net/if_media.h>
50 1.1.2.2 yamt #include <net/if_ether.h>
51 1.1.2.2 yamt
52 1.1.2.2 yamt #include <dev/ic/dp8390reg.h>
53 1.1.2.2 yamt #include <dev/ic/dp8390var.h>
54 1.1.2.2 yamt
55 1.1.2.2 yamt #include <dev/ic/ne2000reg.h>
56 1.1.2.2 yamt #include <dev/ic/ne2000var.h>
57 1.1.2.2 yamt
58 1.1.2.2 yamt #include <dev/ic/rtl80x9reg.h>
59 1.1.2.2 yamt #include <dev/ic/rtl80x9var.h>
60 1.1.2.2 yamt
61 1.1.2.2 yamt #include <amiga/amiga/device.h>
62 1.1.2.2 yamt #include <amiga/amiga/isr.h>
63 1.1.2.2 yamt
64 1.1.2.2 yamt #include <amiga/dev/zbusvar.h>
65 1.1.2.2 yamt #include <amiga/dev/xsurfvar.h>
66 1.1.2.2 yamt
67 1.1.2.2 yamt //#include <amiga/clockport/clockportvar.h>
68 1.1.2.2 yamt
69 1.1.2.2 yamt int xsurf_match(device_t, cfdata_t , void *);
70 1.1.2.2 yamt void xsurf_attach(device_t, device_t, void *);
71 1.1.2.2 yamt static int xsurf_print(void *aux, const char *w);
72 1.1.2.2 yamt
73 1.1.2.2 yamt struct xsurf_softc {
74 1.1.2.2 yamt device_t sc_dev;
75 1.1.2.2 yamt };
76 1.1.2.2 yamt
77 1.1.2.2 yamt CFATTACH_DECL_NEW(xsurf, sizeof(struct xsurf_softc),
78 1.1.2.2 yamt xsurf_match, xsurf_attach, NULL, NULL);
79 1.1.2.2 yamt
80 1.1.2.2 yamt #define XSURF_NE_OFFSET 0x8000
81 1.1.2.2 yamt
82 1.1.2.2 yamt /*
83 1.1.2.2 yamt * Clockport offsets.
84 1.1.2.2 yamt */
85 1.1.2.2 yamt #define XSURF_CP1_BASE 0xA001
86 1.1.2.2 yamt #define XSURF_CP2_BASE 0xC000
87 1.1.2.2 yamt
88 1.1.2.2 yamt /*
89 1.1.2.2 yamt * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
90 1.1.2.2 yamt * Do not attach ne driver to this fake card, otherwise kernel panic
91 1.1.2.2 yamt * may occur.
92 1.1.2.2 yamt */
93 1.1.2.2 yamt #define DENEB_XSURF_SERNO 0xC0FFEE01 /* Serial of the fake card */
94 1.1.2.2 yamt
95 1.1.2.2 yamt int
96 1.1.2.2 yamt xsurf_match(device_t parent, cfdata_t cf, void *aux)
97 1.1.2.2 yamt {
98 1.1.2.2 yamt struct zbus_args *zap = aux;
99 1.1.2.2 yamt
100 1.1.2.2 yamt /* X-surf ethernet card */
101 1.1.2.2 yamt if (zap->manid == 4626 && zap->prodid == 23) {
102 1.1.2.2 yamt return (1);
103 1.1.2.2 yamt }
104 1.1.2.2 yamt
105 1.1.2.2 yamt return (0);
106 1.1.2.2 yamt }
107 1.1.2.2 yamt
108 1.1.2.2 yamt /*
109 1.1.2.2 yamt * Install interface into kernel networking data structures.
110 1.1.2.2 yamt */
111 1.1.2.2 yamt void
112 1.1.2.2 yamt xsurf_attach(device_t parent, device_t self, void *aux)
113 1.1.2.2 yamt {
114 1.1.2.2 yamt struct xsurf_softc *sc;
115 1.1.2.2 yamt struct xsurfbus_attach_args xaa_ne;
116 1.1.2.2 yamt struct xsurfbus_attach_args xaa_gencp1;
117 1.1.2.2 yamt struct xsurfbus_attach_args xaa_gencp2;
118 1.1.2.2 yamt
119 1.1.2.2 yamt struct zbus_args *zap = aux;
120 1.1.2.2 yamt
121 1.1.2.2 yamt sc = device_private(self);
122 1.1.2.2 yamt sc->sc_dev = self;
123 1.1.2.2 yamt
124 1.1.2.2 yamt aprint_normal(": Individual Computers X-Surf\n");
125 1.1.2.2 yamt
126 1.1.2.2 yamt /* Add clockport. */
127 1.1.2.2 yamt xaa_gencp1.xaa_base = (bus_addr_t)zap->va + XSURF_CP1_BASE;
128 1.1.2.2 yamt strcpy(xaa_gencp1.xaa_name, "gencp_xsurf");
129 1.1.2.2 yamt config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp1, xsurf_print);
130 1.1.2.2 yamt
131 1.1.2.2 yamt /* Now... if we are a fake X-Surf that's enough. */
132 1.1.2.2 yamt if (zap->serno == DENEB_XSURF_SERNO) {
133 1.1.2.2 yamt aprint_naive_dev(sc->sc_dev, "fake X-Surf on E3B Deneb");
134 1.1.2.2 yamt return;
135 1.1.2.2 yamt }
136 1.1.2.2 yamt
137 1.1.2.2 yamt /* Otherwise add one more clockport and continue... */
138 1.1.2.2 yamt xaa_gencp2.xaa_base = (bus_addr_t)zap->va + XSURF_CP2_BASE;
139 1.1.2.2 yamt strcpy(xaa_gencp2.xaa_name, "gencp_xsurf");
140 1.1.2.2 yamt config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp2, xsurf_print);
141 1.1.2.2 yamt
142 1.1.2.2 yamt /* Add ne(4). */
143 1.1.2.2 yamt xaa_ne.xaa_base = (bus_addr_t)zap->va + XSURF_NE_OFFSET;
144 1.1.2.2 yamt strcpy(xaa_ne.xaa_name, "ne_xsurf");
145 1.1.2.2 yamt config_found_ia(sc->sc_dev, "xsurfbus", &xaa_ne, xsurf_print);
146 1.1.2.2 yamt }
147 1.1.2.2 yamt
148 1.1.2.2 yamt static int
149 1.1.2.2 yamt xsurf_print(void *aux, const char *w)
150 1.1.2.2 yamt {
151 1.1.2.2 yamt if (w == NULL)
152 1.1.2.2 yamt return 0;
153 1.1.2.2 yamt
154 1.1.2.2 yamt return 0;
155 1.1.2.2 yamt }
156 1.1.2.2 yamt
157