Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 2 | |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 3 | #include <spd.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 5 | #include <device/pci_def.h> |
Kyösti Mälkki | 1a1b04e | 2020-01-07 22:34:33 +0200 | [diff] [blame] | 6 | #include <device/smbus_host.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 7 | #include <console/console.h> |
| 8 | #include "i945.h" |
| 9 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 10 | void print_pci_devices(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 11 | { |
Antonello Dettori | 70f5b82 | 2016-08-30 22:11:24 +0200 | [diff] [blame] | 12 | pci_devfn_t dev; |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 13 | for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 14 | 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 Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 21 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff, |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 22 | (dev >> 15) & 0x1f, (dev >> 12) & 7); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 23 | printk(BIOS_DEBUG, " [%04x:%04x]\n", id & 0xffff, id >> 16); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 24 | } |
| 25 | } |
| 26 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 27 | void dump_pci_device(unsigned int dev) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 28 | { |
| 29 | int i; |
| 30 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 31 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, |
| 32 | (dev >> 12) & 7); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 33 | |
Elyes HAOUAS | 12df950 | 2016-08-23 21:29:48 +0200 | [diff] [blame] | 34 | for (i = 0; i <= 255; i++) { |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 35 | unsigned char val; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 36 | if ((i & 0x0f) == 0) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 37 | printk(BIOS_DEBUG, "%02x:", i); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 38 | val = pci_read_config8(dev, i); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 39 | printk(BIOS_DEBUG, " %02x", val); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 40 | if ((i & 0x0f) == 0x0f) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 41 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 45 | void dump_pci_devices(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 46 | { |
Antonello Dettori | 70f5b82 | 2016-08-30 22:11:24 +0200 | [diff] [blame] | 47 | pci_devfn_t dev; |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 48 | for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 49 | 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 Pons | a60b42a | 2021-03-28 14:06:55 +0200 | [diff] [blame] | 60 | void dump_spd_registers(u8 spd_map[4]) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 61 | { |
Angel Pons | a60b42a | 2021-03-28 14:06:55 +0200 | [diff] [blame] | 62 | for (unsigned int d = 0; d < 4; d++) { |
| 63 | const unsigned int device = spd_map[d]; |
| 64 | if (device == 0) |
| 65 | continue; |
| 66 | |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 67 | int status = 0; |
| 68 | int i; |
| 69 | printk(BIOS_DEBUG, "\ndimm %02x", device); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 70 | |
Elyes HAOUAS | 7db506c | 2016-10-02 11:56:39 +0200 | [diff] [blame] | 71 | for (i = 0; (i < 256); i++) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 72 | if ((i % 16) == 0) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 73 | printk(BIOS_DEBUG, "\n%02x: ", i); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 74 | status = smbus_read_byte(device, i); |
Paul Menzel | b45bbb2 | 2017-03-24 16:17:16 +0100 | [diff] [blame] | 75 | if (status < 0) { |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 76 | printk(BIOS_DEBUG, "bad device: %02x\n", -status); |
| 77 | break; |
Paul Menzel | b45bbb2 | 2017-03-24 16:17:16 +0100 | [diff] [blame] | 78 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 79 | printk(BIOS_DEBUG, "%02x ", status); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 80 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 81 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 82 | } |
| 83 | } |