1 /* 2 * Copyright (c) 1996, Sujal M. Patel 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 * from: pnp.c,v 1.11 1999/05/06 22:11:19 peter Exp 28 */ 29 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/kernel.h> 33 #include <sys/module.h> 34 #include <sys/bus.h> 35 #include <sys/malloc.h> 36 #include <isa/isavar.h> 37 #include <isa/pnpreg.h> 38 #include <isa/pnpvar.h> 39 #include <machine/resource.h> 40 #include <machine/clock.h> 41 42 typedef struct _pnp_id { 43 u_int32_t vendor_id; 44 u_int32_t serial; 45 u_char checksum; 46 } pnp_id; 47 48 struct pnp_set_config_arg { 49 int csn; /* Card number to configure */ 50 int ldn; /* Logical device on card */ 51 }; 52 53 struct pnp_quirk { 54 u_int32_t vendor_id; /* Vendor of the card */ 55 u_int32_t logical_id; /* ID of the device with quirk */ 56 int type; 57 #define PNP_QUIRK_WRITE_REG 1 /* Need to write a pnp register */ 58 int arg1; 59 int arg2; 60 }; 61 62 struct pnp_quirk pnp_quirks[] = { 63 /* 64 * The Gravis UltraSound needs register 0xf2 to be set to 0xff 65 * to enable power. 66 * XXX need to know the logical device id. 67 */ 68 { 0x0100561e /* GRV0001 */, 0, 69 PNP_QUIRK_WRITE_REG, 0xf2, 0xff }, 70 71 { 0 } 72 }; 73 74 #if 0 75 /* 76 * these entries are initialized using the autoconfig menu 77 * The struct is invalid (and must be initialized) if the first 78 * CSN is zero. The init code fills invalid entries with CSN 255 79 * which is not a supported value. 80 */ 81 82 struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN] = { 83 { 0 } 84 }; 85 #endif 86 87 /* The READ_DATA port that we are using currently */ 88 static int pnp_rd_port; 89 90 static void pnp_send_initiation_key(void); 91 static int pnp_get_serial(pnp_id *p); 92 static int pnp_isolation_protocol(device_t parent); 93 94 static void 95 pnp_write(int d, u_char r) 96 { 97 outb (_PNP_ADDRESS, d); 98 outb (_PNP_WRITE_DATA, r); 99 } 100 101 #if 0 102 103 static u_char 104 pnp_read(int d) 105 { 106 outb (_PNP_ADDRESS, d); 107 return (inb(3 | (pnp_rd_port <<2))); 108 } 109 110 #endif 111 112 /* 113 * Send Initiation LFSR as described in "Plug and Play ISA Specification", 114 * Intel May 94. 115 */ 116 static void 117 pnp_send_initiation_key() 118 { 119 int cur, i; 120 121 /* Reset the LSFR */ 122 outb(_PNP_ADDRESS, 0); 123 outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */ 124 125 cur = 0x6a; 126 outb(_PNP_ADDRESS, cur); 127 128 for (i = 1; i < 32; i++) { 129 cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff); 130 outb(_PNP_ADDRESS, cur); 131 } 132 } 133 134 135 /* 136 * Get the device's serial number. Returns 1 if the serial is valid. 137 */ 138 static int 139 pnp_get_serial(pnp_id *p) 140 { 141 int i, bit, valid = 0, sum = 0x6a; 142 u_char *data = (u_char *)p; 143 144 bzero(data, sizeof(char) * 9); 145 outb(_PNP_ADDRESS, PNP_SERIAL_ISOLATION); 146 for (i = 0; i < 72; i++) { 147 bit = inb((pnp_rd_port << 2) | 0x3) == 0x55; 148 DELAY(250); /* Delay 250 usec */ 149 150 /* Can't Short Circuit the next evaluation, so 'and' is last */ 151 bit = (inb((pnp_rd_port << 2) | 0x3) == 0xaa) && bit; 152 DELAY(250); /* Delay 250 usec */ 153 154 valid = valid || bit; 155 156 if (i < 64) 157 sum = (sum >> 1) | 158 (((sum ^ (sum >> 1) ^ bit) << 7) & 0xff); 159 160 data[i / 8] = (data[i / 8] >> 1) | (bit ? 0x80 : 0); 161 } 162 163 valid = valid && (data[8] == sum); 164 165 return valid; 166 } 167 168 /* 169 * Fill's the buffer with resource info from the device. 170 * Returns 0 if the device fails to report 171 */ 172 static int 173 pnp_get_resource_info(u_char *buffer, int len) 174 { 175 int i, j; 176 u_char temp; 177 178 for (i = 0; i < len; i++) { 179 outb(_PNP_ADDRESS, PNP_STATUS); 180 for (j = 0; j < 100; j++) { 181 if ((inb((pnp_rd_port << 2) | 0x3)) & 0x1) 182 break; 183 DELAY(1); 184 } 185 if (j == 100) { 186 printf("PnP device failed to report resource data\n"); 187 return 0; 188 } 189 outb(_PNP_ADDRESS, PNP_RESOURCE_DATA); 190 temp = inb((pnp_rd_port << 2) | 0x3); 191 if (buffer != NULL) 192 buffer[i] = temp; 193 } 194 return 1; 195 } 196 197 #if 0 198 /* 199 * write_pnp_parms initializes a logical device with the parms 200 * in d, and then activates the board if the last parameter is 1. 201 */ 202 203 static int 204 write_pnp_parms(struct pnp_cinfo *d, pnp_id *p, int ldn) 205 { 206 int i, empty = -1 ; 207 208 pnp_write (SET_LDN, ldn ); 209 i = pnp_read(SET_LDN) ; 210 if (i != ldn) { 211 printf("Warning: LDN %d does not exist\n", ldn); 212 } 213 for (i = 0; i < 8; i++) { 214 pnp_write(IO_CONFIG_BASE + i * 2, d->ic_port[i] >> 8 ); 215 pnp_write(IO_CONFIG_BASE + i * 2 + 1, d->ic_port[i] & 0xff ); 216 } 217 for (i = 0; i < 4; i++) { 218 pnp_write(MEM_CONFIG + i*8, (d->ic_mem[i].base >> 16) & 0xff ); 219 pnp_write(MEM_CONFIG + i*8+1, (d->ic_mem[i].base >> 8) & 0xff ); 220 pnp_write(MEM_CONFIG + i*8+2, d->ic_mem[i].control & 0xff ); 221 pnp_write(MEM_CONFIG + i*8+3, (d->ic_mem[i].range >> 16) & 0xff ); 222 pnp_write(MEM_CONFIG + i*8+4, (d->ic_mem[i].range >> 8) & 0xff ); 223 } 224 for (i = 0; i < 2; i++) { 225 pnp_write(IRQ_CONFIG + i*2 , d->irq[i] ); 226 pnp_write(IRQ_CONFIG + i*2 + 1, d->irq_type[i] ); 227 pnp_write(DRQ_CONFIG + i, d->drq[i] ); 228 } 229 /* 230 * store parameters read into the current kernel 231 * so manual editing next time is easier 232 */ 233 for (i = 0 ; i < MAX_PNP_LDN; i++) { 234 if (pnp_ldn_overrides[i].csn == d->csn && 235 pnp_ldn_overrides[i].ldn == ldn) { 236 d->flags = pnp_ldn_overrides[i].flags ; 237 pnp_ldn_overrides[i] = *d ; 238 break ; 239 } else if (pnp_ldn_overrides[i].csn < 1 || 240 pnp_ldn_overrides[i].csn == 255) 241 empty = i ; 242 } 243 if (i== MAX_PNP_LDN && empty != -1) 244 pnp_ldn_overrides[empty] = *d; 245 246 /* 247 * Here should really perform the range check, and 248 * return a failure if not successful. 249 */ 250 pnp_write (IO_RANGE_CHECK, 0); 251 DELAY(1000); /* XXX is it really necessary ? */ 252 pnp_write (ACTIVATE, d->enable ? 1 : 0); 253 DELAY(1000); /* XXX is it really necessary ? */ 254 return 1 ; 255 } 256 #endif 257 258 /* 259 * This function is called after the bus has assigned resource 260 * locations for a logical device. 261 */ 262 static void 263 pnp_set_config(void *arg, struct isa_config *config, int enable) 264 { 265 int csn = ((struct pnp_set_config_arg *) arg)->csn; 266 int ldn = ((struct pnp_set_config_arg *) arg)->ldn; 267 int i; 268 269 /* 270 * First put all cards into Sleep state with the initiation 271 * key, then put our card into Config state. 272 */ 273 pnp_send_initiation_key(); 274 pnp_write(PNP_WAKE, csn); 275 276 /* 277 * Select our logical device so that we can program it. 278 */ 279 pnp_write(PNP_SET_LDN, ldn); 280 281 /* 282 * Now program the resources. 283 */ 284 for (i = 0; i < config->ic_nmem; i++) { 285 u_int32_t start = config->ic_mem[i].ir_start; 286 u_int32_t size = config->ic_mem[i].ir_size; 287 if (start & 0xff) 288 panic("pnp_set_config: bogus memory assignment"); 289 pnp_write(PNP_MEM_BASE_HIGH(i), (start >> 16) & 0xff); 290 pnp_write(PNP_MEM_BASE_LOW(i), (start >> 8) & 0xff); 291 pnp_write(PNP_MEM_RANGE_HIGH(i), (size >> 16) & 0xff); 292 pnp_write(PNP_MEM_RANGE_LOW(i), (size >> 8) & 0xff); 293 } 294 for (; i < ISA_NMEM; i++) { 295 pnp_write(PNP_MEM_BASE_HIGH(i), 0); 296 pnp_write(PNP_MEM_BASE_LOW(i), 0); 297 pnp_write(PNP_MEM_RANGE_HIGH(i), 0); 298 pnp_write(PNP_MEM_RANGE_LOW(i), 0); 299 } 300 301 for (i = 0; i < config->ic_nport; i++) { 302 u_int32_t start = config->ic_port[i].ir_start; 303 pnp_write(PNP_IO_BASE_HIGH(i), (start >> 8) & 0xff); 304 pnp_write(PNP_IO_BASE_LOW(i), (start >> 0) & 0xff); 305 } 306 for (; i < ISA_NPORT; i++) { 307 pnp_write(PNP_IO_BASE_HIGH(i), 0); 308 pnp_write(PNP_IO_BASE_LOW(i), 0); 309 } 310 311 for (i = 0; i < config->ic_nirq; i++) { 312 int irq = ffs(config->ic_irqmask[i]) - 1; 313 pnp_write(PNP_IRQ_LEVEL(i), irq); 314 pnp_write(PNP_IRQ_TYPE(i), 2); /* XXX */ 315 } 316 for (; i < ISA_NIRQ; i++) { 317 /* 318 * IRQ 0 is not a valid interrupt selection and 319 * represents no interrupt selection. 320 */ 321 pnp_write(PNP_IRQ_LEVEL(i), 0); 322 } 323 324 for (i = 0; i < config->ic_ndrq; i++) { 325 int drq = ffs(config->ic_drqmask[i]) - 1; 326 pnp_write(PNP_DMA_CHANNEL(i), drq); 327 } 328 for (; i < ISA_NDRQ; i++) { 329 /* 330 * DMA channel 4, the cascade channel is used to 331 * indicate no DMA channel is active. 332 */ 333 pnp_write(PNP_DMA_CHANNEL(i), 4); 334 } 335 336 pnp_write(PNP_ACTIVATE, enable ? 1 : 0); 337 338 /* 339 * Wake everyone up again, we are finished. 340 */ 341 pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_WAIT_FOR_KEY); 342 } 343 344 /* 345 * Process quirks for a logical device.. The card must be in Config state. 346 */ 347 static void 348 pnp_check_quirks(u_int32_t vendor_id, u_int32_t logical_id, int ldn) 349 { 350 struct pnp_quirk *qp; 351 352 for (qp = &pnp_quirks[0]; qp->vendor_id; qp++) { 353 if (qp->vendor_id == vendor_id 354 && (qp->logical_id == 0 355 || qp->logical_id == logical_id)) { 356 switch (qp->type) { 357 case PNP_QUIRK_WRITE_REG: 358 pnp_write(PNP_SET_LDN, ldn); 359 pnp_write(qp->arg1, qp->arg2); 360 break; 361 } 362 } 363 } 364 } 365 366 /* 367 * Scan Resource Data for Logical Devices. 368 * 369 * This function exits as soon as it gets an error reading *ANY* 370 * Resource Data or ir reaches the end of Resource Data. In the first 371 * case the return value will be TRUE, FALSE otherwise. 372 */ 373 static int 374 pnp_scan_resdata(device_t parent, pnp_id *p, int csn) 375 { 376 u_char tag, resinfo[16]; 377 int large_len, scanning = 1024, retval = FALSE; 378 u_int32_t logical_id; 379 u_int32_t compat_id; 380 device_t dev = 0; 381 int ldn = 0; 382 struct isa_config card, logdev, alt; 383 struct isa_config *config; 384 struct pnp_set_config_arg *csnldn; 385 int priority = 0; 386 char *desc = 0; 387 388 bzero(&card, sizeof card); 389 bzero(&logdev, sizeof logdev); 390 bzero(&alt, sizeof alt); 391 config = &card; 392 while (scanning-- > 0 && pnp_get_resource_info(&tag, 1)) { 393 if (PNP_RES_TYPE(tag) == 0) { 394 /* Small resource */ 395 if (pnp_get_resource_info(resinfo, 396 PNP_SRES_LEN(tag)) == 0) { 397 scanning = 0; 398 continue; 399 } 400 401 switch (PNP_SRES_NUM(tag)) { 402 case PNP_TAG_LOGICAL_DEVICE: 403 /* 404 * A new logical device. Scan 405 * resourcea and add device. 406 */ 407 bcopy(resinfo, &logical_id, 4); 408 pnp_check_quirks(p->vendor_id, 409 logical_id, 410 ldn); 411 compat_id = 0; 412 logdev = card; 413 config = &logdev; 414 dev = BUS_ADD_CHILD(parent, 415 ISA_ORDER_PNP, NULL, -1); 416 if (desc) 417 device_set_desc_copy(dev, desc); 418 isa_set_vendorid(dev, p->vendor_id); 419 isa_set_serial(dev, p->serial); 420 isa_set_logicalid(dev, logical_id); 421 csnldn = malloc(sizeof *csnldn, 422 M_DEVBUF, M_NOWAIT); 423 if (!csnldn) { 424 device_printf(parent, 425 "out of memory\n"); 426 scanning = 0; 427 break; 428 } 429 csnldn->csn = csn; 430 csnldn->ldn = ldn; 431 ISA_SET_CONFIG_CALLBACK(parent, dev, 432 pnp_set_config, 433 csnldn); 434 ldn++; 435 break; 436 437 case PNP_TAG_COMPAT_DEVICE: 438 /* 439 * Got a compatible device id 440 * resource. Should keep a list of 441 * compat ids in the device. 442 */ 443 bcopy(resinfo, &compat_id, 4); 444 if (dev) 445 isa_set_compatid(dev, compat_id); 446 break; 447 448 case PNP_TAG_IRQ_FORMAT: 449 if (config->ic_nirq == ISA_NIRQ) { 450 device_printf(parent, 451 "CSN %d too many irqs", 452 csn); 453 scanning = 0; 454 break; 455 } 456 config->ic_irqmask[config->ic_nirq] = 457 resinfo[0] + (resinfo[1]<<8); 458 config->ic_nirq++; 459 break; 460 461 case PNP_TAG_DMA_FORMAT: 462 if (config->ic_ndrq == ISA_NDRQ) { 463 device_printf(parent, 464 "CSN %d too many drqs", 465 csn); 466 scanning = 0; 467 break; 468 } 469 config->ic_drqmask[config->ic_ndrq] = 470 resinfo[0]; 471 config->ic_ndrq++; 472 break; 473 474 case PNP_TAG_START_DEPENDANT: 475 if (config == &alt) { 476 ISA_ADD_CONFIG(parent, dev, 477 priority, config); 478 } else if (config != &logdev) { 479 device_printf(parent, 480 "CSN %d malformed\n", 481 csn); 482 scanning = 0; 483 break; 484 } 485 /* 486 * If the priority is not specified, 487 * then use the default of 488 * 'acceptable' 489 */ 490 if (PNP_SRES_LEN(tag) > 0) 491 priority = resinfo[0]; 492 else 493 priority = 1; 494 alt = logdev; 495 config = &alt; 496 break; 497 498 case PNP_TAG_END_DEPENDANT: 499 ISA_ADD_CONFIG(parent, dev, priority, config); 500 config = &logdev; 501 break; 502 503 case PNP_TAG_IO_RANGE: 504 if (config->ic_nport == ISA_NPORT) { 505 device_printf(parent, 506 "CSN %d too many ports", 507 csn); 508 scanning = 0; 509 break; 510 } 511 config->ic_port[config->ic_nport].ir_start = 512 resinfo[1] + (resinfo[2]<<8); 513 config->ic_port[config->ic_nport].ir_end = 514 resinfo[3] + (resinfo[4]<<8) 515 + resinfo[6] - 1; 516 config->ic_port[config->ic_nport].ir_size 517 = 518 resinfo[6]; 519 config->ic_port[config->ic_nport].ir_align = 520 resinfo[5]; 521 config->ic_nport++; 522 break; 523 524 case PNP_TAG_IO_FIXED: 525 if (config->ic_nport == ISA_NPORT) { 526 device_printf(parent, 527 "CSN %d too many ports", 528 csn); 529 scanning = 0; 530 break; 531 } 532 config->ic_port[config->ic_nport].ir_start = 533 resinfo[0] + (resinfo[1]<<8); 534 config->ic_port[config->ic_nport].ir_end = 535 resinfo[0] + (resinfo[1]<<8) 536 + resinfo[2] - 1; 537 config->ic_port[config->ic_nport].ir_size 538 = resinfo[2]; 539 config->ic_port[config->ic_nport].ir_align = 1; 540 config->ic_nport++; 541 break; 542 543 case PNP_TAG_END: 544 scanning = 0; 545 break; 546 547 default: 548 /* Skip this resource */ 549 break; 550 } 551 } else { 552 /* Large resource */ 553 if (pnp_get_resource_info(resinfo, 2) == 0) { 554 scanning = 0; 555 continue; 556 } 557 large_len = resinfo[0] + (resinfo[1] << 8); 558 559 if (PNP_LRES_NUM(tag) == PNP_TAG_ID_ANSI) { 560 if (desc) 561 free(desc, M_TEMP); 562 desc = malloc(large_len + 1, 563 M_TEMP, M_NOWAIT); 564 /* 565 * Note: if malloc fails, this will 566 * skip the resource instead of 567 * reading it into desc. 568 */ 569 if (pnp_get_resource_info(desc, 570 large_len) == 0) { 571 scanning = 0; 572 } 573 if (desc) { 574 /* 575 * Trim trailing spaces. 576 */ 577 while (desc[large_len-1] == ' ') 578 large_len--; 579 desc[large_len] = '\0'; 580 if (dev) 581 device_set_desc_copy 582 (dev, desc); 583 } 584 continue; 585 } 586 587 if (PNP_LRES_NUM(tag) != PNP_TAG_MEMORY_RANGE) { 588 /* skip */ 589 if (pnp_get_resource_info(NULL, 590 large_len) == 0) { 591 scanning = 0; 592 } 593 continue; 594 } 595 596 if (pnp_get_resource_info(resinfo, large_len) == 0) { 597 scanning = 0; 598 continue; 599 } 600 601 if (config->ic_nmem == ISA_NMEM) { 602 device_printf(parent, 603 "CSN %d too many memory ranges", 604 csn); 605 scanning = 0; 606 break; 607 } 608 609 config->ic_mem[config->ic_nmem].ir_start = 610 (resinfo[4]<<8) + (resinfo[5]<<16); 611 config->ic_mem[config->ic_nmem].ir_end = 612 (resinfo[6]<<8) + (resinfo[7]<<16); 613 config->ic_mem[config->ic_nmem].ir_size = 614 (resinfo[10]<<8) + (resinfo[11]<<16); 615 config->ic_mem[config->ic_nmem].ir_align = 616 resinfo[8] + (resinfo[9]<<8); 617 if (!config->ic_mem[config->ic_nmem].ir_align) 618 config->ic_mem[config->ic_nmem].ir_align = 619 0x10000; 620 config->ic_nmem++; 621 } 622 } 623 624 if (desc) 625 free(desc, M_TEMP); 626 627 return retval; 628 } 629 630 /* 631 * Run the isolation protocol. Use pnp_rd_port as the READ_DATA port 632 * value (caller should try multiple READ_DATA locations before giving 633 * up). Upon exiting, all cards are aware that they should use 634 * pnp_rd_port as the READ_DATA port. 635 * 636 * In the first pass, a csn is assigned to each board and pnp_id's 637 * are saved to an array, pnp_devices. In the second pass, each 638 * card is woken up and the device configuration is called. 639 */ 640 static int 641 pnp_isolation_protocol(device_t parent) 642 { 643 int csn; 644 pnp_id id; 645 int found = 0; 646 647 /* 648 * Put all cards into the Sleep state so that we can clear 649 * their CSNs. 650 */ 651 pnp_send_initiation_key(); 652 653 /* 654 * Clear the CSN for all cards. 655 */ 656 pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_RESET_CSN); 657 658 /* 659 * Move all cards to the Isolation state. 660 */ 661 pnp_write(PNP_WAKE, 0); 662 663 /* 664 * Tell them where the read point is going to be this time. 665 */ 666 pnp_write(PNP_SET_RD_DATA, pnp_rd_port); 667 668 for (csn = 1; csn < PNP_MAX_CARDS; csn++) { 669 /* 670 * Start the serial isolation protocol. 671 */ 672 outb(_PNP_ADDRESS, PNP_SERIAL_ISOLATION); 673 DELAY(1000); /* Delay 1 msec */ 674 675 if (pnp_get_serial(&id)) { 676 /* 677 * We have read the id from a card 678 * successfully. The card which won the 679 * isolation protocol will be in Isolation 680 * mode and all others will be in Sleep. * 681 * Program the CSN of the isolated card 682 * (taking it to Config state) and read its 683 * resources, creating devices as we find 684 * logical devices on the card. 685 */ 686 pnp_write(PNP_SET_CSN, csn); 687 pnp_scan_resdata(parent, &id, csn); 688 found++; 689 } else 690 break; 691 692 /* 693 * Put this card back to the Sleep state and 694 * simultaneously move all cards which don't have a 695 * CSN yet to Isolation state. 696 */ 697 pnp_write(PNP_WAKE, 0); 698 } 699 700 /* 701 * Unless we have chosen the wrong read port, all cards will 702 * be in Sleep state. Put them back into WaitForKey for 703 * now. Their resources will be programmed later. 704 */ 705 pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_WAIT_FOR_KEY); 706 707 return found; 708 } 709 710 711 /* 712 * pnp_identify() 713 * 714 * autoconfiguration of pnp devices. This routine just runs the 715 * isolation protocol over several ports, until one is successful. 716 * 717 * may be called more than once ? 718 * 719 */ 720 721 static void 722 pnp_identify(driver_t *driver, device_t parent) 723 { 724 int num_pnp_devs; 725 726 #if 0 727 if (pnp_ldn_overrides[0].csn == 0) { 728 if (bootverbose) 729 printf("Initializing PnP override table\n"); 730 bzero (pnp_ldn_overrides, sizeof(pnp_ldn_overrides)); 731 pnp_ldn_overrides[0].csn = 255 ; 732 } 733 #endif 734 735 /* Try various READ_DATA ports from 0x203-0x3ff */ 736 for (pnp_rd_port = 0x80; (pnp_rd_port < 0xff); pnp_rd_port += 0x10) { 737 if (bootverbose) 738 printf("Trying Read_Port at %x\n", (pnp_rd_port << 2) | 0x3); 739 740 num_pnp_devs = pnp_isolation_protocol(parent); 741 if (num_pnp_devs) 742 break; 743 } 744 } 745 746 static device_method_t pnp_methods[] = { 747 /* Device interface */ 748 DEVMETHOD(device_identify, pnp_identify), 749 750 { 0, 0 } 751 }; 752 753 static driver_t pnp_driver = { 754 "pnp", 755 pnp_methods, 756 1, /* no softc */ 757 }; 758 759 static devclass_t pnp_devclass; 760 761 DRIVER_MODULE(pnp, isa, pnp_driver, pnp_devclass, 0, 0); 762