blob: d311c2db235a7037070ff40f9fa5599229a84a05 [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.
16 *
David Hendricksce6b2fa2011-07-11 22:12:43 -070017 */
18
David Hendricksce6b2fa2011-07-11 22:12:43 -070019#if defined(__i386__) || defined(__x86_64__)
20
stefanct1fc3a732011-09-15 23:52:55 +000021#include "ich_descriptors.h"
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070022
23#ifdef ICH_DESCRIPTORS_FROM_DUMP
24
25#include <stdio.h>
26#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 */
40
41#ifndef min
42#define min(a, b) (a < b) ? a : b
43#endif
44
stefanct1fc3a732011-09-15 23:52:55 +000045void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity)
David Hendricksce6b2fa2011-07-11 22:12:43 -070046{
stefanct1fc3a732011-09-15 23:52:55 +000047 print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF);
48 print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF);
49 print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF);
50 print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF);
51 print(verbosity, "EO=0x%x, ", (reg_val & VSCC_EO) >> VSCC_EO_OFF);
52 print(verbosity, "VCL=%d\n", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF);
David Hendricksce6b2fa2011-07-11 22:12:43 -070053}
54
stefanct1fc3a732011-09-15 23:52:55 +000055#define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0)
56#define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0)
57#define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0)
58#define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0)
59#define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0)
60
61void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -070062{
stefanct1fc3a732011-09-15 23:52:55 +000063 prettyprint_ich_descriptor_content(&desc->content);
64 prettyprint_ich_descriptor_component(desc);
65 prettyprint_ich_descriptor_region(desc);
Duncan Lauriedbbf2222019-04-25 12:06:19 -070066 prettyprint_ich_descriptor_master(cs, &desc->master);
Stefan Tauner34f6f5a2016-08-03 11:20:38 -070067#ifdef ICH_DESCRIPTORS_FROM_DUMP
68 if (cs >= CHIPSET_ICH8) {
69 prettyprint_ich_descriptor_upper_map(&desc->upper);
70 prettyprint_ich_descriptor_straps(cs, desc);
71 }
72#endif /* ICH_DESCRIPTORS_FROM_DUMP */
David Hendricksce6b2fa2011-07-11 22:12:43 -070073}
74
stefanct1fc3a732011-09-15 23:52:55 +000075void prettyprint_ich_descriptor_content(const struct ich_desc_content *cont)
David Hendricksce6b2fa2011-07-11 22:12:43 -070076{
stefanct1fc3a732011-09-15 23:52:55 +000077 msg_pdbg2("=== Content Section ===\n");
78 msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG);
79 msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0);
80 msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1);
81 msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2);
82 msg_pdbg2("\n");
83
84 msg_pdbg2("--- Details ---\n");
85 msg_pdbg2("NR (Number of Regions): %5d\n",
86 cont->NR + 1);
87 msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n",
88 getFRBA(cont));
89 msg_pdbg2("NC (Number of Components): %5d\n",
90 cont->NC + 1);
91 msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n",
92 getFCBA(cont));
93 msg_pdbg2("ISL (ICH/PCH Strap Length): %5d\n",
94 cont->ISL);
95 msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address): 0x%03x\n",
96 getFISBA(cont));
97 msg_pdbg2("NM (Number of Masters): %5d\n",
98 cont->NM + 1);
99 msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n",
100 getFMBA(cont));
101 msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n",
102 cont->MSL);
103 msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n",
104 getFMSBA(cont));
105 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700106}
107
stefanct1fc3a732011-09-15 23:52:55 +0000108void prettyprint_ich_descriptor_component(const struct ich_descriptors *desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700109{
stefanct1fc3a732011-09-15 23:52:55 +0000110 static const char * const freq_str[8] = {
111 "20 MHz", /* 000 */
112 "33 MHz", /* 001 */
113 "reserved", /* 010 */
114 "reserved", /* 011 */
115 "50 MHz", /* 100 */
116 "reserved", /* 101 */
117 "reserved", /* 110 */
118 "reserved" /* 111 */
119 };
120 static const char * const size_str[8] = {
121 "512 kB", /* 000 */
122 " 1 MB", /* 001 */
123 " 2 MB", /* 010 */
124 " 4 MB", /* 011 */
125 " 8 MB", /* 100 */
126 " 16 MB", /* 101 */
Satya Popuri87ecc332016-07-25 17:04:04 -0700127 " 32 MB", /* 110 */
128 " 64 MB", /* 111 */
David Hendricksce6b2fa2011-07-11 22:12:43 -0700129 };
130
stefanct1fc3a732011-09-15 23:52:55 +0000131 msg_pdbg2("=== Component Section ===\n");
132 msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP);
133 msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL );
134 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700135
stefanct1fc3a732011-09-15 23:52:55 +0000136 msg_pdbg2("--- Details ---\n");
137 msg_pdbg2("Component 1 density: %s\n",
138 size_str[desc->component.comp1_density]);
139 if (desc->content.NC)
140 msg_pdbg2("Component 2 density: %s\n",
141 size_str[desc->component.comp2_density]);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700142 else
stefanct1fc3a732011-09-15 23:52:55 +0000143 msg_pdbg2("Component 2 is not used.\n");
144 msg_pdbg2("Read Clock Frequency: %s\n",
145 freq_str[desc->component.freq_read]);
146 msg_pdbg2("Read ID and Status Clock Freq.: %s\n",
147 freq_str[desc->component.freq_read_id]);
148 msg_pdbg2("Write and Erase Clock Freq.: %s\n",
149 freq_str[desc->component.freq_write]);
150 msg_pdbg2("Fast Read is %ssupported.\n",
151 desc->component.fastread ? "" : "not ");
152 if (desc->component.fastread)
153 msg_pdbg2("Fast Read Clock Frequency: %s\n",
154 freq_str[desc->component.freq_fastread]);
155 if (desc->component.FLILL == 0)
156 msg_pdbg2("No forbidden opcodes.\n");
157 else {
158 msg_pdbg2("Invalid instruction 0: 0x%02x\n",
159 desc->component.invalid_instr0);
160 msg_pdbg2("Invalid instruction 1: 0x%02x\n",
161 desc->component.invalid_instr1);
162 msg_pdbg2("Invalid instruction 2: 0x%02x\n",
163 desc->component.invalid_instr2);
164 msg_pdbg2("Invalid instruction 3: 0x%02x\n",
165 desc->component.invalid_instr3);
166 }
167 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700168}
169
stefanct1fc3a732011-09-15 23:52:55 +0000170static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700171{
stefanct1fc3a732011-09-15 23:52:55 +0000172 static const char *const region_names[5] = {
173 "Descr.", "BIOS", "ME", "GbE", "Platf."
David Hendricksce6b2fa2011-07-11 22:12:43 -0700174 };
stefanct1fc3a732011-09-15 23:52:55 +0000175 if (i >= 5) {
176 msg_pdbg2("%s: region index too high.\n", __func__);
177 return;
David Hendricksce6b2fa2011-07-11 22:12:43 -0700178 }
stefanct1fc3a732011-09-15 23:52:55 +0000179 uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]);
180 uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]);
181 msg_pdbg2("Region %d (%-6s) ", i, region_names[i]);
182 if (base > limit)
183 msg_pdbg2("is unused.\n");
184 else
185 msg_pdbg2("0x%08x - 0x%08x\n", base, limit | 0x0fff);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700186}
187
stefanct1fc3a732011-09-15 23:52:55 +0000188void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700189{
stefanct1fc3a732011-09-15 23:52:55 +0000190 uint8_t i;
191 uint8_t nr = desc->content.NR + 1;
192 msg_pdbg2("=== Region Section ===\n");
193 if (nr >= 5) {
194 msg_pdbg2("%s: number of regions too high (%d).\n", __func__,
195 nr);
196 return;
197 }
198 for (i = 0; i <= nr; i++)
199 msg_pdbg2("FLREG%d 0x%08x\n", i, desc->region.FLREGs[i]);
200 msg_pdbg2("\n");
201
202 msg_pdbg2("--- Details ---\n");
203 for (i = 0; i <= nr; i++)
204 pprint_freg(&desc->region, i);
205 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700206}
207
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700208static void prettyprint_ich_descriptor_master_ich(const struct ich_desc_master_ich *mstr)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700209{
stefanct1fc3a732011-09-15 23:52:55 +0000210 msg_pdbg2("=== Master Section ===\n");
211 msg_pdbg2("FLMSTR1 0x%08x\n", mstr->FLMSTR1);
212 msg_pdbg2("FLMSTR2 0x%08x\n", mstr->FLMSTR2);
213 msg_pdbg2("FLMSTR3 0x%08x\n", mstr->FLMSTR3);
214 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700215
stefanct1fc3a732011-09-15 23:52:55 +0000216 msg_pdbg2("--- Details ---\n");
217 msg_pdbg2(" Descr. BIOS ME GbE Platf.\n");
218 msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n",
219 (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
220 (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
221 (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
222 (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
223 (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ');
224 msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n",
225 (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
226 (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
227 (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
228 (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
229 (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ');
230 msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n",
231 (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
232 (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
233 (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
234 (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
235 (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ');
236 msg_pdbg2("\n");
David Hendricksce6b2fa2011-07-11 22:12:43 -0700237}
238
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700239static void prettyprint_ich_descriptor_master_pch100(const struct ich_desc_master_pch100 *mstr)
240{
241 msg_pdbg2("=== Master Section ===\n");
242 msg_pdbg2("FLMSTR1 0x%08x\n", mstr->FLMSTR1);
243 msg_pdbg2("FLMSTR2 0x%08x\n", mstr->FLMSTR2);
244 msg_pdbg2("FLMSTR3 0x%08x\n", mstr->FLMSTR3);
245 msg_pdbg2("FLMSTR4 0x%08x\n", mstr->FLMSTR4);
246 msg_pdbg2("FLMSTR5 0x%08x\n", mstr->FLMSTR5);
247 msg_pdbg2("\n");
248
249 msg_pdbg2("--- Details ---\n");
250 msg_pdbg2(" Descr. BIOS ME GbE Plat EC\n");
251 msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c %c%c\n",
252 (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
253 (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
254 (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
255 (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
256 (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ',
257 (mstr->BIOS_EC_r) ?'r':' ', (mstr->BIOS_EC_w) ?'w':' ');
258 msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c %c%c\n",
259 (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
260 (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
261 (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
262 (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
263 (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ',
264 (mstr->ME_EC_r) ?'r':' ', (mstr->ME_EC_w) ?'w':' ');
265 msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c %c%c\n",
266 (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
267 (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
268 (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
269 (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
270 (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ',
271 (mstr->GbE_EC_r) ?'r':' ', (mstr->GbE_EC_w) ?'w':' ');
272 msg_pdbg2("Plat %c%c %c%c %c%c %c%c %c%c %c%c\n",
273 (mstr->plat_descr_r) ?'r':' ', (mstr->plat_descr_w) ?'w':' ',
274 (mstr->plat_BIOS_r) ?'r':' ', (mstr->plat_BIOS_w) ?'w':' ',
275 (mstr->plat_ME_r) ?'r':' ', (mstr->plat_ME_w) ?'w':' ',
276 (mstr->plat_GbE_r) ?'r':' ', (mstr->plat_GbE_w) ?'w':' ',
277 (mstr->plat_plat_r) ?'r':' ', (mstr->plat_plat_w) ?'w':' ',
278 (mstr->plat_EC_r) ?'r':' ', (mstr->plat_EC_w) ?'w':' ');
279 msg_pdbg2("EC %c%c %c%c %c%c %c%c %c%c %c%c\n",
280 (mstr->EC_descr_r) ?'r':' ', (mstr->EC_descr_w) ?'w':' ',
281 (mstr->EC_BIOS_r) ?'r':' ', (mstr->EC_BIOS_w) ?'w':' ',
282 (mstr->EC_ME_r) ?'r':' ', (mstr->EC_ME_w) ?'w':' ',
283 (mstr->EC_GbE_r) ?'r':' ', (mstr->EC_GbE_w) ?'w':' ',
284 (mstr->EC_plat_r) ?'r':' ', (mstr->EC_plat_w) ?'w':' ',
285 (mstr->EC_EC_r) ?'r':' ', (mstr->EC_EC_w) ?'w':' ');
286 msg_pdbg2("\n");
287}
288
289void prettyprint_ich_descriptor_master(enum ich_chipset cs,
290 const struct ich_desc_master *mstr)
291{
292 msg_pdbg2("%s: cs=%d\n", __func__, cs);
293 if (cs >= CHIPSET_100_SERIES_SUNRISE_POINT)
294 prettyprint_ich_descriptor_master_pch100(&mstr->pch100);
295 else
296 prettyprint_ich_descriptor_master_ich(&mstr->ich);
297}
298
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700299#ifdef ICH_DESCRIPTORS_FROM_DUMP
300
301void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc)
302{
303 static const char * const str_GPIO12[4] = {
304 "GPIO12",
305 "LAN PHY Power Control Function (Native Output)",
306 "GLAN_DOCK# (Native Input)",
307 "invalid configuration",
308 };
309
310 msg_pdbg2("--- MCH details ---\n");
311 msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en");
312 msg_pdbg2("\n");
313
314 msg_pdbg2("--- ICH details ---\n");
315 msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD);
316 msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2);
317 msg_pdbg2("ME SMBus Controller is connected to the %s.\n",
318 desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins");
319 msg_pdbg2("SPI CS1 is used for %s.\n",
320 desc->south.ich8.SPICS1_LANPHYPC_SEL ?
321 "LAN PHY Power Control Function" :
322 "SPI Chip Select");
323 msg_pdbg2("GPIO12 is used as %s.\n",
324 str_GPIO12[desc->south.ich8.GPIO12_SEL]);
325 msg_pdbg2("PCIe Port 6 is used for %s.\n",
326 desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express");
327 msg_pdbg2("%sn BMC Mode: "
328 "Intel AMT SMBus Controller 1 is connected to %s.\n",
329 desc->south.ich8.BMCMODE ? "I" : "Not i",
330 desc->south.ich8.BMCMODE ? "SMLink" : "SMBus");
331 msg_pdbg2("TCO is in %s Mode.\n",
332 desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible");
333 msg_pdbg2("ME A is %sabled.\n",
334 desc->south.ich8.ME_DISABLE ? "dis" : "en");
335 msg_pdbg2("\n");
336}
337
338static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off)
339{
340 msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1);
341
342 off *= 4;
343 switch(conf){
344 case 0:
345 msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off);
346 break;
347 case 1:
348 msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), "
349 "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off);
350 break;
351 case 2:
352 msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports "
353 "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off);
354 break;
355 case 3:
356 msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)",
357 1+off, 2+off, 4+off);
358 break;
359 }
360 msg_pdbg2("\n");
361}
362
363void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s)
364{
365 /* PCHSTRP4 */
366 msg_pdbg2("Intel PHY is %s.\n",
367 (s->ibex.PHYCON == 2) ? "connected" :
368 (s->ibex.PHYCON == 0) ? "disconnected" : "reserved");
369 msg_pdbg2("GbE MAC SMBus address is %sabled.\n",
370 s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis");
371 msg_pdbg2("GbE MAC SMBus address: 0x%02x\n",
372 s->ibex.GBEMAC_SMBUS_ADDR);
373 msg_pdbg2("GbE PHY SMBus address: 0x%02x\n",
374 s->ibex.GBEPHY_SMBUS_ADDR);
375
376 /* PCHSTRP5 */
377 /* PCHSTRP6 */
378 /* PCHSTRP7 */
379 msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n",
380 s->ibex.MESMA2UDID_VENDOR);
381 msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n",
382 s->ibex.MESMA2UDID_VENDOR);
383
384 /* PCHSTRP8 */
385}
386
387void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s)
388{
389 /* PCHSTRP11 */
390 msg_pdbg2("SMLink1 GP Address is %sabled.\n",
391 s->ibex.SML1GPAEN ? "en" : "dis");
392 msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n",
393 s->ibex.SML1GPA);
394 msg_pdbg2("SMLink1 I2C Target address is %sabled.\n",
395 s->ibex.SML1I2CAEN ? "en" : "dis");
396 msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n",
397 s->ibex.SML1I2CA);
398
399 /* PCHSTRP12 */
400 /* PCHSTRP13 */
401}
402
403void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s)
404{
Patrick Georgi3a5bcb92017-04-11 20:45:07 +0200405 static const uint8_t dec_t209min[4] = {
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700406 100,
407 50,
408 5,
409 1
410 };
411
412 msg_pdbg2("--- PCH ---\n");
413
414 /* PCHSTRP0 */
415 msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2);
416 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
417 s->ibex.SMB_EN ? "en" : "dis");
418 msg_pdbg2("SMLink0 segment is %sabled.\n",
419 s->ibex.SML0_EN ? "en" : "dis");
420 msg_pdbg2("SMLink1 segment is %sabled.\n",
421 s->ibex.SML1_EN ? "en" : "dis");
422 msg_pdbg2("SMLink1 Frequency: %s\n",
423 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
424 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
425 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
426 msg_pdbg2("SMLink0 Frequency: %s\n",
427 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
428 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
429 "LAN_PHY_PWR_CTRL" : "general purpose output");
430 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1);
431 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
432 s->ibex.DMI_REQID_DIS ? "en" : "dis");
433 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
434 1 << (6 + s->ibex.BBBS));
435
436 /* PCHSTRP1 */
437 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
438
439 /* PCHSTRP2 */
440 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
441 s->ibex.MESMASDEN ? "en" : "dis");
442 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
443 s->ibex.MESMASDA);
444 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
445 s->ibex.MESMI2CEN ? "en" : "dis");
446 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
447 s->ibex.MESMI2CA);
448
449 /* PCHSTRP3 */
450 prettyprint_ich_descriptor_pchstraps45678_56(s);
451 /* PCHSTRP9 */
452 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
453 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
454 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
455 s->ibex.PCIELR1 ? "" : "not ");
456 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
457 s->ibex.PCIELR2 ? "" : "not ");
458 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
459 s->ibex.DMILR ? "" : "not ");
460 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
461 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
462 s->ibex.PHY_PCIE_EN ? "en" : "dis");
463
464 /* PCHSTRP10 */
465 msg_pdbg2("Management Engine will boot from %sflash.\n",
466 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
467 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5);
468 msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n",
469 s->ibex.VE_EN ? "en" : "dis");
470 msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n",
471 s->ibex.MMDDE ? "en" : "dis");
472 msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n",
473 s->ibex.MMADDR);
474 msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7);
475 msg_pdbg2("Integrated Clocking Configuration is %d.\n",
476 (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL);
477 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
478 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
479
480 prettyprint_ich_descriptor_pchstraps111213_56(s);
481
482 /* PCHSTRP14 */
483 msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n",
484 s->ibex.VE_EN2 ? "en" : "dis");
485 msg_pdbg2("Virtualization Engine will boot from %sflash.\n",
486 s->ibex.VE_BOOT_FLASH ? "" : "ROM, then ");
487 msg_pdbg2("Braidwood SSD functionality is %sabled.\n",
488 s->ibex.BW_SSD ? "en" : "dis");
489 msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n",
490 s->ibex.NVMHCI_EN ? "en" : "dis");
491
492 /* PCHSTRP15 */
493 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6);
494 msg_pdbg2("Integrated wired LAN Solution is %sabled.\n",
495 s->ibex.IWL_EN ? "en" : "dis");
496 msg_pdbg2("t209 min Timing: %d ms\n",
497 dec_t209min[s->ibex.t209min]);
498 msg_pdbg2("\n");
499}
500
501void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s)
502{
503 msg_pdbg2("--- PCH ---\n");
504
505 /* PCHSTRP0 */
506 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1);
507 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
508 s->ibex.SMB_EN ? "en" : "dis");
509 msg_pdbg2("SMLink0 segment is %sabled.\n",
510 s->ibex.SML0_EN ? "en" : "dis");
511 msg_pdbg2("SMLink1 segment is %sabled.\n",
512 s->ibex.SML1_EN ? "en" : "dis");
513 msg_pdbg2("SMLink1 Frequency: %s\n",
514 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
515 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
516 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
517 msg_pdbg2("SMLink0 Frequency: %s\n",
518 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
519 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
520 "LAN_PHY_PWR_CTRL" : "general purpose output");
521 msg_pdbg2("LinkSec is %sabled.\n",
522 s->cougar.LINKSEC_DIS ? "en" : "dis");
523 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
524 s->ibex.DMI_REQID_DIS ? "en" : "dis");
525 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
526 1 << (6 + s->ibex.BBBS));
527
528 /* PCHSTRP1 */
529 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
530 msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2);
531
532 /* PCHSTRP2 */
533 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
534 s->ibex.MESMASDEN ? "en" : "dis");
535 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
536 s->ibex.MESMASDA);
537 msg_pdbg2("ME SMBus MCTP Address is %sabled.\n",
538 s->cougar.MESMMCTPAEN ? "en" : "dis");
539 msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n",
540 s->cougar.MESMMCTPA);
541 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
542 s->ibex.MESMI2CEN ? "en" : "dis");
543 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
544 s->ibex.MESMI2CA);
545
546 /* PCHSTRP3 */
547 prettyprint_ich_descriptor_pchstraps45678_56(s);
548 /* PCHSTRP9 */
549 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
550 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
551 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
552 s->ibex.PCIELR1 ? "" : "not ");
553 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
554 s->ibex.PCIELR2 ? "" : "not ");
555 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
556 s->ibex.DMILR ? "" : "not ");
557 msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n",
558 s->cougar.MDSMBE_EN ? "en" : "dis");
559 msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n",
560 s->cougar.MDSMBE_ADD);
561 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
562 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
563 s->ibex.PHY_PCIE_EN ? "en" : "dis");
564 msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n",
565 s->cougar.SUB_DECODE_EN ? "en" : "dis");
566 msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ?
567 "PCHHOT#" : "SML1ALERT#");
568
569 /* PCHSTRP10 */
570 msg_pdbg2("Management Engine will boot from %sflash.\n",
571 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
572
573 msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n",
574 s->cougar.MDSMBE_EN ? "en" : "dis");
575 msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n",
576 s->cougar.MDSMBE_ADD);
577
578 msg_pdbg2("Integrated Clocking Configuration used: %d\n",
579 s->cougar.ICC_SEL);
580 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
581 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
582 msg_pdbg2("ICC Profile is selected by %s.\n",
583 s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
584 msg_pdbg2("Deep SX is %ssupported on the platform.\n",
585 s->cougar.Deep_SX_EN ? "not " : "");
586 msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n",
587 s->cougar.ME_DBG_LAN ? "en" : "dis");
588
589 prettyprint_ich_descriptor_pchstraps111213_56(s);
590
591 /* PCHSTRP14 */
592 /* PCHSTRP15 */
593 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6);
594 msg_pdbg2("Integrated wired LAN is %sabled.\n",
595 s->cougar.IWL_EN ? "en" : "dis");
596 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
597 msg_pdbg2("SMLink1 provides temperature from %s.\n",
598 s->cougar.SMLINK1_THERM_SEL ?
599 "PCH only" : "the CPU, PCH and DIMMs");
600 msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
601 "general purpose output" : "SLP_LAN#");
602
603 /* PCHSTRP16 */
604 /* PCHSTRP17 */
605 msg_pdbg2("Integrated Clock: %s Clock Mode\n",
606 s->cougar.ICML ? "Buffered Through" : "Full Integrated");
607 msg_pdbg2("\n");
608}
609
610void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc)
611{
612 unsigned int i, max;
613 msg_pdbg2("=== Softstraps ===\n");
614
615 if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
616 max = sizeof(desc->north.STRPs) / 4 + 1;
617 msg_pdbg2("MSL (%u) is greater than the current maximum of %u "
618 "entries.\n", desc->content.MSL, max + 1);
619 msg_pdbg2("Only the first %u entries will be printed.\n", max);
620 } else
621 max = desc->content.MSL;
622
623 msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max);
624 for (i = 0; i < max; i++)
625 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
626 msg_pdbg2("\n");
627
628 if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
629 max = sizeof(desc->south.STRPs) / 4;
630 msg_pdbg2("ISL (%u) is greater than the current maximum of %u "
631 "entries.\n", desc->content.ISL, max);
632 msg_pdbg2("Only the first %u entries will be printed.\n", max);
633 } else
634 max = desc->content.ISL;
635
636 msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max);
637 for (i = 0; i < max; i++)
638 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
639 msg_pdbg2("\n");
640
641 switch (cs) {
642 case CHIPSET_ICH8:
643 if (sizeof(desc->north.ich8) / 4 != desc->content.MSL)
644 msg_pdbg2("Detailed North/MCH/PROC information is "
645 "probably not reliable, printing anyway.\n");
646 if (sizeof(desc->south.ich8) / 4 != desc->content.ISL)
647 msg_pdbg2("Detailed South/ICH/PCH information is "
648 "probably not reliable, printing anyway.\n");
649 prettyprint_ich_descriptor_straps_ich8(desc);
650 break;
651 case CHIPSET_5_SERIES_IBEX_PEAK:
652 /* PCH straps only. PROCSTRPs are unknown. */
653 if (sizeof(desc->south.ibex) / 4 != desc->content.ISL)
654 msg_pdbg2("Detailed South/ICH/PCH information is "
655 "probably not reliable, printing anyway.\n");
656 prettyprint_ich_descriptor_straps_ibex(&desc->south);
657 break;
658 case CHIPSET_6_SERIES_COUGAR_POINT:
659 /* PCH straps only. PROCSTRP0 is "reserved". */
660 if (sizeof(desc->south.cougar) / 4 != desc->content.ISL)
661 msg_pdbg2("Detailed South/ICH/PCH information is "
662 "probably not reliable, printing anyway.\n");
663 prettyprint_ich_descriptor_straps_cougar(&desc->south);
664 break;
665 case CHIPSET_ICH_UNKNOWN:
666 break;
667 default:
668 msg_pdbg2("The meaning of the descriptor straps are unknown "
669 "yet.\n\n");
670 break;
671 }
672}
673
674void prettyprint_rdid(uint32_t reg_val)
675{
676 uint8_t mid = reg_val & 0xFF;
677 uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00);
678 msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did);
679}
680
681void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap)
682{
683 int i;
684 msg_pdbg2("=== Upper Map Section ===\n");
685 msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1);
686 msg_pdbg2("\n");
687
688 msg_pdbg2("--- Details ---\n");
689 msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL);
690 msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap));
691 msg_pdbg2("\n");
692
693 msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
694 for (i = 0; i < umap->VTL/2; i++)
695 {
696 uint32_t jid = umap->vscc_table[i].JID;
697 uint32_t vscc = umap->vscc_table[i].VSCC;
698 msg_pdbg2(" JID%d = 0x%08x\n", i, jid);
699 msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc);
700 msg_pdbg2(" "); /* indention */
701 prettyprint_rdid(jid);
702 msg_pdbg2(" "); /* indention */
703 prettyprint_ich_reg_vscc(vscc, 0);
704 }
705 msg_pdbg2("\n");
706}
707
708/* len is the length of dump in bytes */
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700709int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len,
710 struct ich_descriptors *desc,
711 enum ich_chipset cs)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700712{
713 unsigned int i, max;
714 uint8_t pch_bug_offset = 0;
715
716 if (dump == NULL || desc == NULL)
717 return ICH_RET_PARAM;
718
719 if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) {
720 if (dump[4] == DESCRIPTOR_MODE_SIGNATURE)
721 pch_bug_offset = 4;
722 else
723 return ICH_RET_ERR;
724 }
725
726 /* map */
Nico Huber61b10c72017-03-28 17:08:46 +0200727 if (len < (4 + pch_bug_offset) * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700728 return ICH_RET_OOB;
729 desc->content.FLVALSIG = dump[0 + pch_bug_offset];
730 desc->content.FLMAP0 = dump[1 + pch_bug_offset];
731 desc->content.FLMAP1 = dump[2 + pch_bug_offset];
732 desc->content.FLMAP2 = dump[3 + pch_bug_offset];
733
734 /* component */
Nico Huber61b10c72017-03-28 17:08:46 +0200735 if (len < getFCBA(&desc->content) + 3 * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700736 return ICH_RET_OOB;
737 desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0];
738 desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
739 desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
740
741 /* region */
Nico Huber61b10c72017-03-28 17:08:46 +0200742 if (len < getFRBA(&desc->content) + 5 * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700743 return ICH_RET_OOB;
744 desc->region.FLREGs[0] = dump[(getFRBA(&desc->content) >> 2) + 0];
745 desc->region.FLREGs[1] = dump[(getFRBA(&desc->content) >> 2) + 1];
746 desc->region.FLREGs[2] = dump[(getFRBA(&desc->content) >> 2) + 2];
747 desc->region.FLREGs[3] = dump[(getFRBA(&desc->content) >> 2) + 3];
748 desc->region.FLREGs[4] = dump[(getFRBA(&desc->content) >> 2) + 4];
749
750 /* master */
Nico Huber61b10c72017-03-28 17:08:46 +0200751 if (len < getFMBA(&desc->content) + 3 * 4)
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700752 return ICH_RET_OOB;
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700753 if (cs >= CHIPSET_100_SERIES_SUNRISE_POINT) {
754 desc->master.pch100.FLMSTR1 = dump[(getFMBA(&desc->content) >> 2) + 0];
755 desc->master.pch100.FLMSTR2 = dump[(getFMBA(&desc->content) >> 2) + 1];
756 desc->master.pch100.FLMSTR3 = dump[(getFMBA(&desc->content) >> 2) + 2];
757 desc->master.pch100.FLMSTR4 = dump[(getFMBA(&desc->content) >> 2) + 3];
758 desc->master.pch100.FLMSTR5 = dump[(getFMBA(&desc->content) >> 2) + 4];
759 } else {
760 desc->master.ich.FLMSTR1 = dump[(getFMBA(&desc->content) >> 2) + 0];
761 desc->master.ich.FLMSTR2 = dump[(getFMBA(&desc->content) >> 2) + 1];
762 desc->master.ich.FLMSTR3 = dump[(getFMBA(&desc->content) >> 2) + 2];
763 }
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700764
765 /* upper map */
766 desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
767
768 /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
769 * "Identifies the 1s based number of DWORDS contained in the VSCC
770 * Table. Each SPI component entry in the table is 2 DWORDS long." So
771 * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
772 * check ensures that the maximum offset actually accessed is available.
773 */
Nico Huber61b10c72017-03-28 17:08:46 +0200774 if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8))
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700775 return ICH_RET_OOB;
776
777 for (i = 0; i < desc->upper.VTL/2; i++) {
778 desc->upper.vscc_table[i].JID =
779 dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
780 desc->upper.vscc_table[i].VSCC =
781 dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
782 }
783
784 /* MCH/PROC (aka. North) straps */
785 if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
786 return ICH_RET_OOB;
787
788 /* limit the range to be written */
789 max = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
790 for (i = 0; i < max; i++)
791 desc->north.STRPs[i] =
792 dump[(getFMSBA(&desc->content) >> 2) + i];
793
794 /* ICH/PCH (aka. South) straps */
795 if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
796 return ICH_RET_OOB;
797
798 /* limit the range to be written */
799 max = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
800 for (i = 0; i < max; i++)
801 desc->south.STRPs[i] =
802 dump[(getFISBA(&desc->content) >> 2) + i];
803
804 return ICH_RET_OK;
805}
806
807#else /* ICH_DESCRIPTORS_FROM_DUMP */
808
stefanct3d3b6ee2011-10-20 12:57:14 +0000809/** Returns the integer representation of the component density with index
810idx in bytes or 0 if a correct size can not be determined. */
811int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx)
812{
813 uint8_t size_enc;
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700814
stefanct3d3b6ee2011-10-20 12:57:14 +0000815 switch(idx) {
816 case 0:
817 size_enc = desc->component.comp1_density;
818 break;
819 case 1:
820 if (desc->content.NC == 0)
821 return 0;
822 size_enc = desc->component.comp2_density;
823 break;
824 default:
825 msg_perr("Only ICH SPI component index 0 or 1 are supported "
826 "yet.\n");
827 return 0;
828 }
Satya Popuri87ecc332016-07-25 17:04:04 -0700829 if (size_enc > 7) {
stefanct3d3b6ee2011-10-20 12:57:14 +0000830 msg_perr("Density of ICH SPI component with index %d is "
831 "invalid. Encoded density is 0x%x.\n", idx, size_enc);
832 return 0;
833 }
834 return (1 << (19 + size_enc));
835}
836
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530837static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset,
838 void *spibar, int chipset)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700839{
840 uint32_t control = 0;
841 control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS;
842 control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI;
Furquan Shaikh44088752016-07-11 22:48:08 -0700843 if ((chipset == CHIPSET_100_SERIES_SUNRISE_POINT) ||
844 (chipset == CHIPSET_APL)) {
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530845 mmio_le_writel(control, spibar + PCH100_REG_FDOC);
846 return mmio_le_readl(spibar + PCH100_REG_FDOD);
847 } else {
848 mmio_le_writel(control, spibar + ICH9_REG_FDOC);
849 return mmio_le_readl(spibar + ICH9_REG_FDOD);
850 }
851
David Hendricksce6b2fa2011-07-11 22:12:43 -0700852}
853
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530854int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc,
855 int chipset)
David Hendricksce6b2fa2011-07-11 22:12:43 -0700856{
stefanct1fc3a732011-09-15 23:52:55 +0000857 uint8_t i;
858 uint8_t nr;
859 struct ich_desc_region *r = &desc->region;
860
861 /* Test if bit-fields are working as expected.
862 * FIXME: Replace this with dynamic bitfield fixup
863 */
864 for (i = 0; i < 4; i++)
865 desc->region.FLREGs[i] = 0x5A << (i * 8);
866 if (r->reg0_base != 0x005A || r->reg0_limit != 0x0000 ||
867 r->reg1_base != 0x1A00 || r->reg1_limit != 0x0000 ||
868 r->reg2_base != 0x0000 || r->reg2_limit != 0x005A ||
869 r->reg3_base != 0x0000 || r->reg3_limit != 0x1A00) {
870 msg_pdbg("The combination of compiler and CPU architecture used"
871 "does not lay out bit-fields as expected, sorry.\n");
872 msg_pspew("r->reg0_base = 0x%04X (0x005A)\n", r->reg0_base);
873 msg_pspew("r->reg0_limit = 0x%04X (0x0000)\n", r->reg0_limit);
874 msg_pspew("r->reg1_base = 0x%04X (0x1A00)\n", r->reg1_base);
875 msg_pspew("r->reg1_limit = 0x%04X (0x0000)\n", r->reg1_limit);
876 msg_pspew("r->reg2_base = 0x%04X (0x0000)\n", r->reg2_base);
877 msg_pspew("r->reg2_limit = 0x%04X (0x005A)\n", r->reg2_limit);
878 msg_pspew("r->reg3_base = 0x%04X (0x0000)\n", r->reg3_base);
879 msg_pspew("r->reg3_limit = 0x%04X (0x1A00)\n", r->reg3_limit);
880 return ICH_RET_ERR;
881 }
882
883 msg_pdbg2("Reading flash descriptors "
David Hendricksce6b2fa2011-07-11 22:12:43 -0700884 "mapped by the chipset via FDOC/FDOD...");
stefanct1fc3a732011-09-15 23:52:55 +0000885 /* content section */
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530886 desc->content.FLVALSIG = read_descriptor_reg(0, 0, spibar, chipset);
887 desc->content.FLMAP0 = read_descriptor_reg(0, 1, spibar, chipset);
888 desc->content.FLMAP1 = read_descriptor_reg(0, 2, spibar, chipset);
889 desc->content.FLMAP2 = read_descriptor_reg(0, 3, spibar, chipset);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700890
891 /* component section */
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530892 desc->component.FLCOMP = read_descriptor_reg(1, 0, spibar, chipset);
893 desc->component.FLILL = read_descriptor_reg(1, 1, spibar, chipset);
894 desc->component.FLPB = read_descriptor_reg(1, 2, spibar, chipset);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700895
896 /* region section */
stefanct1fc3a732011-09-15 23:52:55 +0000897 nr = desc->content.NR + 1;
898 if (nr >= 5) {
899 msg_pdbg2("%s: number of regions too high (%d) - failed\n",
900 __func__, nr);
901 return ICH_RET_ERR;
902 }
903 for (i = 0; i <= nr; i++)
Ramya Vijaykumara9a64f92015-04-15 15:26:22 +0530904 desc->region.FLREGs[i] = read_descriptor_reg(2, i,
905 spibar, chipset);
David Hendricksce6b2fa2011-07-11 22:12:43 -0700906
907 /* master section */
Duncan Lauriedbbf2222019-04-25 12:06:19 -0700908 if (chipset >= CHIPSET_100_SERIES_SUNRISE_POINT) {
909 desc->master.pch100.FLMSTR1 = read_descriptor_reg(3, 0, spibar, chipset);
910 desc->master.pch100.FLMSTR2 = read_descriptor_reg(3, 1, spibar, chipset);
911 desc->master.pch100.FLMSTR3 = read_descriptor_reg(3, 2, spibar, chipset);
912 desc->master.pch100.FLMSTR4 = read_descriptor_reg(3, 3, spibar, chipset);
913 desc->master.pch100.FLMSTR5 = read_descriptor_reg(3, 4, spibar, chipset);
914 } else {
915 desc->master.ich.FLMSTR1 = read_descriptor_reg(3, 0, spibar, chipset);
916 desc->master.ich.FLMSTR2 = read_descriptor_reg(3, 1, spibar, chipset);
917 desc->master.ich.FLMSTR3 = read_descriptor_reg(3, 2, spibar, chipset);
918 }
David Hendricksce6b2fa2011-07-11 22:12:43 -0700919
stefanct1fc3a732011-09-15 23:52:55 +0000920 /* Accessing the strap section via FDOC/D is only possible on ICH8 and
921 * reading the upper map is impossible on all chipsets, so don't bother.
922 */
923
924 msg_pdbg2(" done.\n");
925 return ICH_RET_OK;
David Hendricksce6b2fa2011-07-11 22:12:43 -0700926}
Stefan Tauner34f6f5a2016-08-03 11:20:38 -0700927#endif /* ICH_DESCRIPTORS_FROM_DUMP */
stefanct1fc3a732011-09-15 23:52:55 +0000928#endif /* defined(__i386__) || defined(__x86_64__) */