Rev 1120 | Rev 1246 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1120 | Rev 1239 | ||
---|---|---|---|
Line 443... | Line 443... | ||
443 | // } |
443 | // } |
444 | return 0; |
444 | return 0; |
445 | } |
445 | } |
446 | 446 | ||
Line -... | Line 447... | ||
- | 447 | #define PCI_FIND_CAP_TTL 48 |
|
- | 448 | ||
- | 449 | static int __pci_find_next_cap_ttl(unsigned int bus, unsigned int devfn, |
|
- | 450 | u8 pos, int cap, int *ttl) |
|
- | 451 | { |
|
- | 452 | u8 id; |
|
- | 453 | ||
- | 454 | while ((*ttl)--) { |
|
- | 455 | pos = PciRead8(bus, devfn, pos); |
|
- | 456 | if (pos < 0x40) |
|
- | 457 | break; |
|
- | 458 | pos &= ~3; |
|
- | 459 | id = PciRead8(bus, devfn, pos + PCI_CAP_LIST_ID); |
|
- | 460 | if (id == 0xff) |
|
- | 461 | break; |
|
- | 462 | if (id == cap) |
|
- | 463 | return pos; |
|
- | 464 | pos += PCI_CAP_LIST_NEXT; |
|
- | 465 | } |
|
- | 466 | return 0; |
|
- | 467 | } |
|
- | 468 | ||
- | 469 | static int __pci_find_next_cap(unsigned int bus, unsigned int devfn, |
|
- | 470 | u8 pos, int cap) |
|
- | 471 | { |
|
- | 472 | int ttl = PCI_FIND_CAP_TTL; |
|
- | 473 | ||
- | 474 | return __pci_find_next_cap_ttl(bus, devfn, pos, cap, &ttl); |
|
- | 475 | } |
|
- | 476 | ||
- | 477 | static int __pci_bus_find_cap_start(unsigned int bus, |
|
- | 478 | unsigned int devfn, u8 hdr_type) |
|
- | 479 | { |
|
- | 480 | u16 status; |
|
- | 481 | ||
- | 482 | status = PciRead16(bus, devfn, PCI_STATUS); |
|
- | 483 | if (!(status & PCI_STATUS_CAP_LIST)) |
|
- | 484 | return 0; |
|
- | 485 | ||
- | 486 | switch (hdr_type) { |
|
- | 487 | case PCI_HEADER_TYPE_NORMAL: |
|
- | 488 | case PCI_HEADER_TYPE_BRIDGE: |
|
- | 489 | return PCI_CAPABILITY_LIST; |
|
- | 490 | case PCI_HEADER_TYPE_CARDBUS: |
|
- | 491 | return PCI_CB_CAPABILITY_LIST; |
|
- | 492 | default: |
|
- | 493 | return 0; |
|
- | 494 | } |
|
- | 495 | ||
- | 496 | return 0; |
|
- | 497 | } |
|
- | 498 | ||
- | 499 | ||
- | 500 | int pci_find_capability(struct pci_dev *dev, int cap) |
|
- | 501 | { |
|
- | 502 | int pos; |
|
- | 503 | ||
- | 504 | pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type); |
|
- | 505 | if (pos) |
|
- | 506 | pos = __pci_find_next_cap(dev->bus, dev->devfn, pos, cap); |
|
- | 507 | ||
- | 508 | return pos; |
|
- | 509 | } |
|
- | 510 | ||
- | 511 | ||
447 | #if 0 |
512 | #if 0 |
448 | /** |
513 | /** |
449 | * pci_set_power_state - Set the power state of a PCI device |
514 | * pci_set_power_state - Set the power state of a PCI device |
450 | * @dev: PCI device to be suspended |
515 | * @dev: PCI device to be suspended |
451 | * @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering |
516 | * @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering |