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