blob: 859a1ef6137e2ea9b6abaadc49c6c302b48c8426 [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
Uwe Hermannd773fd32010-11-20 20:23:08 +000022#include <spd.h>
Patrick Georgid0835952010-10-05 09:07:10 +000023#include <lib.h>
24#include <arch/io.h>
25#include <arch/romcc_io.h>
26#include <device/pci_def.h>
27#include <console/console.h>
28#include "i945.h"
29
Patrick Georgid0835952010-10-05 09:07:10 +000030void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000031{
32 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000033 for(dev = PCI_DEV(0, 0, 0);
34 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000035 dev += PCI_DEV(0,0,1)) {
36 uint32_t id;
37 id = pci_read_config32(dev, PCI_VENDOR_ID);
38 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
39 (((id >> 16) & 0xffff) == 0xffff) ||
40 (((id >> 16) & 0xffff) == 0x0000)) {
41 continue;
42 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000043 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000044 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000045 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000046 }
47}
48
Patrick Georgid0835952010-10-05 09:07:10 +000049void dump_pci_device(unsigned dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000050{
51 int i;
52
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000053 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000054
55 for(i = 0; i <= 255; i++) {
56 unsigned char val;
57 if ((i & 0x0f) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000058 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000059 }
60 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000061 printk(BIOS_DEBUG, " %02x", val);
Stefan Reinauer36a22682008-10-29 04:52:57 +000062 if ((i & 0x0f) == 0x0f) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000063 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000064 }
65 }
66}
67
Patrick Georgid0835952010-10-05 09:07:10 +000068void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000069{
70 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000071 for(dev = PCI_DEV(0, 0, 0);
72 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000073 dev += PCI_DEV(0,0,1)) {
74 uint32_t id;
75 id = pci_read_config32(dev, PCI_VENDOR_ID);
76 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
77 (((id >> 16) & 0xffff) == 0xffff) ||
78 (((id >> 16) & 0xffff) == 0x0000)) {
79 continue;
80 }
81 dump_pci_device(dev);
82 }
83}
84
Patrick Georgid0835952010-10-05 09:07:10 +000085void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000086{
87 unsigned device;
Uwe Hermannd773fd32010-11-20 20:23:08 +000088 device = DIMM0;
89 while(device <= DIMM3) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000090 int status = 0;
91 int i;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000092 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000093
Stefan Reinauer36a22682008-10-29 04:52:57 +000094 for(i = 0; (i < 256) ; i++) {
95 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000096 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000097 }
98 status = smbus_read_byte(device, i);
99 if (status < 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000100 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000101 break;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000102 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000103 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000104 }
Uwe Hermannd773fd32010-11-20 20:23:08 +0000105 device++;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000106 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000107 }
108}
109
Patrick Georgid0835952010-10-05 09:07:10 +0000110void dump_mem(unsigned start, unsigned end)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000111{
112 unsigned i;
113 print_debug("dump_mem:");
114 for(i=start;i<end;i++) {
115 if((i & 0xf)==0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000116 printk(BIOS_DEBUG, "\n%08x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000117 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000118 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
Stefan Reinauer36a22682008-10-29 04:52:57 +0000119 }
Stefan Reinauer67cd8022010-01-16 16:35:38 +0000120 print_debug("\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000121 }