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