Mercurial > nand-ecoscentric
comparison packages/io/pci/current/src/pci.c @ 143:6b5f480c6929 ecos-sw-2000-12-08
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
| author | jlarmour |
|---|---|
| date | Fri, 08 Dec 2000 03:30:06 +0000 |
| parents | 289bf90c6a9b |
| children | d397fc472bcf |
comparison
equal
deleted
inserted
replaced
| 142:12eccf9656f3 | 143:6b5f480c6929 |
|---|---|
| 44 //####DESCRIPTIONEND#### | 44 //####DESCRIPTIONEND#### |
| 45 // | 45 // |
| 46 //============================================================================= | 46 //============================================================================= |
| 47 | 47 |
| 48 #include <pkgconf/hal.h> | 48 #include <pkgconf/hal.h> |
| 49 #include <pkgconf/io_pci.h> | |
| 49 #include <cyg/io/pci_hw.h> | 50 #include <cyg/io/pci_hw.h> |
| 50 | 51 |
| 51 // CYG_PCI_PRESENT only gets defined for targets that provide PCI HAL support. | 52 // CYG_PCI_PRESENT only gets defined for targets that provide PCI HAL support. |
| 52 // See pci_hw.h for details. | 53 // See pci_hw.h for details. |
| 53 #ifdef CYG_PCI_PRESENT | 54 #ifdef CYG_PCI_PRESENT |
| 410 cyg_uint8 bus = CYG_PCI_DEV_GET_BUS(cur_devid); | 411 cyg_uint8 bus = CYG_PCI_DEV_GET_BUS(cur_devid); |
| 411 cyg_uint8 devfn = CYG_PCI_DEV_GET_DEVFN(cur_devid); | 412 cyg_uint8 devfn = CYG_PCI_DEV_GET_DEVFN(cur_devid); |
| 412 cyg_uint8 dev = CYG_PCI_DEV_GET_DEV(devfn); | 413 cyg_uint8 dev = CYG_PCI_DEV_GET_DEV(devfn); |
| 413 cyg_uint8 fn = CYG_PCI_DEV_GET_FN(devfn); | 414 cyg_uint8 fn = CYG_PCI_DEV_GET_FN(devfn); |
| 414 | 415 |
| 415 #ifdef DEBUG_PCI | 416 #ifdef CYGPKG_IO_PCI_DEBUG |
| 416 printf("cyg_pci_find_next: start[%x] ...",(unsigned)cur_devid); | 417 printf("cyg_pci_find_next: start[%x] ...\n",(unsigned)cur_devid); |
| 417 #endif | 418 #endif |
| 418 | 419 |
| 419 // If this is the initializer, start with 0/0/0 | 420 // If this is the initializer, start with 0/0/0 |
| 420 if (CYG_PCI_NULL_DEVID == cur_devid) { | 421 if (CYG_PCI_NULL_DEVID == cur_devid) { |
| 421 bus = dev = fn = 0; | 422 bus = dev = fn = 0; |
| 448 for (;fn < CYG_PCI_MAX_FN; fn++) { | 449 for (;fn < CYG_PCI_MAX_FN; fn++) { |
| 449 cyg_uint16 vendor; | 450 cyg_uint16 vendor; |
| 450 devfn = CYG_PCI_DEV_MAKE_DEVFN(dev, fn); | 451 devfn = CYG_PCI_DEV_MAKE_DEVFN(dev, fn); |
| 451 cyg_pcihw_read_config_uint16(bus, devfn, | 452 cyg_pcihw_read_config_uint16(bus, devfn, |
| 452 CYG_PCI_CFG_VENDOR, &vendor); | 453 CYG_PCI_CFG_VENDOR, &vendor); |
| 453 | |
| 454 if (CYG_PCI_VENDOR_UNDEFINED != vendor) { | 454 if (CYG_PCI_VENDOR_UNDEFINED != vendor) { |
| 455 #ifdef CYGPKG_IO_PCI_DEBUG | |
| 456 printf(" Bus: %d, Dev: %d, Fn: %d, Vendor: %x\n", bus, dev, fn, vendor); | |
| 457 #endif | |
| 455 *next_devid = CYG_PCI_DEV_MAKE_ID(bus, devfn); | 458 *next_devid = CYG_PCI_DEV_MAKE_ID(bus, devfn); |
| 456 return true; | 459 return true; |
| 457 } | 460 } |
| 458 } | 461 } |
| 459 } | 462 } |
| 460 } | 463 } |
| 461 | 464 |
| 462 #ifdef DEBUG_PCI | 465 #ifdef CYGPKG_IO_PCI_DEBUG |
| 463 printf("nothing.\n"); | 466 printf("nothing.\n"); |
| 464 #endif | 467 #endif |
| 465 | 468 |
| 466 return false; | 469 return false; |
| 467 } | 470 } |
| 474 cyg_pci_find_device( cyg_uint16 vendor, cyg_uint16 device, | 477 cyg_pci_find_device( cyg_uint16 vendor, cyg_uint16 device, |
| 475 cyg_pci_device_id *devid ) | 478 cyg_pci_device_id *devid ) |
| 476 { | 479 { |
| 477 cyg_pci_device_id new_devid = *devid; | 480 cyg_pci_device_id new_devid = *devid; |
| 478 | 481 |
| 482 #ifdef CYGPKG_IO_PCI_DEBUG | |
| 483 printf("cyg_pci_find_device - vendor: %x, device: %x\n", vendor, device); | |
| 484 #endif | |
| 479 // Scan entire bus, check for matches on valid devices. | 485 // Scan entire bus, check for matches on valid devices. |
| 480 while (cyg_pci_find_next(new_devid, &new_devid)) { | 486 while (cyg_pci_find_next(new_devid, &new_devid)) { |
| 481 cyg_uint8 bus = CYG_PCI_DEV_GET_BUS(new_devid); | 487 cyg_uint8 bus = CYG_PCI_DEV_GET_BUS(new_devid); |
| 482 cyg_uint8 devfn = CYG_PCI_DEV_GET_DEVFN(new_devid); | 488 cyg_uint8 devfn = CYG_PCI_DEV_GET_DEVFN(new_devid); |
| 483 cyg_uint16 v, d; | 489 cyg_uint16 v, d; |
| 484 | 490 |
| 485 // Check that vendor matches. | 491 // Check that vendor matches. |
| 486 cyg_pcihw_read_config_uint16(bus, devfn, | 492 cyg_pcihw_read_config_uint16(bus, devfn, |
| 487 CYG_PCI_CFG_VENDOR, &v); | 493 CYG_PCI_CFG_VENDOR, &v); |
| 488 if (v != vendor) continue; | |
| 489 | |
| 490 // Check that device matches. | |
| 491 cyg_pcihw_read_config_uint16(bus, devfn, | 494 cyg_pcihw_read_config_uint16(bus, devfn, |
| 492 CYG_PCI_CFG_DEVICE, &d); | 495 CYG_PCI_CFG_DEVICE, &d); |
| 496 #ifdef CYGPKG_IO_PCI_DEBUG | |
| 497 printf("... PCI vendor = %x, device = %x\n", v, d); | |
| 498 #endif | |
| 499 if (v != vendor) continue; | |
| 500 | |
| 501 // Check that device matches. | |
| 493 if (d == device) { | 502 if (d == device) { |
| 494 *devid = new_devid; | 503 *devid = new_devid; |
| 495 return true; | 504 return true; |
| 496 } | 505 } |
| 497 } | 506 } |
| 763 CYG_PCI_ADDRESS32 io_start, io_limit, io_base; | 772 CYG_PCI_ADDRESS32 io_start, io_limit, io_base; |
| 764 | 773 |
| 765 // Scan only this bus for valid devices. | 774 // Scan only this bus for valid devices. |
| 766 devid = CYG_PCI_DEV_MAKE_ID(bus, 0) | CYG_PCI_NULL_DEVFN; | 775 devid = CYG_PCI_DEV_MAKE_ID(bus, 0) | CYG_PCI_NULL_DEVFN; |
| 767 | 776 |
| 768 #ifdef DEBUG_PCI | 777 #ifdef CYGPKG_IO_PCI_DEBUG |
| 769 printf("Configuring bus %d.\n", bus); | 778 printf("Configuring bus %d.\n", bus); |
| 770 #endif | 779 #endif |
| 771 | 780 |
| 772 while (cyg_pci_find_next(devid, &devid) && bus == CYG_PCI_DEV_GET_BUS(devid)) { | 781 while (cyg_pci_find_next(devid, &devid) && bus == CYG_PCI_DEV_GET_BUS(devid)) { |
| 773 | 782 |
| 774 devfn = CYG_PCI_DEV_GET_DEVFN(devid); | 783 devfn = CYG_PCI_DEV_GET_DEVFN(devid); |
| 775 | 784 |
| 776 // Get the device info | 785 // Get the device info |
| 777 cyg_pci_get_device_info(devid, &dev_info); | 786 cyg_pci_get_device_info(devid, &dev_info); |
| 778 | 787 |
| 779 #ifdef DEBUG_PCI | 788 #ifdef CYGPKG_IO_PCI_DEBUG |
| 780 printf("\n"); | 789 printf("\n"); |
| 781 printf("Configuring PCI Bus : %d\n", bus); | 790 printf("Configuring PCI Bus : %d\n", bus); |
| 782 printf(" PCI Device: %d\n", CYG_PCI_DEV_GET_DEV(devfn)); | 791 printf(" PCI Device: %d\n", CYG_PCI_DEV_GET_DEV(devfn)); |
| 783 printf(" PCI Func : %d\n", CYG_PCI_DEV_GET_FN(devfn)); | 792 printf(" PCI Func : %d\n", CYG_PCI_DEV_GET_FN(devfn)); |
| 784 printf(" Vendor Id : 0x%08X\n", dev_info.vendor); | 793 printf(" Vendor Id : 0x%08X\n", dev_info.vendor); |
| 956 dev_info.header.bridge.control |= CYG_PCI_CFG_BRIDGE_CTL_MASTER; | 965 dev_info.header.bridge.control |= CYG_PCI_CFG_BRIDGE_CTL_MASTER; |
| 957 cyg_pcihw_write_config_uint16(bus, devfn, CYG_PCI_CFG_BRIDGE_CONTROL, | 966 cyg_pcihw_write_config_uint16(bus, devfn, CYG_PCI_CFG_BRIDGE_CONTROL, |
| 958 dev_info.header.bridge.control); | 967 dev_info.header.bridge.control); |
| 959 } | 968 } |
| 960 } | 969 } |
| 961 #ifdef DEBUG_PCI | 970 #ifdef CYGPKG_IO_PCI_DEBUG |
| 962 printf("Finished configuring bus %d.\n", bus); | 971 printf("Finished configuring bus %d.\n", bus); |
| 963 #endif | 972 #endif |
| 964 | 973 |
| 965 return true; | 974 return true; |
| 966 } | 975 } |
