blob: 6073f59eed124a69afecdddc6ecbeeb920463f63 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer36a22682008-10-29 04:52:57 +00002
Uwe Hermannd773fd32010-11-20 20:23:08 +00003#include <spd.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Patrick Georgid0835952010-10-05 09:07:10 +00005#include <device/pci_def.h>
Kyösti Mälkki1a1b04e2020-01-07 22:34:33 +02006#include <device/smbus_host.h>
Patrick Georgid0835952010-10-05 09:07:10 +00007#include <console/console.h>
8#include "i945.h"
9
Patrick Georgid0835952010-10-05 09:07:10 +000010void print_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000011{
Antonello Dettori70f5b822016-08-30 22:11:24 +020012 pci_devfn_t dev;
Elyes HAOUAS3dff32c2020-03-30 17:16:51 +020013 for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000014 uint32_t id;
15 id = pci_read_config32(dev, PCI_VENDOR_ID);
16 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
17 (((id >> 16) & 0xffff) == 0xffff) ||
18 (((id >> 16) & 0xffff) == 0x0000)) {
19 continue;
20 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000021 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
Stefan Reinauer36a22682008-10-29 04:52:57 +000022 (dev >> 15) & 0x1f, (dev >> 12) & 7);
Arthur Heymans70a8e342017-03-09 11:30:23 +010023 printk(BIOS_DEBUG, " [%04x:%04x]\n", id & 0xffff, id >> 16);
Stefan Reinauer36a22682008-10-29 04:52:57 +000024 }
25}
26
Arthur Heymans70a8e342017-03-09 11:30:23 +010027void dump_pci_device(unsigned int dev)
Stefan Reinauer36a22682008-10-29 04:52:57 +000028{
29 int i;
30
Elyes HAOUAS3dff32c2020-03-30 17:16:51 +020031 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f,
32 (dev >> 12) & 7);
Stefan Reinauer36a22682008-10-29 04:52:57 +000033
Elyes HAOUAS12df9502016-08-23 21:29:48 +020034 for (i = 0; i <= 255; i++) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000035 unsigned char val;
Arthur Heymans70a8e342017-03-09 11:30:23 +010036 if ((i & 0x0f) == 0)
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000037 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000038 val = pci_read_config8(dev, i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000039 printk(BIOS_DEBUG, " %02x", val);
Arthur Heymans70a8e342017-03-09 11:30:23 +010040 if ((i & 0x0f) == 0x0f)
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000041 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000042 }
43}
44
Patrick Georgid0835952010-10-05 09:07:10 +000045void dump_pci_devices(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000046{
Antonello Dettori70f5b822016-08-30 22:11:24 +020047 pci_devfn_t dev;
Elyes HAOUAS3dff32c2020-03-30 17:16:51 +020048 for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauer36a22682008-10-29 04:52:57 +000049 uint32_t id;
50 id = pci_read_config32(dev, PCI_VENDOR_ID);
51 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
52 (((id >> 16) & 0xffff) == 0xffff) ||
53 (((id >> 16) & 0xffff) == 0x0000)) {
54 continue;
55 }
56 dump_pci_device(dev);
57 }
58}
59
Angel Ponsa60b42a2021-03-28 14:06:55 +020060void dump_spd_registers(u8 spd_map[4])
Stefan Reinauer36a22682008-10-29 04:52:57 +000061{
Angel Ponsa60b42a2021-03-28 14:06:55 +020062 for (unsigned int d = 0; d < 4; d++) {
63 const unsigned int device = spd_map[d];
64 if (device == 0)
65 continue;
66
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020067 int status = 0;
68 int i;
69 printk(BIOS_DEBUG, "\ndimm %02x", device);
Stefan Reinauer14e22772010-04-27 06:56:47 +000070
Elyes HAOUAS7db506c2016-10-02 11:56:39 +020071 for (i = 0; (i < 256); i++) {
Arthur Heymans70a8e342017-03-09 11:30:23 +010072 if ((i % 16) == 0)
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000073 printk(BIOS_DEBUG, "\n%02x: ", i);
Stefan Reinauer36a22682008-10-29 04:52:57 +000074 status = smbus_read_byte(device, i);
Paul Menzelb45bbb22017-03-24 16:17:16 +010075 if (status < 0) {
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +020076 printk(BIOS_DEBUG, "bad device: %02x\n", -status);
77 break;
Paul Menzelb45bbb22017-03-24 16:17:16 +010078 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000079 printk(BIOS_DEBUG, "%02x ", status);
Stefan Reinauer36a22682008-10-29 04:52:57 +000080 }
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000081 printk(BIOS_DEBUG, "\n");
Stefan Reinauer36a22682008-10-29 04:52:57 +000082 }
83}