blob: 370131fb513e72937cc40b63db8c9df443f5d8d5 [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 <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.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);
Arthur Heymans70a8e342017-03-09 11:30:23 +010029 dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000030 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);
Arthur Heymans70a8e342017-03-09 11:30:23 +010039 printk(BIOS_DEBUG, " [%04x:%04x]\n", id & 0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000040 }
41}
42
Arthur Heymans70a8e342017-03-09 11:30:23 +010043void dump_pci_device(unsigned int 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;
Arthur Heymans70a8e342017-03-09 11:30:23 +010051 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 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000054 printk(BIOS_DEBUG, " %02x", val);
Arthur Heymans70a8e342017-03-09 11:30:23 +010055 if ((i & 0x0f) == 0x0f)
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000056 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000057 }
58}
59
Patrick Georgid0835952010-10-05 09:07:10 +000060void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000061{
Antonello Dettori70f5b822016-08-30 22:11:24 +020062 pci_devfn_t dev;
Elyes HAOUAS12df9502016-08-23 21:29:48 +020063 for (dev = PCI_DEV(0, 0, 0);
Stefan Reinauer14e22772010-04-27 06:56:47 +000064 dev <= PCI_DEV(0, 0x1f, 0x7);
Arthur Heymans70a8e342017-03-09 11:30:23 +010065 dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000066 uint32_t id;
67 id = pci_read_config32(dev, PCI_VENDOR_ID);
68 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
69 (((id >> 16) & 0xffff) == 0xffff) ||
70 (((id >> 16) & 0xffff) == 0x0000)) {
71 continue;
72 }
73 dump_pci_device(dev);
74 }
75}
76
Patrick Georgid0835952010-10-05 09:07:10 +000077void dump_spd_registers(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000078{
Arthur Heymans70a8e342017-03-09 11:30:23 +010079 unsigned int device;
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020080 device = DIMM0;
81 while (device <= DIMM3) {
82 int status = 0;
83 int i;
84 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000085
Elyes HAOUAS7db506c2016-10-02 11:56:39 +020086 for (i = 0; (i < 256); i++) {
Arthur Heymans70a8e342017-03-09 11:30:23 +010087 if ((i % 16) == 0)
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000088 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000089 status = smbus_read_byte(device, i);
Paul Menzelb45bbb22017-03-24 16:17:16 +010090 if (status < 0) {
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020091 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
92 break;
Paul Menzelb45bbb22017-03-24 16:17:16 +010093 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000094 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +000095 }
Uwe Hermannd773fd32010-11-20 20:23:08 +000096 device++;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000097 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000098 }
99}