blob: 397bd4beb9a052d8e3cfd95ce8c288d482bb68f1 [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>
Patrick Georgid0835952010-10-05 09:07:10 +000025#include <device/pci_def.h>
26#include <console/console.h>
27#include "i945.h"
28
Patrick Georgid0835952010-10-05 09:07:10 +000029void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000030{
31 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000032 for(dev = PCI_DEV(0, 0, 0);
33 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000034 dev += PCI_DEV(0,0,1)) {
35 uint32_t id;
36 id = pci_read_config32(dev, PCI_VENDOR_ID);
37 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
38 (((id >> 16) & 0xffff) == 0xffff) ||
39 (((id >> 16) & 0xffff) == 0x0000)) {
40 continue;
41 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000042 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000043 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000044 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000045 }
46}
47
Patrick Georgid0835952010-10-05 09:07:10 +000048void dump_pci_device(unsigned dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000049{
50 int i;
51
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000052 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000053
54 for(i = 0; i <= 255; i++) {
55 unsigned char val;
56 if ((i & 0x0f) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000058 }
59 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000060 printk(BIOS_DEBUG, " %02x", val);
Stefan Reinauer36a22682008-10-29 04:52:57 +000061 if ((i & 0x0f) == 0x0f) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000062 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000063 }
64 }
65}
66
Patrick Georgid0835952010-10-05 09:07:10 +000067void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000068{
69 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000070 for(dev = PCI_DEV(0, 0, 0);
71 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000072 dev += PCI_DEV(0,0,1)) {
73 uint32_t id;
74 id = pci_read_config32(dev, PCI_VENDOR_ID);
75 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
76 (((id >> 16) & 0xffff) == 0xffff) ||
77 (((id >> 16) & 0xffff) == 0x0000)) {
78 continue;
79 }
80 dump_pci_device(dev);
81 }
82}
83
Patrick Georgid0835952010-10-05 09:07:10 +000084void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000085{
86 unsigned device;
Uwe Hermannd773fd32010-11-20 20:23:08 +000087 device = DIMM0;
88 while(device <= DIMM3) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000089 int status = 0;
90 int i;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000091 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000092
Stefan Reinauer36a22682008-10-29 04:52:57 +000093 for(i = 0; (i < 256) ; i++) {
94 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000095 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000096 }
97 status = smbus_read_byte(device, i);
98 if (status < 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000099 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000100 break;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000101 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000102 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000103 }
Uwe Hermannd773fd32010-11-20 20:23:08 +0000104 device++;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000105 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000106 }
107}
108
Patrick Georgid0835952010-10-05 09:07:10 +0000109void dump_mem(unsigned start, unsigned end)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000110{
111 unsigned i;
Stefan Reinauer65b72ab2015-01-05 12:59:54 -0800112 printk(BIOS_DEBUG, "dump_mem:");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000113 for(i=start;i<end;i++) {
114 if((i & 0xf)==0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000115 printk(BIOS_DEBUG, "\n%08x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000116 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000117 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
Stefan Reinauer36a22682008-10-29 04:52:57 +0000118 }
Stefan Reinauer65b72ab2015-01-05 12:59:54 -0800119 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000120 }