arch/x86: Buildtest clang targets with VBOOT_STARTS_BEFORE_BOOTBLOCK
[coreboot.git] / util / inteltool / lpc.c
blob2d3c91c70452c6c70d5f5677b3b7225879f1952c
1 /* inteltool - dump all registers on an Intel CPU + chipset based system */
2 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <inttypes.h>
7 #include <commonlib/helpers.h>
8 #include "inteltool.h"
10 #define SUNRISE_LPC_BC 0xdc
12 static const io_register_t sunrise_lpc_cfg_registers[] = {
13 {0x00, 4, "ID"},
14 {0x04, 2, "CMD"},
15 {0x06, 2, "STS"},
16 {0x08, 1, "RID"},
17 {0x09, 1, "CC[3]"},
18 {0x0A, 1, "CC[2]"},
19 {0x0B, 1, "CC[1]"},
20 {0x0C, 1, "CC[0]"},
21 {0x0E, 1, "HTYPE"},
22 {0x2C, 4, "SS"},
23 {0x34, 1, "CAPP"},
24 {0x64, 1, "SCNT"},
25 {0x80, 2, "IOD"},
26 {0x82, 2, "IOE"},
27 {0x84, 4, "LGIR1"},
28 {0x88, 4, "LGIR2"},
29 {0x8C, 4, "LGIR3"},
30 {0x90, 4, "LGIR4"},
31 {0x94, 4, "ULKMC"},
32 {0x98, 4, "LGMR"},
33 {0xD0, 2, "FS1"},
34 {0xD4, 2, "FS2"},
35 {0xD8, 2, "BDE"},
36 {0xDC, 1, "BC"},
37 {0xE0, 4, "PCCTL"},
40 static const io_register_t sunrise_espi_cfg_registers[] = {
41 {0x00, 4, "ESPI_DID_VID"},
42 {0x04, 4, "ESPI_STS_CMD"},
43 {0x08, 4, "ESPI_CC_RID"},
44 {0x0C, 4, "ESPI_BIST_HTYPE_PLT_CLS"},
45 {0x2C, 4, "ESPI_SS"},
46 {0x34, 4, "ESPI_CAPP"},
47 {0x80, 4, "ESPI_IOD_IOE"},
48 {0x84, 4, "ESPI_LGIR1"},
49 {0x88, 4, "ESPI_LGIR2"},
50 {0x8C, 4, "ESPI_LGIR3"},
51 {0x90, 4, "ESPI_LGIR4"},
52 {0x94, 4, "ESPI_ULKMC"},
53 {0x98, 4, "ESPI_LGMR"},
54 {0xD0, 4, "ESPI_FS1"},
55 {0xD4, 4, "ESPI_FS2"},
56 {0xD8, 4, "ESPI_BDE"},
57 {0xDC, 4, "ESPI_BC"},
60 int print_lpc(struct pci_dev *sb, struct pci_access *pacc)
62 size_t i, cfg_registers_size = 0;
63 const io_register_t *cfg_registers;
64 struct pci_dev *dev = NULL;
65 uint32_t bc;
67 printf("\n========== LPC/eSPI =========\n\n");
69 switch (sb->device_id) {
70 case PCI_DEVICE_ID_INTEL_H110:
71 case PCI_DEVICE_ID_INTEL_H170:
72 case PCI_DEVICE_ID_INTEL_Z170:
73 case PCI_DEVICE_ID_INTEL_Q170:
74 case PCI_DEVICE_ID_INTEL_Q150:
75 case PCI_DEVICE_ID_INTEL_B150:
76 case PCI_DEVICE_ID_INTEL_C236:
77 case PCI_DEVICE_ID_INTEL_C232:
78 case PCI_DEVICE_ID_INTEL_QM170:
79 case PCI_DEVICE_ID_INTEL_HM170:
80 case PCI_DEVICE_ID_INTEL_CM236:
81 case PCI_DEVICE_ID_INTEL_HM175:
82 case PCI_DEVICE_ID_INTEL_QM175:
83 case PCI_DEVICE_ID_INTEL_CM238:
84 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_PRE:
85 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_BASE_SKL:
86 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_PREM_SKL:
87 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_PREM_SKL:
88 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_BASE_KBL:
89 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_PREM_KBL:
90 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_PREM_KBL:
91 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_IHDCP_BASE:
92 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_IHDCP_PREM:
93 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_IHDCP_PREM:
94 dev = pci_get_dev(pacc, sb->domain, sb->bus, sb->dev, 0);
95 if (!dev) {
96 printf("LPC/eSPI interface not found.\n");
97 return 1;
99 bc = pci_read_long(dev, SUNRISE_LPC_BC);
100 if (bc & (1 << 2)) {
101 printf("Device 0:1f.0 is eSPI (BC.LPC_ESPI=1)\n\n");
102 cfg_registers = sunrise_espi_cfg_registers;
103 cfg_registers_size = ARRAY_SIZE(sunrise_espi_cfg_registers);
105 } else {
106 printf("Device 0:1f.0 is LPC (BC.LPC_ESPI=0)\n\n");
107 cfg_registers = sunrise_lpc_cfg_registers;
108 cfg_registers_size = ARRAY_SIZE(sunrise_lpc_cfg_registers);
110 break;
112 default:
113 printf("Error: Dumping LPC/eSPI on this southbridge is not (yet) supported.\n");
114 return 1;
117 for (i = 0; i < cfg_registers_size; i++) {
118 switch (cfg_registers[i].size) {
119 case 4:
120 printf("0x%04x: 0x%08x (%s)\n",
121 cfg_registers[i].addr,
122 pci_read_long(dev, cfg_registers[i].addr),
123 cfg_registers[i].name);
124 break;
125 case 2:
126 printf("0x%04x: 0x%04x (%s)\n",
127 cfg_registers[i].addr,
128 pci_read_word(dev, cfg_registers[i].addr),
129 cfg_registers[i].name);
130 break;
131 case 1:
132 printf("0x%04x: 0x%02x (%s)\n",
133 cfg_registers[i].addr,
134 pci_read_byte(dev, cfg_registers[i].addr),
135 cfg_registers[i].name);
136 break;
137 default:
138 printf("Error: register size %d not implemented.\n",
139 cfg_registers[i].size);
140 break;
144 if (dev)
145 pci_free_dev(dev);
147 return 0;