Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * (C) 2007-2009 coresystems GmbH |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 19 | * MA 02110-1301 USA |
| 20 | */ |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 21 | |
| 22 | static void print_debug_pci_dev(unsigned dev) |
| 23 | { |
| 24 | print_debug("PCI: "); |
| 25 | print_debug_hex8((dev >> 16) & 0xff); |
| 26 | print_debug_char(':'); |
| 27 | print_debug_hex8((dev >> 11) & 0x1f); |
| 28 | print_debug_char('.'); |
| 29 | print_debug_hex8((dev >> 8) & 7); |
| 30 | } |
| 31 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 32 | static inline void print_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 33 | { |
| 34 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 35 | for (dev = PCI_DEV(0, 0, 0); |
| 36 | dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
| 37 | u32 id; |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 38 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 39 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 40 | || (((id >> 16) & 0xffff) == 0xffff) |
| 41 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 42 | continue; |
| 43 | } |
| 44 | print_debug_pci_dev(dev); |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 45 | print_debug("\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | |
| 49 | static void dump_pci_device(unsigned dev) |
| 50 | { |
| 51 | int i; |
| 52 | print_debug_pci_dev(dev); |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 53 | print_debug("\n"); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 54 | |
| 55 | for (i = 0; i <= 255; i++) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 56 | unsigned char val; |
| 57 | if ((i & 0x0f) == 0) { |
| 58 | print_debug_hex8(i); |
| 59 | print_debug_char(':'); |
| 60 | } |
| 61 | val = pci_read_config8(dev, i); |
| 62 | print_debug_char(' '); |
| 63 | print_debug_hex8(val); |
| 64 | if ((i & 0x0f) == 0x0f) { |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 65 | print_debug("\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 70 | static inline void dump_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 71 | { |
| 72 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 73 | for (dev = PCI_DEV(0, 0, 0); |
| 74 | dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
| 75 | u32 id; |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 76 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 77 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 78 | || (((id >> 16) & 0xffff) == 0xffff) |
| 79 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 80 | continue; |
| 81 | } |
| 82 | dump_pci_device(dev); |
| 83 | } |
| 84 | } |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame^] | 85 | |
| 86 | |
| 87 | static inline void dump_io_resources(unsigned port) |
| 88 | { |
| 89 | |
| 90 | int i; |
| 91 | udelay(2000); |
| 92 | print_debug_hex16(port); |
| 93 | print_debug(":\n"); |
| 94 | for (i = 0; i < 256; i++) { |
| 95 | u8 val; |
| 96 | if ((i & 0x0f) == 0) { |
| 97 | print_debug_hex8(i); |
| 98 | print_debug_char(':'); |
| 99 | } |
| 100 | val = inb(port); |
| 101 | print_debug_char(' '); |
| 102 | print_debug_hex8(val); |
| 103 | if ((i & 0x0f) == 0x0f) { |
| 104 | print_debug("\n"); |
| 105 | } |
| 106 | port++; |
| 107 | } |
| 108 | } |