7b854455a9680c5569af723aaa6a13a0e051774c
[coreboot.git] / src / northbridge / intel / i855pm / debug.c
1 /*
2  * generic K8 debug code, used by mainboard specific romstage.c
3  *
4  */
5 #if 1
6 static void print_debug_pci_dev(unsigned dev)
7 {
8         print_debug("PCI: ");
9         print_debug_hex8((dev >> 16) & 0xff);
10         print_debug_char(':');
11         print_debug_hex8((dev >> 11) & 0x1f);
12         print_debug_char('.');
13         print_debug_hex8((dev >> 8) & 7);
14 }
15
16 static void print_pci_devices(void)
17 {
18         device_t dev;
19         for(dev = PCI_DEV(0, 0, 0); 
20                 dev <= PCI_DEV(0, 0x1f, 0x7); 
21                 dev += PCI_DEV(0,0,1)) {
22                 uint32_t id;
23                 id = pci_read_config32(dev, PCI_VENDOR_ID);
24                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
25                         (((id >> 16) & 0xffff) == 0xffff) ||
26                         (((id >> 16) & 0xffff) == 0x0000)) {
27                         continue;
28                 }
29                 print_debug_pci_dev(dev);
30                 print_debug("\r\n");
31         }
32 }
33
34 static void dump_pci_device(unsigned dev)
35 {
36         int i;
37         print_debug_pci_dev(dev);
38         print_debug("\r\n");
39         
40         for(i = 0; i <= 255; i++) {
41                 unsigned char val;
42                 if ((i & 0x0f) == 0) {
43                         print_debug_hex8(i);
44                         print_debug_char(':');
45                 }
46                 val = pci_read_config8(dev, i);
47                 print_debug_char(' ');
48                 print_debug_hex8(val);
49                 if ((i & 0x0f) == 0x0f) {
50                         print_debug("\r\n");
51                 }
52         }
53 }
54
55 static void dump_pci_devices(void)
56 {
57         device_t dev;
58         for(dev = PCI_DEV(0, 0, 0); 
59                 dev <= PCI_DEV(0, 0x1f, 0x7); 
60                 dev += PCI_DEV(0,0,1)) {
61                 uint32_t id;
62                 id = pci_read_config32(dev, PCI_VENDOR_ID);
63                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
64                         (((id >> 16) & 0xffff) == 0xffff) ||
65                         (((id >> 16) & 0xffff) == 0x0000)) {
66                         continue;
67                 }
68                 dump_pci_device(dev);
69         }
70 }
71
72 static void dump_spd_registers(const struct mem_controller *ctrl)
73 {
74         int i;
75         print_debug("\r\n");
76         for(i = 0; i < 4; i++) {
77                 unsigned device;
78                 device = ctrl->channel0[i];
79                 if (device) {
80                         int j;
81                         print_debug("dimm: "); 
82                         print_debug_hex8(i); 
83                         print_debug(".0: ");
84                         print_debug_hex8(device);
85                         for(j = 0; j < 256; j++) {
86                                 int status;
87                                 unsigned char byte;
88                                 if ((j & 0xf) == 0) {
89                                         print_debug("\r\n");
90                                         print_debug_hex8(j);
91                                         print_debug(": ");
92                                 }
93                                 status = smbus_read_byte(device, j);
94                                 if (status < 0) {
95                                         print_debug("bad device\r\n");
96                                         break;
97                                 }
98                                 byte = status & 0xff;
99                                 print_debug_hex8(byte);
100                                 print_debug_char(' ');
101                         }
102                         print_debug("\r\n");
103                 }
104 #if 0
105                 device = ctrl->channel1[i];
106                 if (device) {
107                         int j;
108                         print_debug("dimm: "); 
109                         print_debug_hex8(i); 
110                         print_debug(".1: ");
111                         print_debug_hex8(device);
112                         for(j = 0; j < 256; j++) {
113                                 int status;
114                                 unsigned char byte;
115                                 if ((j & 0xf) == 0) {
116                                         print_debug("\r\n");
117                                         print_debug_hex8(j);
118                                         print_debug(": ");
119                                 }
120                                 status = smbus_read_byte(device, j);
121                                 if (status < 0) {
122                                         print_debug("bad device\r\n");
123                                         break;
124                                 }
125                                 byte = status & 0xff;
126                                 print_debug_hex8(byte);
127                                 print_debug_char(' ');
128                         }
129                         print_debug("\r\n");
130                 }
131 #endif
132         }
133 }
134 static void dump_smbus_registers(void)
135 {
136         int i;
137         print_debug("\r\n");
138         for(i = 1; i < 0x80; i++) {
139                 unsigned device;
140                 device = i;
141                 int j;
142                 print_debug("smbus: ");
143                 print_debug_hex8(device);
144                 for(j = 0; j < 256; j++) {
145                         int status; 
146                         unsigned char byte;
147                         if ((j & 0xf) == 0) {
148                                 print_debug("\r\n");
149                                 print_debug_hex8(j);
150                                 print_debug(": ");
151                         }
152                         status = smbus_read_byte(device, j);
153                         if (status < 0) {
154                                 print_debug("bad device\r\n");
155                                 break;
156                         }
157                         byte = status & 0xff;
158                         print_debug_hex8(byte);
159                         print_debug_char(' ');
160                 }
161                 print_debug("\r\n");
162         }       
163 }
164 #endif