Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 1 | #ifndef AMDK8_F_PCI_C |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 2 | #define AMDK8_F_PCI_C |
Stefan Reinauer | 116ec61 | 2010-04-23 19:16:30 +0000 | [diff] [blame] | 3 | |
| 4 | #ifdef UNUSED_CODE |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 5 | /* bit [10,8] are dev func, bit[1,0] are dev index */ |
| 6 | static uint32_t pci_read_config32_index(device_t dev, uint32_t index_reg, uint32_t index) |
| 7 | { |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 8 | uint32_t dword; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 9 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 10 | pci_write_config32(dev, index_reg, index); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 11 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 12 | dword = pci_read_config32(dev, index_reg+0x4); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 13 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 14 | return dword; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | static void pci_write_config32_index(device_t dev, uint32_t index_reg, uint32_t index, uint32_t data) |
| 18 | { |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 19 | pci_write_config32(dev, index_reg, index); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 20 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 21 | pci_write_config32(dev, index_reg + 0x4, data); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 22 | } |
Stefan Reinauer | 116ec61 | 2010-04-23 19:16:30 +0000 | [diff] [blame] | 23 | #endif |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 24 | |
| 25 | static uint32_t pci_read_config32_index_wait(device_t dev, uint32_t index_reg, uint32_t index) |
| 26 | { |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 27 | uint32_t dword; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 28 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 29 | index &= ~(1<<30); |
| 30 | pci_write_config32(dev, index_reg, index); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 31 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 32 | do { |
| 33 | dword = pci_read_config32(dev, index_reg); |
| 34 | } while (!(dword & (1<<31))); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 35 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 36 | dword = pci_read_config32(dev, index_reg+0x4); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 37 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 38 | return dword; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static void pci_write_config32_index_wait(device_t dev, uint32_t index_reg, uint32_t index, uint32_t data) |
| 42 | { |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 43 | uint32_t dword; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 44 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 45 | pci_write_config32(dev, index_reg + 0x4, data); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 46 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 47 | index |= (1<<30); |
| 48 | pci_write_config32(dev, index_reg, index); |
| 49 | do { |
| 50 | dword = pci_read_config32(dev, index_reg); |
| 51 | } while (!(dword & (1<<31))); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | #endif |