Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 16 | #include "debug.h" |
| 17 | #include <console/console.h> |
| 18 | #include <arch/io.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 19 | #include <device/pci_ops.h> |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 20 | #include <device/pci_def.h> |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 21 | #include <delay.h> |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 22 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 23 | void print_debug_addr(const char *str, void *val) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 24 | { |
Martin Roth | 77a58b9 | 2017-06-24 14:45:48 -0600 | [diff] [blame] | 25 | #if IS_ENABLED(CONFIG_DEBUG_CAR) |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 26 | printk(BIOS_DEBUG, "------Address debug: %s%p------\n", str, val); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 27 | #endif |
| 28 | } |
| 29 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 30 | void print_debug_pci_dev(u32 dev) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 31 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 32 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev>>20) & 0xff, (dev>>15) & 0x1f, (dev>>12) & 0x7); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 35 | void print_pci_devices(void) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 36 | { |
Antonello Dettori | f65ccb2 | 2016-09-03 10:45:33 +0200 | [diff] [blame] | 37 | pci_devfn_t dev; |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 38 | for (dev = PCI_DEV(0, 0, 0); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 39 | dev <= PCI_DEV(0xff, 0x1f, 0x7); |
| 40 | dev += PCI_DEV(0,0,1)) { |
| 41 | u32 id; |
| 42 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 43 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 44 | (((id >> 16) & 0xffff) == 0xffff) || |
| 45 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 46 | continue; |
| 47 | } |
| 48 | print_debug_pci_dev(dev); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 49 | printk(BIOS_DEBUG, " %04x:%04x\n", (id & 0xffff), (id>>16)); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 50 | if (((dev>>12) & 0x07) == 0) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 51 | u8 hdr_type; |
| 52 | hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 53 | if ((hdr_type & 0x80) != 0x80) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 54 | dev += PCI_DEV(0,0,7); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 60 | void print_pci_devices_on_bus(u32 busn) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 61 | { |
Antonello Dettori | f65ccb2 | 2016-09-03 10:45:33 +0200 | [diff] [blame] | 62 | pci_devfn_t dev; |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 63 | for (dev = PCI_DEV(busn, 0, 0); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 64 | dev <= PCI_DEV(busn, 0x1f, 0x7); |
| 65 | dev += PCI_DEV(0,0,1)) { |
| 66 | u32 id; |
| 67 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 68 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 69 | (((id >> 16) & 0xffff) == 0xffff) || |
| 70 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 71 | continue; |
| 72 | } |
| 73 | print_debug_pci_dev(dev); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 74 | printk(BIOS_DEBUG, " %04x:%04x\n", (id & 0xffff), (id>>16)); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 75 | if (((dev>>12) & 0x07) == 0) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 76 | u8 hdr_type; |
| 77 | hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 78 | if ((hdr_type & 0x80) != 0x80) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 79 | dev += PCI_DEV(0,0,7); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 85 | void dump_pci_device_range(u32 dev, u32 start_reg, u32 size) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 86 | { |
| 87 | int i; |
| 88 | print_debug_pci_dev(dev); |
| 89 | int j; |
| 90 | int end = start_reg + size; |
| 91 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 92 | for (i = start_reg; i < end; i+=4) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 93 | u32 val; |
| 94 | if ((i & 0x0f) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 95 | printk(BIOS_DEBUG, "\n%04x:",i); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 96 | } |
| 97 | val = pci_read_config32(dev, i); |
Elyes HAOUAS | 04f8fd9 | 2016-09-19 10:24:34 -0600 | [diff] [blame] | 98 | for (j = 0; j < 4; j++) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 99 | printk(BIOS_DEBUG, " %02x", val & 0xff); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 100 | val >>= 8; |
| 101 | } |
| 102 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 103 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 104 | } |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 105 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 106 | void dump_pci_device(u32 dev) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 107 | { |
| 108 | dump_pci_device_range(dev, 0, 4096); |
| 109 | } |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 110 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 111 | void dump_pci_device_index_wait_range(u32 dev, u32 index_reg, u32 start, |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 112 | u32 size) |
| 113 | { |
| 114 | int i; |
| 115 | int end = start + size; |
| 116 | print_debug_pci_dev(dev); |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 117 | printk(BIOS_DEBUG, " -- index_reg=%08x", index_reg); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 118 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 119 | for (i = start; i < end; i++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 120 | u32 val; |
| 121 | int j; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 122 | printk(BIOS_DEBUG, "\n%02x:",i); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 123 | val = pci_read_config32_index_wait(dev, index_reg, i); |
Elyes HAOUAS | 04f8fd9 | 2016-09-19 10:24:34 -0600 | [diff] [blame] | 124 | for (j = 0; j < 4; j++) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 125 | printk(BIOS_DEBUG, " %02x", val & 0xff); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 126 | val >>= 8; |
| 127 | } |
| 128 | |
| 129 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 130 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 131 | } |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 132 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 133 | void dump_pci_device_index_wait(u32 dev, u32 index_reg) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 134 | { |
| 135 | dump_pci_device_index_wait_range(dev, index_reg, 0, 0x54); |
| 136 | dump_pci_device_index_wait_range(dev, index_reg, 0x100, 0x08); //DIMM1 when memclk > 400Hz |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 139 | void dump_pci_device_index(u32 dev, u32 index_reg, u32 type, u32 length) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 140 | { |
| 141 | int i; |
| 142 | print_debug_pci_dev(dev); |
| 143 | |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 144 | printk(BIOS_DEBUG, " index reg: %04x type: %02x", index_reg, type); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 145 | |
| 146 | type<<=28; |
| 147 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 148 | for (i = 0; i < length; i++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 149 | u32 val; |
| 150 | if ((i & 0x0f) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 151 | printk(BIOS_DEBUG, "\n%02x:",i); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 152 | } |
| 153 | val = pci_read_config32_index(dev, index_reg, i|type); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 154 | printk(BIOS_DEBUG, " %08x", val); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 155 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 156 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 159 | void dump_pci_devices(void) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 160 | { |
Antonello Dettori | f65ccb2 | 2016-09-03 10:45:33 +0200 | [diff] [blame] | 161 | pci_devfn_t dev; |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 162 | for (dev = PCI_DEV(0, 0, 0); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 163 | dev <= PCI_DEV(0xff, 0x1f, 0x7); |
| 164 | dev += PCI_DEV(0,0,1)) { |
| 165 | u32 id; |
| 166 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 167 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 168 | (((id >> 16) & 0xffff) == 0xffff) || |
| 169 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 170 | continue; |
| 171 | } |
| 172 | dump_pci_device(dev); |
| 173 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 174 | if (((dev>>12) & 0x07) == 0) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 175 | u8 hdr_type; |
| 176 | hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 177 | if ((hdr_type & 0x80) != 0x80) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 178 | dev += PCI_DEV(0,0,7); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 184 | void dump_pci_devices_on_bus(u32 busn) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 185 | { |
Antonello Dettori | f65ccb2 | 2016-09-03 10:45:33 +0200 | [diff] [blame] | 186 | pci_devfn_t dev; |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 187 | for (dev = PCI_DEV(busn, 0, 0); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 188 | dev <= PCI_DEV(busn, 0x1f, 0x7); |
| 189 | dev += PCI_DEV(0,0,1)) { |
| 190 | u32 id; |
| 191 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
| 192 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) || |
| 193 | (((id >> 16) & 0xffff) == 0xffff) || |
| 194 | (((id >> 16) & 0xffff) == 0x0000)) { |
| 195 | continue; |
| 196 | } |
| 197 | dump_pci_device(dev); |
| 198 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 199 | if (((dev>>12) & 0x07) == 0) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 200 | u8 hdr_type; |
| 201 | hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 202 | if ((hdr_type & 0x80) != 0x80) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 203 | dev += PCI_DEV(0,0,7); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
Martin Roth | 77a58b9 | 2017-06-24 14:45:48 -0600 | [diff] [blame] | 209 | #if IS_ENABLED(CONFIG_DEBUG_SMBUS) |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 210 | void dump_spd_registers(const struct mem_controller *ctrl) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 211 | { |
| 212 | int i; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 213 | printk(BIOS_DEBUG, "\n"); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 214 | for (i = 0; i < DIMM_SOCKETS; i++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 215 | u32 device; |
| 216 | device = ctrl->spd_addr[i]; |
| 217 | if (device) { |
| 218 | int j; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 219 | printk(BIOS_DEBUG, "dimm: %02x.0: %02x", i, device); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 220 | for (j = 0; j < 128; j++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 221 | int status; |
| 222 | u8 byte; |
| 223 | if ((j & 0xf) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 224 | printk(BIOS_DEBUG, "\n%02x: ", j); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 225 | } |
| 226 | status = smbus_read_byte(device, j); |
| 227 | if (status < 0) { |
| 228 | break; |
| 229 | } |
| 230 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 231 | printk(BIOS_DEBUG, "%02x ", byte); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 232 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 233 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 234 | } |
| 235 | device = ctrl->spd_addr[i+DIMM_SOCKETS]; |
| 236 | if (device) { |
| 237 | int j; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 238 | printk(BIOS_DEBUG, "dimm: %02x.1: %02x", i, device); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 239 | for (j = 0; j < 128; j++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 240 | int status; |
| 241 | u8 byte; |
| 242 | if ((j & 0xf) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 243 | printk(BIOS_DEBUG, "\n%02x: ", j); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 244 | } |
| 245 | status = smbus_read_byte(device, j); |
| 246 | if (status < 0) { |
| 247 | break; |
| 248 | } |
| 249 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 250 | printk(BIOS_DEBUG, "%02x ", byte); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 251 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 252 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | } |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 256 | |
| 257 | void dump_smbus_registers(void) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 258 | { |
| 259 | u32 device; |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 260 | printk(BIOS_DEBUG, "\n"); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 261 | for (device = 1; device < 0x80; device++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 262 | int j; |
Elyes HAOUAS | 04f8fd9 | 2016-09-19 10:24:34 -0600 | [diff] [blame] | 263 | if (smbus_read_byte(device, 0) < 0) continue; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 264 | printk(BIOS_DEBUG, "smbus: %02x", device); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 265 | for (j = 0; j < 256; j++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 266 | int status; |
| 267 | u8 byte; |
| 268 | status = smbus_read_byte(device, j); |
| 269 | if (status < 0) { |
| 270 | break; |
| 271 | } |
| 272 | if ((j & 0xf) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 273 | printk(BIOS_DEBUG, "\n%02x: ",j); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 274 | } |
| 275 | byte = status & 0xff; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 276 | printk(BIOS_DEBUG, "%02x ", byte); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 277 | } |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 278 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | #endif |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 282 | |
| 283 | void dump_io_resources(u32 port) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 284 | { |
| 285 | |
| 286 | int i; |
Stefan Reinauer | 2d85fbed | 2010-04-14 15:44:21 +0000 | [diff] [blame] | 287 | udelay(2000); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 288 | printk(BIOS_DEBUG, "%04x:\n", port); |
Elyes HAOUAS | 04f8fd9 | 2016-09-19 10:24:34 -0600 | [diff] [blame] | 289 | for (i = 0; i < 256; i++) { |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 290 | u8 val; |
| 291 | if ((i & 0x0f) == 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 292 | printk(BIOS_DEBUG, "%02x:", i); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 293 | } |
| 294 | val = inb(port); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 295 | printk(BIOS_DEBUG, " %02x",val); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 296 | if ((i & 0x0f) == 0x0f) { |
Stefan Reinauer | 65b72ab | 2015-01-05 12:59:54 -0800 | [diff] [blame] | 297 | printk(BIOS_DEBUG, "\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 298 | } |
| 299 | port++; |
| 300 | } |
| 301 | } |
| 302 | |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 303 | #if IS_ENABLED(CONFIG_DIMM_DDR2) |
| 304 | void print_tx(const char *strval, u32 val) |
| 305 | { |
Martin Roth | 77a58b9 | 2017-06-24 14:45:48 -0600 | [diff] [blame] | 306 | #if IS_ENABLED(CONFIG_DEBUG_RAM_SETUP) |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 307 | printk(BIOS_DEBUG, "%s%08x\n", strval, val); |
| 308 | #endif |
| 309 | } |
| 310 | |
| 311 | void print_t(const char *strval) |
| 312 | { |
Martin Roth | 77a58b9 | 2017-06-24 14:45:48 -0600 | [diff] [blame] | 313 | #if IS_ENABLED(CONFIG_DEBUG_RAM_SETUP) |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 314 | printk(BIOS_DEBUG, "%s", strval); |
| 315 | #endif |
| 316 | } |
| 317 | #endif /* CONFIG_DIMM_DDR2 */ |
| 318 | |
| 319 | void print_tf(const char *func, const char *strval) |
| 320 | { |
Martin Roth | 77a58b9 | 2017-06-24 14:45:48 -0600 | [diff] [blame] | 321 | #if IS_ENABLED(CONFIG_DEBUG_RAM_SETUP) |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 322 | printk(BIOS_DEBUG, "%s: %s", func, strval); |
| 323 | #endif |
| 324 | } |