soc/intel/common/block/itss: Route PCI INT pin to PIRQ using PIR
[coreboot2.git] / util / inteltool / lpc.c
blob4ce06ae5b9c7bad741878ac63eeaa7dd45338ae1
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 static const io_register_t alderlake_espi_cfg_registers[] = {
61 {0x00, 4, "ESPI_DID_VID"},
62 {0x04, 4, "ESPI_STS_CMD"},
63 {0x08, 4, "ESPI_CC_RID"},
64 {0x2C, 4, "ESPI_SS"},
65 {0x34, 4, "ESPI_CAPP"},
66 {0x80, 4, "ESPI_IOD_IOE"},
67 {0x84, 4, "ESPI_LGIR1"},
68 {0x88, 4, "ESPI_LGIR2"},
69 {0x8C, 4, "ESPI_LGIR3"},
70 {0x90, 4, "ESPI_LGIR4"},
71 {0x94, 4, "ESPI_ULKMC"},
72 {0x98, 4, "ESPI_LGMR"},
73 {0xA0, 4, "ESPI_CS1IORE"},
74 {0xA4, 4, "ESPI_CS1GIR1"},
75 {0xA8, 4, "ESPI_CS1GMR1"},
76 {0xD8, 4, "ESPI_BDE"},
77 {0xDC, 4, "ESPI_BC"},
80 static const io_register_t elkhart_espi_cfg_registers[] = {
81 {0x00, 4, "ESPI_DID_VID"},
82 {0x04, 4, "ESPI_STS_CMD"},
83 {0x08, 4, "ESPI_CC_RID"},
84 {0x0C, 4, "ESPI_BIST_HTYPE_PLT_CLS"},
85 {0x2C, 4, "ESPI_SS"},
86 {0x34, 4, "ESPI_CAPP"},
87 {0x80, 4, "ESPI_IOD_IOE"},
88 {0x84, 4, "ESPI_LGIR1"},
89 {0x88, 4, "ESPI_LGIR2"},
90 {0x8C, 4, "ESPI_LGIR3"},
91 {0x90, 4, "ESPI_LGIR4"},
92 {0x94, 4, "ESPI_ULKMC"},
93 {0xA0, 4, "ESPI_CS1IORE"},
94 {0xA4, 4, "ESPI_CS1GIR1"},
95 {0xA8, 4, "ESPI_CS1GMR1"},
96 {0xD0, 4, "ESPI_FS1"},
97 {0xD4, 4, "ESPI_FS2"},
98 {0xD8, 4, "ESPI_BDE"},
99 {0xDC, 4, "ESPI_BC"},
102 int print_lpc(struct pci_dev *sb, struct pci_access *pacc)
104 size_t i, cfg_registers_size = 0;
105 const io_register_t *cfg_registers;
106 struct pci_dev *dev = NULL;
107 uint32_t bc;
109 printf("\n========== LPC/eSPI =========\n\n");
111 switch (sb->device_id) {
112 case PCI_DEVICE_ID_INTEL_H110:
113 case PCI_DEVICE_ID_INTEL_H170:
114 case PCI_DEVICE_ID_INTEL_Z170:
115 case PCI_DEVICE_ID_INTEL_Q170:
116 case PCI_DEVICE_ID_INTEL_Q150:
117 case PCI_DEVICE_ID_INTEL_B150:
118 case PCI_DEVICE_ID_INTEL_C236:
119 case PCI_DEVICE_ID_INTEL_C232:
120 case PCI_DEVICE_ID_INTEL_QM170:
121 case PCI_DEVICE_ID_INTEL_HM170:
122 case PCI_DEVICE_ID_INTEL_CM236:
123 case PCI_DEVICE_ID_INTEL_HM175:
124 case PCI_DEVICE_ID_INTEL_QM175:
125 case PCI_DEVICE_ID_INTEL_CM238:
126 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_PRE:
127 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_BASE_SKL:
128 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_PREM_SKL:
129 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_PREM_SKL:
130 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_BASE_KBL:
131 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_PREM_KBL:
132 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_PREM_KBL:
133 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_IHDCP_BASE:
134 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_U_IHDCP_PREM:
135 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_Y_IHDCP_PREM:
136 dev = pci_get_dev(pacc, sb->domain, sb->bus, sb->dev, 0);
137 if (!dev) {
138 printf("LPC/eSPI interface not found.\n");
139 return 1;
141 bc = pci_read_long(dev, SUNRISE_LPC_BC);
142 if (bc & (1 << 2)) {
143 printf("Device 0:1f.0 is eSPI (BC.LPC_ESPI=1)\n\n");
144 cfg_registers = sunrise_espi_cfg_registers;
145 cfg_registers_size = ARRAY_SIZE(sunrise_espi_cfg_registers);
147 } else {
148 printf("Device 0:1f.0 is LPC (BC.LPC_ESPI=0)\n\n");
149 cfg_registers = sunrise_lpc_cfg_registers;
150 cfg_registers_size = ARRAY_SIZE(sunrise_lpc_cfg_registers);
152 break;
153 case PCI_DEVICE_ID_INTEL_ADL_N:
154 dev = pci_get_dev(pacc, sb->domain, sb->bus, sb->dev, 0);
155 if (!dev) {
156 printf("LPC/eSPI interface not found.\n");
157 return 1;
159 printf("Device 0:1f.0 is eSPI (BC.LPC_ESPI=1)\n\n");
160 cfg_registers = alderlake_espi_cfg_registers;
161 cfg_registers_size = ARRAY_SIZE(alderlake_espi_cfg_registers);
162 break;
163 case PCI_DEVICE_ID_INTEL_EHL:
164 dev = pci_get_dev(pacc, sb->domain, sb->bus, sb->dev, 0);
165 if (!dev) {
166 printf("LPC/eSPI interface not found.\n");
167 return 1;
169 bc = pci_read_long(dev, SUNRISE_LPC_BC);
170 if (bc & (1 << 2)) {
171 printf("Device 0:1f.0 is eSPI (BC.LPC_ESPI=1)\n\n");
172 cfg_registers = elkhart_espi_cfg_registers;
173 cfg_registers_size = ARRAY_SIZE(elkhart_espi_cfg_registers);
175 } else {
176 printf("Device 0:1f.0 is LPC (BC.LPC_ESPI=0)\n\n");
177 cfg_registers = sunrise_lpc_cfg_registers;
178 cfg_registers_size = ARRAY_SIZE(sunrise_lpc_cfg_registers);
180 break;
181 default:
182 printf("Error: Dumping LPC/eSPI on this southbridge is not (yet) supported.\n");
183 return 1;
186 for (i = 0; i < cfg_registers_size; i++) {
187 switch (cfg_registers[i].size) {
188 case 4:
189 printf("0x%04x: 0x%08x (%s)\n",
190 cfg_registers[i].addr,
191 pci_read_long(dev, cfg_registers[i].addr),
192 cfg_registers[i].name);
193 break;
194 case 2:
195 printf("0x%04x: 0x%04x (%s)\n",
196 cfg_registers[i].addr,
197 pci_read_word(dev, cfg_registers[i].addr),
198 cfg_registers[i].name);
199 break;
200 case 1:
201 printf("0x%04x: 0x%02x (%s)\n",
202 cfg_registers[i].addr,
203 pci_read_byte(dev, cfg_registers[i].addr),
204 cfg_registers[i].name);
205 break;
206 default:
207 printf("Error: register size %d not implemented.\n",
208 cfg_registers[i].size);
209 break;
213 if (dev)
214 pci_free_dev(dev);
216 return 0;