2fe1ea305b49132fc4592af958dc4c37a9b34cbf
[coreboot.git] / src / lib / generic_dump_spd.c
1 /*
2  * This code is derived from the Opteron boards' debug.c.
3  * It should go away either there or here, depending what fits better.
4  */
5
6 static void dump_spd_registers(const struct mem_controller *ctrl)
7 {
8         int i;
9         print_debug("\n");
10         for(i = 0; i < 4; i++) {
11                 unsigned device;
12                 device = ctrl->channel0[i];
13                 if (device) {
14                         int j;
15                         print_debug("dimm: "); 
16                         print_debug_hex8(i); 
17                         print_debug(".0: ");
18                         print_debug_hex8(device);
19                         for(j = 0; j < 256; j++) {
20                                 int status;
21                                 unsigned char byte;
22                                 if ((j & 0xf) == 0) {
23                                         print_debug("\n");
24                                         print_debug_hex8(j);
25                                         print_debug(": ");
26                                 }
27                                 status = spd_read_byte(device, j);
28                                 if (status < 0) {
29                                         print_debug("bad device\n");
30                                         break;
31                                 }
32                                 byte = status & 0xff;
33                                 print_debug_hex8(byte);
34                                 print_debug_char(' ');
35                         }
36                         print_debug("\n");
37                 }
38                 device = ctrl->channel1[i];
39                 if (device) {
40                         int j;
41                         print_debug("dimm: "); 
42                         print_debug_hex8(i); 
43                         print_debug(".1: ");
44                         print_debug_hex8(device);
45                         for(j = 0; j < 256; j++) {
46                                 int status;
47                                 unsigned char byte;
48                                 if ((j & 0xf) == 0) {
49                                         print_debug("\n");
50                                         print_debug_hex8(j);
51                                         print_debug(": ");
52                                 }
53                                 status = spd_read_byte(device, j);
54                                 if (status < 0) {
55                                         print_debug("bad device\n");
56                                         break;
57                                 }
58                                 byte = status & 0xff;
59                                 print_debug_hex8(byte);
60                                 print_debug_char(' ');
61                         }
62                         print_debug("\n");
63                 }
64         }
65 }
66
67 #if 0
68 void dump_spd_registers(void)
69 {
70         unsigned device;
71         device = SMBUS_MEM_DEVICE_START;
72         printk(BIOS_DEBUG, "\n");
73         while(device <= SMBUS_MEM_DEVICE_END) {
74                 int status = 0;
75                 int i;
76                 printk(BIOS_DEBUG, "dimm %02x", device);
77                 for(i = 0; (i < 256) && (status == 0); i++) {
78                         unsigned char byte;
79                         if ((i % 20) == 0) {
80                                 printk(BIOS_DEBUG, "\n%3d: ", i);
81                         }
82                         status = smbus_read_byte(device, i, &byte);
83                         if (status != 0) {
84                                 printk(BIOS_DEBUG, "bad device\n");
85                                 continue;
86                         }
87                         printk(BIOS_DEBUG, "%02x ", byte);
88                 }
89                 device += SMBUS_MEM_DEVICE_INC;
90                 printk(BIOS_DEBUG, "\n");
91         }
92 }
93 #endif