Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 38f147e | 2010-02-08 12:20:50 +0000 | [diff] [blame] | 2 | * generic debug code, used by mainboard specific romstage.c |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 3 | * |
| 4 | */ |
| 5 | #if 1 |
| 6 | static void print_debug_pci_dev(unsigned dev) |
| 7 | { |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 8 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%x", |
| 9 | (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 10 | } |
| 11 | |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 12 | static inline void print_pci_devices(void) |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 13 | { |
| 14 | device_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 15 | for(dev = PCI_DEV(0, 0, 0); |
| 16 | dev <= PCI_DEV(0xff, 0x1f, 0x7); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 17 | dev += PCI_DEV(0,0,1)) { |
| 18 | uint32_t id; |
| 19 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 20 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 21 | (((id >> 16) & 0xffff) == 0xffff) || |
| 22 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 23 | continue; |
| 24 | } |
| 25 | print_debug_pci_dev(dev); |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 26 | printk(BIOS_DEBUG, "\n"); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 27 | } |
| 28 | } |
| 29 | |
| 30 | static void dump_pci_device(unsigned dev) |
| 31 | { |
| 32 | int i; |
| 33 | print_debug_pci_dev(dev); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 34 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 35 | for(i = 0; i < 256; i++) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 36 | unsigned char val; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 37 | if ((i & 0x0f) == 0) |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 38 | printk(BIOS_DEBUG, "\n%02x:",i); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 39 | val = pci_read_config8(dev, i); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 40 | printk(BIOS_DEBUG, " %02x", val); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 41 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 42 | printk(BIOS_DEBUG, "\n"); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 45 | static inline void dump_pci_devices(void) |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 46 | { |
| 47 | device_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 48 | for(dev = PCI_DEV(0, 0, 0); |
| 49 | dev <= PCI_DEV(0xff, 0x1f, 0x7); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 50 | dev += PCI_DEV(0,0,1)) { |
| 51 | uint32_t id; |
| 52 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 53 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 54 | (((id >> 16) & 0xffff) == 0xffff) || |
| 55 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 56 | continue; |
| 57 | } |
| 58 | dump_pci_device(dev); |
| 59 | } |
| 60 | } |
| 61 | |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 62 | static inline void dump_pci_devices_on_bus(unsigned busn) |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 63 | { |
| 64 | device_t dev; |
| 65 | for(dev = PCI_DEV(busn, 0, 0); |
| 66 | dev <= PCI_DEV(busn, 0x1f, 0x7); |
| 67 | dev += PCI_DEV(0,0,1)) { |
| 68 | uint32_t id; |
| 69 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 70 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 71 | (((id >> 16) & 0xffff) == 0xffff) || |
| 72 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 73 | continue; |
| 74 | } |
| 75 | dump_pci_device(dev); |
| 76 | } |
| 77 | } |
| 78 | |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 79 | static inline void dump_spd_registers(const struct mem_controller *ctrl) |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 80 | { |
| 81 | int i; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 82 | printk(BIOS_DEBUG, "\n"); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 83 | for(i = 0; i < 4; i++) { |
| 84 | unsigned device; |
| 85 | device = ctrl->channel0[i]; |
| 86 | if (device) { |
| 87 | int j; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 88 | printk(BIOS_DEBUG, "dimm: %02x.0: %02x", i, device); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 89 | for(j = 0; j < 128; j++) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 90 | int status; |
| 91 | unsigned char byte; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 92 | if ((j & 0xf) == 0) |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 93 | printk(BIOS_DEBUG, "\n%02x: ", j); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 94 | status = smbus_read_byte(device, j); |
| 95 | if (status < 0) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 96 | break; |
| 97 | } |
| 98 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 99 | printk(BIOS_DEBUG, "%02x ", byte); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 100 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 101 | printk(BIOS_DEBUG, "\n"); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 102 | } |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 103 | device = ctrl->channel1[i]; |
| 104 | if (device) { |
| 105 | int j; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 106 | printk(BIOS_DEBUG, "dimm: %02x.1: %02x", i, device); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 107 | for(j = 0; j < 128; j++) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 108 | int status; |
| 109 | unsigned char byte; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 110 | if ((j & 0xf) == 0) |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 111 | printk(BIOS_DEBUG, "\n%02x: ", j); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 112 | status = smbus_read_byte(device, j); |
| 113 | if (status < 0) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 114 | break; |
| 115 | } |
| 116 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 117 | printk(BIOS_DEBUG, "%02x ", byte); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 118 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 119 | printk(BIOS_DEBUG, "\n"); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 120 | } |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 121 | } |
| 122 | } |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 123 | static inline void dump_smbus_registers(void) |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 124 | { |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 125 | unsigned device; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 126 | printk(BIOS_DEBUG, "\n"); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 127 | for(device = 1; device < 0x80; device++) { |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 128 | int j; |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 129 | if( smbus_read_byte(device, 0) < 0 ) continue; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 130 | printk(BIOS_DEBUG, "smbus: %02x", device); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 131 | for(j = 0; j < 256; j++) { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 132 | int status; |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 133 | unsigned char byte; |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 134 | status = smbus_read_byte(device, j); |
| 135 | if (status < 0) { |
| 136 | break; |
| 137 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 138 | if ((j & 0xf) == 0) |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 139 | printk(BIOS_DEBUG, "\n%02x: ",j); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 140 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 141 | printk(BIOS_DEBUG, "%02x ", byte); |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 142 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 143 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 144 | } |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 145 | } |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 146 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 147 | static inline void dump_io_resources(unsigned port) |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 148 | { |
| 149 | |
| 150 | int i; |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 151 | printk(BIOS_DEBUG, "%04x:\n", port); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 152 | for(i=0;i<256;i++) { |
| 153 | uint8_t val; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 154 | if ((i & 0x0f) == 0) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 155 | printk(BIOS_DEBUG, "%02x:", i); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 156 | val = inb(port); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 157 | printk(BIOS_DEBUG, " %02x",val); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 158 | if ((i & 0x0f) == 0x0f) { |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 159 | printk(BIOS_DEBUG, "\n"); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 160 | } |
| 161 | port++; |
| 162 | } |
| 163 | } |
| 164 | |
Stefan Reinauer | 23836e2 | 2010-04-15 12:39:29 +0000 | [diff] [blame] | 165 | static inline void dump_mem(unsigned start, unsigned end) |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 166 | { |
| 167 | unsigned i; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 168 | printk(BIOS_DEBUG, "dump_mem:"); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 169 | for(i=start;i<end;i++) { |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 170 | if((i & 0xf)==0) |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 171 | printk(BIOS_DEBUG, "\n%08x:", i); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 172 | printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i)); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 173 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 174 | printk(BIOS_DEBUG, "\n"); |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 175 | } |
Yinghai Lu | 70093f7 | 2004-07-01 03:55:03 +0000 | [diff] [blame] | 176 | #endif |