Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / arima / hdama / debug.c
1
2 static void print_debug_pci_dev(unsigned dev)
3 {
4         print_debug("PCI: ");
5         print_debug_hex8((dev >> 16) & 0xff);
6         print_debug_char(':');
7         print_debug_hex8((dev >> 11) & 0x1f);
8         print_debug_char('.');
9         print_debug_hex8((dev >> 8) & 7);
10 }
11
12 static void print_pci_devices(void)
13 {
14         device_t dev;
15         for(dev = PCI_DEV(0, 0, 0);
16                 dev <= PCI_DEV(0, 0x1f, 0x7);
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);
26                 print_debug("\n");
27         }
28 }
29
30 static void dump_pci_device(unsigned dev)
31 {
32         int i;
33         print_debug_pci_dev(dev);
34         print_debug("\n");
35
36         for(i = 0; i <= 255; i++) {
37                 unsigned char val;
38                 if ((i & 0x0f) == 0) {
39                         print_debug_hex8(i);
40                         print_debug_char(':');
41                 }
42                 val = pci_read_config8(dev, i);
43                 print_debug_char(' ');
44                 print_debug_hex8(val);
45                 if ((i & 0x0f) == 0x0f) {
46                         print_debug("\n");
47                 }
48         }
49 }
50
51 static void dump_pci_devices(void)
52 {
53         device_t dev;
54         for(dev = PCI_DEV(0, 0, 0);
55                 dev <= PCI_DEV(0, 0x1f, 0x7);
56                 dev += PCI_DEV(0,0,1)) {
57                 uint32_t id;
58                 id = pci_read_config32(dev, PCI_VENDOR_ID);
59                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
60                         (((id >> 16) & 0xffff) == 0xffff) ||
61                         (((id >> 16) & 0xffff) == 0x0000)) {
62                         continue;
63                 }
64                 dump_pci_device(dev);
65         }
66 }
67
68 static void dump_spd_registers(int controllers, const struct mem_controller *ctrl)
69 {
70         int n;
71         for(n = 0; n < controllers; n++) {
72                 int i;
73                 print_debug("\n");
74                 activate_spd_rom(&ctrl[n]);
75                 for(i = 0; i < 4; i++) {
76                         unsigned device;
77                         device = ctrl[n].channel0[i];
78                         if (device) {
79                                 int j;
80                                 print_debug("dimm: ");
81                                 print_debug_hex8(n);
82                                 print_debug_char('.');
83                                 print_debug_hex8(i);
84                                 print_debug(".0: ");
85                                 print_debug_hex8(device);
86                                 for(j = 0; j < 256; j++) {
87                                         int status;
88                                         unsigned char byte;
89                                         if ((j & 0xf) == 0) {
90                                                 print_debug("\n");
91                                                 print_debug_hex8(j);
92                                                 print_debug(": ");
93                                         }
94                                         status = spd_read_byte(device, j);
95                                         if (status < 0) {
96                                                 print_debug("bad device\n");
97                                                 break;
98                                         }
99 #if 0
100                                         byte = status & 0xff;
101                                         print_debug_hex8(byte);
102 #else
103                                         print_debug_hex8(status & 0xff);
104 #endif
105                                         print_debug_char(' ');
106                                 }
107                                 print_debug("\n");
108                         }
109                         device = ctrl[n].channel1[i];
110                         if (device) {
111                                 int j;
112                                 print_debug("dimm: ");
113                                 print_debug_hex8(n);
114                                 print_debug_char('.');
115                                 print_debug_hex8(i);
116                                 print_debug(".1: ");
117                                 print_debug_hex8(device);
118                                 for(j = 0; j < 256; j++) {
119                                         int status;
120                                         unsigned char byte;
121                                         if ((j & 0xf) == 0) {
122                                                 print_debug("\n");
123                                                 print_debug_hex8(j);
124                                                 print_debug(": ");
125                                         }
126                                         status = spd_read_byte(device, j);
127                                         if (status < 0) {
128                                                 print_debug("bad device\n");
129                                                 break;
130                                         }
131 #if 0
132                                         byte = status & 0xff;
133                                         print_debug_hex8(byte);
134 #else
135                                         print_debug_hex8(status & 0xff);
136 #endif
137                                         print_debug_char(' ');
138                                 }
139                                 print_debug("\n");
140                         }
141                 }
142         }
143 }