1 /* inteltool - dump all registers on an Intel CPU + chipset based system */
2 /* SPDX-License-Identifier: GPL-2.0-only */
7 #include <commonlib/helpers.h>
10 #define SUNRISE_LPC_BC 0xdc
12 static const io_register_t sunrise_lpc_cfg_registers
[] = {
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"},
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"},
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"},
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"},
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"},
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"},
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
;
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);
138 printf("LPC/eSPI interface not found.\n");
141 bc
= pci_read_long(dev
, SUNRISE_LPC_BC
);
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
);
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
);
153 case PCI_DEVICE_ID_INTEL_ADL_N
:
154 dev
= pci_get_dev(pacc
, sb
->domain
, sb
->bus
, sb
->dev
, 0);
156 printf("LPC/eSPI interface not found.\n");
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
);
163 case PCI_DEVICE_ID_INTEL_EHL
:
164 dev
= pci_get_dev(pacc
, sb
->domain
, sb
->bus
, sb
->dev
, 0);
166 printf("LPC/eSPI interface not found.\n");
169 bc
= pci_read_long(dev
, SUNRISE_LPC_BC
);
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
);
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
);
182 printf("Error: Dumping LPC/eSPI on this southbridge is not (yet) supported.\n");
186 for (i
= 0; i
< cfg_registers_size
; i
++) {
187 switch (cfg_registers
[i
].size
) {
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
);
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
);
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
);
207 printf("Error: register size %d not implemented.\n",
208 cfg_registers
[i
].size
);