via epia; also yh lu tyan.
[coreboot.git] / src / mainboard / via / epia / 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("\r\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("\r\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("\r\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 #if 0
68 static void dump_spd_registers(const struct mem_controller *ctrl)
69 {
70         int i;
71         print_debug("\r\n");
72         for(i = 0; i < 4; i++) {
73                 unsigned device;
74                 device = ctrl->channel0[i];
75                 if (device) {
76                         int j;
77                         print_debug("dimm: "); 
78                         print_debug_hex8(i); 
79                         print_debug(".0: ");
80                         print_debug_hex8(device);
81                         for(j = 0; j < 256; j++) {
82                                 int status;
83                                 unsigned char byte;
84                                 if ((j & 0xf) == 0) {
85                                         print_debug("\r\n");
86                                         print_debug_hex8(j);
87                                         print_debug(": ");
88                                 }
89                                 status = smbus_read_byte(device, j);
90                                 if (status < 0) {
91                                         print_debug("bad device\r\n");
92                                         break;
93                                 }
94                                 byte = status & 0xff;
95                                 print_debug_hex8(byte);
96                                 print_debug_char(' ');
97                         }
98                         print_debug("\r\n");
99                 }
100                 device = ctrl->channel1[i];
101                 if (device) {
102                         int j;
103                         print_debug("dimm: "); 
104                         print_debug_hex8(i); 
105                         print_debug(".1: ");
106                         print_debug_hex8(device);
107                         for(j = 0; j < 256; j++) {
108                                 int status;
109                                 unsigned char byte;
110                                 if ((j & 0xf) == 0) {
111                                         print_debug("\r\n");
112                                         print_debug_hex8(j);
113                                         print_debug(": ");
114                                 }
115                                 status = smbus_read_byte(device, j);
116                                 if (status < 0) {
117                                         print_debug("bad device\r\n");
118                                         break;
119                                 }
120                                 byte = status & 0xff;
121                                 print_debug_hex8(byte);
122                                 print_debug_char(' ');
123                         }
124                         print_debug("\r\n");
125                 }
126         }
127 }
128 #endif