blob: dd095ca7b37f1c6a896fcff96b5422355837bde6 [file] [log] [blame]
Stefan Reinauer36a22682008-10-29 04:52:57 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinauer36a22682008-10-29 04:52:57 +00004 * Copyright (C) 2007-2008 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
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,
19 * MA 02110-1301 USA
20 */
21
22#define SMBUS_MEM_DEVICE_START 0x50
23#define SMBUS_MEM_DEVICE_END 0x53
24#define SMBUS_MEM_DEVICE_INC 1
25
Stefan Reinauer53b0ea42010-03-22 11:50:52 +000026static inline void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000027{
28 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000029 for(dev = PCI_DEV(0, 0, 0);
30 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000031 dev += PCI_DEV(0,0,1)) {
32 uint32_t id;
33 id = pci_read_config32(dev, PCI_VENDOR_ID);
34 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
35 (((id >> 16) & 0xffff) == 0xffff) ||
36 (((id >> 16) & 0xffff) == 0x0000)) {
37 continue;
38 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000039 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000040 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000041 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000042 }
43}
44
Stefan Reinauer53b0ea42010-03-22 11:50:52 +000045static inline void dump_pci_device(unsigned dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000046{
47 int i;
48
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000049 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000050
51 for(i = 0; i <= 255; i++) {
52 unsigned char val;
53 if ((i & 0x0f) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000054 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000055 }
56 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_DEBUG, " %02x", val);
Stefan Reinauer36a22682008-10-29 04:52:57 +000058 if ((i & 0x0f) == 0x0f) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000059 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000060 }
61 }
62}
63
Stefan Reinauer53b0ea42010-03-22 11:50:52 +000064static inline void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000065{
66 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000067 for(dev = PCI_DEV(0, 0, 0);
68 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000069 dev += PCI_DEV(0,0,1)) {
70 uint32_t id;
71 id = pci_read_config32(dev, PCI_VENDOR_ID);
72 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
73 (((id >> 16) & 0xffff) == 0xffff) ||
74 (((id >> 16) & 0xffff) == 0x0000)) {
75 continue;
76 }
77 dump_pci_device(dev);
78 }
79}
80
Stefan Reinauer53b0ea42010-03-22 11:50:52 +000081static inline void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000082{
83 unsigned device;
84 device = SMBUS_MEM_DEVICE_START;
85 while(device <= SMBUS_MEM_DEVICE_END) {
86 int status = 0;
87 int i;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000088 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000089
Stefan Reinauer36a22682008-10-29 04:52:57 +000090 for(i = 0; (i < 256) ; i++) {
91 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000092 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000093 }
94 status = smbus_read_byte(device, i);
95 if (status < 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000096 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
Stefan Reinauer14e22772010-04-27 06:56:47 +000097 break;
Stefan Reinauer36a22682008-10-29 04:52:57 +000098 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000099 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000100 }
101 device += SMBUS_MEM_DEVICE_INC;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000102 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000103 }
104}
105
Stefan Reinauer53b0ea42010-03-22 11:50:52 +0000106static inline void dump_mem(unsigned start, unsigned end)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000107{
108 unsigned i;
109 print_debug("dump_mem:");
110 for(i=start;i<end;i++) {
111 if((i & 0xf)==0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000112 printk(BIOS_DEBUG, "\n%08x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000113 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000114 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
Stefan Reinauer36a22682008-10-29 04:52:57 +0000115 }
Stefan Reinauer67cd8022010-01-16 16:35:38 +0000116 print_debug("\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000117 }