| 47 | } |
| 48 | |
| 49 | static rt_uint8_t pci_find_next_cap_ttl(struct rt_pci_bus *bus, |
| 50 | rt_uint32_t devfn, rt_uint8_t pos, int cap, int *ttl) |
| 51 | { |
| 52 | rt_uint8_t ret = 0, id; |
| 53 | rt_uint16_t ent; |
| 54 | |
| 55 | rt_pci_bus_read_config_u8(bus, devfn, pos, &pos); |
| 56 | |
| 57 | while ((*ttl)--) |
| 58 | { |
| 59 | if (pos < 0x40) |
| 60 | { |
| 61 | break; |
| 62 | } |
| 63 | |
| 64 | pos &= ~3; |
| 65 | rt_pci_bus_read_config_u16(bus, devfn, pos, &ent); |
| 66 | |
| 67 | id = ent & 0xff; |
| 68 | if (id == 0xff) |
| 69 | { |
| 70 | break; |
| 71 | } |
| 72 | if (id == cap) |
| 73 | { |
| 74 | ret = pos; |
| 75 | break; |
| 76 | } |
| 77 | pos = (ent >> 8); |
| 78 | } |
| 79 | |
| 80 | return ret; |
| 81 | } |
| 82 | |
| 83 | static rt_uint8_t pci_find_next_cap(struct rt_pci_bus *bus, |
| 84 | rt_uint32_t devfn, rt_uint8_t pos, int cap) |