i855: Remove useless memctrl indirection.
[coreboot.git] / src / northbridge / intel / i855 / debug.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2003 Ronald G. Minnich
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; either version 2 of the License, or
9  * (at your option) any later version.
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, MA  02110-1301 USA
19  */
20
21 #include <spd.h>
22
23 static void print_debug_pci_dev(unsigned dev)
24 {
25         print_debug("PCI: ");
26         print_debug_hex8((dev >> 20) & 0xff);
27         print_debug_char(':');
28         print_debug_hex8((dev >> 15) & 0x1f);
29         print_debug_char('.');
30         print_debug_hex8((dev >> 12) & 0x07);
31 }
32
33 static inline void print_pci_devices(void)
34 {
35         device_t dev;
36         for(dev = PCI_DEV(0, 0, 0);
37                 dev <= PCI_DEV(0, 0x1f, 0x7);
38                 dev += PCI_DEV(0,0,1)) {
39                 uint32_t id;
40                 id = pci_read_config32(dev, PCI_VENDOR_ID);
41                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
42                         (((id >> 16) & 0xffff) == 0xffff) ||
43                         (((id >> 16) & 0xffff) == 0x0000)) {
44                         continue;
45                 }
46                 print_debug_pci_dev(dev);
47                 print_debug("\n");
48         }
49 }
50
51 static void dump_pci_device(unsigned dev)
52 {
53         int i;
54         print_debug_pci_dev(dev);
55         print_debug("\n");
56
57         for(i = 0; i <= 255; i++) {
58                 unsigned char val;
59                 if ((i & 0x0f) == 0) {
60                         print_debug_hex8(i);
61                         print_debug_char(':');
62                 }
63                 val = pci_read_config8(dev, i);
64                 print_debug_char(' ');
65                 print_debug_hex8(val);
66                 if ((i & 0x0f) == 0x0f) {
67                         print_debug("\n");
68                 }
69         }
70 }
71
72 static inline void dump_pci_devices(void)
73 {
74         device_t dev;
75         for(dev = PCI_DEV(0, 0, 0);
76                 dev <= PCI_DEV(0, 0x1f, 0x7);
77                 dev += PCI_DEV(0,0,1)) {
78                 uint32_t id;
79                 id = pci_read_config32(dev, PCI_VENDOR_ID);
80                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
81                         (((id >> 16) & 0xffff) == 0xffff) ||
82                         (((id >> 16) & 0xffff) == 0x0000)) {
83                         continue;
84                 }
85                 dump_pci_device(dev);
86         }
87 }
88
89 static inline void dump_spd_registers(void)
90 {
91         int i;
92         print_debug("\n");
93         for(i = 0; i < 2; i++) {
94                 unsigned device;
95                 device = DIMM0 + i;
96                 if (device) {
97                         int j;
98                         print_debug("dimm: ");
99                         print_debug_hex8(i);
100                         print_debug(".0: ");
101                         print_debug_hex8(device);
102                         for(j = 0; j < 256; j++) {
103                                 int status;
104                                 unsigned char byte;
105                                 if ((j & 0xf) == 0) {
106                                         print_debug("\n");
107                                         print_debug_hex8(j);
108                                         print_debug(": ");
109                                 }
110                                 status = smbus_read_byte(device, j);
111                                 if (status < 0) {
112                                         print_debug("bad device\n");
113                                         break;
114                                 }
115                                 byte = status & 0xff;
116                                 print_debug_hex8(byte);
117                                 print_debug_char(' ');
118                         }
119                         print_debug("\n");
120                 }
121         }
122 }
123
124 static inline void dump_smbus_registers(void)
125 {
126         int i;
127         print_debug("\n");
128         for(i = 1; i < 0x80; i++) {
129                 unsigned device;
130                 device = i;
131                 int j;
132                 print_debug("smbus: ");
133                 print_debug_hex8(device);
134                 for(j = 0; j < 256; j++) {
135                         int status;
136                         unsigned char byte;
137                         if ((j & 0xf) == 0) {
138                                 print_debug("\n");
139                                 print_debug_hex8(j);
140                                 print_debug(": ");
141                         }
142                         status = smbus_read_byte(device, j);
143                         if (status < 0) {
144                                 print_debug("bad device\n");
145                                 break;
146                         }
147                         byte = status & 0xff;
148                         print_debug_hex8(byte);
149                         print_debug_char(' ');
150                 }
151                 print_debug("\n");
152         }
153 }