pnp.c revision 51346
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: head/sys/isa/pnp.c 51346 1999-09-17 08:18:34Z dfr $ 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 42typedef struct _pnp_id { 43 u_int32_t vendor_id; 44 u_int32_t serial; 45 u_char checksum; 46} pnp_id; 47 48struct pnp_set_config_arg { 49 int csn; /* Card number to configure */ 50 int ldn; /* Logical device on card */ 51}; 52 53struct 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 62struct 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 82struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN] = { 83 { 0 } 84}; 85#endif 86 87/* The READ_DATA port that we are using currently */ 88static int pnp_rd_port; 89 90static void pnp_send_initiation_key(void); 91static int pnp_get_serial(pnp_id *p); 92static int pnp_isolation_protocol(device_t parent); 93 94static void 95pnp_write(int d, u_char r) 96{ 97 outb (_PNP_ADDRESS, d); 98 outb (_PNP_WRITE_DATA, r); 99} 100 101#if 0 102 103static u_char 104pnp_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 */ 116static void 117pnp_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 */ 138static int 139pnp_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 */ 172static int 173pnp_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 203static int 204write_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 */ 262static void 263pnp_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 */ 347static void 348pnp_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 */ 373static int 374pnp_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 int seenalt = 0; 387 char *desc = 0; 388 389 bzero(&card, sizeof card); 390 bzero(&logdev, sizeof logdev); 391 bzero(&alt, sizeof alt); 392 config = &card; 393 while (scanning-- > 0 && pnp_get_resource_info(&tag, 1)) { 394 if (PNP_RES_TYPE(tag) == 0) { 395 /* Small resource */ 396 if (pnp_get_resource_info(resinfo, 397 PNP_SRES_LEN(tag)) == 0) { 398 scanning = 0; 399 continue; 400 } 401 402 switch (PNP_SRES_NUM(tag)) { 403 case PNP_TAG_LOGICAL_DEVICE: 404 /* 405 * A new logical device. Scan 406 * resourcea and add device. 407 */ 408 bcopy(resinfo, &logical_id, 4); 409 pnp_check_quirks(p->vendor_id, 410 logical_id, 411 ldn); 412 compat_id = 0; 413 logdev = card; 414 config = &logdev; 415 dev = BUS_ADD_CHILD(parent, 416 ISA_ORDER_PNP, NULL, -1); 417 if (desc) 418 device_set_desc_copy(dev, desc); 419 isa_set_vendorid(dev, p->vendor_id); 420 isa_set_serial(dev, p->serial); 421 isa_set_logicalid(dev, logical_id); 422 csnldn = malloc(sizeof *csnldn, 423 M_DEVBUF, M_NOWAIT); 424 if (!csnldn) { 425 device_printf(parent, 426 "out of memory\n"); 427 scanning = 0; 428 break; 429 } 430 csnldn->csn = csn; 431 csnldn->ldn = ldn; 432 ISA_SET_CONFIG_CALLBACK(parent, dev, 433 pnp_set_config, 434 csnldn); 435 seenalt = 0; 436 ldn++; 437 break; 438 439 case PNP_TAG_COMPAT_DEVICE: 440 /* 441 * Got a compatible device id 442 * resource. Should keep a list of 443 * compat ids in the device. 444 */ 445 bcopy(resinfo, &compat_id, 4); 446 if (dev) 447 isa_set_compatid(dev, compat_id); 448 break; 449 450 case PNP_TAG_IRQ_FORMAT: 451 if (config->ic_nirq == ISA_NIRQ) { 452 device_printf(parent, 453 "CSN %d too many irqs", 454 csn); 455 scanning = 0; 456 break; 457 } 458 config->ic_irqmask[config->ic_nirq] = 459 resinfo[0] + (resinfo[1]<<8); 460 config->ic_nirq++; 461 break; 462 463 case PNP_TAG_DMA_FORMAT: 464 if (config->ic_ndrq == ISA_NDRQ) { 465 device_printf(parent, 466 "CSN %d too many drqs", 467 csn); 468 scanning = 0; 469 break; 470 } 471 config->ic_drqmask[config->ic_ndrq] = 472 resinfo[0]; 473 config->ic_ndrq++; 474 break; 475 476 case PNP_TAG_START_DEPENDANT: 477 if (config == &alt) { 478 ISA_ADD_CONFIG(parent, dev, 479 priority, config); 480 } else if (config != &logdev) { 481 device_printf(parent, 482 "CSN %d malformed\n", 483 csn); 484 scanning = 0; 485 break; 486 } 487 /* 488 * If the priority is not specified, 489 * then use the default of 490 * 'acceptable' 491 */ 492 if (PNP_SRES_LEN(tag) > 0) 493 priority = resinfo[0]; 494 else 495 priority = 1; 496 alt = logdev; 497 config = &alt; 498 break; 499 500 case PNP_TAG_END_DEPENDANT: 501 ISA_ADD_CONFIG(parent, dev, priority, config); 502 config = &logdev; 503 seenalt = 1; 504 break; 505 506 case PNP_TAG_IO_RANGE: 507 if (config->ic_nport == ISA_NPORT) { 508 device_printf(parent, 509 "CSN %d too many ports", 510 csn); 511 scanning = 0; 512 break; 513 } 514 config->ic_port[config->ic_nport].ir_start = 515 resinfo[1] + (resinfo[2]<<8); 516 config->ic_port[config->ic_nport].ir_end = 517 resinfo[3] + (resinfo[4]<<8) 518 + resinfo[6] - 1; 519 config->ic_port[config->ic_nport].ir_size 520 = 521 resinfo[6]; 522 config->ic_port[config->ic_nport].ir_align = 523 resinfo[5]; 524 config->ic_nport++; 525 break; 526 527 case PNP_TAG_IO_FIXED: 528 if (config->ic_nport == ISA_NPORT) { 529 device_printf(parent, 530 "CSN %d too many ports", 531 csn); 532 scanning = 0; 533 break; 534 } 535 config->ic_port[config->ic_nport].ir_start = 536 resinfo[0] + (resinfo[1]<<8); 537 config->ic_port[config->ic_nport].ir_end = 538 resinfo[0] + (resinfo[1]<<8) 539 + resinfo[2] - 1; 540 config->ic_port[config->ic_nport].ir_size 541 = resinfo[2]; 542 config->ic_port[config->ic_nport].ir_align = 1; 543 config->ic_nport++; 544 break; 545 546 case PNP_TAG_END: 547 if (!seenalt) 548 ISA_ADD_CONFIG(parent, dev, 549 priority, config); 550 scanning = 0; 551 break; 552 553 default: 554 /* Skip this resource */ 555 break; 556 } 557 } else { 558 /* Large resource */ 559 if (pnp_get_resource_info(resinfo, 2) == 0) { 560 scanning = 0; 561 continue; 562 } 563 large_len = resinfo[0] + (resinfo[1] << 8); 564 565 if (PNP_LRES_NUM(tag) == PNP_TAG_ID_ANSI) { 566 if (desc) 567 free(desc, M_TEMP); 568 desc = malloc(large_len + 1, 569 M_TEMP, M_NOWAIT); 570 /* 571 * Note: if malloc fails, this will 572 * skip the resource instead of 573 * reading it into desc. 574 */ 575 if (pnp_get_resource_info(desc, 576 large_len) == 0) { 577 scanning = 0; 578 } 579 if (desc) { 580 /* 581 * Trim trailing spaces. 582 */ 583 while (desc[large_len-1] == ' ') 584 large_len--; 585 desc[large_len] = '\0'; 586 if (dev) 587 device_set_desc_copy 588 (dev, desc); 589 } 590 continue; 591 } 592 593 if (PNP_LRES_NUM(tag) != PNP_TAG_MEMORY_RANGE) { 594 /* skip */ 595 if (pnp_get_resource_info(NULL, 596 large_len) == 0) { 597 scanning = 0; 598 } 599 continue; 600 } 601 602 if (pnp_get_resource_info(resinfo, large_len) == 0) { 603 scanning = 0; 604 continue; 605 } 606 607 if (config->ic_nmem == ISA_NMEM) { 608 device_printf(parent, 609 "CSN %d too many memory ranges", 610 csn); 611 scanning = 0; 612 break; 613 } 614 615 config->ic_mem[config->ic_nmem].ir_start = 616 (resinfo[4]<<8) + (resinfo[5]<<16); 617 config->ic_mem[config->ic_nmem].ir_end = 618 (resinfo[6]<<8) + (resinfo[7]<<16); 619 config->ic_mem[config->ic_nmem].ir_size = 620 (resinfo[10]<<8) + (resinfo[11]<<16); 621 config->ic_mem[config->ic_nmem].ir_align = 622 resinfo[8] + (resinfo[9]<<8); 623 if (!config->ic_mem[config->ic_nmem].ir_align) 624 config->ic_mem[config->ic_nmem].ir_align = 625 0x10000; 626 config->ic_nmem++; 627 } 628 } 629 630 if (desc) 631 free(desc, M_TEMP); 632 633 return retval; 634} 635 636/* 637 * Run the isolation protocol. Use pnp_rd_port as the READ_DATA port 638 * value (caller should try multiple READ_DATA locations before giving 639 * up). Upon exiting, all cards are aware that they should use 640 * pnp_rd_port as the READ_DATA port. 641 * 642 * In the first pass, a csn is assigned to each board and pnp_id's 643 * are saved to an array, pnp_devices. In the second pass, each 644 * card is woken up and the device configuration is called. 645 */ 646static int 647pnp_isolation_protocol(device_t parent) 648{ 649 int csn; 650 pnp_id id; 651 int found = 0; 652 653 /* 654 * Put all cards into the Sleep state so that we can clear 655 * their CSNs. 656 */ 657 pnp_send_initiation_key(); 658 659 /* 660 * Clear the CSN for all cards. 661 */ 662 pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_RESET_CSN); 663 664 /* 665 * Move all cards to the Isolation state. 666 */ 667 pnp_write(PNP_WAKE, 0); 668 669 /* 670 * Tell them where the read point is going to be this time. 671 */ 672 pnp_write(PNP_SET_RD_DATA, pnp_rd_port); 673 674 for (csn = 1; csn < PNP_MAX_CARDS; csn++) { 675 /* 676 * Start the serial isolation protocol. 677 */ 678 outb(_PNP_ADDRESS, PNP_SERIAL_ISOLATION); 679 DELAY(1000); /* Delay 1 msec */ 680 681 if (pnp_get_serial(&id)) { 682 /* 683 * We have read the id from a card 684 * successfully. The card which won the 685 * isolation protocol will be in Isolation 686 * mode and all others will be in Sleep. * 687 * Program the CSN of the isolated card 688 * (taking it to Config state) and read its 689 * resources, creating devices as we find 690 * logical devices on the card. 691 */ 692 pnp_write(PNP_SET_CSN, csn); 693 pnp_scan_resdata(parent, &id, csn); 694 found++; 695 } else 696 break; 697 698 /* 699 * Put this card back to the Sleep state and 700 * simultaneously move all cards which don't have a 701 * CSN yet to Isolation state. 702 */ 703 pnp_write(PNP_WAKE, 0); 704 } 705 706 /* 707 * Unless we have chosen the wrong read port, all cards will 708 * be in Sleep state. Put them back into WaitForKey for 709 * now. Their resources will be programmed later. 710 */ 711 pnp_write(PNP_CONFIG_CONTROL, PNP_CONFIG_CONTROL_WAIT_FOR_KEY); 712 713 return found; 714} 715 716 717/* 718 * pnp_identify() 719 * 720 * autoconfiguration of pnp devices. This routine just runs the 721 * isolation protocol over several ports, until one is successful. 722 * 723 * may be called more than once ? 724 * 725 */ 726 727static void 728pnp_identify(driver_t *driver, device_t parent) 729{ 730 int num_pnp_devs; 731 732#if 0 733 if (pnp_ldn_overrides[0].csn == 0) { 734 if (bootverbose) 735 printf("Initializing PnP override table\n"); 736 bzero (pnp_ldn_overrides, sizeof(pnp_ldn_overrides)); 737 pnp_ldn_overrides[0].csn = 255 ; 738 } 739#endif 740 741 /* Try various READ_DATA ports from 0x203-0x3ff */ 742 for (pnp_rd_port = 0x80; (pnp_rd_port < 0xff); pnp_rd_port += 0x10) { 743 if (bootverbose) 744 printf("Trying Read_Port at %x\n", (pnp_rd_port << 2) | 0x3); 745 746 num_pnp_devs = pnp_isolation_protocol(parent); 747 if (num_pnp_devs) 748 break; 749 } 750} 751 752static device_method_t pnp_methods[] = { 753 /* Device interface */ 754 DEVMETHOD(device_identify, pnp_identify), 755 756 { 0, 0 } 757}; 758 759static driver_t pnp_driver = { 760 "pnp", 761 pnp_methods, 762 1, /* no softc */ 763}; 764 765static devclass_t pnp_devclass; 766 767DRIVER_MODULE(pnp, isa, pnp_driver, pnp_devclass, 0, 0); 768