pccard.c revision 102702
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2/* $FreeBSD: head/sys/dev/pccard/pccard.c 102702 2002-08-31 14:38:24Z phk $ */ 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#ifdef COOKIE_FOR_IMP 408 end = start + cfe->iospace[i].length - 1; 409#else 410 goto not_this_one; 411#endif 412 else 413 end = ~0; 414 cfe->iorid[i] = i; 415 DEVPRINTF((bus, "I/O rid %d start %x end %x\n", 416 i, start, end)); 417 r = cfe->iores[i] = bus_alloc_resource(bus, 418 SYS_RES_IOPORT, &cfe->iorid[i], start, end, 419 cfe->iospace[i].length, 420 rman_make_alignment_flags(cfe->iospace[i].length)); 421 if (cfe->iores[i] == NULL) 422 goto not_this_one; 423 resource_list_add(rl, SYS_RES_IOPORT, cfe->iorid[i], 424 rman_get_start(r), rman_get_end(r), 425 cfe->iospace[i].length); 426 rle = resource_list_find(rl, SYS_RES_IOPORT, 427 cfe->iorid[i]); 428 rle->res = r; 429 spaces++; 430 } 431 if (cfe->num_memspace > 0) { 432 /* 433 * Not implement yet, Fix me. 434 */ 435 DEVPRINTF((bus, "Memory space not yet implemented.\n")); 436 } 437 if (spaces == 0) { 438 DEVPRINTF((bus, "Neither memory nor I/O mampped\n")); 439 goto not_this_one; 440 } 441 if (cfe->irqmask) { 442 cfe->irqrid = 0; 443 r = cfe->irqres = bus_alloc_resource(bus, SYS_RES_IRQ, 444 &cfe->irqrid, 0, ~0, 1, 0); 445 if (cfe->irqres == NULL) 446 goto not_this_one; 447 resource_list_add(rl, SYS_RES_IRQ, cfe->irqrid, 448 rman_get_start(r), rman_get_end(r), 1); 449 rle = resource_list_find(rl, SYS_RES_IRQ, 450 cfe->irqrid); 451 rle->res = r; 452 } 453 /* If we get to here, we've allocated all we need */ 454 pf->cfe = cfe; 455 break; 456 not_this_one:; 457 DEVPRVERBOSE((bus, "Allocation failed for cfe %d\n", 458 cfe->number)); 459 /* 460 * Release resources that we partially allocated 461 * from this config entry. 462 */ 463 for (i = 0; i < cfe->num_iospace; i++) { 464 if (cfe->iores[i] != NULL) { 465 bus_release_resource(bus, SYS_RES_IOPORT, 466 cfe->iorid[i], cfe->iores[i]); 467 rle = resource_list_find(rl, SYS_RES_IOPORT, 468 cfe->iorid[i]); 469 rle->res = NULL; 470 resource_list_delete(rl, SYS_RES_IOPORT, 471 cfe->iorid[i]); 472 } 473 cfe->iores[i] = NULL; 474 } 475 if (cfe->irqmask && cfe->irqres != NULL) { 476 bus_release_resource(bus, SYS_RES_IRQ, 477 cfe->irqrid, cfe->irqres); 478 rle = resource_list_find(rl, SYS_RES_IRQ, 479 cfe->irqrid); 480 rle->res = NULL; 481 resource_list_delete(rl, SYS_RES_IRQ, cfe->irqrid); 482 cfe->irqres = NULL; 483 } 484 } 485} 486 487/* 488 * Free resources allocated by pccard_function_init(), May be called as long 489 * as the function is disabled. 490 * 491 * NOTE: This function should be unnecessary. pccard_function_init should 492 * never keep resources initialized. 493 */ 494static void 495pccard_function_free(struct pccard_function *pf) 496{ 497 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 498 struct resource_list_entry *rle; 499 500 if (pf->pf_flags & PFF_ENABLED) { 501 printf("pccard_function_init: function is enabled"); 502 return; 503 } 504 505 SLIST_FOREACH(rle, &devi->resources, link) { 506 if (rle->res) { 507 if (rle->res->r_dev != pf->sc->dev) 508 device_printf(pf->sc->dev, 509 "function_free: Resource still owned by " 510 "child, oops. " 511 "(type=%d, rid=%d, addr=%lx)\n", 512 rle->type, rle->rid, 513 rman_get_start(rle->res)); 514 BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), 515 rle->res->r_dev, rle->type, rle->rid, rle->res); 516 rle->res = NULL; 517 } 518 } 519 resource_list_free(&devi->resources); 520} 521 522/* Enable a PCCARD function */ 523static int 524pccard_function_enable(struct pccard_function *pf) 525{ 526 struct pccard_function *tmp; 527 int reg; 528 device_t dev = pf->sc->dev; 529 530 if (pf->cfe == NULL) { 531 DEVPRVERBOSE((dev, "No config entry could be allocated.\n")); 532 return (ENOMEM); 533 } 534 535 /* 536 * Increase the reference count on the socket, enabling power, if 537 * necessary. 538 */ 539 pf->sc->sc_enabled_count++; 540 541 if (pf->pf_flags & PFF_ENABLED) { 542 /* 543 * Don't do anything if we're already enabled. 544 */ 545 return (0); 546 } 547 548 /* 549 * it's possible for different functions' CCRs to be in the same 550 * underlying page. Check for that. 551 */ 552 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 553 if ((tmp->pf_flags & PFF_ENABLED) && 554 (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && 555 ((pf->ccr_base + PCCARD_CCR_SIZE) <= 556 (tmp->ccr_base - tmp->pf_ccr_offset + 557 tmp->pf_ccr_realsize))) { 558 pf->pf_ccrt = tmp->pf_ccrt; 559 pf->pf_ccrh = tmp->pf_ccrh; 560 pf->pf_ccr_realsize = tmp->pf_ccr_realsize; 561 562 /* 563 * pf->pf_ccr_offset = (tmp->pf_ccr_offset - 564 * tmp->ccr_base) + pf->ccr_base; 565 */ 566 /* pf->pf_ccr_offset = 567 (tmp->pf_ccr_offset + pf->ccr_base) - 568 tmp->ccr_base; */ 569 pf->pf_ccr_window = tmp->pf_ccr_window; 570 break; 571 } 572 } 573 if (tmp == NULL) { 574 pf->ccr_rid = 0; 575 pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 576 &pf->ccr_rid, 0, ~0, 1 << 10, RF_ACTIVE); 577 if (!pf->ccr_res) 578 goto bad; 579 DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%lx\n", 580 rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), 581 pf->ccr_base)); 582 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, 583 pf->ccr_rid, PCCARD_A_MEM_ATTR); 584 CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, 585 pf->ccr_rid, pf->ccr_base, &pf->pf_ccr_offset); 586 pf->pf_ccrt = rman_get_bustag(pf->ccr_res); 587 pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); 588 pf->pf_ccr_realsize = 1; 589 } 590 591 reg = (pf->cfe->number & PCCARD_CCR_OPTION_CFINDEX); 592 reg |= PCCARD_CCR_OPTION_LEVIREQ; 593 if (pccard_mfc(pf->sc)) { 594 reg |= (PCCARD_CCR_OPTION_FUNC_ENABLE | 595 PCCARD_CCR_OPTION_ADDR_DECODE); 596 /* PCCARD_CCR_OPTION_IRQ_ENABLE set elsewhere as needed */ 597 } 598 pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); 599 600 reg = 0; 601 if ((pf->cfe->flags & PCCARD_CFE_IO16) == 0) 602 reg |= PCCARD_CCR_STATUS_IOIS8; 603 if (pf->cfe->flags & PCCARD_CFE_AUDIO) 604 reg |= PCCARD_CCR_STATUS_AUDIO; 605 pccard_ccr_write(pf, PCCARD_CCR_STATUS, reg); 606 607 pccard_ccr_write(pf, PCCARD_CCR_SOCKETCOPY, 0); 608 609 if (pccard_mfc(pf->sc)) { 610 long tmp, iosize; 611 612 tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; 613 /* round up to nearest (2^n)-1 */ 614 for (iosize = 1; iosize < tmp; iosize <<= 1) 615 ; 616 iosize--; 617 618 pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, 619 pf->pf_mfc_iobase & 0xff); 620 pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, 621 (pf->pf_mfc_iobase >> 8) & 0xff); 622 pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); 623 pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); 624 625 pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); 626 } 627 628#ifdef PCCARDDEBUG 629 if (pccard_debug) { 630 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 631 device_printf(tmp->sc->dev, 632 "function %d CCR at %d offset %x: " 633 "%x %x %x %x, %x %x %x %x, %x\n", 634 tmp->number, tmp->pf_ccr_window, 635 tmp->pf_ccr_offset, 636 pccard_ccr_read(tmp, 0x00), 637 pccard_ccr_read(tmp, 0x02), 638 pccard_ccr_read(tmp, 0x04), 639 pccard_ccr_read(tmp, 0x06), 640 pccard_ccr_read(tmp, 0x0A), 641 pccard_ccr_read(tmp, 0x0C), 642 pccard_ccr_read(tmp, 0x0E), 643 pccard_ccr_read(tmp, 0x10), 644 pccard_ccr_read(tmp, 0x12)); 645 } 646 } 647#endif 648 pf->pf_flags |= PFF_ENABLED; 649 return (0); 650 651 bad: 652 /* 653 * Decrement the reference count, and power down the socket, if 654 * necessary. 655 */ 656 pf->sc->sc_enabled_count--; 657 DEVPRINTF((dev, "bad --enabled_count = %d\n", pf->sc->sc_enabled_count)); 658 659 return (1); 660} 661 662/* Disable PCCARD function. */ 663static void 664pccard_function_disable(struct pccard_function *pf) 665{ 666 struct pccard_function *tmp; 667 device_t dev = pf->sc->dev; 668 669 if (pf->cfe == NULL) 670 panic("pccard_function_disable: function not initialized"); 671 672 if ((pf->pf_flags & PFF_ENABLED) == 0) { 673 /* 674 * Don't do anything if we're already disabled. 675 */ 676 return; 677 } 678 679 if (pf->intr_handler != NULL) { 680 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 681 struct resource_list_entry *rle = 682 resource_list_find(&devi->resources, SYS_RES_IRQ, 0); 683 BUS_TEARDOWN_INTR(dev, pf->dev, rle->res, 684 pf->intr_handler_cookie); 685 } 686 687 /* 688 * it's possible for different functions' CCRs to be in the same 689 * underlying page. Check for that. Note we mark us as disabled 690 * first to avoid matching ourself. 691 */ 692 693 pf->pf_flags &= ~PFF_ENABLED; 694 STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { 695 if ((tmp->pf_flags & PFF_ENABLED) && 696 (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && 697 ((pf->ccr_base + PCCARD_CCR_SIZE) <= 698 (tmp->ccr_base - tmp->pf_ccr_offset + 699 tmp->pf_ccr_realsize))) 700 break; 701 } 702 703 /* Not used by anyone else; unmap the CCR. */ 704 if (tmp == NULL) { 705 bus_release_resource(dev, SYS_RES_MEMORY, pf->ccr_rid, 706 pf->ccr_res); 707 pf->ccr_res = NULL; 708 } 709 710 /* 711 * Decrement the reference count, and power down the socket, if 712 * necessary. 713 */ 714 pf->sc->sc_enabled_count--; 715} 716 717#if 0 718/* XXX These functions are needed, but not like this XXX */ 719int 720pccard_io_map(struct pccard_function *pf, int width, bus_addr_t offset, 721 bus_size_t size, struct pccard_io_handle *pcihp, int *windowp) 722{ 723 int reg; 724 725 if (pccard_chip_io_map(pf->sc->pct, pf->sc->pch, width, offset, size, 726 pcihp, windowp)) 727 return (1); 728 729 /* 730 * XXX in the multifunction multi-iospace-per-function case, this 731 * needs to cooperate with io_alloc to make sure that the spaces 732 * don't overlap, and that the ccr's are set correctly 733 */ 734 735 if (pccard_mfc(pf->sc)) { 736 long tmp, iosize; 737 738 if (pf->pf_mfc_iomax == 0) { 739 pf->pf_mfc_iobase = pcihp->addr + offset; 740 pf->pf_mfc_iomax = pf->pf_mfc_iobase + size; 741 } else { 742 /* this makes the assumption that nothing overlaps */ 743 if (pf->pf_mfc_iobase > pcihp->addr + offset) 744 pf->pf_mfc_iobase = pcihp->addr + offset; 745 if (pf->pf_mfc_iomax < pcihp->addr + offset + size) 746 pf->pf_mfc_iomax = pcihp->addr + offset + size; 747 } 748 749 tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; 750 /* round up to nearest (2^n)-1 */ 751 for (iosize = 1; iosize >= tmp; iosize <<= 1) 752 ; 753 iosize--; 754 755 pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, 756 pf->pf_mfc_iobase & 0xff); 757 pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, 758 (pf->pf_mfc_iobase >> 8) & 0xff); 759 pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); 760 pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); 761 762 pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); 763 764 reg = pccard_ccr_read(pf, PCCARD_CCR_OPTION); 765 reg |= PCCARD_CCR_OPTION_ADDR_DECODE; 766 pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); 767 } 768 return (0); 769} 770 771void 772pccard_io_unmap(struct pccard_function *pf, int window) 773{ 774 775 pccard_chip_io_unmap(pf->sc->pct, pf->sc->pch, window); 776 777 /* XXX Anything for multi-function cards? */ 778} 779#endif 780 781/* 782 * simulate the old "probe" routine. In the new world order, the driver 783 * needs to grab devices while in the old they were assigned to the device by 784 * the pccardd process. These symbols are exported to the upper layers. 785 */ 786static int 787pccard_compat_do_probe(device_t bus, device_t dev) 788{ 789 return (CARD_COMPAT_MATCH(dev)); 790} 791 792static int 793pccard_compat_do_attach(device_t bus, device_t dev) 794{ 795 int err; 796 797 err = CARD_COMPAT_PROBE(dev); 798 if (err == 0) 799 err = CARD_COMPAT_ATTACH(dev); 800 return (err); 801} 802 803#define PCCARD_NPORT 2 804#define PCCARD_NMEM 5 805#define PCCARD_NIRQ 1 806#define PCCARD_NDRQ 0 807 808static int 809pccard_add_children(device_t dev, int busno) 810{ 811 /* Call parent to scan for any current children */ 812 return (0); 813} 814 815static int 816pccard_probe(device_t dev) 817{ 818 device_set_desc(dev, "16-bit PCCard bus"); 819 return (pccard_add_children(dev, device_get_unit(dev))); 820} 821 822static int 823pccard_attach(device_t dev) 824{ 825 struct pccard_softc *sc = PCCARD_SOFTC(dev); 826 827 sc->dev = dev; 828 sc->sc_enabled_count = 0; 829 return (bus_generic_attach(dev)); 830} 831 832static int 833pccard_detach(device_t dev) 834{ 835 pccard_detach_card(dev, 0); 836 return 0; 837} 838 839static int 840pccard_suspend(device_t self) 841{ 842 pccard_detach_card(self, 0); 843 return (0); 844} 845 846static 847int 848pccard_resume(device_t self) 849{ 850 return (0); 851} 852 853static void 854pccard_print_resources(struct resource_list *rl, const char *name, int type, 855 int count, const char *format) 856{ 857 struct resource_list_entry *rle; 858 int printed; 859 int i; 860 861 printed = 0; 862 for (i = 0; i < count; i++) { 863 rle = resource_list_find(rl, type, i); 864 if (rle != NULL) { 865 if (printed == 0) 866 printf(" %s ", name); 867 else if (printed > 0) 868 printf(","); 869 printed++; 870 printf(format, rle->start); 871 if (rle->count > 1) { 872 printf("-"); 873 printf(format, rle->start + rle->count - 1); 874 } 875 } else if (i > 3) { 876 /* check the first few regardless */ 877 break; 878 } 879 } 880} 881 882static int 883pccard_print_child(device_t dev, device_t child) 884{ 885 struct pccard_ivar *devi = PCCARD_IVAR(child); 886 struct resource_list *rl = &devi->resources; 887 int retval = 0; 888 889 retval += bus_print_child_header(dev, child); 890 retval += printf(" at"); 891 892 if (devi != NULL) { 893 pccard_print_resources(rl, "port", SYS_RES_IOPORT, 894 PCCARD_NPORT, "%#lx"); 895 pccard_print_resources(rl, "iomem", SYS_RES_MEMORY, 896 PCCARD_NMEM, "%#lx"); 897 pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ, 898 "%ld"); 899 pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ, 900 "%ld"); 901 retval += printf(" function %d config %d", devi->fcn->number, 902 devi->fcn->cfe->number); 903 } 904 905 retval += bus_print_child_footer(dev, child); 906 907 return (retval); 908} 909 910static int 911pccard_set_resource(device_t dev, device_t child, int type, int rid, 912 u_long start, u_long count) 913{ 914 struct pccard_ivar *devi = PCCARD_IVAR(child); 915 struct resource_list *rl = &devi->resources; 916 917 if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY 918 && type != SYS_RES_IRQ && type != SYS_RES_DRQ) 919 return (EINVAL); 920 if (rid < 0) 921 return (EINVAL); 922 if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT) 923 return (EINVAL); 924 if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM) 925 return (EINVAL); 926 if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ) 927 return (EINVAL); 928 if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ) 929 return (EINVAL); 930 931 resource_list_add(rl, type, rid, start, start + count - 1, count); 932 if (NULL != resource_list_alloc(rl, device_get_parent(dev), dev, 933 type, &rid, start, start + count - 1, count, 0)) 934 return 0; 935 else 936 return ENOMEM; 937} 938 939static int 940pccard_get_resource(device_t dev, device_t child, int type, int rid, 941 u_long *startp, u_long *countp) 942{ 943 struct pccard_ivar *devi = PCCARD_IVAR(child); 944 struct resource_list *rl = &devi->resources; 945 struct resource_list_entry *rle; 946 947 rle = resource_list_find(rl, type, rid); 948 if (rle == NULL) 949 return (ENOENT); 950 951 if (startp != NULL) 952 *startp = rle->start; 953 if (countp != NULL) 954 *countp = rle->count; 955 956 return (0); 957} 958 959static void 960pccard_delete_resource(device_t dev, device_t child, int type, int rid) 961{ 962 struct pccard_ivar *devi = PCCARD_IVAR(child); 963 struct resource_list *rl = &devi->resources; 964 resource_list_delete(rl, type, rid); 965} 966 967static int 968pccard_set_res_flags(device_t dev, device_t child, int type, int rid, 969 u_int32_t flags) 970{ 971 return (CARD_SET_RES_FLAGS(device_get_parent(dev), child, type, 972 rid, flags)); 973} 974 975static int 976pccard_set_memory_offset(device_t dev, device_t child, int rid, 977 u_int32_t offset, u_int32_t *deltap) 978 979{ 980 return (CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid, 981 offset, deltap)); 982} 983 984static int 985pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) 986{ 987 struct pccard_ivar *devi = PCCARD_IVAR(child); 988 struct pccard_function *func = devi->fcn; 989 struct pccard_softc *sc = PCCARD_SOFTC(bus); 990 991 /* PCCARD_IVAR_ETHADDR unhandled from oldcard */ 992 switch (which) { 993 default: 994 case PCCARD_IVAR_ETHADDR: 995 bcopy(func->pf_funce_lan_nid, result, ETHER_ADDR_LEN); 996 break; 997 case PCCARD_IVAR_VENDOR: 998 *(u_int32_t *) result = sc->card.manufacturer; 999 break; 1000 case PCCARD_IVAR_PRODUCT: 1001 *(u_int32_t *) result = sc->card.product; 1002 break; 1003 case PCCARD_IVAR_PRODEXT: 1004 *(u_int16_t *) result = sc->card.prodext; 1005 break; 1006 case PCCARD_IVAR_FUNCTION: 1007 *(u_int32_t *) result = func->function; 1008 break; 1009 case PCCARD_IVAR_FUNCTION_NUMBER: 1010 if (!func) { 1011 device_printf(bus, "No function number, bug!\n"); 1012 return (ENOENT); 1013 } 1014 *(u_int32_t *) result = func->number; 1015 break; 1016 case PCCARD_IVAR_VENDOR_STR: 1017 *(char **) result = sc->card.cis1_info[0]; 1018 break; 1019 case PCCARD_IVAR_PRODUCT_STR: 1020 *(char **) result = sc->card.cis1_info[1]; 1021 break; 1022 case PCCARD_IVAR_CIS3_STR: 1023 *(char **) result = sc->card.cis1_info[2]; 1024 break; 1025 case PCCARD_IVAR_CIS4_STR: 1026 *(char **) result = sc->card.cis1_info[2]; 1027 break; 1028 } 1029 return (0); 1030} 1031 1032static void 1033pccard_driver_added(device_t dev, driver_t *driver) 1034{ 1035 struct pccard_softc *sc = PCCARD_SOFTC(dev); 1036 struct pccard_function *pf; 1037 device_t child; 1038 1039 if (sc->sc_enabled_count == 0) { 1040 CARD_REPROBE_CARD(device_get_parent(dev), dev); 1041 return; 1042 } 1043 1044 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 1045 if (STAILQ_EMPTY(&pf->cfe_head)) 1046 continue; 1047 child = pf->dev; 1048 if (device_get_state(child) != DS_NOTPRESENT) 1049 continue; 1050 if (pccard_function_enable(pf) == 0 && 1051 device_probe_and_attach(child) == 0) { 1052 DEVPRINTF((sc->dev, "function %d CCR at %d " 1053 "offset %x: %x %x %x %x, %x %x %x %x, %x\n", 1054 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, 1055 pccard_ccr_read(pf, 0x00), 1056 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), 1057 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), 1058 pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), 1059 pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); 1060 } else { 1061 if (pf->cfe != NULL) 1062 pccard_function_disable(pf); 1063 } 1064 } 1065 return; 1066} 1067 1068static struct resource * 1069pccard_alloc_resource(device_t dev, device_t child, int type, int *rid, 1070 u_long start, u_long end, u_long count, u_int flags) 1071{ 1072 struct pccard_ivar *dinfo; 1073 struct resource_list_entry *rle = 0; 1074 int passthrough = (device_get_parent(child) != dev); 1075 1076 if (passthrough) { 1077 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 1078 type, rid, start, end, count, flags)); 1079 } 1080 1081 dinfo = device_get_ivars(child); 1082 rle = resource_list_find(&dinfo->resources, type, *rid); 1083 1084 if (!rle) 1085 return NULL; /* no resource of that type/rid */ 1086 1087 if (!rle->res) { 1088 device_printf(dev, "WARNING: Resource not reserved by pccard bus\n"); 1089 return NULL; 1090 } else { 1091 if (rle->res->r_dev != dev) 1092 return (NULL); 1093 bus_release_resource(dev, type, *rid, rle->res); 1094 rle->res = NULL; 1095 switch(type) { 1096 case SYS_RES_IOPORT: 1097 case SYS_RES_MEMORY: 1098 if (!(flags & RF_ALIGNMENT_MASK)) 1099 flags |= rman_make_alignment_flags(rle->count); 1100 break; 1101 case SYS_RES_IRQ: 1102 flags |= RF_SHAREABLE; 1103 break; 1104 } 1105 rle->res = resource_list_alloc(&dinfo->resources, dev, child, 1106 type, rid, rle->start, rle->end, rle->count, flags); 1107 return (rle->res); 1108 } 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 1176 if (pf->intr_handler == NULL) 1177 return; 1178 1179 /* 1180 * XXX The CCR_STATUS register bits used here are 1181 * only valid for multi function cards. 1182 */ 1183 reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS); 1184 if (reg & PCCARD_CCR_STATUS_INTR) { 1185 pccard_ccr_write(pf, PCCARD_CCR_STATUS, 1186 reg & ~PCCARD_CCR_STATUS_INTR); 1187 pf->intr_handler(pf->intr_handler_arg); 1188 } 1189} 1190 1191static int 1192pccard_setup_intr(device_t dev, device_t child, struct resource *irq, 1193 int flags, driver_intr_t *intr, void *arg, void **cookiep) 1194{ 1195 struct pccard_ivar *ivar = PCCARD_IVAR(child); 1196 struct pccard_function *func = ivar->fcn; 1197 int err; 1198 1199 if (func->intr_handler != NULL) 1200 panic("Only one interrupt handler per function allowed"); 1201 err = bus_generic_setup_intr(dev, child, irq, flags, pccard_intr, 1202 func, cookiep); 1203 if (err != 0) 1204 return (err); 1205 func->intr_handler = intr; 1206 func->intr_handler_arg = arg; 1207 func->intr_handler_cookie = *cookiep; 1208 /* XXX Not sure this is right to write to ccr */ 1209 pccard_ccr_write(func, PCCARD_CCR_OPTION, 1210 pccard_ccr_read(func, PCCARD_CCR_OPTION) | 1211 PCCARD_CCR_OPTION_IREQ_ENABLE); 1212 return (0); 1213} 1214 1215static int 1216pccard_teardown_intr(device_t dev, device_t child, struct resource *r, 1217 void *cookie) 1218{ 1219 struct pccard_ivar *ivar = PCCARD_IVAR(child); 1220 struct pccard_function *func = ivar->fcn; 1221 int ret; 1222 1223 /* XXX Not sure this is right to write to ccr */ 1224 pccard_ccr_write(func, PCCARD_CCR_OPTION, 1225 pccard_ccr_read(func, PCCARD_CCR_OPTION) & 1226 ~PCCARD_CCR_OPTION_IREQ_ENABLE); 1227 ret = bus_generic_teardown_intr(dev, child, r, cookie); 1228 if (ret == 0) { 1229 func->intr_handler = NULL; 1230 func->intr_handler_arg = NULL; 1231 func->intr_handler_cookie = NULL; 1232 } 1233 1234 return (ret); 1235} 1236 1237static device_method_t pccard_methods[] = { 1238 /* Device interface */ 1239 DEVMETHOD(device_probe, pccard_probe), 1240 DEVMETHOD(device_attach, pccard_attach), 1241 DEVMETHOD(device_detach, pccard_detach), 1242 DEVMETHOD(device_shutdown, bus_generic_shutdown), 1243 DEVMETHOD(device_suspend, pccard_suspend), 1244 DEVMETHOD(device_resume, pccard_resume), 1245 1246 /* Bus interface */ 1247 DEVMETHOD(bus_print_child, pccard_print_child), 1248 DEVMETHOD(bus_driver_added, pccard_driver_added), 1249 DEVMETHOD(bus_child_detached, pccard_child_detached), 1250 DEVMETHOD(bus_alloc_resource, pccard_alloc_resource), 1251 DEVMETHOD(bus_release_resource, pccard_release_resource), 1252 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 1253 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 1254 DEVMETHOD(bus_setup_intr, pccard_setup_intr), 1255 DEVMETHOD(bus_teardown_intr, pccard_teardown_intr), 1256 DEVMETHOD(bus_set_resource, pccard_set_resource), 1257 DEVMETHOD(bus_get_resource, pccard_get_resource), 1258 DEVMETHOD(bus_delete_resource, pccard_delete_resource), 1259 DEVMETHOD(bus_read_ivar, pccard_read_ivar), 1260 1261 /* Card Interface */ 1262 DEVMETHOD(card_set_res_flags, pccard_set_res_flags), 1263 DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset), 1264 DEVMETHOD(card_get_type, pccard_card_gettype), 1265 DEVMETHOD(card_attach_card, pccard_attach_card), 1266 DEVMETHOD(card_detach_card, pccard_detach_card), 1267 DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), 1268 DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), 1269 DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), 1270 1271 { 0, 0 } 1272}; 1273 1274static driver_t pccard_driver = { 1275 "pccard", 1276 pccard_methods, 1277 sizeof(struct pccard_softc) 1278}; 1279 1280devclass_t pccard_devclass; 1281 1282/* Maybe we need to have a slot device? */ 1283DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 1284DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); 1285DRIVER_MODULE(pccard, cbb, pccard_driver, pccard_devclass, 0, 0); 1286DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); 1287MODULE_VERSION(pccard, 1); 1288/*MODULE_DEPEND(pccard, pcic, 1, 1, 1);*/ 1289