blob: 4804544555bd3144253a3d4f96c522494aaa42e5 [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{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020081 unsigned device;
82 device = DIMM0;
83 while (device <= DIMM3) {
84 int status = 0;
85 int i;
86 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000087
Elyes HAOUAS7db506c2016-10-02 11:56:39 +020088 for (i = 0; (i < 256); i++) {
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020089 if ((i % 16) == 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000090 printk(BIOS_DEBUG, "\n%02x: ", i);
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020091 }
Stefan Reinauer36a22682008-10-29 04:52:57 +000092 status = smbus_read_byte(device, i);
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020093 if (status < 0) {
94 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
95 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{
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +0200106 unsigned i;
Stefan Reinauer65b72ab2015-01-05 12:59:54 -0800107 printk(BIOS_DEBUG, "dump_mem:");
Elyes HAOUAS0a15fe92016-09-17 19:12:27 +0200108 for (i = start; i < end; i++) {
Elyes HAOUAS12df9502016-08-23 21:29:48 +0200109 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));
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +0200113 }
114 printk(BIOS_DEBUG, "\n");
115}