blob: 5779a96fb179229c0e3e288170951df013a51b27 [file] [log] [blame]
David Hendricksce6b2fa2011-07-11 22:12:43 -07001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (c) 2010 Matthias Wenzel <bios at mazzoo dot de>
5 * Copyright (c) 2011 Stefan Tauner
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
David Hendricksce6b2fa2011-07-11 22:12:43 -070016 */
17
David Hendricksce6b2fa2011-07-11 22:12:43 -070018#if defined(__i386__) || defined(__x86_64__)
19
stefanct1fc3a732011-09-15 23:52:55 +000020#include "ich_descriptors.h"
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070021
22#ifdef ICH_DESCRIPTORS_FROM_DUMP
23
24#include <stdio.h>
Edward O'Callaghan568cd262020-05-26 23:10:45 +100025#include <string.h>
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070026#define print(t, ...) printf(__VA_ARGS__)
27#define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a
28/* The upper map is located in the word before the 256B-long OEM section at the
29 * end of the 4kB-long flash descriptor.
30 */
31#define UPPER_MAP_OFFSET (4096 - 256 - 4)
32#define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0)
33
34#else /* ICH_DESCRIPTORS_FROM_DUMP */
35
David Hendricksce6b2fa2011-07-11 22:12:43 -070036#include "flash.h" /* for msg_* */
stefanct1fc3a732011-09-15 23:52:55 +000037#include "programmer.h"
David Hendricksce6b2fa2011-07-11 22:12:43 -070038
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070039#endif /* ICH_DESCRIPTORS_FROM_DUMP */
Edward O'Callaghane7efd052020-07-03 14:57:28 +100040ssize_t ich_number_of_regions(const enum ich_chipset cs, const struct ich_desc_content *const cont)
41{
42 switch (cs) {
43 case CHIPSET_APOLLO_LAKE:
44 return 6;
45 case CHIPSET_C620_SERIES_LEWISBURG:
46 case CHIPSET_300_SERIES_CANNON_POINT:
47 return 16;
48 case CHIPSET_100_SERIES_SUNRISE_POINT:
49 return 10;
50 case CHIPSET_9_SERIES_WILDCAT_POINT_LP:
51 case CHIPSET_9_SERIES_WILDCAT_POINT:
52 case CHIPSET_8_SERIES_LYNX_POINT_LP:
53 case CHIPSET_8_SERIES_LYNX_POINT:
54 case CHIPSET_8_SERIES_WELLSBURG:
55 if (cont->NR <= 6)
56 return cont->NR + 1;
57 else
58 return -1;
59 default:
60 if (cont->NR <= 4)
61 return cont->NR + 1;
62 else
63 return -1;
64 }
65}
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070066
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +100067ssize_t ich_number_of_masters(const enum ich_chipset cs, const struct ich_desc_content *const cont)
68{
69 switch (cs) {
70 case CHIPSET_C620_SERIES_LEWISBURG:
71 case CHIPSET_APOLLO_LAKE:
72 if (cont->NM <= MAX_NUM_MASTERS)
73 return cont->NM;
74 break;
75 default:
76 if (cont->NM < MAX_NUM_MASTERS)
77 return cont->NM + 1;
78 }
79
80 return -1;
81}
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070082
Edward O'Callaghand757b422020-05-26 21:22:12 +100083void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl)
David Hendricksce6b2fa2011-07-11 22:12:43 -070084{
stefanct1fc3a732011-09-15 23:52:55 +000085 print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF);
86 print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF);
87 print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF);
88 print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF);
Edward O'Callaghand757b422020-05-26 21:22:12 +100089 print(verbosity, "EO=0x%x", (reg_val & VSCC_EO) >> VSCC_EO_OFF);
90 if (print_vcl)
91 print(verbosity, ", VCL=%d", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF);
92 print(verbosity, "\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -070093}
94
stefanct1fc3a732011-09-15 23:52:55 +000095#define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0)
96#define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0)
97#define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0)
98#define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0)
99#define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0)
100
101void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700102{
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000103 prettyprint_ich_descriptor_content(cs, &desc->content);
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000104 prettyprint_ich_descriptor_component(cs, desc);
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000105 prettyprint_ich_descriptor_region(cs, desc);
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000106 prettyprint_ich_descriptor_master(cs, desc);
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700107#ifdef ICH_DESCRIPTORS_FROM_DUMP
108 if (cs >= CHIPSET_ICH8) {
109 prettyprint_ich_descriptor_upper_map(&desc->upper);
110 prettyprint_ich_descriptor_straps(cs, desc);
111 }
112#endif /* ICH_DESCRIPTORS_FROM_DUMP */
David Hendricksce6b2fa2011-07-11 22:12:43 -0700113}
114
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000115void prettyprint_ich_descriptor_content(enum ich_chipset cs, const struct ich_desc_content *cont)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700116{
stefanct1fc3a732011-09-15 23:52:55 +0000117 msg_pdbg2("=== Content Section ===\n");
118 msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG);
119 msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0);
120 msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1);
121 msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2);
122 msg_pdbg2("\n");
123
124 msg_pdbg2("--- Details ---\n");
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000125 msg_pdbg2("NR (Number of Regions): %5zd\n", ich_number_of_regions(cs, cont));
Edward O'Callaghan86bd8da2020-07-09 18:17:42 +1000126 msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n", getFRBA(cont));
127 msg_pdbg2("NC (Number of Components): %5d\n", cont->NC + 1);
128 msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n", getFCBA(cont));
129 msg_pdbg2("ISL (ICH/PCH/SoC Strap Length): %5d\n", cont->ISL);
130 msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH/SoC Strap Base Addr): 0x%03x\n", getFISBA(cont));
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000131 msg_pdbg2("NM (Number of Masters): %5zd\n", ich_number_of_masters(cs, cont));
Edward O'Callaghan86bd8da2020-07-09 18:17:42 +1000132 msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n", getFMBA(cont));
133 msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n", cont->MSL);
134 msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n", getFMSBA(cont));
stefanct1fc3a732011-09-15 23:52:55 +0000135 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700136}
137
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000138static const char *pprint_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700139{
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000140 if (idx > 1) {
141 msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
142 return NULL;
143 }
144
145 if (desc->content.NC == 0 && idx > 0)
146 return "unused";
147
148 static const char * const size_str[] = {
149 "512 kB", /* 0000 */
150 "1 MB", /* 0001 */
151 "2 MB", /* 0010 */
152 "4 MB", /* 0011 */
153 "8 MB", /* 0100 */
154 "16 MB", /* 0101 */ /* Maximum up to Lynx Point (excl.) */
155 "32 MB", /* 0110 */
156 "64 MB", /* 0111 */
David Hendricksce6b2fa2011-07-11 22:12:43 -0700157 };
158
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000159 switch (cs) {
160 case CHIPSET_ICH8:
161 case CHIPSET_ICH9:
162 case CHIPSET_ICH10:
163 case CHIPSET_5_SERIES_IBEX_PEAK:
164 case CHIPSET_6_SERIES_COUGAR_POINT:
165 case CHIPSET_7_SERIES_PANTHER_POINT:
166 case CHIPSET_BAYTRAIL: {
167 uint8_t size_enc;
168 if (idx == 0) {
169 size_enc = desc->component.dens_old.comp1_density;
170 } else {
171 size_enc = desc->component.dens_old.comp2_density;
172 }
173 if (size_enc > 5)
174 return "reserved";
175 return size_str[size_enc];
176 }
177 case CHIPSET_8_SERIES_LYNX_POINT:
178 case CHIPSET_8_SERIES_LYNX_POINT_LP:
179 case CHIPSET_8_SERIES_WELLSBURG:
180 case CHIPSET_9_SERIES_WILDCAT_POINT:
181 case CHIPSET_9_SERIES_WILDCAT_POINT_LP:
182 case CHIPSET_100_SERIES_SUNRISE_POINT:
183 case CHIPSET_C620_SERIES_LEWISBURG:
184 case CHIPSET_300_SERIES_CANNON_POINT:
185 case CHIPSET_APOLLO_LAKE: {
186 uint8_t size_enc;
187 if (idx == 0) {
188 size_enc = desc->component.dens_new.comp1_density;
189 } else {
190 size_enc = desc->component.dens_new.comp2_density;
191 }
192 if (size_enc > 7)
193 return "reserved";
194 return size_str[size_enc];
195 }
196 case CHIPSET_ICH_UNKNOWN:
197 default:
198 return "unknown";
199 }
200}
201
202static const char *pprint_freq(enum ich_chipset cs, uint8_t value)
203{
204 static const char *const freq_str[3][8] = { {
205 "20 MHz",
206 "33 MHz",
207 "reserved",
208 "reserved",
209 "50 MHz", /* New since Ibex Peak */
210 "reserved",
211 "reserved",
212 "reserved"
213 }, {
214 "reserved",
215 "reserved",
216 "48 MHz",
217 "reserved",
218 "30 MHz",
219 "reserved",
220 "17 MHz",
221 "reserved"
222 }, {
223 "reserved",
224 "50 MHz",
225 "40 MHz",
226 "reserved",
227 "25 MHz",
228 "reserved",
229 "14 MHz / 17 MHz",
230 "reserved"
231 } };
232
233 switch (cs) {
234 case CHIPSET_ICH8:
235 case CHIPSET_ICH9:
236 case CHIPSET_ICH10:
237 if (value > 1)
238 return "reserved";
239 /* Fall through. */
240 case CHIPSET_5_SERIES_IBEX_PEAK:
241 case CHIPSET_6_SERIES_COUGAR_POINT:
242 case CHIPSET_7_SERIES_PANTHER_POINT:
243 case CHIPSET_8_SERIES_LYNX_POINT:
244 case CHIPSET_BAYTRAIL:
245 case CHIPSET_8_SERIES_LYNX_POINT_LP:
246 case CHIPSET_8_SERIES_WELLSBURG:
247 case CHIPSET_9_SERIES_WILDCAT_POINT:
248 case CHIPSET_9_SERIES_WILDCAT_POINT_LP:
249 return freq_str[0][value];
250 case CHIPSET_100_SERIES_SUNRISE_POINT:
251 case CHIPSET_C620_SERIES_LEWISBURG:
252 case CHIPSET_300_SERIES_CANNON_POINT:
253 return freq_str[1][value];
254 case CHIPSET_APOLLO_LAKE:
255 return freq_str[2][value];
256 case CHIPSET_ICH_UNKNOWN:
257 default:
258 return "unknown";
259 }
260}
261
262void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc)
263{
Edward O'Callaghan224e6ba2020-07-09 18:19:36 +1000264 bool has_flill1;
265
266 switch (cs) {
267 case CHIPSET_100_SERIES_SUNRISE_POINT:
268 case CHIPSET_C620_SERIES_LEWISBURG:
269 case CHIPSET_300_SERIES_CANNON_POINT:
270 case CHIPSET_APOLLO_LAKE:
271 has_flill1 = true;
272 break;
273 default:
274 has_flill1 = false;
275 break;
276 }
277
stefanct1fc3a732011-09-15 23:52:55 +0000278 msg_pdbg2("=== Component Section ===\n");
279 msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP);
280 msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL );
Edward O'Callaghan224e6ba2020-07-09 18:19:36 +1000281 if (has_flill1)
282 msg_pdbg2("FLILL1 0x%08x\n", desc->component.FLILL1);
stefanct1fc3a732011-09-15 23:52:55 +0000283 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700284
stefanct1fc3a732011-09-15 23:52:55 +0000285 msg_pdbg2("--- Details ---\n");
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000286 msg_pdbg2("Component 1 density: %s\n", pprint_density(cs, desc, 0));
stefanct1fc3a732011-09-15 23:52:55 +0000287 if (desc->content.NC)
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000288 msg_pdbg2("Component 2 density: %s\n", pprint_density(cs, desc, 1));
David Hendricksce6b2fa2011-07-11 22:12:43 -0700289 else
stefanct1fc3a732011-09-15 23:52:55 +0000290 msg_pdbg2("Component 2 is not used.\n");
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000291 msg_pdbg2("Read Clock Frequency: %s\n", pprint_freq(cs, desc->component.modes.freq_read));
292 msg_pdbg2("Read ID and Status Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_read_id));
293 msg_pdbg2("Write and Erase Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_write));
294 msg_pdbg2("Fast Read is %ssupported.\n", desc->component.modes.fastread ? "" : "not ");
295 if (desc->component.modes.fastread)
stefanct1fc3a732011-09-15 23:52:55 +0000296 msg_pdbg2("Fast Read Clock Frequency: %s\n",
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000297 pprint_freq(cs, desc->component.modes.freq_fastread));
298 if (cs > CHIPSET_6_SERIES_COUGAR_POINT)
299 msg_pdbg2("Dual Output Fast Read Support: %sabled\n",
300 desc->component.modes.dual_output ? "dis" : "en");
301
302 int has_forbidden_opcode = 0;
303 if (desc->component.FLILL != 0) {
304 has_forbidden_opcode = 1;
stefanct1fc3a732011-09-15 23:52:55 +0000305 msg_pdbg2("Invalid instruction 0: 0x%02x\n",
306 desc->component.invalid_instr0);
307 msg_pdbg2("Invalid instruction 1: 0x%02x\n",
308 desc->component.invalid_instr1);
309 msg_pdbg2("Invalid instruction 2: 0x%02x\n",
310 desc->component.invalid_instr2);
311 msg_pdbg2("Invalid instruction 3: 0x%02x\n",
312 desc->component.invalid_instr3);
313 }
Edward O'Callaghan224e6ba2020-07-09 18:19:36 +1000314 if (has_flill1) {
315 if (desc->component.FLILL1 != 0) {
316 has_forbidden_opcode = 1;
317 msg_pdbg2("Invalid instruction 4: 0x%02x\n",
318 desc->component.invalid_instr4);
319 msg_pdbg2("Invalid instruction 5: 0x%02x\n",
320 desc->component.invalid_instr5);
321 msg_pdbg2("Invalid instruction 6: 0x%02x\n",
322 desc->component.invalid_instr6);
323 msg_pdbg2("Invalid instruction 7: 0x%02x\n",
324 desc->component.invalid_instr7);
325 }
326 }
Edward O'Callaghan87595e12020-07-03 13:09:18 +1000327 if (!has_forbidden_opcode)
328 msg_pdbg2("No forbidden opcodes.\n");
329
stefanct1fc3a732011-09-15 23:52:55 +0000330 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700331}
332
stefanct1fc3a732011-09-15 23:52:55 +0000333static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700334{
Edward O'Callaghan133ef002020-05-26 23:15:56 +1000335 static const char *const region_names[] = {
336 "Descr.", "BIOS", "ME", "GbE", "Platf.", "DevExp", "BIOS2", "unknown",
337 "EC/BMC", "unknown", "IE", "10GbE", "unknown", "unknown", "unknown", "unknown"
David Hendricksce6b2fa2011-07-11 22:12:43 -0700338 };
Edward O'Callaghan133ef002020-05-26 23:15:56 +1000339 if (i >= ARRAY_SIZE(region_names)) {
stefanct1fc3a732011-09-15 23:52:55 +0000340 msg_pdbg2("%s: region index too high.\n", __func__);
341 return;
David Hendricksce6b2fa2011-07-11 22:12:43 -0700342 }
stefanct1fc3a732011-09-15 23:52:55 +0000343 uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]);
344 uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]);
Edward O'Callaghan133ef002020-05-26 23:15:56 +1000345 msg_pdbg2("Region %d (%-7s) ", i, region_names[i]);
stefanct1fc3a732011-09-15 23:52:55 +0000346 if (base > limit)
347 msg_pdbg2("is unused.\n");
348 else
Edward O'Callaghan133ef002020-05-26 23:15:56 +1000349 msg_pdbg2("0x%08x - 0x%08x\n", base, limit);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700350}
351
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000352void prettyprint_ich_descriptor_region(const enum ich_chipset cs, const struct ich_descriptors *const desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700353{
stefanct1fc3a732011-09-15 23:52:55 +0000354 uint8_t i;
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000355 const ssize_t nr = ich_number_of_regions(cs, &desc->content);
stefanct1fc3a732011-09-15 23:52:55 +0000356 msg_pdbg2("=== Region Section ===\n");
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000357 if (nr < 0) {
stefanct1fc3a732011-09-15 23:52:55 +0000358 msg_pdbg2("%s: number of regions too high (%d).\n", __func__,
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000359 desc->content.NR + 1);
stefanct1fc3a732011-09-15 23:52:55 +0000360 return;
361 }
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000362 for (i = 0; i < nr; i++)
stefanct1fc3a732011-09-15 23:52:55 +0000363 msg_pdbg2("FLREG%d 0x%08x\n", i, desc->region.FLREGs[i]);
364 msg_pdbg2("\n");
365
366 msg_pdbg2("--- Details ---\n");
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000367 for (i = 0; i < nr; i++)
stefanct1fc3a732011-09-15 23:52:55 +0000368 pprint_freg(&desc->region, i);
369 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700370}
371
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000372void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct ich_descriptors *const desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700373{
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000374 ssize_t i;
375 const ssize_t nm = ich_number_of_masters(cs, &desc->content);
stefanct1fc3a732011-09-15 23:52:55 +0000376 msg_pdbg2("=== Master Section ===\n");
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000377 if (nm < 0) {
378 msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
379 desc->content.NM + 1);
380 return;
381 }
382 for (i = 0; i < nm; i++)
383 msg_pdbg2("FLMSTR%zd 0x%08x\n", i + 1, desc->master.FLMSTRs[i]);
stefanct1fc3a732011-09-15 23:52:55 +0000384 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700385
stefanct1fc3a732011-09-15 23:52:55 +0000386 msg_pdbg2("--- Details ---\n");
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000387 if (cs == CHIPSET_100_SERIES_SUNRISE_POINT ||
388 cs == CHIPSET_300_SERIES_CANNON_POINT) {
389 const char *const master_names[] = {
390 "BIOS", "ME", "GbE", "unknown", "EC",
391 };
392 if (nm >= (ssize_t)ARRAY_SIZE(master_names)) {
393 msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
394 desc->content.NM + 1);
395 return;
396 }
David Hendricksce6b2fa2011-07-11 22:12:43 -0700397
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000398 size_t num_regions;
399 msg_pdbg2(" FD BIOS ME GbE Pltf Reg5 Reg6 Reg7 EC Reg9");
400 if (cs == CHIPSET_100_SERIES_SUNRISE_POINT) {
401 num_regions = 10;
402 msg_pdbg2("\n");
403 } else {
404 num_regions = 16;
405 msg_pdbg2(" RegA RegB RegC RegD RegE RegF\n");
406 }
407 for (i = 0; i < nm; i++) {
408 size_t j;
409 msg_pdbg2("%-4s", master_names[i]);
410 for (j = 0; j < (size_t)MIN(num_regions, 12); j++)
411 msg_pdbg2(" %c%c ",
412 desc->master.mstr[i].read & (1 << j) ? 'r' : ' ',
413 desc->master.mstr[i].write & (1 << j) ? 'w' : ' ');
414 for (; j < num_regions; j++)
415 msg_pdbg2(" %c%c ",
416 desc->master.mstr[i].ext_read & (1 << (j - 12)) ? 'r' : ' ',
417 desc->master.mstr[i].ext_write & (1 << (j - 12)) ? 'w' : ' ');
418 msg_pdbg2("\n");
419 }
420 } else if (cs == CHIPSET_C620_SERIES_LEWISBURG) {
421 const char *const master_names[] = {
422 "BIOS", "ME", "GbE", "DE", "BMC", "IE",
423 };
424 /* NM starts at 1 instead of 0 for LBG */
425 if (nm > (ssize_t)ARRAY_SIZE(master_names)) {
426 msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
427 desc->content.NM);
428 return;
429 }
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700430
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000431 msg_pdbg2("%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",
432 " ", /* width of master name (4 chars minimum) */
433 " FD ", " BIOS", " ME ", " GbE ", " Pltf",
434 " DE ", "BIOS2", " Reg7", " BMC ", " DE2 ",
435 " IE ", "10GbE", "OpROM", "Reg13", "Reg14",
436 "Reg15");
437 for (i = 0; i < nm; i++) {
438 size_t j;
439 msg_pdbg2("%-4s", master_names[i]);
440 for (j = 0; j < 16; j++)
441 msg_pdbg2(" %c%c ",
442 desc->master.mstr[i].read & (1 << j) ? 'r' : ' ',
443 desc->master.mstr[i].write & (1 << j) ? 'w' : ' ');
444 msg_pdbg2("\n");
445 }
446 } else if (cs == CHIPSET_APOLLO_LAKE) {
447 const char *const master_names[] = { "BIOS", "TXE", };
448 if (nm > (ssize_t)ARRAY_SIZE(master_names)) {
449 msg_pdbg2("%s: number of masters too high (%d).\n", __func__, desc->content.NM);
450 return;
451 }
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700452
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000453 msg_pdbg2(" FD IFWI TXE n/a Platf DevExp\n");
454 for (i = 0; i < nm; i++) {
455 ssize_t j;
456 msg_pdbg2("%-4s", master_names[i]);
457 for (j = 0; j < ich_number_of_regions(cs, &desc->content); j++)
458 msg_pdbg2(" %c%c ",
459 desc->master.mstr[i].read & (1 << j) ? 'r' : ' ',
460 desc->master.mstr[i].write & (1 << j) ? 'w' : ' ');
461 msg_pdbg2("\n");
462 }
463 } else {
464 const struct ich_desc_master *const mstr = &desc->master;
465 msg_pdbg2(" Descr. BIOS ME GbE Platf.\n");
466 msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n",
467 (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
468 (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
469 (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
470 (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
471 (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ');
472 msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n",
473 (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
474 (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
475 (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
476 (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
477 (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ');
478 msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n",
479 (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
480 (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
481 (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
482 (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
483 (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ');
484 }
485 msg_pdbg2("\n");
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700486}
487
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700488#ifdef ICH_DESCRIPTORS_FROM_DUMP
489
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000490static void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700491{
492 static const char * const str_GPIO12[4] = {
493 "GPIO12",
494 "LAN PHY Power Control Function (Native Output)",
495 "GLAN_DOCK# (Native Input)",
496 "invalid configuration",
497 };
498
499 msg_pdbg2("--- MCH details ---\n");
500 msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en");
501 msg_pdbg2("\n");
502
503 msg_pdbg2("--- ICH details ---\n");
504 msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD);
505 msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2);
506 msg_pdbg2("ME SMBus Controller is connected to the %s.\n",
507 desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins");
508 msg_pdbg2("SPI CS1 is used for %s.\n",
509 desc->south.ich8.SPICS1_LANPHYPC_SEL ?
510 "LAN PHY Power Control Function" :
511 "SPI Chip Select");
512 msg_pdbg2("GPIO12 is used as %s.\n",
513 str_GPIO12[desc->south.ich8.GPIO12_SEL]);
514 msg_pdbg2("PCIe Port 6 is used for %s.\n",
515 desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express");
516 msg_pdbg2("%sn BMC Mode: "
517 "Intel AMT SMBus Controller 1 is connected to %s.\n",
518 desc->south.ich8.BMCMODE ? "I" : "Not i",
519 desc->south.ich8.BMCMODE ? "SMLink" : "SMBus");
520 msg_pdbg2("TCO is in %s Mode.\n",
521 desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible");
522 msg_pdbg2("ME A is %sabled.\n",
523 desc->south.ich8.ME_DISABLE ? "dis" : "en");
524 msg_pdbg2("\n");
525}
526
527static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off)
528{
529 msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1);
530
531 off *= 4;
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000532 switch (conf){
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700533 case 0:
534 msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off);
535 break;
536 case 1:
537 msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), "
538 "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off);
539 break;
540 case 2:
541 msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports "
542 "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off);
543 break;
544 case 3:
545 msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)",
546 1+off, 2+off, 4+off);
547 break;
548 }
549 msg_pdbg2("\n");
550}
551
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000552static void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700553{
554 /* PCHSTRP4 */
555 msg_pdbg2("Intel PHY is %s.\n",
556 (s->ibex.PHYCON == 2) ? "connected" :
557 (s->ibex.PHYCON == 0) ? "disconnected" : "reserved");
558 msg_pdbg2("GbE MAC SMBus address is %sabled.\n",
559 s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis");
560 msg_pdbg2("GbE MAC SMBus address: 0x%02x\n",
561 s->ibex.GBEMAC_SMBUS_ADDR);
562 msg_pdbg2("GbE PHY SMBus address: 0x%02x\n",
563 s->ibex.GBEPHY_SMBUS_ADDR);
564
565 /* PCHSTRP5 */
566 /* PCHSTRP6 */
567 /* PCHSTRP7 */
568 msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n",
569 s->ibex.MESMA2UDID_VENDOR);
570 msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n",
571 s->ibex.MESMA2UDID_VENDOR);
572
573 /* PCHSTRP8 */
574}
575
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000576static void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700577{
578 /* PCHSTRP11 */
579 msg_pdbg2("SMLink1 GP Address is %sabled.\n",
580 s->ibex.SML1GPAEN ? "en" : "dis");
581 msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n",
582 s->ibex.SML1GPA);
583 msg_pdbg2("SMLink1 I2C Target address is %sabled.\n",
584 s->ibex.SML1I2CAEN ? "en" : "dis");
585 msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n",
586 s->ibex.SML1I2CA);
587
588 /* PCHSTRP12 */
589 /* PCHSTRP13 */
590}
591
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000592static void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700593{
Patrick Georgi3a5bcb92017-04-11 20:45:07 +0200594 static const uint8_t dec_t209min[4] = {
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700595 100,
596 50,
597 5,
598 1
599 };
600
601 msg_pdbg2("--- PCH ---\n");
602
603 /* PCHSTRP0 */
604 msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2);
605 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
606 s->ibex.SMB_EN ? "en" : "dis");
607 msg_pdbg2("SMLink0 segment is %sabled.\n",
608 s->ibex.SML0_EN ? "en" : "dis");
609 msg_pdbg2("SMLink1 segment is %sabled.\n",
610 s->ibex.SML1_EN ? "en" : "dis");
611 msg_pdbg2("SMLink1 Frequency: %s\n",
612 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
613 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
614 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
615 msg_pdbg2("SMLink0 Frequency: %s\n",
616 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
617 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
618 "LAN_PHY_PWR_CTRL" : "general purpose output");
619 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1);
620 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
621 s->ibex.DMI_REQID_DIS ? "en" : "dis");
622 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
623 1 << (6 + s->ibex.BBBS));
624
625 /* PCHSTRP1 */
626 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
627
628 /* PCHSTRP2 */
629 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
630 s->ibex.MESMASDEN ? "en" : "dis");
631 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
632 s->ibex.MESMASDA);
633 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
634 s->ibex.MESMI2CEN ? "en" : "dis");
635 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
636 s->ibex.MESMI2CA);
637
638 /* PCHSTRP3 */
639 prettyprint_ich_descriptor_pchstraps45678_56(s);
640 /* PCHSTRP9 */
641 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
642 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
643 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
644 s->ibex.PCIELR1 ? "" : "not ");
645 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
646 s->ibex.PCIELR2 ? "" : "not ");
647 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
648 s->ibex.DMILR ? "" : "not ");
649 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
650 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
651 s->ibex.PHY_PCIE_EN ? "en" : "dis");
652
653 /* PCHSTRP10 */
654 msg_pdbg2("Management Engine will boot from %sflash.\n",
655 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
656 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5);
657 msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n",
658 s->ibex.VE_EN ? "en" : "dis");
659 msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n",
660 s->ibex.MMDDE ? "en" : "dis");
661 msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n",
662 s->ibex.MMADDR);
663 msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7);
664 msg_pdbg2("Integrated Clocking Configuration is %d.\n",
665 (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL);
666 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
667 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
668
669 prettyprint_ich_descriptor_pchstraps111213_56(s);
670
671 /* PCHSTRP14 */
672 msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n",
673 s->ibex.VE_EN2 ? "en" : "dis");
674 msg_pdbg2("Virtualization Engine will boot from %sflash.\n",
675 s->ibex.VE_BOOT_FLASH ? "" : "ROM, then ");
676 msg_pdbg2("Braidwood SSD functionality is %sabled.\n",
677 s->ibex.BW_SSD ? "en" : "dis");
678 msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n",
679 s->ibex.NVMHCI_EN ? "en" : "dis");
680
681 /* PCHSTRP15 */
682 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6);
683 msg_pdbg2("Integrated wired LAN Solution is %sabled.\n",
684 s->ibex.IWL_EN ? "en" : "dis");
685 msg_pdbg2("t209 min Timing: %d ms\n",
686 dec_t209min[s->ibex.t209min]);
687 msg_pdbg2("\n");
688}
689
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000690static void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700691{
692 msg_pdbg2("--- PCH ---\n");
693
694 /* PCHSTRP0 */
695 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1);
696 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
697 s->ibex.SMB_EN ? "en" : "dis");
698 msg_pdbg2("SMLink0 segment is %sabled.\n",
699 s->ibex.SML0_EN ? "en" : "dis");
700 msg_pdbg2("SMLink1 segment is %sabled.\n",
701 s->ibex.SML1_EN ? "en" : "dis");
702 msg_pdbg2("SMLink1 Frequency: %s\n",
703 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
704 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
705 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
706 msg_pdbg2("SMLink0 Frequency: %s\n",
707 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
708 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
709 "LAN_PHY_PWR_CTRL" : "general purpose output");
710 msg_pdbg2("LinkSec is %sabled.\n",
711 s->cougar.LINKSEC_DIS ? "en" : "dis");
712 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
713 s->ibex.DMI_REQID_DIS ? "en" : "dis");
714 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
715 1 << (6 + s->ibex.BBBS));
716
717 /* PCHSTRP1 */
718 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
719 msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2);
720
721 /* PCHSTRP2 */
722 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
723 s->ibex.MESMASDEN ? "en" : "dis");
724 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
725 s->ibex.MESMASDA);
726 msg_pdbg2("ME SMBus MCTP Address is %sabled.\n",
727 s->cougar.MESMMCTPAEN ? "en" : "dis");
728 msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n",
729 s->cougar.MESMMCTPA);
730 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
731 s->ibex.MESMI2CEN ? "en" : "dis");
732 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
733 s->ibex.MESMI2CA);
734
735 /* PCHSTRP3 */
736 prettyprint_ich_descriptor_pchstraps45678_56(s);
737 /* PCHSTRP9 */
738 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
739 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
740 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
741 s->ibex.PCIELR1 ? "" : "not ");
742 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
743 s->ibex.PCIELR2 ? "" : "not ");
744 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
745 s->ibex.DMILR ? "" : "not ");
746 msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n",
747 s->cougar.MDSMBE_EN ? "en" : "dis");
748 msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n",
749 s->cougar.MDSMBE_ADD);
750 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
751 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
752 s->ibex.PHY_PCIE_EN ? "en" : "dis");
753 msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n",
754 s->cougar.SUB_DECODE_EN ? "en" : "dis");
755 msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ?
756 "PCHHOT#" : "SML1ALERT#");
757
758 /* PCHSTRP10 */
759 msg_pdbg2("Management Engine will boot from %sflash.\n",
760 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
761
762 msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n",
763 s->cougar.MDSMBE_EN ? "en" : "dis");
764 msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n",
765 s->cougar.MDSMBE_ADD);
766
767 msg_pdbg2("Integrated Clocking Configuration used: %d\n",
768 s->cougar.ICC_SEL);
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000769 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a reset.\n",
770 s->ibex.MER_CL1 ? "" : "not ");
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700771 msg_pdbg2("ICC Profile is selected by %s.\n",
772 s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
773 msg_pdbg2("Deep SX is %ssupported on the platform.\n",
774 s->cougar.Deep_SX_EN ? "not " : "");
775 msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n",
776 s->cougar.ME_DBG_LAN ? "en" : "dis");
777
778 prettyprint_ich_descriptor_pchstraps111213_56(s);
779
780 /* PCHSTRP14 */
781 /* PCHSTRP15 */
782 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6);
783 msg_pdbg2("Integrated wired LAN is %sabled.\n",
784 s->cougar.IWL_EN ? "en" : "dis");
785 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
786 msg_pdbg2("SMLink1 provides temperature from %s.\n",
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000787 s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and DIMMs");
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700788 msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
789 "general purpose output" : "SLP_LAN#");
790
791 /* PCHSTRP16 */
792 /* PCHSTRP17 */
793 msg_pdbg2("Integrated Clock: %s Clock Mode\n",
794 s->cougar.ICML ? "Buffered Through" : "Full Integrated");
795 msg_pdbg2("\n");
796}
797
798void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc)
799{
Edward O'Callaghanc172e172020-05-26 23:19:02 +1000800 unsigned int i, max_count;
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700801 msg_pdbg2("=== Softstraps ===\n");
802
Edward O'Callaghanc172e172020-05-26 23:19:02 +1000803 max_count = MIN(ARRAY_SIZE(desc->north.STRPs), desc->content.MSL);
804 if (max_count < desc->content.MSL) {
805 msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
806 desc->content.MSL, max_count);
807 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
808 }
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700809
Edward O'Callaghanc172e172020-05-26 23:19:02 +1000810 msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
811 for (i = 0; i < max_count; i++)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700812 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
813 msg_pdbg2("\n");
814
Edward O'Callaghanc172e172020-05-26 23:19:02 +1000815 max_count = MIN(ARRAY_SIZE(desc->south.STRPs), desc->content.ISL);
816 if (max_count < desc->content.ISL) {
817 msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
818 desc->content.ISL, max_count);
819 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
820 }
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700821
Edward O'Callaghanc172e172020-05-26 23:19:02 +1000822 msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
823 for (i = 0; i < max_count; i++)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700824 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
825 msg_pdbg2("\n");
826
827 switch (cs) {
828 case CHIPSET_ICH8:
829 if (sizeof(desc->north.ich8) / 4 != desc->content.MSL)
830 msg_pdbg2("Detailed North/MCH/PROC information is "
831 "probably not reliable, printing anyway.\n");
832 if (sizeof(desc->south.ich8) / 4 != desc->content.ISL)
833 msg_pdbg2("Detailed South/ICH/PCH information is "
834 "probably not reliable, printing anyway.\n");
835 prettyprint_ich_descriptor_straps_ich8(desc);
836 break;
837 case CHIPSET_5_SERIES_IBEX_PEAK:
838 /* PCH straps only. PROCSTRPs are unknown. */
839 if (sizeof(desc->south.ibex) / 4 != desc->content.ISL)
840 msg_pdbg2("Detailed South/ICH/PCH information is "
841 "probably not reliable, printing anyway.\n");
842 prettyprint_ich_descriptor_straps_ibex(&desc->south);
843 break;
844 case CHIPSET_6_SERIES_COUGAR_POINT:
845 /* PCH straps only. PROCSTRP0 is "reserved". */
846 if (sizeof(desc->south.cougar) / 4 != desc->content.ISL)
847 msg_pdbg2("Detailed South/ICH/PCH information is "
848 "probably not reliable, printing anyway.\n");
849 prettyprint_ich_descriptor_straps_cougar(&desc->south);
850 break;
851 case CHIPSET_ICH_UNKNOWN:
852 break;
853 default:
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000854 msg_pdbg2("The meaning of the descriptor straps are unknown yet.\n\n");
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700855 break;
856 }
857}
858
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000859static void prettyprint_rdid(uint32_t reg_val)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700860{
861 uint8_t mid = reg_val & 0xFF;
862 uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00);
863 msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did);
864}
865
866void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap)
867{
868 int i;
869 msg_pdbg2("=== Upper Map Section ===\n");
870 msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1);
871 msg_pdbg2("\n");
872
873 msg_pdbg2("--- Details ---\n");
874 msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL);
875 msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap));
876 msg_pdbg2("\n");
877
878 msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000879 for (i = 0; i < umap->VTL/2; i++) {
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700880 uint32_t jid = umap->vscc_table[i].JID;
881 uint32_t vscc = umap->vscc_table[i].VSCC;
882 msg_pdbg2(" JID%d = 0x%08x\n", i, jid);
883 msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc);
884 msg_pdbg2(" "); /* indention */
885 prettyprint_rdid(jid);
886 msg_pdbg2(" "); /* indention */
Edward O'Callaghand757b422020-05-26 21:22:12 +1000887 prettyprint_ich_reg_vscc(vscc, 0, false);
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700888 }
889 msg_pdbg2("\n");
890}
891
892/* len is the length of dump in bytes */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000893int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
894 enum ich_chipset *const cs, struct ich_descriptors *const desc)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700895{
896 unsigned int i, max;
897 uint8_t pch_bug_offset = 0;
898
899 if (dump == NULL || desc == NULL)
900 return ICH_RET_PARAM;
901
902 if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) {
903 if (dump[4] == DESCRIPTOR_MODE_SIGNATURE)
904 pch_bug_offset = 4;
905 else
906 return ICH_RET_ERR;
907 }
908
909 /* map */
Nico Huber61b10c72017-03-28 17:08:46 +0200910 if (len < (4 + pch_bug_offset) * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700911 return ICH_RET_OOB;
912 desc->content.FLVALSIG = dump[0 + pch_bug_offset];
913 desc->content.FLMAP0 = dump[1 + pch_bug_offset];
914 desc->content.FLMAP1 = dump[2 + pch_bug_offset];
915 desc->content.FLMAP2 = dump[3 + pch_bug_offset];
916
917 /* component */
Nico Huber61b10c72017-03-28 17:08:46 +0200918 if (len < getFCBA(&desc->content) + 3 * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700919 return ICH_RET_OOB;
920 desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0];
921 desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
922 desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
923
924 /* region */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000925 const ssize_t nr = ich_number_of_regions(*cs, &desc->content);
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000926 if (nr < 0 || len < getFRBA(&desc->content) + (size_t)nr * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700927 return ICH_RET_OOB;
Edward O'Callaghane7efd052020-07-03 14:57:28 +1000928 for (i = 0; i < nr; i++)
929 desc->region.FLREGs[i] = dump[(getFRBA(&desc->content) >> 2) + i];
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700930
931 /* master */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000932 const ssize_t nm = ich_number_of_masters(*cs, &desc->content);
933 if (nm < 0 || len < getFMBA(&desc->content) + (size_t)nm * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700934 return ICH_RET_OOB;
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000935 for (i = 0; i < nm; i++)
936 desc->master.FLMSTRs[i] = dump[(getFMBA(&desc->content) >> 2) + i];
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700937
938 /* upper map */
939 desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
940
941 /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
942 * "Identifies the 1s based number of DWORDS contained in the VSCC
943 * Table. Each SPI component entry in the table is 2 DWORDS long." So
944 * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
945 * check ensures that the maximum offset actually accessed is available.
946 */
Nico Huber61b10c72017-03-28 17:08:46 +0200947 if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8))
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700948 return ICH_RET_OOB;
949
950 for (i = 0; i < desc->upper.VTL/2; i++) {
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000951 desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
952 desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700953 }
954
955 /* MCH/PROC (aka. North) straps */
956 if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
957 return ICH_RET_OOB;
958
959 /* limit the range to be written */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000960 max = MIN(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700961 for (i = 0; i < max; i++)
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000962 desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i];
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700963
964 /* ICH/PCH (aka. South) straps */
965 if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
966 return ICH_RET_OOB;
967
968 /* limit the range to be written */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +1000969 max = MIN(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700970 for (i = 0; i < max; i++)
Edward O'Callaghan568cd262020-05-26 23:10:45 +1000971 desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i];
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700972
973 return ICH_RET_OK;
974}
975
976#else /* ICH_DESCRIPTORS_FROM_DUMP */
977
stefanct3d3b6ee2011-10-20 12:57:14 +0000978/** Returns the integer representation of the component density with index
Jack Rosenthal936934a2020-07-28 09:51:26 -0600979idx in bytes or 0 if a correct size can not be determined. */
980int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx)
stefanct3d3b6ee2011-10-20 12:57:14 +0000981{
Edward O'Callaghan1229b212020-07-05 13:28:03 +1000982 uint8_t size_enc;
Edward O'Callaghan1229b212020-07-05 13:28:03 +1000983
Jack Rosenthal936934a2020-07-28 09:51:26 -0600984 switch(idx) {
985 case 0:
986 size_enc = desc->component.dens_old.comp1_density;
stefanct3d3b6ee2011-10-20 12:57:14 +0000987 break;
Jack Rosenthal936934a2020-07-28 09:51:26 -0600988 case 1:
989 if (desc->content.NC == 0)
990 return 0;
991 size_enc = desc->component.dens_old.comp2_density;
stefanct3d3b6ee2011-10-20 12:57:14 +0000992 break;
993 default:
Jack Rosenthal936934a2020-07-28 09:51:26 -0600994 msg_perr("Only ICH SPI component index 0 or 1 are supported "
995 "yet.\n");
996 return 0;
stefanct3d3b6ee2011-10-20 12:57:14 +0000997 }
Jack Rosenthal936934a2020-07-28 09:51:26 -0600998 if (size_enc > 7) {
999 msg_perr("Density of ICH SPI component with index %d is "
1000 "invalid. Encoded density is 0x%x.\n", idx, size_enc);
1001 return 0;
stefanct3d3b6ee2011-10-20 12:57:14 +00001002 }
1003 return (1 << (19 + size_enc));
1004}
1005
Edward O'Callaghan5a7ae7a2020-05-18 16:29:45 +10001006static uint32_t read_descriptor_reg(enum ich_chipset cs, uint8_t section, uint16_t offset, void *spibar)
David Hendricksce6b2fa2011-07-11 22:12:43 -07001007{
1008 uint32_t control = 0;
1009 control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS;
1010 control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI;
Edward O'Callaghan9e6046c2020-05-26 23:24:08 +10001011 switch (cs) {
1012 case CHIPSET_100_SERIES_SUNRISE_POINT:
1013 case CHIPSET_C620_SERIES_LEWISBURG:
1014 case CHIPSET_300_SERIES_CANNON_POINT:
1015 case CHIPSET_APOLLO_LAKE:
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +05301016 mmio_le_writel(control, spibar + PCH100_REG_FDOC);
1017 return mmio_le_readl(spibar + PCH100_REG_FDOD);
Edward O'Callaghan9e6046c2020-05-26 23:24:08 +10001018 default:
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +05301019 mmio_le_writel(control, spibar + ICH9_REG_FDOC);
1020 return mmio_le_readl(spibar + ICH9_REG_FDOD);
1021 }
David Hendricksce6b2fa2011-07-11 22:12:43 -07001022}
1023
Edward O'Callaghan4b90b622020-05-18 16:20:56 +10001024int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -07001025{
Edward O'Callaghan0f6a2e52020-07-09 18:16:16 +10001026 ssize_t i;
stefanct1fc3a732011-09-15 23:52:55 +00001027 struct ich_desc_region *r = &desc->region;
1028
1029 /* Test if bit-fields are working as expected.
1030 * FIXME: Replace this with dynamic bitfield fixup
1031 */
1032 for (i = 0; i < 4; i++)
1033 desc->region.FLREGs[i] = 0x5A << (i * 8);
Edward O'Callaghan0f6a2e52020-07-09 18:16:16 +10001034 if (r->old_reg[0].base != 0x005A || r->old_reg[0].limit != 0x0000 ||
1035 r->old_reg[1].base != 0x1A00 || r->old_reg[1].limit != 0x0000 ||
1036 r->old_reg[2].base != 0x0000 || r->old_reg[2].limit != 0x005A ||
1037 r->old_reg[3].base != 0x0000 || r->old_reg[3].limit != 0x1A00) {
stefanct1fc3a732011-09-15 23:52:55 +00001038 msg_pdbg("The combination of compiler and CPU architecture used"
1039 "does not lay out bit-fields as expected, sorry.\n");
Edward O'Callaghan0f6a2e52020-07-09 18:16:16 +10001040 msg_pspew("r->old_reg[0].base = 0x%04X (0x005A)\n", r->old_reg[0].base);
1041 msg_pspew("r->old_reg[0].limit = 0x%04X (0x0000)\n", r->old_reg[0].limit);
1042 msg_pspew("r->old_reg[1].base = 0x%04X (0x1A00)\n", r->old_reg[1].base);
1043 msg_pspew("r->old_reg[1].limit = 0x%04X (0x0000)\n", r->old_reg[1].limit);
1044 msg_pspew("r->old_reg[2].base = 0x%04X (0x0000)\n", r->old_reg[2].base);
1045 msg_pspew("r->old_reg[2].limit = 0x%04X (0x005A)\n", r->old_reg[2].limit);
1046 msg_pspew("r->old_reg[3].base = 0x%04X (0x0000)\n", r->old_reg[3].base);
1047 msg_pspew("r->old_reg[3].limit = 0x%04X (0x1A00)\n", r->old_reg[3].limit);
stefanct1fc3a732011-09-15 23:52:55 +00001048 return ICH_RET_ERR;
1049 }
1050
Edward O'Callaghan568cd262020-05-26 23:10:45 +10001051 msg_pdbg2("Reading flash descriptors mapped by the chipset via FDOC/FDOD...");
stefanct1fc3a732011-09-15 23:52:55 +00001052 /* content section */
Edward O'Callaghan5a7ae7a2020-05-18 16:29:45 +10001053 desc->content.FLVALSIG = read_descriptor_reg(cs, 0, 0, spibar);
1054 desc->content.FLMAP0 = read_descriptor_reg(cs, 0, 1, spibar);
1055 desc->content.FLMAP1 = read_descriptor_reg(cs, 0, 2, spibar);
1056 desc->content.FLMAP2 = read_descriptor_reg(cs, 0, 3, spibar);
David Hendricksce6b2fa2011-07-11 22:12:43 -07001057
1058 /* component section */
Edward O'Callaghan5a7ae7a2020-05-18 16:29:45 +10001059 desc->component.FLCOMP = read_descriptor_reg(cs, 1, 0, spibar);
1060 desc->component.FLILL = read_descriptor_reg(cs, 1, 1, spibar);
1061 desc->component.FLPB = read_descriptor_reg(cs, 1, 2, spibar);
David Hendricksce6b2fa2011-07-11 22:12:43 -07001062
1063 /* region section */
Edward O'Callaghane7efd052020-07-03 14:57:28 +10001064 const ssize_t nr = ich_number_of_regions(cs, &desc->content);
1065 if (nr < 0) {
stefanct1fc3a732011-09-15 23:52:55 +00001066 msg_pdbg2("%s: number of regions too high (%d) - failed\n",
Edward O'Callaghane7efd052020-07-03 14:57:28 +10001067 __func__, desc->content.NR + 1);
stefanct1fc3a732011-09-15 23:52:55 +00001068 return ICH_RET_ERR;
1069 }
Edward O'Callaghane7efd052020-07-03 14:57:28 +10001070 for (i = 0; i < nr; i++)
Edward O'Callaghan5a7ae7a2020-05-18 16:29:45 +10001071 desc->region.FLREGs[i] = read_descriptor_reg(cs, 2, i, spibar);
David Hendricksce6b2fa2011-07-11 22:12:43 -07001072
1073 /* master section */
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +10001074 const ssize_t nm = ich_number_of_masters(cs, &desc->content);
1075 if (nm < 0) {
1076 msg_pdbg2("%s: number of masters too high (%d) - failed\n",
1077 __func__, desc->content.NM + 1);
1078 return ICH_RET_ERR;
Duncan Lauriedbbf2222019-04-25 12:06:19 -07001079 }
Edward O'Callaghanaef44cb2020-07-03 15:31:14 +10001080 for (i = 0; i < nm; i++)
1081 desc->master.FLMSTRs[i] = read_descriptor_reg(cs, 3, i, spibar);
David Hendricksce6b2fa2011-07-11 22:12:43 -07001082
stefanct1fc3a732011-09-15 23:52:55 +00001083 /* Accessing the strap section via FDOC/D is only possible on ICH8 and
1084 * reading the upper map is impossible on all chipsets, so don't bother.
1085 */
1086
1087 msg_pdbg2(" done.\n");
1088 return ICH_RET_OK;
David Hendricksce6b2fa2011-07-11 22:12:43 -07001089}
Stefan Tauner34f6f5a2016-08-03 11:20:38 -07001090#endif /* ICH_DESCRIPTORS_FROM_DUMP */
stefanct1fc3a732011-09-15 23:52:55 +00001091#endif /* defined(__i386__) || defined(__x86_64__) */