if_cs_ofisa_machdep.c revision 1.2 1 /* $NetBSD: if_cs_ofisa_machdep.c,v 1.2 2003/06/23 11:01:38 martin Exp $ */
2
3 /*
4 * Copyright 1998
5 * Digital Equipment Corporation. All rights reserved.
6 *
7 * This software is furnished under license and may be used and
8 * copied only in accordance with the following terms and conditions.
9 * Subject to these conditions, you may download, copy, install,
10 * use, modify and distribute this software in source and/or binary
11 * form. No title or ownership is transferred hereby.
12 *
13 * 1) Any source code used, modified or distributed must reproduce
14 * and retain this copyright notice and list of conditions as
15 * they appear in the source file.
16 *
17 * 2) No right is granted to use any trade name, trademark, or logo of
18 * Digital Equipment Corporation. Neither the "Digital Equipment
19 * Corporation" name nor any trademark or logo of Digital Equipment
20 * Corporation may be used to endorse or promote products derived
21 * from this software without the prior written permission of
22 * Digital Equipment Corporation.
23 *
24 * 3) This software is provided "AS-IS" and any express or implied
25 * warranties, including but not limited to, any implied warranties
26 * of merchantability, fitness for a particular purpose, or
27 * non-infringement are disclaimed. In no event shall DIGITAL be
28 * liable for any damages whatsoever, and in particular, DIGITAL
29 * shall not be liable for special, indirect, consequential, or
30 * incidental damages or damages for lost profits, loss of
31 * revenue or loss of use, whether such damages arise in contract,
32 * negligence, tort, under statute, in equity, at law or otherwise,
33 * even if advised of the possibility of such damage.
34 */
35
36 /*
37 * WARNING: THIS FILE IS VERY SHARK-SPECIFIC!
38 */
39 #include "opt_compat_old_ofw.h"
40
41 #include <sys/param.h>
42 #include <sys/device.h>
43 #include <sys/systm.h>
44 #include <sys/malloc.h>
45 #include <sys/socket.h>
46
47 #include <net/if.h>
48 #include <net/if_ether.h>
49 #include <net/if_media.h>
50
51 #include <machine/bus.h>
52 #include <machine/intr.h>
53
54 #include <dev/ofw/openfirm.h>
55 #include <dev/isa/isavar.h>
56 #include <dev/ofisa/ofisavar.h>
57
58 #include <dev/ic/cs89x0reg.h>
59 #include <dev/ic/cs89x0var.h>
60
61 #ifdef COMPAT_OLD_OFW
62
63 int
64 cs_ofisa_md_match(parent, cf, aux)
65 struct device *parent;
66 struct cfdata *cf;
67 void *aux;
68 {
69 struct ofisa_attach_args *aa = aux;
70 char type[64];
71 char name[64];
72 char model[64];
73 char compatible[64];
74 int rv;
75
76 rv = 0;
77 if (1) { /* XXX old firmware compat enabled */
78 /* At a minimum, must match type and name properties. */
79 if (OF_getprop(aa->oba.oba_phandle, "device_type", type,
80 sizeof(type)) < 0 || strcmp(type, "network") != 0 ||
81 OF_getprop(aa->oba.oba_phandle, "name", name,
82 sizeof(name)) < 0 || strcmp(name, "ethernet") != 0)
83 return (0);
84
85 /* Full match on model. */
86 if (OF_getprop(aa->oba.oba_phandle, "model", model,
87 sizeof(model)) > 0 && strcmp(model, "CS8900") == 0)
88 rv = 3;
89
90 /* Check for compatible match. */
91 if (OF_getprop(aa->oba.oba_phandle, "compatible", compatible,
92 sizeof(compatible)) > 0 && pmatch(compatible, "*CS8900*",
93 NULL) > 0)
94 rv = 2;
95 }
96 return (rv);
97 }
98
99 int
100 cs_ofisa_md_reg_fixup(parent, self, aux, descp, ndescs, ndescsfilled)
101 struct device *parent, *self;
102 void *aux;
103 struct ofisa_reg_desc *descp;
104 int ndescs, ndescsfilled;
105 {
106
107 if (1) { /* XXX old firmware compat enabled */
108 /* We can't provide it. */
109 if (ndescs != 2)
110 return (ndescsfilled);
111
112 /* Firmware provided it. */
113 if (ndescsfilled == 2)
114 return (ndescsfilled);
115
116 descp[0].type = OFISA_REG_TYPE_IO;
117 descp[0].addr = 0x300;
118 descp[0].len = CS8900_IOSIZE;
119
120 descp[1].type = OFISA_REG_TYPE_MEM;
121 descp[1].addr = 0xd0000;
122 descp[1].len = 4096;
123 }
124 return (ndescsfilled);
125 }
126
127 int
128 cs_ofisa_md_intr_fixup(parent, self, aux, descp, ndescs, ndescsfilled)
129 struct device *parent, *self;
130 void *aux;
131 struct ofisa_intr_desc *descp;
132 int ndescs, ndescsfilled;
133 {
134
135 if (1) /* XXX old firmware compat enabled */
136 if (ndescs > 0 && ndescsfilled > 0)
137 descp[0].share = IST_LEVEL;
138 return (ndescsfilled);
139 }
140
141 int *
142 cs_ofisa_md_media_fixup(parent, self, aux, media, nmediap, defmediap)
143 struct device *parent, *self;
144 void *aux;
145 int *media, *nmediap, *defmediap;
146 {
147
148 if (1) { /* XXX old firmware compat enabled */
149 if (media == NULL) {
150 media = malloc(2 * sizeof(int), M_TEMP, M_NOWAIT);
151 if (media == NULL)
152 return (NULL);
153 media[0] = IFM_ETHER|IFM_10_T;
154 media[1] = IFM_ETHER|IFM_10_T|IFM_FDX;
155 *nmediap = 2;
156 *defmediap = media[0];
157 }
158 }
159 return (media);
160 }
161
162 int
163 cs_ofisa_md_dma_fixup(parent, self, aux, descp, ndescs, ndescsfilled)
164 struct device *parent, *self;
165 void *aux;
166 struct ofisa_dma_desc *descp;
167 int ndescs, ndescsfilled;
168 {
169 struct ofisa_attach_args *aa = aux;
170
171 if (ndescs > 0 && ndescsfilled > 0) {
172 if (OF_getproplen(aa->oba.oba_phandle, "no-dma") >= 0)
173 descp[0].drq = ISACF_DRQ_DEFAULT;
174 }
175 return (ndescsfilled);
176 }
177
178 #endif /* COMPAT_OLD_OFW */
179
180 int
181 cs_ofisa_md_cfgflags_fixup(parent, self, aux)
182 struct device *parent, *self;
183 void *aux;
184 {
185
186 return (CFGFLG_USE_SA|CFGFLG_IOCHRDY|CFGFLG_NOT_EEPROM);
187 }
188