blob: 8dc76fe44755fb9102b9355ba2a33d40c98edaa3 [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
Patrick Georgid0835952010-10-05 09:07:10 +000022#include <lib.h>
23#include <arch/io.h>
24#include <arch/romcc_io.h>
25#include <device/pci_def.h>
26#include <console/console.h>
27#include "i945.h"
28
Stefan Reinauer36a22682008-10-29 04:52:57 +000029#define SMBUS_MEM_DEVICE_START 0x50
30#define SMBUS_MEM_DEVICE_END 0x53
31#define SMBUS_MEM_DEVICE_INC 1
32
Patrick Georgid0835952010-10-05 09:07:10 +000033void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000034{
35 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000036 for(dev = PCI_DEV(0, 0, 0);
37 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000038 dev += PCI_DEV(0,0,1)) {
39 uint32_t id;
40 id = pci_read_config32(dev, PCI_VENDOR_ID);
41 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
42 (((id >> 16) & 0xffff) == 0xffff) ||
43 (((id >> 16) & 0xffff) == 0x0000)) {
44 continue;
45 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000046 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000047 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000048 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000049 }
50}
51
Patrick Georgid0835952010-10-05 09:07:10 +000052void dump_pci_device(unsigned dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000053{
54 int i;
55
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000056 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000057
58 for(i = 0; i <= 255; i++) {
59 unsigned char val;
60 if ((i & 0x0f) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000061 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000062 }
63 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000064 printk(BIOS_DEBUG, " %02x", val);
Stefan Reinauer36a22682008-10-29 04:52:57 +000065 if ((i & 0x0f) == 0x0f) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000066 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000067 }
68 }
69}
70
Patrick Georgid0835952010-10-05 09:07:10 +000071void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000072{
73 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000074 for(dev = PCI_DEV(0, 0, 0);
75 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000076 dev += PCI_DEV(0,0,1)) {
77 uint32_t id;
78 id = pci_read_config32(dev, PCI_VENDOR_ID);
79 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
80 (((id >> 16) & 0xffff) == 0xffff) ||
81 (((id >> 16) & 0xffff) == 0x0000)) {
82 continue;
83 }
84 dump_pci_device(dev);
85 }
86}
87
Patrick Georgid0835952010-10-05 09:07:10 +000088void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000089{
90 unsigned device;
91 device = SMBUS_MEM_DEVICE_START;
92 while(device <= SMBUS_MEM_DEVICE_END) {
93 int status = 0;
94 int i;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000095 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000096
Stefan Reinauer36a22682008-10-29 04:52:57 +000097 for(i = 0; (i < 256) ; i++) {
98 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000099 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000100 }
101 status = smbus_read_byte(device, i);
102 if (status < 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000103 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000104 break;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000105 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000106 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000107 }
108 device += SMBUS_MEM_DEVICE_INC;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000109 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000110 }
111}
112
Patrick Georgid0835952010-10-05 09:07:10 +0000113void dump_mem(unsigned start, unsigned end)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000114{
115 unsigned i;
116 print_debug("dump_mem:");
117 for(i=start;i<end;i++) {
118 if((i & 0xf)==0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000119 printk(BIOS_DEBUG, "\n%08x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000120 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000121 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
Stefan Reinauer36a22682008-10-29 04:52:57 +0000122 }
Stefan Reinauer67cd8022010-01-16 16:35:38 +0000123 print_debug("\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000124 }