Deleted Added
full compact
if_xe_pccard.c (119418) if_xe_pccard.c (121099)
1/*
2 * Copyright (c) 2002 Takeshi Shibagaki
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2002 Takeshi Shibagaki
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe_pccard.c 119418 2003-08-24 17:55:58Z obrien $");
28__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe_pccard.c 121099 2003-10-14 22:51:35Z rsm $");
29
30/* xe pccard interface driver */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/socket.h>
36

--- 13 unchanged lines hidden (view full) ---

50
51#include <dev/xe/if_xereg.h>
52#include <dev/xe/if_xevar.h>
53
54#include <dev/pccard/pccardvar.h>
55#include <dev/pccard/pccarddevs.h>
56#include "card_if.h"
57
29
30/* xe pccard interface driver */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/socket.h>
36

--- 13 unchanged lines hidden (view full) ---

50
51#include <dev/xe/if_xereg.h>
52#include <dev/xe/if_xevar.h>
53
54#include <dev/pccard/pccardvar.h>
55#include <dev/pccard/pccarddevs.h>
56#include "card_if.h"
57
58/*
59 * Set XE_DEBUG to enable debug messages
60 * Larger values increase verbosity
61 */
62#define XE_DEBUG 0
63
58#define XE_VENDOR_ID_XIRCOM 0x0105
59#define XE_VENDOR_ID_COMPAQ_1 0x0138
60#define XE_VENDOR_ID_COMPAQ_2 0x0183
61#define XE_VENDOR_ID_INTEL 0x0089
62#define XE_VENDOR_ID_UNKNOWN 0
63
64struct xe_vendor_table {
65 u_int32_t vendor_id;
66 char *vendor_desc;
67} xe_vendor_devs[] = {
68 { XE_VENDOR_ID_XIRCOM, "Xircom" },
69 { XE_VENDOR_ID_COMPAQ_1, "Compaq" },
64#define XE_VENDOR_ID_XIRCOM 0x0105
65#define XE_VENDOR_ID_COMPAQ_1 0x0138
66#define XE_VENDOR_ID_COMPAQ_2 0x0183
67#define XE_VENDOR_ID_INTEL 0x0089
68#define XE_VENDOR_ID_UNKNOWN 0
69
70struct xe_vendor_table {
71 u_int32_t vendor_id;
72 char *vendor_desc;
73} xe_vendor_devs[] = {
74 { XE_VENDOR_ID_XIRCOM, "Xircom" },
75 { XE_VENDOR_ID_COMPAQ_1, "Compaq" },
70 { XE_VENDOR_ID_COMPAQ_2, "Compaq" },
76 { XE_VENDOR_ID_COMPAQ_2, "Compaq" }, /* Maybe Paralon Techologies, Inc */
71 { XE_VENDOR_ID_INTEL, "Intel" },
72 { XE_VENDOR_ID_UNKNOWN, "Unknown" }
73};
74
75#define XE_CARD_TYPE_FLAGS_NO 0x0
76#define XE_CARD_TYPE_FLAGS_CE2 0x1
77#define XE_CARD_TYPE_FLAGS_MOHAWK 0x2
78#define XE_CARD_TYPE_FLAGS_DINGO 0x4
77 { XE_VENDOR_ID_INTEL, "Intel" },
78 { XE_VENDOR_ID_UNKNOWN, "Unknown" }
79};
80
81#define XE_CARD_TYPE_FLAGS_NO 0x0
82#define XE_CARD_TYPE_FLAGS_CE2 0x1
83#define XE_CARD_TYPE_FLAGS_MOHAWK 0x2
84#define XE_CARD_TYPE_FLAGS_DINGO 0x4
79#define XE_PROD_UMASK 0x100f
80#define XE_PROD_MODEM_UMASK 0x1000
81#define XE_PROD_SINGLE_ID1 0x1
82#define XE_PROD_SINGLE_ID2 0x2
83#define XE_PROD_SINGLE_ID3 0x3
84#define XE_PROD_MULTI_ID1 0x1001
85#define XE_PROD_MULTI_ID2 0x1002
86#define XE_PROD_MULTI_ID3 0x1003
87#define XE_PROD_MULTI_ID4 0x1004
88#define XE_PROD_MULTI_ID5 0x1005
89#define XE_PROD_MULTI_ID6 0x1006
90#define XE_PROD_MULTI_ID7 0x1007
85#define XE_PROD_UMASK 0x11000f
86#define XE_PROD_ETHER_UMASK 0x010000
87#define XE_PROD_MODEM_UMASK 0x100000
88#define XE_PROD_SINGLE_ID1 0x010001
89#define XE_PROD_SINGLE_ID2 0x010002
90#define XE_PROD_SINGLE_ID3 0x010003
91#define XE_PROD_MULTI_ID1 0x110001
92#define XE_PROD_MULTI_ID2 0x110002
93#define XE_PROD_MULTI_ID3 0x110003
94#define XE_PROD_MULTI_ID4 0x110004
95#define XE_PROD_MULTI_ID5 0x110005
96#define XE_PROD_MULTI_ID6 0x110006
97#define XE_PROD_MULTI_ID7 0x110007
91
92struct xe_card_type_table {
93 u_int32_t prod_type;
94 char *card_type_desc;
95 u_int32_t flags;
96} xe_card_type_devs[] = {
97 { XE_PROD_MULTI_ID1, "CEM", XE_CARD_TYPE_FLAGS_NO },
98 { XE_PROD_MULTI_ID2, "CEM2", XE_CARD_TYPE_FLAGS_CE2 },

--- 8 unchanged lines hidden (view full) ---

107 { XE_PROD_SINGLE_ID2, "CE2", XE_CARD_TYPE_FLAGS_CE2 },
108 { XE_PROD_SINGLE_ID3, "CE3", XE_CARD_TYPE_FLAGS_MOHAWK },
109 { 0, NULL, -1 }
110};
111
112/*
113 * Prototypes
114 */
98
99struct xe_card_type_table {
100 u_int32_t prod_type;
101 char *card_type_desc;
102 u_int32_t flags;
103} xe_card_type_devs[] = {
104 { XE_PROD_MULTI_ID1, "CEM", XE_CARD_TYPE_FLAGS_NO },
105 { XE_PROD_MULTI_ID2, "CEM2", XE_CARD_TYPE_FLAGS_CE2 },

--- 8 unchanged lines hidden (view full) ---

114 { XE_PROD_SINGLE_ID2, "CE2", XE_CARD_TYPE_FLAGS_CE2 },
115 { XE_PROD_SINGLE_ID3, "CE3", XE_CARD_TYPE_FLAGS_MOHAWK },
116 { 0, NULL, -1 }
117};
118
119/*
120 * Prototypes
121 */
115static int xe_cem56fix(device_t dev);
122static int xe_cemfix(device_t dev);
116static struct xe_vendor_table *xe_vendor_lookup(u_int32_t devid,
117 struct xe_vendor_table *tbl);
118static struct xe_card_type_table *xe_card_type_lookup(u_int32_t devid,
119 struct xe_card_type_table *tbl);
120
121/*
123static struct xe_vendor_table *xe_vendor_lookup(u_int32_t devid,
124 struct xe_vendor_table *tbl);
125static struct xe_card_type_table *xe_card_type_lookup(u_int32_t devid,
126 struct xe_card_type_table *tbl);
127
128/*
122 * Fixing for RealPort cards - they need a little furtling to get the
123 * ethernet working. But this codes don't work well in NEWCARD.
129 * Fixing for CEM2, CEM3 and CEM56/REM56 cards. These need some magic to
130 * enable the Ethernet function, which isn't mentioned anywhere in the CIS.
131 * Despite the register names, most of this isn't Dingo-specific.
124 */
125static int
132 */
133static int
126xe_cem56fix(device_t dev)
134xe_cemfix(device_t dev)
127{
128 struct xe_softc *sc = (struct xe_softc *) device_get_softc(dev);
129 bus_space_tag_t bst;
130 bus_space_handle_t bsh;
131 struct resource *r;
132 int rid;
133 int ioport;
134
135{
136 struct xe_softc *sc = (struct xe_softc *) device_get_softc(dev);
137 bus_space_tag_t bst;
138 bus_space_handle_t bsh;
139 struct resource *r;
140 int rid;
141 int ioport;
142
135 device_printf(dev, "Realport port 0x%0lx, size 0x%0lx\n",
143#if XE_DEBUG > 1
144 device_printf(dev, "cemfix\n");
145#endif
146
147 device_printf(dev, "CEM I/O port 0x%0lx, size 0x%0lx\n",
136 bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid),
137 bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid));
138
139 rid = 0;
140 r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0,
141 ~0, 4 << 10, RF_ACTIVE);
142 if (!r) {
143 device_printf(dev, "Can't map in attribute memory\n");

--- 9 unchanged lines hidden (view full) ---

153 bus_space_write_1(bst, bsh, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL |
154 DINGO_ECOR_INT_ENABLE |
155 DINGO_ECOR_IOB_ENABLE |
156 DINGO_ECOR_ETH_ENABLE);
157 ioport = bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid);
158 bus_space_write_1(bst, bsh, DINGO_EBAR0, ioport & 0xff);
159 bus_space_write_1(bst, bsh, DINGO_EBAR1, (ioport >> 8) & 0xff);
160
148 bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid),
149 bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid));
150
151 rid = 0;
152 r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0,
153 ~0, 4 << 10, RF_ACTIVE);
154 if (!r) {
155 device_printf(dev, "Can't map in attribute memory\n");

--- 9 unchanged lines hidden (view full) ---

165 bus_space_write_1(bst, bsh, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL |
166 DINGO_ECOR_INT_ENABLE |
167 DINGO_ECOR_IOB_ENABLE |
168 DINGO_ECOR_ETH_ENABLE);
169 ioport = bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid);
170 bus_space_write_1(bst, bsh, DINGO_EBAR0, ioport & 0xff);
171 bus_space_write_1(bst, bsh, DINGO_EBAR1, (ioport >> 8) & 0xff);
172
161 bus_space_write_1(bst, bsh, DINGO_DCOR0, DINGO_DCOR0_SF_INT);
162 bus_space_write_1(bst, bsh, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL |
163 DINGO_DCOR1_EEDIO);
164 bus_space_write_1(bst, bsh, DINGO_DCOR2, 0x00);
165 bus_space_write_1(bst, bsh, DINGO_DCOR3, 0x00);
166 bus_space_write_1(bst, bsh, DINGO_DCOR4, 0x00);
173 if (sc->dingo) {
174 bus_space_write_1(bst, bsh, DINGO_DCOR0, DINGO_DCOR0_SF_INT);
175 bus_space_write_1(bst, bsh, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL |
176 DINGO_DCOR1_EEDIO);
177 bus_space_write_1(bst, bsh, DINGO_DCOR2, 0x00);
178 bus_space_write_1(bst, bsh, DINGO_DCOR3, 0x00);
179 bus_space_write_1(bst, bsh, DINGO_DCOR4, 0x00);
180 }
167
168 bus_release_resource(dev, SYS_RES_MEMORY, rid, r);
169
170 /* success! */
171 return (0);
172}
173
174static struct xe_vendor_table *

--- 29 unchanged lines hidden (view full) ---

204 struct xe_softc *scp = (struct xe_softc *) device_get_softc(dev);
205 u_int32_t vendor,prodid,prod;
206 u_int16_t prodext;
207 char *cis3_str=NULL;
208 struct xe_vendor_table *vendor_itm;
209 struct xe_card_type_table *card_itm;
210 int i;
211
181
182 bus_release_resource(dev, SYS_RES_MEMORY, rid, r);
183
184 /* success! */
185 return (0);
186}
187
188static struct xe_vendor_table *

--- 29 unchanged lines hidden (view full) ---

218 struct xe_softc *scp = (struct xe_softc *) device_get_softc(dev);
219 u_int32_t vendor,prodid,prod;
220 u_int16_t prodext;
221 char *cis3_str=NULL;
222 struct xe_vendor_table *vendor_itm;
223 struct xe_card_type_table *card_itm;
224 int i;
225
226#if XE_DEBUG > 1
227 char* vendor_str = NULL;
228 char* product_str = NULL;
229 char* cis4_str = NULL;
230 device_printf(dev, "pccard_probe\n");
231 pccard_get_vendor(dev, &vendor);
232 pccard_get_product(dev, &prodid);
233 pccard_get_prodext(dev, &prodext);
234 pccard_get_vendor_str(dev, &vendor_str);
235 pccard_get_product_str(dev, &product_str);
236 pccard_get_cis3_str(dev, &cis3_str);
237 pccard_get_cis4_str(dev, &cis4_str);
238 device_printf(dev, "vendor = 0x%04x\n", vendor);
239 device_printf(dev, "product = 0x%04x\n", prodid);
240 device_printf(dev, "prodext = 0x%02x\n", prodext);
241 device_printf(dev, "vendor_str = %s\n", vendor_str);
242 device_printf(dev, "product_str = %s\n", product_str);
243 device_printf(dev, "cis3_str = %s\n", cis3_str);
244 device_printf(dev, "cis4_str = %s\n", cis4_str);
245#endif
246
212 /*
213 * PCCARD_CISTPL_MANFID = 0x20
214 */
215 pccard_get_vendor(dev, &vendor);
216 vendor_itm = xe_vendor_lookup(vendor, &xe_vendor_devs[0]);
217 if (vendor_itm == NULL)
218 return (ENODEV);
219 scp->vendor = vendor_itm->vendor_desc;

--- 20 unchanged lines hidden (view full) ---

240 scp->dingo = 1; break;
241 }
242 }
243 /*
244 * PCCARD_CISTPL_VERS_1 = 0x15
245 */
246 pccard_get_cis3_str(dev, &cis3_str);
247 if (strcmp(scp->card_type, "CE") == 0)
247 /*
248 * PCCARD_CISTPL_MANFID = 0x20
249 */
250 pccard_get_vendor(dev, &vendor);
251 vendor_itm = xe_vendor_lookup(vendor, &xe_vendor_devs[0]);
252 if (vendor_itm == NULL)
253 return (ENODEV);
254 scp->vendor = vendor_itm->vendor_desc;

--- 20 unchanged lines hidden (view full) ---

275 scp->dingo = 1; break;
276 }
277 }
278 /*
279 * PCCARD_CISTPL_VERS_1 = 0x15
280 */
281 pccard_get_cis3_str(dev, &cis3_str);
282 if (strcmp(scp->card_type, "CE") == 0)
248 if (strcmp(cis3_str, "CE2") ==0)
283 if (cis3_str != NULL && strcmp(cis3_str, "PS-CE2-10") == 0)
249 scp->card_type = "CE2"; /* Look for "CE2" string */
250
251 /*
252 * PCCARD_CISTPL_FUNCE = 0x22
253 */
254 pccard_get_ether(dev, scp->arpcom.ac_enaddr);
255
256 /* Reject unsupported cards */

--- 12 unchanged lines hidden (view full) ---

269 * Attach a device.
270 */
271static int
272xe_pccard_attach(device_t dev)
273{
274 struct xe_softc *scp = device_get_softc(dev);
275 int err;
276
284 scp->card_type = "CE2"; /* Look for "CE2" string */
285
286 /*
287 * PCCARD_CISTPL_FUNCE = 0x22
288 */
289 pccard_get_ether(dev, scp->arpcom.ac_enaddr);
290
291 /* Reject unsupported cards */

--- 12 unchanged lines hidden (view full) ---

304 * Attach a device.
305 */
306static int
307xe_pccard_attach(device_t dev)
308{
309 struct xe_softc *scp = device_get_softc(dev);
310 int err;
311
312#if XE_DEBUG > 1
313 device_printf(dev, "pccard_attach\n");
314#endif
315
277 if ((err = xe_activate(dev)) != 0)
278 return (err);
279
280 /* Hack RealPorts into submission */
316 if ((err = xe_activate(dev)) != 0)
317 return (err);
318
319 /* Hack RealPorts into submission */
281 if (scp->dingo && xe_cem56fix(dev) < 0) {
282 device_printf(dev, "Unable to fix your RealPort\n");
320 if (scp->modem && xe_cemfix(dev) < 0) {
321 device_printf(dev, "Unable to fix your %s combo card\n",
322 scp->card_type);
283 xe_deactivate(dev);
284 return (ENODEV);
285 }
286 if ((err = xe_attach(dev))) {
287 device_printf(dev, "xe_attach() failed! (%d)\n", err);
288 return (err);
289 }
290 return (0);

--- 5 unchanged lines hidden (view full) ---

296 * this function; if not you may well lose packets. In any case, I shut down
297 * the card and the interface, and hope for the best.
298 */
299static int
300xe_pccard_detach(device_t dev)
301{
302 struct xe_softc *sc = device_get_softc(dev);
303
323 xe_deactivate(dev);
324 return (ENODEV);
325 }
326 if ((err = xe_attach(dev))) {
327 device_printf(dev, "xe_attach() failed! (%d)\n", err);
328 return (err);
329 }
330 return (0);

--- 5 unchanged lines hidden (view full) ---

336 * this function; if not you may well lose packets. In any case, I shut down
337 * the card and the interface, and hope for the best.
338 */
339static int
340xe_pccard_detach(device_t dev)
341{
342 struct xe_softc *sc = device_get_softc(dev);
343
344#if XE_DEBUG > 1
345 device_printf(dev, "pccard_detach\n");
346#endif
347
304 sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
305 ether_ifdetach(&sc->arpcom.ac_if);
306 xe_deactivate(dev);
307 return (0);
308}
309
310static const struct pccard_product xe_pccard_products[] = {
311 PCMCIA_CARD(ACCTON, EN2226, 0),
348 sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
349 ether_ifdetach(&sc->arpcom.ac_if);
350 xe_deactivate(dev);
351 return (0);
352}
353
354static const struct pccard_product xe_pccard_products[] = {
355 PCMCIA_CARD(ACCTON, EN2226, 0),
312 PCMCIA_CARD(COMPAQ2, CPQ_10_100, 0), /* Maybe Paralon Techologies, Inc */
356 PCMCIA_CARD(COMPAQ2, CPQ_10_100, 0),
313 PCMCIA_CARD(INTEL, EEPRO100, 0),
314 PCMCIA_CARD(XIRCOM, CE, 0),
315 PCMCIA_CARD(XIRCOM, CE2, 0),
316 PCMCIA_CARD(XIRCOM, CE3, 0),
317 PCMCIA_CARD(XIRCOM, CEM, 0),
318 PCMCIA_CARD(XIRCOM, CEM28, 0),
319 PCMCIA_CARD(XIRCOM, CEM33, 0),
320 PCMCIA_CARD(XIRCOM, CEM56, 0),
321 PCMCIA_CARD(XIRCOM, REM56, 0),
322 { NULL }
323};
324
325static int
326xe_pccard_match(device_t dev)
327{
328 const struct pccard_product *pp;
329
357 PCMCIA_CARD(INTEL, EEPRO100, 0),
358 PCMCIA_CARD(XIRCOM, CE, 0),
359 PCMCIA_CARD(XIRCOM, CE2, 0),
360 PCMCIA_CARD(XIRCOM, CE3, 0),
361 PCMCIA_CARD(XIRCOM, CEM, 0),
362 PCMCIA_CARD(XIRCOM, CEM28, 0),
363 PCMCIA_CARD(XIRCOM, CEM33, 0),
364 PCMCIA_CARD(XIRCOM, CEM56, 0),
365 PCMCIA_CARD(XIRCOM, REM56, 0),
366 { NULL }
367};
368
369static int
370xe_pccard_match(device_t dev)
371{
372 const struct pccard_product *pp;
373
374#if XE_DEBUG > 1
375 device_printf(dev, "pccard_match\n");
376#endif
377
330 if ((pp = pccard_product_lookup(dev, xe_pccard_products,
378 if ((pp = pccard_product_lookup(dev, xe_pccard_products,
331 sizeof(xe_pccard_products[0]), NULL)) != NULL) {
332 if (pp->pp_name != NULL)
333 device_set_desc(dev, pp->pp_name);
334 return (0);
379 sizeof(xe_pccard_products[0]), NULL)) != NULL) {
380 if (pp->pp_name != NULL)
381 device_set_desc(dev, pp->pp_name);
382 return (0);
335 }
336 return (EIO);
337}
338
339static device_method_t xe_pccard_methods[] = {
340 /* Device interface */
341 DEVMETHOD(device_probe, pccard_compat_probe),
342 DEVMETHOD(device_attach, pccard_compat_attach),

--- 19 unchanged lines hidden ---
383 }
384 return (EIO);
385}
386
387static device_method_t xe_pccard_methods[] = {
388 /* Device interface */
389 DEVMETHOD(device_probe, pccard_compat_probe),
390 DEVMETHOD(device_attach, pccard_compat_attach),

--- 19 unchanged lines hidden ---