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