2 * generic K8 debug code, used by mainboard specific auto.c
6 #ifndef CACHE_AS_RAM_ADDRESS_DEBUG
7 #define CACHE_AS_RAM_ADDRESS_DEBUG 0
10 static inline void print_debug_addr(const char *str, void *val)
12 #if CACHE_AS_RAM_ADDRESS_DEBUG == 1
13 #if CONFIG_USE_PRINTK_IN_CAR
14 printk_debug("------Address debug: %s%x------\r\n", str, val);
16 print_debug ("------Address debug: "); print_debug(str); print_debug_hex32(val); print_debug("------\r\n");
22 static void print_debug_pci_dev(unsigned dev)
24 #if CONFIG_USE_PRINTK_IN_CAR
25 printk_debug("PCI: %02x:%02x.%02x", (dev>>20) & 0xff, (dev>>15) & 0x1f, (dev>>12) & 0x7);
28 print_debug_hex8((dev >> 20) & 0xff);
29 print_debug_char(':');
30 print_debug_hex8((dev >> 15) & 0x1f);
31 print_debug_char('.');
32 print_debug_hex8((dev >> 12) & 7);
36 static void print_pci_devices(void)
39 for(dev = PCI_DEV(0, 0, 0);
40 dev <= PCI_DEV(0xff, 0x1f, 0x7);
41 dev += PCI_DEV(0,0,1)) {
43 id = pci_read_config32(dev, PCI_VENDOR_ID);
44 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
45 (((id >> 16) & 0xffff) == 0xffff) ||
46 (((id >> 16) & 0xffff) == 0x0000)) {
49 print_debug_pci_dev(dev);
50 #if CONFIG_USE_PRINTK_IN_CAR
51 printk_debug(" %04x:%04x\r\n", (id & 0xffff), (id>>16));
54 print_debug_hex32(id);
57 if(((dev>>12) & 0x07) == 0) {
59 hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE);
60 if((hdr_type & 0x80) != 0x80) {
61 dev += PCI_DEV(0,0,7);
67 static void dump_pci_device(unsigned dev)
70 print_debug_pci_dev(dev);
72 for(i = 0; i < 256; i++) {
74 if ((i & 0x0f) == 0) {
75 #if CONFIG_USE_PRINTK_IN_CAR
76 printk_debug("\r\n%02x:",i);
80 print_debug_char(':');
83 val = pci_read_config8(dev, i);
84 #if CONFIG_USE_PRINTK_IN_CAR
85 printk_debug(" %02x", val);
87 print_debug_char(' ');
88 print_debug_hex8(val);
94 #if CONFIG_K8_REV_F_SUPPORT == 1
95 static uint32_t pci_read_config32_index_wait(device_t dev, uint32_t index_reg, uint32_t index);
96 static void dump_pci_device_index_wait(unsigned dev, uint32_t index_reg)
99 print_debug_pci_dev(dev);
100 print_debug(" -- index_reg="); print_debug_hex32(index_reg);
102 for(i = 0; i < 0x40; i++) {
105 #if CONFIG_USE_PRINTK_IN_CAR
106 printk_debug("\r\n%02x:",i);
110 print_debug_char(':');
112 val = pci_read_config32_index_wait(dev, index_reg, i);
114 #if CONFIG_USE_PRINTK_IN_CAR
115 printk_debug(" %02x", val & 0xff);
117 print_debug_char(' '); print_debug_hex8(val&0xff);
127 static void dump_pci_devices(void)
130 for(dev = PCI_DEV(0, 0, 0);
131 dev <= PCI_DEV(0xff, 0x1f, 0x7);
132 dev += PCI_DEV(0,0,1)) {
134 id = pci_read_config32(dev, PCI_VENDOR_ID);
135 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
136 (((id >> 16) & 0xffff) == 0xffff) ||
137 (((id >> 16) & 0xffff) == 0x0000)) {
140 dump_pci_device(dev);
142 if(((dev>>12) & 0x07) == 0) {
144 hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE);
145 if((hdr_type & 0x80) != 0x80) {
146 dev += PCI_DEV(0,0,7);
152 static void dump_pci_devices_on_bus(unsigned busn)
155 for(dev = PCI_DEV(busn, 0, 0);
156 dev <= PCI_DEV(busn, 0x1f, 0x7);
157 dev += PCI_DEV(0,0,1)) {
159 id = pci_read_config32(dev, PCI_VENDOR_ID);
160 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
161 (((id >> 16) & 0xffff) == 0xffff) ||
162 (((id >> 16) & 0xffff) == 0x0000)) {
165 dump_pci_device(dev);
167 if(((dev>>12) & 0x07) == 0) {
169 hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE);
170 if((hdr_type & 0x80) != 0x80) {
171 dev += PCI_DEV(0,0,7);
178 #define DEBUG_SMBUS 0
182 static void dump_spd_registers(const struct mem_controller *ctrl)
186 for(i = 0; i < 4; i++) {
188 device = ctrl->channel0[i];
191 #if CONFIG_USE_PRINTK_IN_CAR
192 printk_debug("dimm: %02x.0: %02x", i, device);
194 print_debug("dimm: ");
197 print_debug_hex8(device);
199 for(j = 0; j < 128; j++) {
202 if ((j & 0xf) == 0) {
203 #if CONFIG_USE_PRINTK_IN_CAR
204 printk_debug("\r\n%02x: ", j);
211 status = smbus_read_byte(device, j);
215 byte = status & 0xff;
216 #if CONFIG_USE_PRINTK_IN_CAR
217 printk_debug("%02x ", byte);
219 print_debug_hex8(byte);
220 print_debug_char(' ');
225 device = ctrl->channel1[i];
228 #if CONFIG_USE_PRINTK_IN_CAR
229 printk_debug("dimm: %02x.1: %02x", i, device);
231 print_debug("dimm: ");
234 print_debug_hex8(device);
236 for(j = 0; j < 128; j++) {
239 if ((j & 0xf) == 0) {
240 #if CONFIG_USE_PRINTK_IN_CAR
241 printk_debug("\r\n%02x: ", j);
248 status = smbus_read_byte(device, j);
252 byte = status & 0xff;
253 #if CONFIG_USE_PRINTK_IN_CAR
254 printk_debug("%02x ", byte);
256 print_debug_hex8(byte);
257 print_debug_char(' ');
264 static void dump_smbus_registers(void)
268 for(device = 1; device < 0x80; device++) {
270 if( smbus_read_byte(device, 0) < 0 ) continue;
271 #if CONFIG_USE_PRINTK_IN_CAR
272 printk_debug("smbus: %02x", device);
274 print_debug("smbus: ");
275 print_debug_hex8(device);
277 for(j = 0; j < 256; j++) {
280 status = smbus_read_byte(device, j);
284 if ((j & 0xf) == 0) {
285 #if CONFIG_USE_PRINTK_IN_CAR
286 printk_debug("\r\n%02x: ",j);
293 byte = status & 0xff;
294 #if CONFIG_USE_PRINTK_IN_CAR
295 printk_debug("%02x ", byte);
297 print_debug_hex8(byte);
298 print_debug_char(' ');
306 static void dump_io_resources(unsigned port)
311 #if CONFIG_USE_PRINTK_IN_CAR
312 printk_debug("%04x:\r\n", port);
314 print_debug_hex16(port);
315 print_debug(":\r\n");
319 if ((i & 0x0f) == 0) {
320 #if CONFIG_USE_PRINTK_IN_CAR
321 printk_debug("%02x:", i);
324 print_debug_char(':');
328 #if CONFIG_USE_PRINTK_IN_CAR
329 printk_debug(" %02x",val);
331 print_debug_char(' ');
332 print_debug_hex8(val);
334 if ((i & 0x0f) == 0x0f) {
341 static void dump_mem(unsigned start, unsigned end)
344 print_debug("dump_mem:");
345 for(i=start;i<end;i++) {
347 #if CONFIG_USE_PRINTK_IN_CAR
348 printk_debug("\r\n%08x:", i);
351 print_debug_hex32(i);
355 #if CONFIG_USE_PRINTK_IN_CAR
356 printk_debug(" %02x", (unsigned char)*((unsigned char *)i));
359 print_debug_hex8((unsigned char)*((unsigned char *)i));