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. |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 15 | */ |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 16 | |
Lee Leahy | 75b8599 | 2017-03-08 16:34:12 -0800 | [diff] [blame] | 17 | static void print_debug_pci_dev(unsigned int dev) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 18 | { |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 19 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%x", |
| 20 | (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 23 | static inline void print_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 24 | { |
| 25 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 26 | for (dev = PCI_DEV(0, 0, 0); |
Stefan Reinauer | 5391fe0 | 2010-04-15 12:43:07 +0000 | [diff] [blame] | 27 | dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 28 | u32 id; |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 29 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 30 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 31 | || (((id >> 16) & 0xffff) == 0xffff) |
| 32 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 33 | continue; |
| 34 | } |
| 35 | print_debug_pci_dev(dev); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 36 | printk(BIOS_DEBUG, "\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 37 | } |
| 38 | } |
| 39 | |
Lee Leahy | 75b8599 | 2017-03-08 16:34:12 -0800 | [diff] [blame] | 40 | static void dump_pci_device(unsigned int dev) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 41 | { |
| 42 | int i; |
| 43 | print_debug_pci_dev(dev); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 44 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 45 | |
| 46 | for (i = 0; i <= 255; i++) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 47 | unsigned char val; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 48 | if ((i & 0x0f) == 0) |
| 49 | printk(BIOS_DEBUG, "%02x:", i); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 50 | val = pci_read_config8(dev, i); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 51 | printk(BIOS_DEBUG, " %02x", val); |
| 52 | if ((i & 0x0f) == 0x0f) |
| 53 | printk(BIOS_DEBUG, "\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 57 | static inline void dump_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 58 | { |
| 59 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 60 | for (dev = PCI_DEV(0, 0, 0); |
| 61 | dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
| 62 | u32 id; |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 63 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 64 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 65 | || (((id >> 16) & 0xffff) == 0xffff) |
| 66 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 67 | continue; |
| 68 | } |
| 69 | dump_pci_device(dev); |
| 70 | } |
| 71 | } |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 72 | |
| 73 | |
Lee Leahy | 75b8599 | 2017-03-08 16:34:12 -0800 | [diff] [blame] | 74 | static inline void dump_io_resources(unsigned int port) |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 75 | { |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 76 | int i; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 77 | printk(BIOS_DEBUG, "%04x:\n", port); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 78 | for (i = 0; i < 256; i++) { |
| 79 | u8 val; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 80 | if ((i & 0x0f) == 0) |
| 81 | printk(BIOS_DEBUG, "%02x:", i); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 82 | val = inb(port); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 83 | printk(BIOS_DEBUG, " %02x", val); |
| 84 | if ((i & 0x0f) == 0x0f) |
| 85 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 86 | port++; |
| 87 | } |
| 88 | } |