pccard.c revision 101762
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2/* $FreeBSD: head/sys/dev/pccard/pccard.c 101762 2002-08-12 22:34:12Z imp $ */ 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/malloc.h> 36#include <sys/module.h> 37#include <sys/kernel.h> 38#include <sys/queue.h> 39#include <sys/sysctl.h> 40#include <sys/types.h> 41 42#include <sys/bus.h> 43#include <machine/bus.h> 44#include <sys/rman.h> 45#include <machine/resource.h> 46 47#include <net/ethernet.h> 48 49#include <dev/pccard/pccardreg.h> 50#include <dev/pccard/pccardvar.h> 51 52#include "power_if.h" 53#include "card_if.h" 54 55#define PCCARDDEBUG 56 57/* sysctl vars */ 58SYSCTL_NODE(_hw, OID_AUTO, pccard, CTLFLAG_RD, 0, "PCCARD parameters"); 59 60int pccard_debug = 0; 61TUNABLE_INT("hw.pccard.debug", &pccard_debug); 62SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RW, 63 &pccard_debug, 0, 64 "pccard debug"); 65 66int pccard_cis_debug = 0; 67TUNABLE_INT("hw.pccard.cis_debug", &pccard_cis_debug); 68SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RW, 69 &pccard_cis_debug, 0, "pccard CIS debug"); 70 71#ifdef PCCARDDEBUG 72#define DPRINTF(arg) if (pccard_debug) printf arg 73#define DEVPRINTF(arg) if (pccard_debug) device_printf arg 74#define PRVERBOSE(arg) printf arg 75#define DEVPRVERBOSE(arg) device_printf arg 76#else 77#define DPRINTF(arg) 78#define DEVPRINTF(arg) 79#define PRVERBOSE(arg) if (bootverbose) printf arg 80#define DEVPRVERBOSE(arg) if (bootverbose) device_printf arg 81#endif 82 83static int pccard_ccr_read(struct pccard_function *pf, int ccr); 84static void pccard_ccr_write(struct pccard_function *pf, int ccr, int val); 85static int pccard_attach_card(device_t dev); 86static int pccard_detach_card(device_t dev, int flags); 87static int pccard_card_gettype(device_t dev, int *type); 88static void pccard_function_init(struct pccard_function *pf); 89static void pccard_function_free(struct pccard_function *pf); 90static int pccard_function_enable(struct pccard_function *pf); 91static void pccard_function_disable(struct pccard_function *pf); 92static int pccard_compat_do_probe(device_t bus, device_t dev); 93static int pccard_compat_do_attach(device_t bus, device_t dev); 94static int pccard_add_children(device_t dev, int busno); 95static int pccard_probe(device_t dev); 96static int pccard_attach(device_t dev); 97static int pccard_detach(device_t dev); 98static void pccard_print_resources(struct resource_list *rl, 99 const char *name, int type, int count, const char *format); 100static int pccard_print_child(device_t dev, device_t child); 101static int pccard_set_resource(device_t dev, device_t child, int type, 102 int rid, u_long start, u_long count); 103static int pccard_get_resource(device_t dev, device_t child, int type, 104 int rid, u_long *startp, u_long *countp); 105static void pccard_delete_resource(device_t dev, device_t child, int type, 106 int rid); 107static int pccard_set_res_flags(device_t dev, device_t child, int type, 108 int rid, u_int32_t flags); 109static int pccard_set_memory_offset(device_t dev, device_t child, int rid, 110 u_int32_t offset, u_int32_t *deltap); 111static int pccard_read_ivar(device_t bus, device_t child, int which, 112 u_char *result); 113static void pccard_driver_added(device_t dev, driver_t *driver); 114static struct resource *pccard_alloc_resource(device_t dev, 115 device_t child, int type, int *rid, u_long start, 116 u_long end, u_long count, u_int flags); 117static int pccard_release_resource(device_t dev, device_t child, int type, 118 int rid, struct resource *r); 119static void pccard_child_detached(device_t parent, device_t dev); 120static void pccard_intr(void *arg); 121static int pccard_setup_intr(device_t dev, device_t child, 122 struct resource *irq, int flags, driver_intr_t *intr, 123 void *arg, void **cookiep); 124static int pccard_teardown_intr(device_t dev, device_t child, 125 struct resource *r, void *cookie); 126 127static const struct pccard_product * 128pccard_do_product_lookup(device_t bus, device_t dev, 129 const struct pccard_product *tab, size_t ent_size, 130 pccard_product_match_fn matchfn); 131 132 133static int 134pccard_ccr_read(struct pccard_function *pf, int ccr) 135{ 136 return (bus_space_read_1(pf->pf_ccrt, pf->pf_ccrh, 137 pf->pf_ccr_offset + ccr)); 138} 139 140static void 141pccard_ccr_write(struct pccard_function *pf, int ccr, int val) 142{ 143 if ((pf->ccr_mask) & (1 << (ccr / 2))) { 144 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, 145 pf->pf_ccr_offset + ccr, val); 146 } 147} 148 149static int 150pccard_attach_card(device_t dev) 151{ 152 struct pccard_softc *sc = PCCARD_SOFTC(dev); 153 struct pccard_function *pf; 154 struct pccard_ivar *ivar; 155 device_t child; 156 157 /* 158 * this is here so that when socket_enable calls gettype, trt happens 159 */ 160 STAILQ_INIT(&sc->card.pf_head); 161 162 DEVPRINTF((dev, "chip_socket_enable\n")); 163 POWER_ENABLE_SOCKET(device_get_parent(dev), dev); 164 165 DEVPRINTF((dev, "read_cis\n")); 166 pccard_read_cis(sc); 167 168 DEVPRINTF((dev, "check_cis_quirks\n")); 169 pccard_check_cis_quirks(dev); 170 171 /* 172 * bail now if the card has no functions, or if there was an error in 173 * the cis. 174 */ 175 176 if (sc->card.error) { 177 device_printf (dev, "CARD ERROR!\n"); 178 return (1); 179 } 180 if (STAILQ_EMPTY(&sc->card.pf_head)) { 181 device_printf (dev, "Card has no functions!\n"); 182 return (1); 183 } 184 185 if (bootverbose || pccard_debug) 186 pccard_print_cis(dev); 187 188 DEVPRINTF((dev, "functions scanning\n")); 189 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 190 if (STAILQ_EMPTY(&pf->cfe_head)) 191 continue; 192 193 pf->sc = sc; 194 pf->cfe = NULL; 195 pf->dev = NULL; 196 } 197 198 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 199 if (STAILQ_EMPTY(&pf->cfe_head)) 200 continue; 201 /* 202 * In NetBSD, the drivers are responsible for activating 203 * each function of a card. I think that in FreeBSD we 204 * want to activate them enough for the usual bus_*_resource 205 * routines will do the right thing. This many mean a 206 * departure from the current NetBSD model. 207 * 208 * This could get really ugly for multifunction cards. But 209 * it might also just fall out of the FreeBSD resource model. 210 * 211 */ 212 ivar = malloc(sizeof(struct pccard_ivar), M_DEVBUF, 213 M_WAITOK | M_ZERO); 214 child = device_add_child(dev, NULL, -1); 215 device_set_ivars(child, ivar); 216 ivar->fcn = pf; 217 pf->dev = child; 218 /* 219 * XXX We might want to move the next two lines into 220 * XXX the pccard interface layer. For the moment, this 221 * XXX is OK, but some drivers want to pick the config 222 * XXX entry to use as well as some address tweaks (mostly 223 * XXX due to bugs in decode logic that makes some 224 * XXX addresses illegal or broken). 225 */ 226 pccard_function_init(pf); 227 if (sc->sc_enabled_count == 0) 228 POWER_ENABLE_SOCKET(device_get_parent(dev), dev); 229 if (pccard_function_enable(pf) == 0 && 230 device_probe_and_attach(child) == 0) { 231 DEVPRINTF((sc->dev, "function %d CCR at %d " 232 "offset %x: %x %x %x %x, %x %x %x %x, %x\n", 233 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, 234 pccard_ccr_read(pf, 0x00), 235 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), 236 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), 237 pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), 238 pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); 239 } else { 240 if (pf->cfe != NULL) 241 pccard_function_disable(pf); 242 } 243 } 244 if (sc->sc_enabled_count == 0) 245 pccard_detach_card(dev, 0); 246 return (0); 247} 248 249static int 250pccard_detach_card(device_t dev, int flags) 251{ 252 struct pccard_softc *sc = PCCARD_SOFTC(dev); 253 struct pccard_function *pf; 254 struct pccard_config_entry *cfe; 255 256 /* 257 * We are running on either the PCCARD socket's event thread 258 * or in user context detaching a device by user request. 259 */ 260 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 261 int state = device_get_state(pf->dev); 262 263 if (state == DS_ATTACHED || state == DS_BUSY) 264 device_detach(pf->dev); 265 if (pf->cfe != NULL) 266 pccard_function_disable(pf); 267 pccard_function_free(pf); 268 if (pf->dev != NULL) 269 device_delete_child(dev, pf->dev); 270 } 271 if (sc->sc_enabled_count == 0) 272 POWER_DISABLE_SOCKET(device_get_parent(dev), dev); 273 274 while (NULL != (pf = STAILQ_FIRST(&sc->card.pf_head))) { 275 while (NULL != (cfe = STAILQ_FIRST(&pf->cfe_head))) { 276 STAILQ_REMOVE_HEAD(&pf->cfe_head, cfe_list); 277 free(cfe, M_DEVBUF); 278 } 279 STAILQ_REMOVE_HEAD(&sc->card.pf_head, pf_list); 280 free(pf, M_DEVBUF); 281 } 282 return (0); 283} 284 285static const struct pccard_product * 286pccard_do_product_lookup(device_t bus, device_t dev, 287 const struct pccard_product *tab, size_t ent_size, 288 pccard_product_match_fn matchfn) 289{ 290 const struct pccard_product *ent; 291 int matches; 292 u_int32_t fcn; 293 u_int32_t vendor; 294 u_int32_t prod; 295 char *vendorstr; 296 char *prodstr; 297 298#ifdef DIAGNOSTIC 299 if (sizeof *ent > ent_size) 300 panic("pccard_product_lookup: bogus ent_size %ld", 301 (long) ent_size); 302#endif 303 if (pccard_get_vendor(dev, &vendor)) 304 return (NULL); 305 if (pccard_get_product(dev, &prod)) 306 return (NULL); 307 if (pccard_get_function_number(dev, &fcn)) 308 return (NULL); 309 if (pccard_get_vendor_str(dev, &vendorstr)) 310 return (NULL); 311 if (pccard_get_product_str(dev, &prodstr)) 312 return (NULL); 313 for (ent = tab; ent->pp_name != NULL; ent = 314 (const struct pccard_product *) ((const char *) ent + ent_size)) { 315 matches = 1; 316 if (ent->pp_vendor == PCCARD_VENDOR_ANY && 317 ent->pp_product == PCCARD_VENDOR_ANY && 318 ent->pp_cis[0] == NULL && 319 ent->pp_cis[1] == NULL) { 320 device_printf(dev, 321 "Total wildcard entry ignored for %s\n", 322 ent->pp_name); 323 continue; 324 } 325 if (matches && ent->pp_vendor != PCCARD_VENDOR_ANY && 326 vendor != ent->pp_vendor) 327 matches = 0; 328 if (matches && ent->pp_product != PCCARD_PRODUCT_ANY && 329 prod != ent->pp_product) 330 matches = 0; 331 if (matches && fcn != ent->pp_expfunc) 332 matches = 0; 333 if (matches && ent->pp_cis[0] && 334 strcmp(ent->pp_cis[0], vendorstr) != 0) 335 matches = 0; 336 if (matches && ent->pp_cis[1] && 337 strcmp(ent->pp_cis[1], prodstr) != 0) 338 matches = 0; 339 /* XXX need to match cis[2] and cis[3] also XXX */ 340 if (matchfn != NULL) 341 matches = (*matchfn)(dev, ent, matches); 342 if (matches) 343 return (ent); 344 } 345 return (NULL); 346} 347 348static int 349pccard_card_gettype(device_t dev, int *type) 350{ 351 struct pccard_softc *sc = PCCARD_SOFTC(dev); 352 struct pccard_function *pf; 353 354 /* 355 * set the iftype to memory if this card has no functions (not yet 356 * probed), or only one function, and that is not initialized yet or 357 * that is memory. 358 */ 359 pf = STAILQ_FIRST(&sc->card.pf_head); 360 if (pf == NULL || 361 (STAILQ_NEXT(pf, pf_list) == NULL && 362 (pf->cfe == NULL || pf->cfe->iftype == PCCARD_IFTYPE_MEMORY))) 363 *type = PCCARD_IFTYPE_MEMORY; 364 else 365 *type = PCCARD_IFTYPE_IO; 366 return (0); 367} 368 369/* 370 * Initialize a PCCARD function. May be called as long as the function is 371 * disabled. 372 * 373 * Note: pccard_function_init should not keep resources allocated. It should 374 * only set them up ala isa pnp, set the values in the rl lists, and return. 375 * Any resource held after pccard_function_init is called is a bug. However, 376 * the bus routines to get the resources also assume that pccard_function_init 377 * does this, so they need to be fixed too. 378 */ 379static void 380pccard_function_init(struct pccard_function *pf) 381{ 382 struct pccard_config_entry *cfe; 383 int i; 384 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 385 struct resource_list *rl = &devi->resources; 386 struct resource_list_entry *rle; 387 struct resource *r = 0; 388 device_t bus; 389 int start; 390 int end; 391 int spaces; 392 393 if (pf->pf_flags & PFF_ENABLED) { 394 printf("pccard_function_init: function is enabled"); 395 return; 396 } 397 bus = device_get_parent(pf->dev); 398 /* Remember which configuration entry we are using. */ 399 STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { 400 for (i = 0; i < cfe->num_iospace; i++) 401 cfe->iores[i] = NULL; 402 cfe->irqres = NULL; 403 spaces = 0; 404 for (i = 0; i < cfe->num_iospace; i++) { 405 start = cfe->iospace[i].start; 406 if (start) 407 end = start + cfe->iospace[i].length - 1; 408 else 409 end = ~0; 410 cfe->iorid[i] = i; 411 DEVPRINTF((bus, "I/O rid %d start %x end %x\n", 412 i, start, end)); 413 r = cfe->iores[i] = bus_alloc_resource(bus, 414 SYS_RES_IOPORT, &cfe->iorid[i], start, end, 415 cfe->iospace[i].length, 416 rman_make_alignment_flags(cfe->iospace[i].length)); 417 if (cfe->iores[i] == NULL) 418 goto not_this_one; 419 resource_list_add(rl, SYS_RES_IOPORT, cfe->iorid[i], 420 rman_get_start(r), rman_get_end(r), 421 cfe->iospace[i].length); 422 rle = resource_list_find(rl, SYS_RES_IOPORT, 423 cfe->iorid[i]); 424 rle->res = r; 425 spaces++; 426 } 427 if (cfe->num_memspace > 0) { 428 /* 429 * Not implement yet, Fix me. 430 */ 431 DEVPRINTF((bus, "Memory space not yet implemented.\n")); 432 } 433 if (spaces == 0) { 434 DEVPRINTF((bus, "Neither memory nor I/O mampped\n")); 435 goto not_this_one; 436 } 437 if (cfe->irqmask) { 438 cfe->irqrid = 0; 439 r = cfe->irqres = bus_alloc_resource(bus, SYS_RES_IRQ, 440 &cfe->irqrid, 0, ~0, 1, 0); 441 if (cfe->irqres == NULL) 442 goto not_this_one; 443 resource_list_add(rl, SYS_RES_IRQ, cfe->irqrid, 444 rman_get_start(r), rman_get_end(r), 1); 445 rle = resource_list_find(rl, SYS_RES_IRQ, 446 cfe->irqrid); 447 rle->res = r; 448 } 449 /* If we get to here, we've allocated all we need */ 450 pf->cfe = cfe; 451 break; 452 not_this_one:; 453 DEVPRVERBOSE((bus, "Allocation failed for cfe %d\n", 454 cfe->number)); 455 /* 456 * Release resources that we partially allocated 457 * from this config entry. 458 */ 459 for (i = 0; i < cfe->num_iospace; i++) { 460 if (cfe->iores[i] != NULL) { 461 bus_release_resource(bus, SYS_RES_IOPORT, 462 cfe->iorid[i], cfe->iores[i]); 463 rle = resource_list_find(rl, SYS_RES_IOPORT, 464 cfe->iorid[i]); 465 rle->res = NULL; 466 resource_list_delete(rl, SYS_RES_IOPORT, 467 cfe->iorid[i]); 468 } 469 cfe->iores[i] = NULL; 470 } 471 if (cfe->irqmask && cfe->irqres != NULL) { 472 bus_release_resource(bus, SYS_RES_IRQ, 473 cfe->irqrid, cfe->irqres); 474 rle = resource_list_find(rl, SYS_RES_IRQ, 475 cfe->irqrid); 476 rle->res = NULL; 477 resource_list_delete(rl, SYS_RES_IRQ, cfe->irqrid); 478 cfe->irqres = NULL; 479 } 480 } 481} 482 483/* 484 * Free resources allocated by pccard_function_init(), May be called as long 485 * as the function is disabled. 486 * 487 * NOTE: This function should be unnecessary. pccard_function_init should 488 * never keep resources initialized. 489 */ 490static void 491pccard_function_free(struct pccard_function *pf) 492{ 493 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 494 struct resource_list_entry *rle; 495 496 if (pf->pf_flags & PFF_ENABLED) { 497 printf("pccard_function_init: function is enabled"); 498 return; 499 } 500 501 SLIST_FOREACH(rle, &devi->resources, link) { 502 if (rle->res) { 503 if (rle->res->r_dev != pf->sc->dev) 504 device_printf(pf->sc->dev, 505 "function_free: Resource still owned by " 506 "child, oops. " 507 "(type=%d, rid=%d, addr=%lx)\n", 508 rle->type, rle->rid, 509 rman_get_start(rle->res)); 510 BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), 511 rle->res->r_dev, rle->type, rle->rid, rle->res); 512 rle->res = NULL; 513 } 514 } 515 resource_list_free(&devi->resources); 516} 517 518/* Enable a PCCARD function */ 519static int 520pccard_function_enable(struct pccard_function *pf) 521{ 522 struct pccard_function *tmp; 523 int reg; 524 device_t dev = pf->sc->dev; 525 526 if (pf->cfe == NULL) { 527 DEVPRVERBOSE((dev, "No config entry could be allocated.\n")); 528 return (ENOMEM); 529 } 530 531 /* 532 * Increase the reference count on the socket, enabling power, if 533 * necessary. 534 */ 535 pf->sc->sc_enabled_count++; 536 537 if (pf->pf_flags & PFF_ENABLED) { 538 /* 539 * Don't do anything if we're already enabled. 540 */ 541 return (0); 542 } 543 544 /* 545 * it's possible for different functions' CCRs to be in the same 546 * underlying page. Check for that. 547 */ 548 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 549 if ((tmp->pf_flags & PFF_ENABLED) && 550 (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && 551 ((pf->ccr_base + PCCARD_CCR_SIZE) <= 552 (tmp->ccr_base - tmp->pf_ccr_offset + 553 tmp->pf_ccr_realsize))) { 554 pf->pf_ccrt = tmp->pf_ccrt; 555 pf->pf_ccrh = tmp->pf_ccrh; 556 pf->pf_ccr_realsize = tmp->pf_ccr_realsize; 557 558 /* 559 * pf->pf_ccr_offset = (tmp->pf_ccr_offset - 560 * tmp->ccr_base) + pf->ccr_base; 561 */ 562 /* pf->pf_ccr_offset = 563 (tmp->pf_ccr_offset + pf->ccr_base) - 564 tmp->ccr_base; */ 565 pf->pf_ccr_window = tmp->pf_ccr_window; 566 break; 567 } 568 } 569 if (tmp == NULL) { 570 pf->ccr_rid = 0; 571 pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 572 &pf->ccr_rid, 0, ~0, 1 << 10, RF_ACTIVE); 573 if (!pf->ccr_res) 574 goto bad; 575 DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%lx\n", 576 rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), 577 pf->ccr_base)); 578 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, 579 pf->ccr_rid, PCCARD_A_MEM_ATTR); 580 CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, 581 pf->ccr_rid, pf->ccr_base, &pf->pf_ccr_offset); 582 pf->pf_ccrt = rman_get_bustag(pf->ccr_res); 583 pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); 584 pf->pf_ccr_realsize = 1; 585 } 586 587 reg = (pf->cfe->number & PCCARD_CCR_OPTION_CFINDEX); 588 reg |= PCCARD_CCR_OPTION_LEVIREQ; 589 if (pccard_mfc(pf->sc)) { 590 reg |= (PCCARD_CCR_OPTION_FUNC_ENABLE | 591 PCCARD_CCR_OPTION_ADDR_DECODE); 592 /* PCCARD_CCR_OPTION_IRQ_ENABLE set elsewhere as needed */ 593 } 594 pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); 595 596 reg = 0; 597 if ((pf->cfe->flags & PCCARD_CFE_IO16) == 0) 598 reg |= PCCARD_CCR_STATUS_IOIS8; 599 if (pf->cfe->flags & PCCARD_CFE_AUDIO) 600 reg |= PCCARD_CCR_STATUS_AUDIO; 601 pccard_ccr_write(pf, PCCARD_CCR_STATUS, reg); 602 603 pccard_ccr_write(pf, PCCARD_CCR_SOCKETCOPY, 0); 604 605 if (pccard_mfc(pf->sc)) { 606 long tmp, iosize; 607 608 tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; 609 /* round up to nearest (2^n)-1 */ 610 for (iosize = 1; iosize < tmp; iosize <<= 1) 611 ; 612 iosize--; 613 614 pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, 615 pf->pf_mfc_iobase & 0xff); 616 pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, 617 (pf->pf_mfc_iobase >> 8) & 0xff); 618 pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); 619 pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); 620 621 pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); 622 } 623 624#ifdef PCCARDDEBUG 625 if (pccard_debug) { 626 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 627 device_printf(tmp->sc->dev, 628 "function %d CCR at %d offset %x: " 629 "%x %x %x %x, %x %x %x %x, %x\n", 630 tmp->number, tmp->pf_ccr_window, 631 tmp->pf_ccr_offset, 632 pccard_ccr_read(tmp, 0x00), 633 pccard_ccr_read(tmp, 0x02), 634 pccard_ccr_read(tmp, 0x04), 635 pccard_ccr_read(tmp, 0x06), 636 pccard_ccr_read(tmp, 0x0A), 637 pccard_ccr_read(tmp, 0x0C), 638 pccard_ccr_read(tmp, 0x0E), 639 pccard_ccr_read(tmp, 0x10), 640 pccard_ccr_read(tmp, 0x12)); 641 } 642 } 643#endif 644 pf->pf_flags |= PFF_ENABLED; 645 return (0); 646 647 bad: 648 /* 649 * Decrement the reference count, and power down the socket, if 650 * necessary. 651 */ 652 pf->sc->sc_enabled_count--; 653 DEVPRINTF((dev, "bad --enabled_count = %d\n", pf->sc->sc_enabled_count)); 654 655 return (1); 656} 657 658/* Disable PCCARD function. */ 659static void 660pccard_function_disable(struct pccard_function *pf) 661{ 662 struct pccard_function *tmp; 663 device_t dev = pf->sc->dev; 664 665 if (pf->cfe == NULL) 666 panic("pccard_function_disable: function not initialized"); 667 668 if ((pf->pf_flags & PFF_ENABLED) == 0) { 669 /* 670 * Don't do anything if we're already disabled. 671 */ 672 return; 673 } 674 675 if (pf->intr_handler != NULL) { 676 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 677 struct resource_list_entry *rle = 678 resource_list_find(&devi->resources, SYS_RES_IRQ, 0); 679 BUS_TEARDOWN_INTR(dev, pf->dev, rle->res, 680 pf->intr_handler_cookie); 681 } 682 683 /* 684 * it's possible for different functions' CCRs to be in the same 685 * underlying page. Check for that. Note we mark us as disabled 686 * first to avoid matching ourself. 687 */ 688 689 pf->pf_flags &= ~PFF_ENABLED; 690 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 691 if ((tmp->pf_flags & PFF_ENABLED) && 692 (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && 693 ((pf->ccr_base + PCCARD_CCR_SIZE) <= 694 (tmp->ccr_base - tmp->pf_ccr_offset + 695 tmp->pf_ccr_realsize))) 696 break; 697 } 698 699 /* Not used by anyone else; unmap the CCR. */ 700 if (tmp == NULL) { 701 bus_release_resource(dev, SYS_RES_MEMORY, pf->ccr_rid, 702 pf->ccr_res); 703 pf->ccr_res = NULL; 704 } 705 706 /* 707 * Decrement the reference count, and power down the socket, if 708 * necessary. 709 */ 710 pf->sc->sc_enabled_count--; 711} 712 713#if 0 714/* XXX These functions are needed, but not like this XXX */ 715int 716pccard_io_map(struct pccard_function *pf, int width, bus_addr_t offset, 717 bus_size_t size, struct pccard_io_handle *pcihp, int *windowp) 718{ 719 int reg; 720 721 if (pccard_chip_io_map(pf->sc->pct, pf->sc->pch, width, offset, size, 722 pcihp, windowp)) 723 return (1); 724 725 /* 726 * XXX in the multifunction multi-iospace-per-function case, this 727 * needs to cooperate with io_alloc to make sure that the spaces 728 * don't overlap, and that the ccr's are set correctly 729 */ 730 731 if (pccard_mfc(pf->sc)) { 732 long tmp, iosize; 733 734 if (pf->pf_mfc_iomax == 0) { 735 pf->pf_mfc_iobase = pcihp->addr + offset; 736 pf->pf_mfc_iomax = pf->pf_mfc_iobase + size; 737 } else { 738 /* this makes the assumption that nothing overlaps */ 739 if (pf->pf_mfc_iobase > pcihp->addr + offset) 740 pf->pf_mfc_iobase = pcihp->addr + offset; 741 if (pf->pf_mfc_iomax < pcihp->addr + offset + size) 742 pf->pf_mfc_iomax = pcihp->addr + offset + size; 743 } 744 745 tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; 746 /* round up to nearest (2^n)-1 */ 747 for (iosize = 1; iosize >= tmp; iosize <<= 1) 748 ; 749 iosize--; 750 751 pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, 752 pf->pf_mfc_iobase & 0xff); 753 pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, 754 (pf->pf_mfc_iobase >> 8) & 0xff); 755 pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); 756 pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); 757 758 pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); 759 760 reg = pccard_ccr_read(pf, PCCARD_CCR_OPTION); 761 reg |= PCCARD_CCR_OPTION_ADDR_DECODE; 762 pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); 763 } 764 return (0); 765} 766 767void 768pccard_io_unmap(struct pccard_function *pf, int window) 769{ 770 771 pccard_chip_io_unmap(pf->sc->pct, pf->sc->pch, window); 772 773 /* XXX Anything for multi-function cards? */ 774} 775#endif 776 777/* 778 * simulate the old "probe" routine. In the new world order, the driver 779 * needs to grab devices while in the old they were assigned to the device by 780 * the pccardd process. These symbols are exported to the upper layers. 781 */ 782static int 783pccard_compat_do_probe(device_t bus, device_t dev) 784{ 785 return (CARD_COMPAT_MATCH(dev)); 786} 787 788static int 789pccard_compat_do_attach(device_t bus, device_t dev) 790{ 791 int err; 792 793 err = CARD_COMPAT_PROBE(dev); 794 if (err == 0) 795 err = CARD_COMPAT_ATTACH(dev); 796 return (err); 797} 798 799#define PCCARD_NPORT 2 800#define PCCARD_NMEM 5 801#define PCCARD_NIRQ 1 802#define PCCARD_NDRQ 0 803 804static int 805pccard_add_children(device_t dev, int busno) 806{ 807 /* Call parent to scan for any current children */ 808 return (0); 809} 810 811static int 812pccard_probe(device_t dev) 813{ 814 device_set_desc(dev, "16-bit PCCard bus"); 815 return (pccard_add_children(dev, device_get_unit(dev))); 816} 817 818static int 819pccard_attach(device_t dev) 820{ 821 struct pccard_softc *sc = PCCARD_SOFTC(dev); 822 823 sc->dev = dev; 824 sc->sc_enabled_count = 0; 825 return (bus_generic_attach(dev)); 826} 827 828static int 829pccard_detach(device_t dev) 830{ 831 pccard_detach_card(dev, 0); 832 return 0; 833} 834 835static int 836pccard_suspend(device_t self) 837{ 838 pccard_detach_card(self, 0); 839 return (0); 840} 841 842static 843int 844pccard_resume(device_t self) 845{ 846 return (0); 847} 848 849static void 850pccard_print_resources(struct resource_list *rl, const char *name, int type, 851 int count, const char *format) 852{ 853 struct resource_list_entry *rle; 854 int printed; 855 int i; 856 857 printed = 0; 858 for (i = 0; i < count; i++) { 859 rle = resource_list_find(rl, type, i); 860 if (rle != NULL) { 861 if (printed == 0) 862 printf(" %s ", name); 863 else if (printed > 0) 864 printf(","); 865 printed++; 866 printf(format, rle->start); 867 if (rle->count > 1) { 868 printf("-"); 869 printf(format, rle->start + rle->count - 1); 870 } 871 } else if (i > 3) { 872 /* check the first few regardless */ 873 break; 874 } 875 } 876} 877 878static int 879pccard_print_child(device_t dev, device_t child) 880{ 881 struct pccard_ivar *devi = PCCARD_IVAR(child); 882 struct resource_list *rl = &devi->resources; 883 int retval = 0; 884 885 retval += bus_print_child_header(dev, child); 886 retval += printf(" at"); 887 888 if (devi != NULL) { 889 pccard_print_resources(rl, "port", SYS_RES_IOPORT, 890 PCCARD_NPORT, "%#lx"); 891 pccard_print_resources(rl, "iomem", SYS_RES_MEMORY, 892 PCCARD_NMEM, "%#lx"); 893 pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ, 894 "%ld"); 895 pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ, 896 "%ld"); 897 retval += printf(" function %d config %d", devi->fcn->number, 898 devi->fcn->cfe->number); 899 } 900 901 retval += bus_print_child_footer(dev, child); 902 903 return (retval); 904} 905 906static int 907pccard_set_resource(device_t dev, device_t child, int type, int rid, 908 u_long start, u_long count) 909{ 910 struct pccard_ivar *devi = PCCARD_IVAR(child); 911 struct resource_list *rl = &devi->resources; 912 913 if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY 914 && type != SYS_RES_IRQ && type != SYS_RES_DRQ) 915 return (EINVAL); 916 if (rid < 0) 917 return (EINVAL); 918 if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT) 919 return (EINVAL); 920 if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM) 921 return (EINVAL); 922 if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ) 923 return (EINVAL); 924 if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ) 925 return (EINVAL); 926 927 resource_list_add(rl, type, rid, start, start + count - 1, count); 928 if (NULL != resource_list_alloc(rl, device_get_parent(dev), dev, 929 type, &rid, start, start + count - 1, count, 0)) 930 return 0; 931 else 932 return ENOMEM; 933} 934 935static int 936pccard_get_resource(device_t dev, device_t child, int type, int rid, 937 u_long *startp, u_long *countp) 938{ 939 struct pccard_ivar *devi = PCCARD_IVAR(child); 940 struct resource_list *rl = &devi->resources; 941 struct resource_list_entry *rle; 942 943 rle = resource_list_find(rl, type, rid); 944 if (rle == NULL) 945 return (ENOENT); 946 947 if (startp != NULL) 948 *startp = rle->start; 949 if (countp != NULL) 950 *countp = rle->count; 951 952 return (0); 953} 954 955static void 956pccard_delete_resource(device_t dev, device_t child, int type, int rid) 957{ 958 struct pccard_ivar *devi = PCCARD_IVAR(child); 959 struct resource_list *rl = &devi->resources; 960 resource_list_delete(rl, type, rid); 961} 962 963static int 964pccard_set_res_flags(device_t dev, device_t child, int type, int rid, 965 u_int32_t flags) 966{ 967 return (CARD_SET_RES_FLAGS(device_get_parent(dev), child, type, 968 rid, flags)); 969} 970 971static int 972pccard_set_memory_offset(device_t dev, device_t child, int rid, 973 u_int32_t offset, u_int32_t *deltap) 974 975{ 976 return (CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid, 977 offset, deltap)); 978} 979 980static int 981pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) 982{ 983 struct pccard_ivar *devi = PCCARD_IVAR(child); 984 struct pccard_function *func = devi->fcn; 985 struct pccard_softc *sc = PCCARD_SOFTC(bus); 986 987 /* PCCARD_IVAR_ETHADDR unhandled from oldcard */ 988 switch (which) { 989 default: 990 case PCCARD_IVAR_ETHADDR: 991 bcopy(func->pf_funce_lan_nid, result, ETHER_ADDR_LEN); 992 break; 993 case PCCARD_IVAR_VENDOR: 994 *(u_int32_t *) result = sc->card.manufacturer; 995 break; 996 case PCCARD_IVAR_PRODUCT: 997 *(u_int32_t *) result = sc->card.product; 998 break; 999 case PCCARD_IVAR_PRODEXT: 1000 *(u_int16_t *) result = sc->card.prodext; 1001 break; 1002 case PCCARD_IVAR_FUNCTION: 1003 *(u_int32_t *) result = func->function; 1004 break; 1005 case PCCARD_IVAR_FUNCTION_NUMBER: 1006 if (!func) { 1007 device_printf(bus, "No function number, bug!\n"); 1008 return (ENOENT); 1009 } 1010 *(u_int32_t *) result = func->number; 1011 break; 1012 case PCCARD_IVAR_VENDOR_STR: 1013 *(char **) result = sc->card.cis1_info[0]; 1014 break; 1015 case PCCARD_IVAR_PRODUCT_STR: 1016 *(char **) result = sc->card.cis1_info[1]; 1017 break; 1018 case PCCARD_IVAR_CIS3_STR: 1019 *(char **) result = sc->card.cis1_info[2]; 1020 break; 1021 case PCCARD_IVAR_CIS4_STR: 1022 *(char **) result = sc->card.cis1_info[2]; 1023 break; 1024 } 1025 return (0); 1026} 1027 1028static void 1029pccard_driver_added(device_t dev, driver_t *driver) 1030{ 1031 struct pccard_softc *sc = PCCARD_SOFTC(dev); 1032 struct pccard_function *pf; 1033 device_t child; 1034 1035 if (sc->sc_enabled_count == 0) { 1036 CARD_REPROBE_CARD(device_get_parent(dev), dev); 1037 return; 1038 } 1039 1040 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 1041 if (STAILQ_EMPTY(&pf->cfe_head)) 1042 continue; 1043 child = pf->dev; 1044 if (device_get_state(child) != DS_NOTPRESENT) 1045 continue; 1046 if (pccard_function_enable(pf) == 0 && 1047 device_probe_and_attach(child) == 0) { 1048 DEVPRINTF((sc->dev, "function %d CCR at %d " 1049 "offset %x: %x %x %x %x, %x %x %x %x, %x\n", 1050 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, 1051 pccard_ccr_read(pf, 0x00), 1052 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), 1053 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), 1054 pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), 1055 pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); 1056 } else { 1057 if (pf->cfe != NULL) 1058 pccard_function_disable(pf); 1059 } 1060 } 1061 return; 1062} 1063 1064static struct resource * 1065pccard_alloc_resource(device_t dev, device_t child, int type, int *rid, 1066 u_long start, u_long end, u_long count, u_int flags) 1067{ 1068 struct pccard_ivar *dinfo; 1069 struct resource_list_entry *rle = 0; 1070 int passthrough = (device_get_parent(child) != dev); 1071 1072 if (passthrough) { 1073 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 1074 type, rid, start, end, count, flags)); 1075 } 1076 1077 dinfo = device_get_ivars(child); 1078 rle = resource_list_find(&dinfo->resources, type, *rid); 1079 1080 if (!rle) 1081 return NULL; /* no resource of that type/rid */ 1082 1083 if (!rle->res) { 1084 device_printf(dev, "WARNING: Resource not reserved by pccard bus\n"); 1085 return NULL; 1086 } else { 1087 if (rle->res->r_dev != dev) 1088 return (NULL); 1089 bus_release_resource(dev, type, *rid, rle->res); 1090 rle->res = NULL; 1091 switch(type) { 1092 case SYS_RES_IOPORT: 1093 case SYS_RES_MEMORY: 1094 if (!(flags & RF_ALIGNMENT_MASK)) 1095 flags |= rman_make_alignment_flags(rle->count); 1096 break; 1097 case SYS_RES_IRQ: 1098 flags |= RF_SHAREABLE; 1099 break; 1100 } 1101 rle->res = resource_list_alloc(&dinfo->resources, dev, child, 1102 type, rid, rle->start, rle->end, rle->count, flags); 1103 return (rle->res); 1104 } 1105} 1106 1107static int 1108pccard_release_resource(device_t dev, device_t child, int type, int rid, 1109 struct resource *r) 1110{ 1111 struct pccard_ivar *dinfo; 1112 int passthrough = (device_get_parent(child) != dev); 1113 struct resource_list_entry *rle = 0; 1114 int ret; 1115 int flags; 1116 1117 if (passthrough) 1118 return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, 1119 type, rid, r); 1120 1121 dinfo = device_get_ivars(child); 1122 1123 rle = resource_list_find(&dinfo->resources, type, rid); 1124 1125 if (!rle) { 1126 device_printf(dev, "Allocated resource not found, " 1127 "%d %x %lx %lx\n", 1128 type, rid, rman_get_start(r), rman_get_size(r)); 1129 return ENOENT; 1130 } 1131 if (!rle->res) { 1132 device_printf(dev, "Allocated resource not recorded\n"); 1133 return ENOENT; 1134 } 1135 1136 ret = BUS_RELEASE_RESOURCE(device_get_parent(dev), child, 1137 type, rid, r); 1138 switch(type) { 1139 case SYS_RES_IOPORT: 1140 case SYS_RES_MEMORY: 1141 flags = rman_make_alignment_flags(rle->count); 1142 break; 1143 case SYS_RES_IRQ: 1144 flags = RF_SHAREABLE; 1145 break; 1146 default: 1147 flags = 0; 1148 } 1149 rle->res = bus_alloc_resource(dev, type, &rid, 1150 rle->start, rle->end, rle->count, flags); 1151 if (rle->res == NULL) 1152 device_printf(dev, "release_resource: " 1153 "unable to reaquire resource\n"); 1154 return ret; 1155} 1156 1157static void 1158pccard_child_detached(device_t parent, device_t dev) 1159{ 1160 struct pccard_ivar *ivar = PCCARD_IVAR(dev); 1161 struct pccard_function *pf = ivar->fcn; 1162 1163 pccard_function_disable(pf); 1164} 1165 1166static void 1167pccard_intr(void *arg) 1168{ 1169 struct pccard_function *pf = (struct pccard_function*) arg; 1170 int reg; 1171 1172 if (pf->intr_handler == NULL) 1173 return; 1174 1175 /* 1176 * XXX The CCR_STATUS register bits used here are 1177 * only valid for multi function cards. 1178 */ 1179 reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS); 1180 if (reg & PCCARD_CCR_STATUS_INTR) { 1181 pccard_ccr_write(pf, PCCARD_CCR_STATUS, 1182 reg & ~PCCARD_CCR_STATUS_INTR); 1183 pf->intr_handler(pf->intr_handler_arg); 1184 } 1185} 1186 1187static int 1188pccard_setup_intr(device_t dev, device_t child, struct resource *irq, 1189 int flags, driver_intr_t *intr, void *arg, void **cookiep) 1190{ 1191 struct pccard_ivar *ivar = PCCARD_IVAR(child); 1192 struct pccard_function *func = ivar->fcn; 1193 int err; 1194 1195 if (func->intr_handler != NULL) 1196 panic("Only one interrupt handler per function allowed"); 1197 err = bus_generic_setup_intr(dev, child, irq, flags, pccard_intr, 1198 func, cookiep); 1199 if (err != 0) 1200 return (err); 1201 func->intr_handler = intr; 1202 func->intr_handler_arg = arg; 1203 func->intr_handler_cookie = *cookiep; 1204 /* XXX Not sure this is right to write to ccr */ 1205 pccard_ccr_write(func, PCCARD_CCR_OPTION, 1206 pccard_ccr_read(func, PCCARD_CCR_OPTION) | 1207 PCCARD_CCR_OPTION_IREQ_ENABLE); 1208 return (0); 1209} 1210 1211static int 1212pccard_teardown_intr(device_t dev, device_t child, struct resource *r, 1213 void *cookie) 1214{ 1215 struct pccard_ivar *ivar = PCCARD_IVAR(child); 1216 struct pccard_function *func = ivar->fcn; 1217 int ret; 1218 1219 /* XXX Not sure this is right to write to ccr */ 1220 pccard_ccr_write(func, PCCARD_CCR_OPTION, 1221 pccard_ccr_read(func, PCCARD_CCR_OPTION) & 1222 ~PCCARD_CCR_OPTION_IREQ_ENABLE); 1223 ret = bus_generic_teardown_intr(dev, child, r, cookie); 1224 if (ret == 0) { 1225 func->intr_handler = NULL; 1226 func->intr_handler_arg = NULL; 1227 func->intr_handler_cookie = NULL; 1228 } 1229 1230 return (ret); 1231} 1232 1233static device_method_t pccard_methods[] = { 1234 /* Device interface */ 1235 DEVMETHOD(device_probe, pccard_probe), 1236 DEVMETHOD(device_attach, pccard_attach), 1237 DEVMETHOD(device_detach, pccard_detach), 1238 DEVMETHOD(device_shutdown, bus_generic_shutdown), 1239 DEVMETHOD(device_suspend, pccard_suspend), 1240 DEVMETHOD(device_resume, pccard_resume), 1241 1242 /* Bus interface */ 1243 DEVMETHOD(bus_print_child, pccard_print_child), 1244 DEVMETHOD(bus_driver_added, pccard_driver_added), 1245 DEVMETHOD(bus_child_detached, pccard_child_detached), 1246 DEVMETHOD(bus_alloc_resource, pccard_alloc_resource), 1247 DEVMETHOD(bus_release_resource, pccard_release_resource), 1248 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 1249 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 1250 DEVMETHOD(bus_setup_intr, pccard_setup_intr), 1251 DEVMETHOD(bus_teardown_intr, pccard_teardown_intr), 1252 DEVMETHOD(bus_set_resource, pccard_set_resource), 1253 DEVMETHOD(bus_get_resource, pccard_get_resource), 1254 DEVMETHOD(bus_delete_resource, pccard_delete_resource), 1255 DEVMETHOD(bus_read_ivar, pccard_read_ivar), 1256 1257 /* Card Interface */ 1258 DEVMETHOD(card_set_res_flags, pccard_set_res_flags), 1259 DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset), 1260 DEVMETHOD(card_get_type, pccard_card_gettype), 1261 DEVMETHOD(card_attach_card, pccard_attach_card), 1262 DEVMETHOD(card_detach_card, pccard_detach_card), 1263 DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), 1264 DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), 1265 DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), 1266 1267 { 0, 0 } 1268}; 1269 1270static driver_t pccard_driver = { 1271 "pccard", 1272 pccard_methods, 1273 sizeof(struct pccard_softc) 1274}; 1275 1276devclass_t pccard_devclass; 1277 1278DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 1279DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); 1280DRIVER_MODULE(pccard, pccbb, pccard_driver, pccard_devclass, 0, 0); 1281DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); 1282MODULE_VERSION(pccard, 1); 1283/*MODULE_DEPEND(pccard, pcic, 1, 1, 1);*/ 1284