1 /* $OpenBSD: if_ne_pcmcia.c,v 1.97 2014/11/24 02:03:37 brad Exp $ */ 2 /* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */ 3 4 /* 5 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Marc Horowitz. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <sys/param.h> 34 #include <sys/systm.h> 35 #include <sys/selinfo.h> 36 #include <sys/device.h> 37 #include <sys/socket.h> 38 39 #include <net/if_types.h> 40 #include <net/if.h> 41 #include <net/if_media.h> 42 #include <netinet/in.h> 43 #include <netinet/if_ether.h> 44 45 #include <machine/bus.h> 46 47 #include <dev/pcmcia/pcmciareg.h> 48 #include <dev/pcmcia/pcmciavar.h> 49 #include <dev/pcmcia/pcmciadevs.h> 50 51 #include <dev/mii/miivar.h> 52 #include <dev/mii/mii_bitbang.h> 53 54 #include <dev/ic/dp8390reg.h> 55 #include <dev/ic/dp8390var.h> 56 57 #include <dev/ic/ne2000reg.h> 58 #include <dev/ic/ne2000var.h> 59 60 #include <dev/ic/dl10019reg.h> 61 #include <dev/ic/dl10019var.h> 62 63 #include <dev/ic/rtl80x9reg.h> 64 #include <dev/ic/rtl80x9var.h> 65 66 #include <dev/ic/ax88190reg.h> 67 #include <dev/ic/ax88190var.h> 68 69 int ne_pcmcia_match(struct device *, void *, void *); 70 void ne_pcmcia_attach(struct device *, struct device *, void *); 71 int ne_pcmcia_detach(struct device *, int); 72 int ne_pcmcia_activate(struct device *, int); 73 74 int ne_pcmcia_enable(struct dp8390_softc *); 75 void ne_pcmcia_disable(struct dp8390_softc *); 76 77 struct ne_pcmcia_softc { 78 struct ne2000_softc sc_ne2000; /* real "ne2000" softc */ 79 80 /* PCMCIA-specific goo */ 81 struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o information */ 82 int sc_asic_io_window; /* i/o window for ASIC */ 83 int sc_nic_io_window; /* i/o window for NIC */ 84 struct pcmcia_function *sc_pf; /* our PCMCIA function */ 85 void *sc_ih; /* interrupt handle */ 86 }; 87 88 u_int8_t * 89 ne_pcmcia_get_enaddr(struct ne_pcmcia_softc *, int, 90 u_int8_t[ETHER_ADDR_LEN]); 91 u_int8_t * 92 ne_pcmcia_dl10019_get_enaddr(struct ne_pcmcia_softc *, 93 u_int8_t[ETHER_ADDR_LEN]); 94 int ne_pcmcia_ax88190_set_iobase(struct ne_pcmcia_softc *); 95 96 struct cfattach ne_pcmcia_ca = { 97 sizeof(struct ne_pcmcia_softc), ne_pcmcia_match, ne_pcmcia_attach, 98 ne_pcmcia_detach, ne_pcmcia_activate 99 }; 100 101 const struct ne2000dev { 102 u_int16_t manufacturer; 103 u_int16_t product; 104 char *cis_info[4]; 105 int function; 106 int enet_maddr; 107 unsigned char enet_vendor[3]; 108 int flags; 109 #define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */ 110 } ne2000devs[] = { 111 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 112 PCMCIA_CIS_AMBICOM_AMB8002T, 113 0, -1, { 0x00, 0x10, 0x7a } }, 114 115 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 116 PCMCIA_CIS_PREMAX_PE200, 117 0, 0x07f0, { 0x00, 0x20, 0xe0 } }, 118 119 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 120 PCMCIA_CIS_DIGITAL_DEPCMXX, 121 0, 0x0ff0, { 0x00, 0x00, 0xe8 } }, 122 123 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 124 PCMCIA_CIS_PLANET_SMARTCOM2000, 125 0, 0x0ff0, { 0x00, 0x00, 0xe8 } }, 126 127 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 128 PCMCIA_CIS_DLINK_DE660, 129 0, -1, { 0x00, 0x80, 0xc8 } }, 130 131 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 132 PCMCIA_CIS_DLINK_DE660PLUS, 133 0, -1, { 0x00, 0x80, 0xc8 } }, 134 135 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 136 PCMCIA_CIS_RPTI_EP400, 137 0, -1, { 0x00, 0x40, 0x95 } }, 138 139 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 140 PCMCIA_CIS_RPTI_EP401, 141 0, -1, { 0x00, 0x40, 0x95 } }, 142 143 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 144 PCMCIA_CIS_ACCTON_EN2212, 145 0, 0x0ff0, { 0x00, 0x00, 0xe8 } }, 146 147 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 148 PCMCIA_CIS_ADDTRON_W89C926, 149 0, -1, { 0x00, 0x40, 0x33 } }, 150 151 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 152 PCMCIA_CIS_SVEC_COMBOCARD, 153 0, -1, { 0x00, 0xe0, 0x98 } }, 154 155 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 156 PCMCIA_CIS_SVEC_LANCARD, 157 0, 0x07f0, { 0x00, 0xc0, 0x6c } }, 158 159 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_EPSON_EEN10B, 160 PCMCIA_CIS_EPSON_EEN10B, 161 0, 0x0ff0, { 0x00, 0x00, 0x48 } }, 162 163 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 164 PCMCIA_CIS_EDIMAX_NE2000, 165 0, -1, { 0x00, 0x00, 0xb4 } }, 166 167 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 168 PCMCIA_CIS_CNET_NE2000, 169 0, -1, { 0x00, 0x80, 0xad } }, 170 171 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_CNET_CNF301, 172 PCMCIA_CIS_CNET_CNF301, 173 0, -1, { 0x00, 0x10, 0x60 } }, 174 175 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 176 PCMCIA_CIS_BILLIONTON_LNT10TN, 177 0, -1, { 0x00, 0x00, 0x00 } }, 178 179 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 180 PCMCIA_CIS_NDC_ND5100_E, 181 0, -1, { 0x00, 0x80, 0xc6 } }, 182 183 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 184 PCMCIA_CIS_SYNERGY21_S21810, 185 0, -1, { 0x00, 0x48, 0x54 } }, 186 187 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 188 PCMCIA_CIS_TAMARACK_NE2000, 189 0, -1, { 0x00, 0x47, 0x43 } }, 190 191 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 192 PCMCIA_CIS_GVC_NIC2000P, 193 0, 0x0ff0, { 0x00, 0x00, 0xe8 } }, 194 195 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 196 PCMCIA_CIS_WISECOM_T210CT, 197 0, -1, { 0x00, 0x20, 0x18 } }, 198 199 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 200 PCMCIA_CIS_WISECOM_IPORT, 201 0, -1, { 0x00, 0x02, 0xdd } }, 202 203 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 204 PCMCIA_CIS_AROWANA_FE, 205 0, -1, { 0x00, 0x48, 0x54 }, NE2000DVF_AX88190 }, 206 207 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 208 PCMCIA_CIS_GVC_NP0335, 209 0, -1, { 0x00, 0x40, 0x05 } }, 210 211 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 212 PCMCIA_CIS_RELIA_RE2408T, 213 0, -1, { 0x00, 0xc0, 0x0c } }, 214 215 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 216 PCMCIA_CIS_BILLIONTON_CFLT2, 217 0, -1, { 0x00, 0x10, 0x60 } }, 218 219 /* 220 * You have to add new entries which contains 221 * PCMCIA_VENDOR_INVALID and/or PCMCIA_PRODUCT_INVALID 222 * in front of this comment. 223 * 224 * There are cards which use a generic vendor and product id but needs 225 * a different handling depending on the cis_info, so ne2000_match 226 * needs a table where the exceptions comes first and then the normal 227 * product and vendor entries. 228 */ 229 230 { PCMCIA_VENDOR_GREYCELL, PCMCIA_PRODUCT_GREYCELL_GCS2000, 231 PCMCIA_CIS_GREYCELL_GCS2000, 232 0, -1, { 0x00, 0x47, 0x43 } }, 233 234 { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER, 235 PCMCIA_CIS_IBM_INFOMOVER, 236 0, 0x0ff0, { 0x08, 0x00, 0x5a } }, 237 238 { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER, 239 PCMCIA_CIS_IBM_INFOMOVER, 240 0, 0x0ff0, { 0x00, 0x04, 0xac } }, 241 242 { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER, 243 PCMCIA_CIS_IBM_INFOMOVER, 244 0, 0x0ff0, { 0x00, 0x06, 0x29 } }, 245 246 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ECARD_1, 247 PCMCIA_CIS_LINKSYS_ECARD_1, 248 0, -1, { 0x00, 0x80, 0xc8 } }, 249 250 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_PCM100, 251 PCMCIA_CIS_LINKSYS_PCM100, 252 0, -1, { 0x00, 0x04, 0x5a } }, 253 254 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 255 PCMCIA_CIS_LINKSYS_COMBO_ECARD, 256 0, -1, { 0x00, 0x04, 0x5a }, NE2000DVF_AX88190 }, 257 258 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 259 PCMCIA_CIS_LINKSYS_COMBO_ECARD, 260 0, -1, { 0x00, 0x80, 0xc8 } }, 261 262 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 263 PCMCIA_CIS_PLANEX_FNW3600T, 264 0, -1, { 0x00, 0x90, 0xcc } }, 265 266 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 267 PCMCIA_CIS_SVEC_PN650TX, 268 0, -1, { 0x00, 0xe0, 0x98 } }, 269 270 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 271 PCMCIA_CIS_TRENDNET_TECF100, 272 0, -1, { 0x00, 0x12, 0x0e } }, 273 274 /* 275 * This entry should be here so that above two cards doesn't 276 * match with this. FNW-3700T won't match above entries due to 277 * MAC address check. 278 */ 279 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD, 280 PCMCIA_CIS_PLANEX_FNW3700T, 281 0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 }, 282 283 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST, 284 PCMCIA_CIS_LINKSYS_ETHERFAST, 285 0, -1, { 0x00, 0x80, 0xc8 } }, 286 287 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST, 288 PCMCIA_CIS_LINKSYS_ETHERFAST, 289 0, -1, { 0x00, 0x50, 0xba } }, 290 291 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST, 292 PCMCIA_CIS_DLINK_DE650, 293 0, -1, { 0x00, 0xe0, 0x98 } }, 294 295 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST, 296 PCMCIA_CIS_IODATA_PCETTXR, 297 0, -1, { 0x00, 0xa0, 0xb0 } }, 298 299 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 300 PCMCIA_CIS_DLINK_DFE670TXD, 301 0, -1, { 0x00, 0x05, 0x5d } }, 302 303 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 304 PCMCIA_CIS_DLINK_DFE670TXD, 305 0, -1, { 0x00, 0x50, 0xba } }, 306 307 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 308 PCMCIA_CIS_DLINK_DFE670TXD, 309 0, -1, { 0x00, 0x0d, 0x88 } }, 310 311 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 312 PCMCIA_CIS_DLINK_DFE670TXD, 313 0, -1, { 0x00, 0x13, 0x46 } }, 314 315 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 316 PCMCIA_CIS_DLINK_DFE670TXD, 317 0, -1, { 0x00, 0x40, 0x05 } }, 318 319 { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD, 320 PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD, 321 0, 0x0120, { 0x20, 0x04, 0x49 } }, 322 323 /* Although the comments above say to put VENDOR/PRODUCT INVALID IDs 324 above this list, we need to keep this one below the ECARD_1, or else 325 both will match the same more-generic entry rather than the more 326 specific one above with proper vendor and product IDs. */ 327 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 328 PCMCIA_CIS_LINKSYS_ECARD_2, 329 0, -1, { 0x00, 0x80, 0xc8 } }, 330 331 /* 332 * D-Link DE-650 has many minor versions: 333 * 334 * CIS information Manufacturer Product Note 335 * 1 "D-Link, DE-650" INVALID INVALID white card 336 * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal 337 * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor change in look 338 * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added 339 * 340 * While the 1st and the 2nd types should use the "D-Link DE-650" entry, 341 * the 3rd and the 4th types should use the "Linksys EtherCard" entry. 342 * Therefore, this entry must be below the LINKSYS_ECARD_1. --itohy 343 */ 344 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 345 PCMCIA_CIS_DLINK_DE650, 346 0, 0x0040, { 0x00, 0x80, 0xc8 } }, 347 348 /* 349 * IO-DATA PCLA/TE and later version of PCLA/T has valid 350 * vendor/product ID and it is possible to read MAC address 351 * using standard I/O ports. It also read from CIS offset 0x01c0. 352 * On the other hand, earlier version of PCLA/T doesn't have valid 353 * vendor/product ID and MAC address must be read from CIS offset 354 * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work). 355 * And CIS information of earlier and later version of PCLA/T are 356 * same except fourth element. So, for now, we place the entry for 357 * PCLA/TE (and later version of PCLA/T) followed by entry 358 * for the earlier version of PCLA/T (or, modify to match all CIS 359 * information and have three or more individual entries). 360 */ 361 { PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_PCLATE, 362 PCMCIA_CIS_IODATA_PCLATE, 363 0, -1, { 0x00, 0xa0, 0xb0 } }, 364 365 /* 366 * This entry should be placed after above PCLA-TE entry. 367 * See above comments for detail. 368 */ 369 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, 370 PCMCIA_CIS_IODATA_PCLAT, 371 0, 0x0ff0, { 0x00, 0xa0, 0xb0 } }, 372 373 { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1, 374 PCMCIA_CIS_DAYNA_COMMUNICARD_E_1, 375 0, 0x0110, { 0x00, 0x80, 0x19 } }, 376 377 { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2, 378 PCMCIA_CIS_DAYNA_COMMUNICARD_E_2, 379 0, -1, { 0x00, 0x80, 0x19 } }, 380 381 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_T, 382 PCMCIA_CIS_COREGA_ETHER_PCC_T, 383 0, -1, { 0x00, 0x00, 0xf4 } }, 384 385 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_TD, 386 PCMCIA_CIS_COREGA_ETHER_PCC_TD, 387 0, -1, { 0x00, 0x00, 0xf4 } }, 388 389 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_T, 390 PCMCIA_CIS_COREGA_ETHER_II_PCC_T, 391 0, -1, { 0x00, 0x00, 0xf4 } }, 392 393 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_TD, 394 PCMCIA_CIS_COREGA_ETHER_II_PCC_TD, 395 0, -1, { 0x00, 0x00, 0xf4 } }, 396 397 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FAST_ETHER_PCC_TX, 398 PCMCIA_CIS_COREGA_FAST_ETHER_PCC_TX, 399 0, -1, { 0x00, 0x00, 0xf4 } }, 400 401 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXF, 402 PCMCIA_CIS_COREGA_FETHER_PCC_TXF, 403 0, -1, { 0x00, 0x90, 0x99 } }, 404 405 { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXD, 406 PCMCIA_CIS_COREGA_FETHER_PCC_TXD, 407 0, -1, { 0x00, 0x90, 0x99 } }, 408 409 { PCMCIA_VENDOR_COMPEX, PCMCIA_PRODUCT_COMPEX_LINKPORT_ENET_B, 410 PCMCIA_CIS_COMPEX_LINKPORT_ENET_B, 411 0, 0x01c0, { 0x00, 0xa0, 0x0c } }, 412 413 { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_EZCARD, 414 PCMCIA_CIS_SMC_EZCARD, 415 0, 0x01c0, { 0x00, 0xe0, 0x29 } }, 416 417 { PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_8041TX, 418 PCMCIA_CIS_IODATA_8041TX, 419 0, -1, { 0x00, 0x04, 0xe2 } }, 420 421 { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_8041, 422 PCMCIA_CIS_SMC_8041, 423 0, -1, { 0x00, 0x04, 0xe2 } }, 424 425 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER_CF, 426 PCMCIA_CIS_SOCKET_LP_ETHER_CF, 427 0, -1, { 0x00, 0xc0, 0x1b} }, 428 429 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER, 430 PCMCIA_CIS_SOCKET_LP_ETHER, 431 0, -1, { 0x00, 0xc0, 0x1b } }, 432 433 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_ETHER_CF_10_100, 434 PCMCIA_CIS_SOCKET_ETHER_CF_10_100, 435 0, -1, { 0x00, 0x12, 0x0e } }, 436 437 { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_ETHER_CF_10_100, 438 PCMCIA_CIS_SOCKET_ETHER_CF_10_100, 439 0, -1, { 0x00, 0xe0, 0x98 } }, 440 441 { PCMCIA_VENDOR_XIRCOM, PCMCIA_PRODUCT_XIRCOM_CFE_10, 442 PCMCIA_CIS_XIRCOM_CFE_10, 443 0, -1, { 0x00, 0x10, 0xa4 } }, 444 445 { PCMCIA_VENDOR_MELCO, PCMCIA_PRODUCT_MELCO_LPC3_TX, 446 PCMCIA_CIS_MELCO_LPC3_TX, 447 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 }, 448 449 { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC_CF_CLT, 450 PCMCIA_CIS_INVALID, 451 0, -1, { 0x00, 0x07, 0x40 } }, 452 453 { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC3_CLT, 454 PCMCIA_CIS_INVALID, 455 0, -1, { 0x00, 0x07, 0x40 } }, 456 457 { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC4_CLX, 458 PCMCIA_CIS_INVALID, 459 0, -1, { 0x00, 0x40, 0xfa }, NE2000DVF_AX88190 }, 460 461 { PCMCIA_VENDOR_DUAL, PCMCIA_PRODUCT_DUAL_NE2000, 462 PCMCIA_CIS_DUAL_NE2000, 463 0, 0x0ff0, { 0x00, 0xa0, 0x0c } }, 464 465 { PCMCIA_VENDOR_ALLIEDTELESIS, PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM, 466 PCMCIA_CIS_ALLIEDTELESIS_LA_PCM, 467 0, 0x0ff0, { 0x00, 0x00, 0xf4 } }, 468 469 { PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE_PCM, 470 PCMCIA_CIS_KINGSTON_KNE_PCM, 471 0, 0x0ff0, { 0xe2, 0x0c, 0x0f } }, 472 473 { PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE_PC2, 474 PCMCIA_CIS_KINGSTON_KNE_PC2, 475 0, 0x0180, { 0x00, 0xc0, 0xf0 } }, 476 477 { PCMCIA_VENDOR_TELECOMDEVICE, PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100, 478 PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100, 479 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 }, 480 481 { PCMCIA_VENDOR_MACNICA, PCMCIA_PRODUCT_MACNICA_ME1_JEIDA, 482 PCMCIA_CIS_MACNICA_ME1_JEIDA, 483 0, 0x00b8, { 0x08, 0x00, 0x42 } }, 484 485 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 486 PCMCIA_CIS_NETGEAR_FA410TXC, 487 0, -1, { 0x00, 0x40, 0xf4 } }, 488 489 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 490 PCMCIA_CIS_NETGEAR_FA410TXC, 491 0, -1, { 0x00, 0x48, 0x54 } }, 492 493 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 494 PCMCIA_CIS_DLINK_DFE670TXD, 495 0, -1, { 0x00, 0x40, 0x05 } }, 496 497 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 498 PCMCIA_CIS_DLINK_DFE670TXD, 499 0, -1, { 0x00, 0x11, 0x95 } }, 500 501 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC, 502 PCMCIA_CIS_DLINK_DFE670TXD, 503 0, -1, { 0x00, 0x0d, 0x88 } }, 504 505 { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA411, 506 PCMCIA_CIS_NETGEAR_FA411, 507 0, -1, { 0x00, 0x40, 0xf4 } }, 508 509 { PCMCIA_VENDOR_BELKIN, PCMCIA_PRODUCT_BELKIN_F5D5020, 510 PCMCIA_CIS_BELKIN_F5D5020, 511 0, -1, { 0x00, 0x30, 0xbd } }, 512 513 #if 0 514 /* the rest of these are stolen from the linux pcnet pcmcia device 515 driver. Since I don't know the manfid or cis info strings for 516 any of them, they're not compiled in until I do. */ 517 { "APEX MultiCard", 518 0x0000, 0x0000, NULL, NULL, 0, 519 0x03f4, { 0x00, 0x20, 0xe5 } }, 520 { "ASANTE FriendlyNet", 521 0x0000, 0x0000, NULL, NULL, 0, 522 0x4910, { 0x00, 0x00, 0x94 } }, 523 { "Danpex EN-6200P2", 524 0x0000, 0x0000, NULL, NULL, 0, 525 0x0110, { 0x00, 0x40, 0xc7 } }, 526 { "DataTrek NetCard", 527 0x0000, 0x0000, NULL, NULL, 0, 528 0x0ff0, { 0x00, 0x20, 0xe8 } }, 529 { "EP-210 Ethernet", 530 0x0000, 0x0000, NULL, NULL, 0, 531 0x0110, { 0x00, 0x40, 0x33 } }, 532 { "ELECOM Laneed LD-CDWA", 533 0x0000, 0x0000, NULL, NULL, 0, 534 0x00b8, { 0x08, 0x00, 0x42 } }, 535 { "Grey Cell GCS2220", 536 0x0000, 0x0000, NULL, NULL, 0, 537 0x0000, { 0x00, 0x47, 0x43 } }, 538 { "Hypertec Ethernet", 539 0x0000, 0x0000, NULL, NULL, 0, 540 0x01c0, { 0x00, 0x40, 0x4c } }, 541 { "IBM FME", 542 0x0000, 0x0000, NULL, NULL, 0, 543 0x0374, { 0x00, 0x04, 0xac } }, 544 { "IBM FME", 545 0x0000, 0x0000, NULL, NULL, 0, 546 0x0374, { 0x08, 0x00, 0x5a } }, 547 { "Katron PE-520", 548 0x0000, 0x0000, NULL, NULL, 0, 549 0x0110, { 0x00, 0x40, 0xf6 } }, 550 { "Kingston KNE-PCM/x", 551 0x0000, 0x0000, NULL, NULL, 0, 552 0x0ff0, { 0x00, 0xc0, 0xf0 } }, 553 { "Longshine LCS-8534", 554 0x0000, 0x0000, NULL, NULL, 0, 555 0x0000, { 0x08, 0x00, 0x00 } }, 556 { "Maxtech PCN2000", 557 0x0000, 0x0000, NULL, NULL, 0, 558 0x5000, { 0x00, 0x00, 0xe8 } }, 559 { "NDC Instant-Link", 560 0x0000, 0x0000, NULL, NULL, 0, 561 0x003a, { 0x00, 0x80, 0xc6 } }, 562 { "Network General Sniffer", 563 0x0000, 0x0000, NULL, NULL, 0, 564 0x0ff0, { 0x00, 0x00, 0x65 } }, 565 { "Panasonic VEL211", 566 0x0000, 0x0000, NULL, NULL, 0, 567 0x0ff0, { 0x00, 0x80, 0x45 } }, 568 { "SCM Ethernet", 569 0x0000, 0x0000, NULL, NULL, 0, 570 0x0ff0, { 0x00, 0x20, 0xcb } }, 571 { "Socket EA", 572 0x0000, 0x0000, NULL, NULL, 0, 573 0x4000, { 0x00, 0xc0, 0x1b } }, 574 { "Volktek NPL-402CT", 575 0x0000, 0x0000, NULL, NULL, 0, 576 0x0060, { 0x00, 0x40, 0x05 } }, 577 #endif 578 }; 579 580 #define NE2000_NDEVS (sizeof(ne2000devs) / sizeof(ne2000devs[0])) 581 582 #define ne2000_match(card, fct, n) \ 583 ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \ 584 ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \ 585 ((card)->product != PCMCIA_PRODUCT_INVALID) && \ 586 ((card)->product == ne2000devs[(n)].product)) || \ 587 ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \ 588 ((card)->cis1_info[0]) && ((card)->cis1_info[1]) && \ 589 (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \ 590 (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \ 591 ((fct) == ne2000devs[(n)].function))? \ 592 &ne2000devs[(n)]:NULL) 593 594 int 595 ne_pcmcia_match(parent, match, aux) 596 struct device *parent; 597 void *match, *aux; 598 { 599 struct pcmcia_attach_args *pa = aux; 600 int i; 601 602 for (i = 0; i < NE2000_NDEVS; i++) { 603 if (ne2000_match(pa->card, pa->pf->number, i)) 604 return (1); 605 } 606 607 return (0); 608 } 609 610 void 611 ne_pcmcia_attach(parent, self, aux) 612 struct device *parent, *self; 613 void *aux; 614 { 615 struct ne_pcmcia_softc *psc = (void *) self; 616 struct ne2000_softc *nsc = &psc->sc_ne2000; 617 struct dp8390_softc *dsc = &nsc->sc_dp8390; 618 struct pcmcia_attach_args *pa = aux; 619 struct pcmcia_config_entry *cfe; 620 const struct ne2000dev *ne_dev; 621 const char *intrstr; 622 int i; 623 u_int8_t myea[6], *enaddr; 624 625 psc->sc_pf = pa->pf; 626 627 for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL; 628 cfe = SIMPLEQ_NEXT(cfe, cfe_list)) { 629 #if 0 630 /* 631 * Some ne2000 driver's claim to have memory; others don't. 632 * Since I don't care, I don't check. 633 */ 634 635 if (cfe->num_memspace != 1) { 636 printf(": unexpected number of memory spaces, " 637 " %d should be 1\n", cfe->num_memspace); 638 return; 639 } 640 #endif 641 642 if (cfe->num_iospace == 1) { 643 if (cfe->iospace[0].length != NE2000_NPORTS) { 644 printf(": unexpected I/O space " 645 "configuration\n"); 646 continue; 647 } 648 } else if (cfe->num_iospace == 2) { 649 /* 650 * Some cards report a separate space for NIC and ASIC. 651 * This make some sense, but we must allocate a single 652 * NE2000_NPORTS-sized chunk, due to brain damaged 653 * address decoders on some of these cards. 654 */ 655 if (cfe->iospace[0].length + cfe->iospace[1].length != 656 NE2000_NPORTS) { 657 #ifdef DIAGNOSTIC 658 printf(": unexpected I/O space " 659 "configuration\n"); 660 #endif 661 continue; 662 } 663 } else { 664 #ifdef DIAGNOSTIC 665 printf(": unexpected number of i/o spaces %d" 666 " should be 1 or 2\n", cfe->num_iospace); 667 #endif 668 continue; 669 } 670 671 if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start, 672 NE2000_NPORTS, NE2000_NPORTS, &psc->sc_pcioh)) { 673 #ifdef DIAGNOSTIC 674 printf(": can't allocate I/O space\n"); 675 #endif 676 continue; 677 } 678 679 break; 680 } 681 682 if (cfe == NULL) { 683 printf(": no suitable config entry\n"); 684 goto fail_1; 685 } 686 687 dsc->sc_regt = psc->sc_pcioh.iot; 688 dsc->sc_regh = psc->sc_pcioh.ioh; 689 690 nsc->sc_asict = psc->sc_pcioh.iot; 691 if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh, 692 NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS, &nsc->sc_asich)) { 693 printf(": can't get subregion for asic\n"); 694 goto fail_2; 695 } 696 697 #ifdef notyet 698 /* Set up power management hooks. */ 699 dsc->sc_enable = ne_pcmcia_enable; 700 dsc->sc_disable = ne_pcmcia_disable; 701 #endif 702 703 /* Enable the card. */ 704 pcmcia_function_init(pa->pf, cfe); 705 if (pcmcia_function_enable(pa->pf)) { 706 printf(": function enable failed\n"); 707 goto fail_2; 708 } 709 710 dsc->sc_enabled = 1; 711 712 /* some cards claim to be io16, but they're lying. */ 713 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8, NE2000_NIC_OFFSET, 714 NE2000_NIC_NPORTS, &psc->sc_pcioh, &psc->sc_nic_io_window)) { 715 printf(": can't map NIC I/O space\n"); 716 goto fail_3; 717 } 718 719 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16, NE2000_ASIC_OFFSET, 720 NE2000_ASIC_NPORTS, &psc->sc_pcioh, &psc->sc_asic_io_window)) { 721 printf(": can't map ASIC I/O space\n"); 722 goto fail_4; 723 } 724 725 printf(" port 0x%lx/%d", psc->sc_pcioh.addr, NE2000_NPORTS); 726 727 /* 728 * Read the station address from the board. 729 */ 730 i = 0; 731 again: 732 enaddr = NULL; /* Ask ASIC by default */ 733 for (; i < NE2000_NDEVS; i++) { 734 ne_dev = ne2000_match(pa->card, pa->pf->number, i); 735 if (ne_dev != NULL) { 736 if (ne_dev->enet_maddr >= 0) { 737 enaddr = ne_pcmcia_get_enaddr(psc, 738 ne_dev->enet_maddr, myea); 739 if (enaddr == NULL) 740 continue; 741 } else { 742 enaddr = ne_pcmcia_dl10019_get_enaddr(psc, 743 myea); 744 } 745 break; 746 } 747 } 748 if (i == NE2000_NDEVS) { 749 printf(": can't match ethernet vendor code\n"); 750 goto fail_5; 751 } 752 753 if (enaddr != NULL) { 754 /* 755 * Make sure this is what we expect. 756 */ 757 if (enaddr[0] != ne_dev->enet_vendor[0] || 758 enaddr[1] != ne_dev->enet_vendor[1] || 759 enaddr[2] != ne_dev->enet_vendor[2]) { 760 ++i; 761 goto again; 762 } 763 } 764 765 if ((ne_dev->flags & NE2000DVF_AX88190) != 0) { 766 if (ne_pcmcia_ax88190_set_iobase(psc)) 767 goto fail_5; 768 769 dsc->sc_mediachange = ax88190_mediachange; 770 dsc->sc_mediastatus = ax88190_mediastatus; 771 dsc->init_card = ax88190_init_card; 772 dsc->stop_card = ax88190_stop_card; 773 dsc->sc_media_init = ax88190_media_init; 774 dsc->sc_media_fini = ax88190_media_fini; 775 776 nsc->sc_type = NE2000_TYPE_AX88190; 777 } 778 779 /* 780 * Check for a Realtek 8019. 781 */ 782 bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR, 783 ED_CR_PAGE_0 | ED_CR_STP); 784 if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID0) 785 == RTL0_8019ID0 && 786 bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1) 787 == RTL0_8019ID1) { 788 dsc->sc_mediachange = rtl80x9_mediachange; 789 dsc->sc_mediastatus = rtl80x9_mediastatus; 790 dsc->init_card = rtl80x9_init_card; 791 dsc->sc_media_init = rtl80x9_media_init; 792 } 793 794 if (nsc->sc_type == NE2000_TYPE_DL10019 || 795 nsc->sc_type == NE2000_TYPE_DL10022) { 796 dsc->sc_mediachange = dl10019_mediachange; 797 dsc->sc_mediastatus = dl10019_mediastatus; 798 dsc->init_card = dl10019_init_card; 799 dsc->stop_card = dl10019_stop_card; 800 dsc->sc_media_init = dl10019_media_init; 801 dsc->sc_media_fini = dl10019_media_fini; 802 } 803 804 /* set up the interrupt */ 805 psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr, 806 dsc, dsc->sc_dev.dv_xname); 807 intrstr = pcmcia_intr_string(psc->sc_pf, psc->sc_ih); 808 if (*intrstr) 809 printf(", %s", intrstr); 810 811 if (ne2000_attach(nsc, enaddr)) 812 goto fail_5; 813 814 #if notyet 815 pcmcia_function_disable(pa->pf); 816 #endif 817 return; 818 819 fail_5: 820 /* Unmap ASIC I/O windows. */ 821 pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window); 822 823 fail_4: 824 /* Unmap NIC I/O windows. */ 825 pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window); 826 827 fail_3: 828 pcmcia_function_disable(pa->pf); 829 830 fail_2: 831 /* Free our I/O space. */ 832 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh); 833 834 fail_1: 835 psc->sc_nic_io_window = -1; 836 } 837 838 int 839 ne_pcmcia_detach(dev, flags) 840 struct device *dev; 841 int flags; 842 { 843 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dev; 844 int error; 845 846 if (psc->sc_nic_io_window == -1) 847 /* Nothing to detach. */ 848 return (0); 849 850 error = ne2000_detach(&psc->sc_ne2000, flags); 851 if (error != 0) 852 return (error); 853 854 /* Unmap our i/o windows. */ 855 pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window); 856 pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window); 857 858 /* Free our i/o space. */ 859 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh); 860 861 return (0); 862 } 863 864 int 865 ne_pcmcia_activate(dev, act) 866 struct device *dev; 867 int act; 868 { 869 struct ne_pcmcia_softc *sc = (struct ne_pcmcia_softc *)dev; 870 struct dp8390_softc *esc = &sc->sc_ne2000.sc_dp8390; 871 struct ifnet *ifp = &esc->sc_arpcom.ac_if; 872 873 switch (act) { 874 case DVACT_SUSPEND: 875 ifp->if_timer = 0; 876 if (ifp->if_flags & IFF_RUNNING) { 877 dp8390_stop(esc); 878 ifp->if_flags &= ~IFF_RUNNING; 879 } 880 if (sc->sc_ih != NULL) 881 pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); 882 sc->sc_ih = NULL; 883 pcmcia_function_disable(sc->sc_pf); 884 break; 885 case DVACT_RESUME: 886 pcmcia_function_enable(sc->sc_pf); 887 sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, 888 dp8390_intr, sc, esc->sc_dev.dv_xname); 889 dp8390_enable(esc); 890 if (ifp->if_flags & IFF_UP) 891 dp8390_init(esc); 892 break; 893 case DVACT_DEACTIVATE: 894 ifp->if_timer = 0; 895 if (ifp->if_flags & IFF_RUNNING) { 896 dp8390_stop(esc); 897 ifp->if_flags &= ~IFF_RUNNING; 898 } 899 if (sc->sc_ih != NULL) 900 pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); 901 sc->sc_ih = NULL; 902 pcmcia_function_disable(sc->sc_pf); 903 break; 904 } 905 return (0); 906 } 907 908 #ifdef notyet 909 int 910 ne_pcmcia_enable(dsc) 911 struct dp8390_softc *dsc; 912 { 913 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc; 914 915 /* set up the interrupt */ 916 psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr, 917 dsc, dsc->sc_dev.dv_xname); 918 if (psc->sc_ih == NULL) { 919 printf("%s: couldn't establish interrupt\n", 920 dsc->sc_dev.dv_xname); 921 return (1); 922 } 923 924 return (pcmcia_function_enable(psc->sc_pf)); 925 } 926 927 void 928 ne_pcmcia_disable(dsc) 929 struct dp8390_softc *dsc; 930 { 931 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc; 932 933 pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); 934 pcmcia_function_disable(psc->sc_pf); 935 } 936 #endif 937 938 u_int8_t * 939 ne_pcmcia_get_enaddr(psc, maddr, myea) 940 struct ne_pcmcia_softc *psc; 941 int maddr; 942 u_int8_t myea[ETHER_ADDR_LEN]; 943 { 944 struct ne2000_softc *nsc = &psc->sc_ne2000; 945 struct dp8390_softc *dsc = &nsc->sc_dp8390; 946 struct pcmcia_mem_handle pcmh; 947 bus_size_t offset; 948 u_int8_t *enaddr = NULL; 949 int j, mwindow; 950 951 if (maddr < 0) 952 return (NULL); 953 954 if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) { 955 printf("%s: can't alloc mem for enet addr\n", 956 dsc->sc_dev.dv_xname); 957 goto fail_1; 958 } 959 if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, maddr, 960 ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) { 961 printf("%s: can't map mem for enet addr\n", 962 dsc->sc_dev.dv_xname); 963 goto fail_2; 964 } 965 for (j = 0; j < ETHER_ADDR_LEN; j++) 966 myea[j] = bus_space_read_1(pcmh.memt, pcmh.memh, 967 offset + (j * 2)); 968 enaddr = myea; 969 970 pcmcia_mem_unmap(psc->sc_pf, mwindow); 971 fail_2: 972 pcmcia_mem_free(psc->sc_pf, &pcmh); 973 fail_1: 974 return (enaddr); 975 } 976 977 u_int8_t * 978 ne_pcmcia_dl10019_get_enaddr(psc, myea) 979 struct ne_pcmcia_softc *psc; 980 u_int8_t myea[ETHER_ADDR_LEN]; 981 { 982 struct ne2000_softc *nsc = &psc->sc_ne2000; 983 u_int8_t sum; 984 int j, type; 985 986 for (j = 0, sum = 0; j < 8; j++) { 987 sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 988 0x04 + j); 989 } 990 if (sum != 0xff) 991 return (NULL); 992 993 for (j = 0; j < ETHER_ADDR_LEN; j++) { 994 myea[j] = bus_space_read_1(nsc->sc_asict, 995 nsc->sc_asich, 0x04 + j); 996 } 997 998 /* XXX - magic values from Linux */ 999 type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f); 1000 if (type == 0x91 || type == 0x99) 1001 nsc->sc_type = NE2000_TYPE_DL10022; 1002 else 1003 nsc->sc_type = NE2000_TYPE_DL10019; 1004 1005 return (myea); 1006 } 1007 1008 int 1009 ne_pcmcia_ax88190_set_iobase(psc) 1010 struct ne_pcmcia_softc *psc; 1011 { 1012 struct ne2000_softc *nsc = &psc->sc_ne2000; 1013 struct dp8390_softc *dsc = &nsc->sc_dp8390; 1014 struct pcmcia_mem_handle pcmh; 1015 bus_size_t offset; 1016 int rv = 1, mwindow; 1017 1018 if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) { 1019 printf("%s: can't alloc mem for LAN iobase\n", 1020 dsc->sc_dev.dv_xname); 1021 goto fail_1; 1022 } 1023 if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, 1024 AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE, &pcmh, &offset, 1025 &mwindow)) { 1026 printf("%s: can't map mem for LAN iobase\n", 1027 dsc->sc_dev.dv_xname); 1028 goto fail_2; 1029 } 1030 1031 #ifdef NE_DEBUG 1032 printf(": LAN iobase 0x%x (0x%x) ->", 1033 bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) | 1034 bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8, 1035 (u_int)psc->sc_pcioh.addr); 1036 #endif 1037 bus_space_write_1(pcmh.memt, pcmh.memh, offset, 1038 psc->sc_pcioh.addr & 0xff); 1039 bus_space_write_1(pcmh.memt, pcmh.memh, offset + 2, 1040 psc->sc_pcioh.addr >> 8); 1041 #ifdef NE_DEBUG 1042 printf(" 0x%x", bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) | 1043 bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8); 1044 #endif 1045 rv = 0; 1046 1047 pcmcia_mem_unmap(psc->sc_pf, mwindow); 1048 fail_2: 1049 pcmcia_mem_free(psc->sc_pf, &pcmh); 1050 fail_1: 1051 return (rv); 1052 } 1053