blob: 6228d635b3aa950465bc0c22e52cf6a0037c0442 [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.
Stefan Reinauer36a22682008-10-29 04:52:57 +000015 */
16
Uwe Hermannd773fd32010-11-20 20:23:08 +000017#include <spd.h>
Patrick Georgid0835952010-10-05 09:07:10 +000018#include <lib.h>
19#include <arch/io.h>
Patrick Georgid0835952010-10-05 09:07:10 +000020#include <device/pci_def.h>
21#include <console/console.h>
22#include "i945.h"
23
Patrick Georgid0835952010-10-05 09:07:10 +000024void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000025{
Antonello Dettori70f5b822016-08-30 22:11:24 +020026 pci_devfn_t dev;
Elyes HAOUAS12df9502016-08-23 21:29:48 +020027 for (dev = PCI_DEV(0, 0, 0);
Stefan Reinauer14e22772010-04-27 06:56:47 +000028 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000029 dev += PCI_DEV(0,0,1)) {
30 uint32_t id;
31 id = pci_read_config32(dev, PCI_VENDOR_ID);
32 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
33 (((id >> 16) & 0xffff) == 0xffff) ||
34 (((id >> 16) & 0xffff) == 0x0000)) {
35 continue;
36 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000037 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000038 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000039 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000040 }
41}
42
Patrick Georgid0835952010-10-05 09:07:10 +000043void dump_pci_device(unsigned dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000044{
45 int i;
46
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000047 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000048
Elyes HAOUAS12df9502016-08-23 21:29:48 +020049 for (i = 0; i <= 255; i++) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000050 unsigned char val;
51 if ((i & 0x0f) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000052 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000053 }
54 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000055 printk(BIOS_DEBUG, " %02x", val);
Stefan Reinauer36a22682008-10-29 04:52:57 +000056 if ((i & 0x0f) == 0x0f) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000058 }
59 }
60}
61
Patrick Georgid0835952010-10-05 09:07:10 +000062void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000063{
Antonello Dettori70f5b822016-08-30 22:11:24 +020064 pci_devfn_t dev;
Elyes HAOUAS12df9502016-08-23 21:29:48 +020065 for (dev = PCI_DEV(0, 0, 0);
Stefan Reinauer14e22772010-04-27 06:56:47 +000066 dev <= PCI_DEV(0, 0x1f, 0x7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000067 dev += PCI_DEV(0,0,1)) {
68 uint32_t id;
69 id = pci_read_config32(dev, PCI_VENDOR_ID);
70 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
71 (((id >> 16) & 0xffff) == 0xffff) ||
72 (((id >> 16) & 0xffff) == 0x0000)) {
73 continue;
74 }
75 dump_pci_device(dev);
76 }
77}
78
Patrick Georgid0835952010-10-05 09:07:10 +000079void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000080{
81 unsigned device;
Uwe Hermannd773fd32010-11-20 20:23:08 +000082 device = DIMM0;
Elyes HAOUAS12df9502016-08-23 21:29:48 +020083 while (device <= DIMM3) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000084 int status = 0;
85 int i;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000086 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000087
Elyes HAOUAS12df9502016-08-23 21:29:48 +020088 for (i = 0; (i < 256) ; i++) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000089 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000090 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000091 }
92 status = smbus_read_byte(device, i);
93 if (status < 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000094 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
Stefan Reinauer14e22772010-04-27 06:56:47 +000095 break;
Stefan Reinauer36a22682008-10-29 04:52:57 +000096 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000097 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +000098 }
Uwe Hermannd773fd32010-11-20 20:23:08 +000099 device++;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000100 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000101 }
102}
103
Patrick Georgid0835952010-10-05 09:07:10 +0000104void dump_mem(unsigned start, unsigned end)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000105{
106 unsigned i;
Stefan Reinauer65b72ab2015-01-05 12:59:54 -0800107 printk(BIOS_DEBUG, "dump_mem:");
Elyes HAOUAS12df9502016-08-23 21:29:48 +0200108 for (i=start;i<end;i++) {
109 if ((i & 0xf)==0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000110 printk(BIOS_DEBUG, "\n%08x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000111 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000112 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
Stefan Reinauer36a22682008-10-29 04:52:57 +0000113 }
Stefan Reinauer65b72ab2015-01-05 12:59:54 -0800114 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000115 }