blob: c9ae6cd79644051d60113394310caa62cb142bfb [file] [log] [blame]
Stefan Tauner1e146392011-09-15 23:52:55 +00001/*
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 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#if defined(__i386__) || defined(__x86_64__)
23
24#include "ich_descriptors.h"
Stefan Taunerb3850962011-12-24 00:00:32 +000025
26#ifdef ICH_DESCRIPTORS_FROM_DUMP
27
28#include <stdio.h>
29#define print(t, ...) printf(__VA_ARGS__)
30#define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a
31/* The upper map is located in the word before the 256B-long OEM section at the
32 * end of the 4kB-long flash descriptor.
33 */
34#define UPPER_MAP_OFFSET (4096 - 256 - 4)
35#define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0)
36
37#else /* ICH_DESCRIPTORS_FROM_DUMP */
38
Stefan Tauner1e146392011-09-15 23:52:55 +000039#include "flash.h" /* for msg_* */
40#include "programmer.h"
41
Stefan Taunerb3850962011-12-24 00:00:32 +000042#endif /* ICH_DESCRIPTORS_FROM_DUMP */
43
44#ifndef min
45#define min(a, b) (a < b) ? a : b
46#endif
47
Stefan Tauner1e146392011-09-15 23:52:55 +000048void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity)
49{
50 print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF);
51 print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF);
52 print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF);
53 print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF);
54 print(verbosity, "EO=0x%x, ", (reg_val & VSCC_EO) >> VSCC_EO_OFF);
55 print(verbosity, "VCL=%d\n", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF);
56}
57
58#define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0)
59#define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0)
60#define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0)
61#define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0)
62#define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0)
63
64void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc)
65{
66 prettyprint_ich_descriptor_content(&desc->content);
67 prettyprint_ich_descriptor_component(desc);
68 prettyprint_ich_descriptor_region(desc);
69 prettyprint_ich_descriptor_master(&desc->master);
Stefan Taunerb3850962011-12-24 00:00:32 +000070#ifdef ICH_DESCRIPTORS_FROM_DUMP
71 if (cs >= CHIPSET_ICH8) {
72 prettyprint_ich_descriptor_upper_map(&desc->upper);
73 prettyprint_ich_descriptor_straps(cs, desc);
74 }
75#endif /* ICH_DESCRIPTORS_FROM_DUMP */
Stefan Tauner1e146392011-09-15 23:52:55 +000076}
77
78void prettyprint_ich_descriptor_content(const struct ich_desc_content *cont)
79{
80 msg_pdbg2("=== Content Section ===\n");
81 msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG);
82 msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0);
83 msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1);
84 msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2);
85 msg_pdbg2("\n");
86
87 msg_pdbg2("--- Details ---\n");
Stefan Taunera1a14ec2012-08-13 08:45:13 +000088 msg_pdbg2("NR (Number of Regions): %5d\n", cont->NR + 1);
89 msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n", getFRBA(cont));
90 msg_pdbg2("NC (Number of Components): %5d\n", cont->NC + 1);
91 msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n", getFCBA(cont));
92 msg_pdbg2("ISL (ICH/PCH Strap Length): %5d\n", cont->ISL);
93 msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address): 0x%03x\n", getFISBA(cont));
94 msg_pdbg2("NM (Number of Masters): %5d\n", cont->NM + 1);
95 msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n", getFMBA(cont));
96 msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n", cont->MSL);
97 msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n", getFMSBA(cont));
Stefan Tauner1e146392011-09-15 23:52:55 +000098 msg_pdbg2("\n");
99}
100
101void prettyprint_ich_descriptor_component(const struct ich_descriptors *desc)
102{
103 static const char * const freq_str[8] = {
104 "20 MHz", /* 000 */
105 "33 MHz", /* 001 */
106 "reserved", /* 010 */
107 "reserved", /* 011 */
108 "50 MHz", /* 100 */
109 "reserved", /* 101 */
110 "reserved", /* 110 */
111 "reserved" /* 111 */
112 };
113 static const char * const size_str[8] = {
114 "512 kB", /* 000 */
115 " 1 MB", /* 001 */
116 " 2 MB", /* 010 */
117 " 4 MB", /* 011 */
118 " 8 MB", /* 100 */
119 " 16 MB", /* 101 */
120 "reserved", /* 110 */
121 "reserved", /* 111 */
122 };
123
124 msg_pdbg2("=== Component Section ===\n");
125 msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP);
126 msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL );
127 msg_pdbg2("\n");
128
129 msg_pdbg2("--- Details ---\n");
130 msg_pdbg2("Component 1 density: %s\n",
131 size_str[desc->component.comp1_density]);
132 if (desc->content.NC)
133 msg_pdbg2("Component 2 density: %s\n",
134 size_str[desc->component.comp2_density]);
135 else
136 msg_pdbg2("Component 2 is not used.\n");
137 msg_pdbg2("Read Clock Frequency: %s\n",
138 freq_str[desc->component.freq_read]);
139 msg_pdbg2("Read ID and Status Clock Freq.: %s\n",
140 freq_str[desc->component.freq_read_id]);
141 msg_pdbg2("Write and Erase Clock Freq.: %s\n",
142 freq_str[desc->component.freq_write]);
143 msg_pdbg2("Fast Read is %ssupported.\n",
144 desc->component.fastread ? "" : "not ");
145 if (desc->component.fastread)
146 msg_pdbg2("Fast Read Clock Frequency: %s\n",
147 freq_str[desc->component.freq_fastread]);
148 if (desc->component.FLILL == 0)
149 msg_pdbg2("No forbidden opcodes.\n");
150 else {
151 msg_pdbg2("Invalid instruction 0: 0x%02x\n",
152 desc->component.invalid_instr0);
153 msg_pdbg2("Invalid instruction 1: 0x%02x\n",
154 desc->component.invalid_instr1);
155 msg_pdbg2("Invalid instruction 2: 0x%02x\n",
156 desc->component.invalid_instr2);
157 msg_pdbg2("Invalid instruction 3: 0x%02x\n",
158 desc->component.invalid_instr3);
159 }
160 msg_pdbg2("\n");
161}
162
163static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
164{
165 static const char *const region_names[5] = {
166 "Descr.", "BIOS", "ME", "GbE", "Platf."
167 };
168 if (i >= 5) {
169 msg_pdbg2("%s: region index too high.\n", __func__);
170 return;
171 }
172 uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]);
173 uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]);
174 msg_pdbg2("Region %d (%-6s) ", i, region_names[i]);
175 if (base > limit)
176 msg_pdbg2("is unused.\n");
177 else
178 msg_pdbg2("0x%08x - 0x%08x\n", base, limit | 0x0fff);
179}
180
181void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc)
182{
183 uint8_t i;
184 uint8_t nr = desc->content.NR + 1;
185 msg_pdbg2("=== Region Section ===\n");
Stefan Tauner2abab942012-04-27 20:41:23 +0000186 if (nr > 5) {
Stefan Tauner1e146392011-09-15 23:52:55 +0000187 msg_pdbg2("%s: number of regions too high (%d).\n", __func__,
188 nr);
189 return;
190 }
191 for (i = 0; i <= nr; i++)
192 msg_pdbg2("FLREG%d 0x%08x\n", i, desc->region.FLREGs[i]);
193 msg_pdbg2("\n");
194
195 msg_pdbg2("--- Details ---\n");
196 for (i = 0; i <= nr; i++)
197 pprint_freg(&desc->region, i);
198 msg_pdbg2("\n");
199}
200
201void prettyprint_ich_descriptor_master(const struct ich_desc_master *mstr)
202{
203 msg_pdbg2("=== Master Section ===\n");
204 msg_pdbg2("FLMSTR1 0x%08x\n", mstr->FLMSTR1);
205 msg_pdbg2("FLMSTR2 0x%08x\n", mstr->FLMSTR2);
206 msg_pdbg2("FLMSTR3 0x%08x\n", mstr->FLMSTR3);
207 msg_pdbg2("\n");
208
209 msg_pdbg2("--- Details ---\n");
210 msg_pdbg2(" Descr. BIOS ME GbE Platf.\n");
211 msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n",
212 (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
213 (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
214 (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
215 (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
216 (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ');
217 msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n",
218 (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
219 (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
220 (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
221 (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
222 (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ');
223 msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n",
224 (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
225 (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
226 (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
227 (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
228 (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ');
229 msg_pdbg2("\n");
230}
231
Stefan Taunerb3850962011-12-24 00:00:32 +0000232#ifdef ICH_DESCRIPTORS_FROM_DUMP
233
234void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc)
235{
236 static const char * const str_GPIO12[4] = {
237 "GPIO12",
238 "LAN PHY Power Control Function (Native Output)",
239 "GLAN_DOCK# (Native Input)",
240 "invalid configuration",
241 };
242
243 msg_pdbg2("--- MCH details ---\n");
244 msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en");
245 msg_pdbg2("\n");
246
247 msg_pdbg2("--- ICH details ---\n");
248 msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD);
249 msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2);
250 msg_pdbg2("ME SMBus Controller is connected to the %s.\n",
251 desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins");
252 msg_pdbg2("SPI CS1 is used for %s.\n",
253 desc->south.ich8.SPICS1_LANPHYPC_SEL ?
254 "LAN PHY Power Control Function" :
255 "SPI Chip Select");
256 msg_pdbg2("GPIO12 is used as %s.\n",
257 str_GPIO12[desc->south.ich8.GPIO12_SEL]);
258 msg_pdbg2("PCIe Port 6 is used for %s.\n",
259 desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express");
260 msg_pdbg2("%sn BMC Mode: "
261 "Intel AMT SMBus Controller 1 is connected to %s.\n",
262 desc->south.ich8.BMCMODE ? "I" : "Not i",
263 desc->south.ich8.BMCMODE ? "SMLink" : "SMBus");
264 msg_pdbg2("TCO is in %s Mode.\n",
265 desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible");
266 msg_pdbg2("ME A is %sabled.\n",
267 desc->south.ich8.ME_DISABLE ? "dis" : "en");
268 msg_pdbg2("\n");
269}
270
271static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off)
272{
273 msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1);
274
275 off *= 4;
276 switch(conf){
277 case 0:
278 msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off);
279 break;
280 case 1:
281 msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), "
282 "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off);
283 break;
284 case 2:
285 msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports "
286 "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off);
287 break;
288 case 3:
289 msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)",
290 1+off, 2+off, 4+off);
291 break;
292 }
293 msg_pdbg2("\n");
294}
295
296void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s)
297{
298 /* PCHSTRP4 */
299 msg_pdbg2("Intel PHY is %s.\n",
300 (s->ibex.PHYCON == 2) ? "connected" :
301 (s->ibex.PHYCON == 0) ? "disconnected" : "reserved");
302 msg_pdbg2("GbE MAC SMBus address is %sabled.\n",
303 s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis");
304 msg_pdbg2("GbE MAC SMBus address: 0x%02x\n",
305 s->ibex.GBEMAC_SMBUS_ADDR);
306 msg_pdbg2("GbE PHY SMBus address: 0x%02x\n",
307 s->ibex.GBEPHY_SMBUS_ADDR);
308
309 /* PCHSTRP5 */
310 /* PCHSTRP6 */
311 /* PCHSTRP7 */
312 msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n",
313 s->ibex.MESMA2UDID_VENDOR);
314 msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n",
315 s->ibex.MESMA2UDID_VENDOR);
316
317 /* PCHSTRP8 */
318}
319
320void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s)
321{
322 /* PCHSTRP11 */
323 msg_pdbg2("SMLink1 GP Address is %sabled.\n",
324 s->ibex.SML1GPAEN ? "en" : "dis");
325 msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n",
326 s->ibex.SML1GPA);
327 msg_pdbg2("SMLink1 I2C Target address is %sabled.\n",
328 s->ibex.SML1I2CAEN ? "en" : "dis");
329 msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n",
330 s->ibex.SML1I2CA);
331
332 /* PCHSTRP12 */
333 /* PCHSTRP13 */
334}
335
336void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s)
337{
338 static const uint8_t const dec_t209min[4] = {
339 100,
340 50,
341 5,
342 1
343 };
344
345 msg_pdbg2("--- PCH ---\n");
346
347 /* PCHSTRP0 */
348 msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2);
349 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
350 s->ibex.SMB_EN ? "en" : "dis");
351 msg_pdbg2("SMLink0 segment is %sabled.\n",
352 s->ibex.SML0_EN ? "en" : "dis");
353 msg_pdbg2("SMLink1 segment is %sabled.\n",
354 s->ibex.SML1_EN ? "en" : "dis");
355 msg_pdbg2("SMLink1 Frequency: %s\n",
356 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
357 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
358 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
359 msg_pdbg2("SMLink0 Frequency: %s\n",
360 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
361 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
362 "LAN_PHY_PWR_CTRL" : "general purpose output");
363 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1);
364 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
365 s->ibex.DMI_REQID_DIS ? "en" : "dis");
366 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
367 1 << (6 + s->ibex.BBBS));
368
369 /* PCHSTRP1 */
370 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
371
372 /* PCHSTRP2 */
373 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
374 s->ibex.MESMASDEN ? "en" : "dis");
375 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
376 s->ibex.MESMASDA);
377 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
378 s->ibex.MESMI2CEN ? "en" : "dis");
379 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
380 s->ibex.MESMI2CA);
381
382 /* PCHSTRP3 */
383 prettyprint_ich_descriptor_pchstraps45678_56(s);
384 /* PCHSTRP9 */
385 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
386 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
387 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
388 s->ibex.PCIELR1 ? "" : "not ");
389 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
390 s->ibex.PCIELR2 ? "" : "not ");
391 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
392 s->ibex.DMILR ? "" : "not ");
393 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
394 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
395 s->ibex.PHY_PCIE_EN ? "en" : "dis");
396
397 /* PCHSTRP10 */
398 msg_pdbg2("Management Engine will boot from %sflash.\n",
399 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
400 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5);
401 msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n",
402 s->ibex.VE_EN ? "en" : "dis");
403 msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n",
404 s->ibex.MMDDE ? "en" : "dis");
405 msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n",
406 s->ibex.MMADDR);
407 msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7);
408 msg_pdbg2("Integrated Clocking Configuration is %d.\n",
409 (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL);
410 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
411 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
412
413 prettyprint_ich_descriptor_pchstraps111213_56(s);
414
415 /* PCHSTRP14 */
416 msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n",
417 s->ibex.VE_EN2 ? "en" : "dis");
418 msg_pdbg2("Virtualization Engine will boot from %sflash.\n",
419 s->ibex.VE_BOOT_FLASH ? "" : "ROM, then ");
420 msg_pdbg2("Braidwood SSD functionality is %sabled.\n",
421 s->ibex.BW_SSD ? "en" : "dis");
422 msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n",
423 s->ibex.NVMHCI_EN ? "en" : "dis");
424
425 /* PCHSTRP15 */
426 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6);
427 msg_pdbg2("Integrated wired LAN Solution is %sabled.\n",
428 s->ibex.IWL_EN ? "en" : "dis");
429 msg_pdbg2("t209 min Timing: %d ms\n",
430 dec_t209min[s->ibex.t209min]);
431 msg_pdbg2("\n");
432}
433
434void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s)
435{
436 msg_pdbg2("--- PCH ---\n");
437
438 /* PCHSTRP0 */
439 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1);
440 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
441 s->ibex.SMB_EN ? "en" : "dis");
442 msg_pdbg2("SMLink0 segment is %sabled.\n",
443 s->ibex.SML0_EN ? "en" : "dis");
444 msg_pdbg2("SMLink1 segment is %sabled.\n",
445 s->ibex.SML1_EN ? "en" : "dis");
446 msg_pdbg2("SMLink1 Frequency: %s\n",
447 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
448 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
449 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
450 msg_pdbg2("SMLink0 Frequency: %s\n",
451 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
452 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
453 "LAN_PHY_PWR_CTRL" : "general purpose output");
454 msg_pdbg2("LinkSec is %sabled.\n",
455 s->cougar.LINKSEC_DIS ? "en" : "dis");
456 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
457 s->ibex.DMI_REQID_DIS ? "en" : "dis");
458 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
459 1 << (6 + s->ibex.BBBS));
460
461 /* PCHSTRP1 */
462 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
463 msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2);
464
465 /* PCHSTRP2 */
466 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
467 s->ibex.MESMASDEN ? "en" : "dis");
468 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
469 s->ibex.MESMASDA);
470 msg_pdbg2("ME SMBus MCTP Address is %sabled.\n",
471 s->cougar.MESMMCTPAEN ? "en" : "dis");
472 msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n",
473 s->cougar.MESMMCTPA);
474 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
475 s->ibex.MESMI2CEN ? "en" : "dis");
476 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
477 s->ibex.MESMI2CA);
478
479 /* PCHSTRP3 */
480 prettyprint_ich_descriptor_pchstraps45678_56(s);
481 /* PCHSTRP9 */
482 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
483 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
484 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
485 s->ibex.PCIELR1 ? "" : "not ");
486 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
487 s->ibex.PCIELR2 ? "" : "not ");
488 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
489 s->ibex.DMILR ? "" : "not ");
490 msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n",
491 s->cougar.MDSMBE_EN ? "en" : "dis");
492 msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n",
493 s->cougar.MDSMBE_ADD);
494 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
495 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
496 s->ibex.PHY_PCIE_EN ? "en" : "dis");
497 msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n",
498 s->cougar.SUB_DECODE_EN ? "en" : "dis");
499 msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ?
500 "PCHHOT#" : "SML1ALERT#");
501
502 /* PCHSTRP10 */
503 msg_pdbg2("Management Engine will boot from %sflash.\n",
504 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
505
506 msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n",
507 s->cougar.MDSMBE_EN ? "en" : "dis");
508 msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n",
509 s->cougar.MDSMBE_ADD);
510
511 msg_pdbg2("Integrated Clocking Configuration used: %d\n",
512 s->cougar.ICC_SEL);
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000513 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a reset.\n",
514 s->ibex.MER_CL1 ? "" : "not ");
Stefan Taunerb3850962011-12-24 00:00:32 +0000515 msg_pdbg2("ICC Profile is selected by %s.\n",
516 s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
517 msg_pdbg2("Deep SX is %ssupported on the platform.\n",
518 s->cougar.Deep_SX_EN ? "not " : "");
519 msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n",
520 s->cougar.ME_DBG_LAN ? "en" : "dis");
521
522 prettyprint_ich_descriptor_pchstraps111213_56(s);
523
524 /* PCHSTRP14 */
525 /* PCHSTRP15 */
526 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6);
527 msg_pdbg2("Integrated wired LAN is %sabled.\n",
528 s->cougar.IWL_EN ? "en" : "dis");
529 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
530 msg_pdbg2("SMLink1 provides temperature from %s.\n",
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000531 s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and DIMMs");
Stefan Taunerb3850962011-12-24 00:00:32 +0000532 msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
533 "general purpose output" : "SLP_LAN#");
534
535 /* PCHSTRP16 */
536 /* PCHSTRP17 */
537 msg_pdbg2("Integrated Clock: %s Clock Mode\n",
538 s->cougar.ICML ? "Buffered Through" : "Full Integrated");
539 msg_pdbg2("\n");
540}
541
542void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc)
543{
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000544 unsigned int i, max_count;
Stefan Taunerb3850962011-12-24 00:00:32 +0000545 msg_pdbg2("=== Softstraps ===\n");
546
547 if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000548 max_count = sizeof(desc->north.STRPs) / 4 + 1;
549 msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
550 desc->content.MSL, max_count + 1);
551 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
Stefan Taunerb3850962011-12-24 00:00:32 +0000552 } else
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000553 max_count = desc->content.MSL;
Stefan Taunerb3850962011-12-24 00:00:32 +0000554
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000555 msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
556 for (i = 0; i < max_count; i++)
Stefan Taunerb3850962011-12-24 00:00:32 +0000557 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
558 msg_pdbg2("\n");
559
560 if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000561 max_count = sizeof(desc->south.STRPs) / 4;
562 msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
563 desc->content.ISL, max_count);
564 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
Stefan Taunerb3850962011-12-24 00:00:32 +0000565 } else
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000566 max_count = desc->content.ISL;
Stefan Taunerb3850962011-12-24 00:00:32 +0000567
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000568 msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
569 for (i = 0; i < max_count; i++)
Stefan Taunerb3850962011-12-24 00:00:32 +0000570 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
571 msg_pdbg2("\n");
572
573 switch (cs) {
574 case CHIPSET_ICH8:
575 if (sizeof(desc->north.ich8) / 4 != desc->content.MSL)
576 msg_pdbg2("Detailed North/MCH/PROC information is "
577 "probably not reliable, printing anyway.\n");
578 if (sizeof(desc->south.ich8) / 4 != desc->content.ISL)
579 msg_pdbg2("Detailed South/ICH/PCH information is "
580 "probably not reliable, printing anyway.\n");
581 prettyprint_ich_descriptor_straps_ich8(desc);
582 break;
583 case CHIPSET_5_SERIES_IBEX_PEAK:
584 /* PCH straps only. PROCSTRPs are unknown. */
585 if (sizeof(desc->south.ibex) / 4 != desc->content.ISL)
586 msg_pdbg2("Detailed South/ICH/PCH information is "
587 "probably not reliable, printing anyway.\n");
588 prettyprint_ich_descriptor_straps_ibex(&desc->south);
589 break;
590 case CHIPSET_6_SERIES_COUGAR_POINT:
591 /* PCH straps only. PROCSTRP0 is "reserved". */
592 if (sizeof(desc->south.cougar) / 4 != desc->content.ISL)
593 msg_pdbg2("Detailed South/ICH/PCH information is "
594 "probably not reliable, printing anyway.\n");
595 prettyprint_ich_descriptor_straps_cougar(&desc->south);
596 break;
597 case CHIPSET_ICH_UNKNOWN:
598 break;
599 default:
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000600 msg_pdbg2("The meaning of the descriptor straps are unknown yet.\n\n");
Stefan Taunerb3850962011-12-24 00:00:32 +0000601 break;
602 }
603}
604
605void prettyprint_rdid(uint32_t reg_val)
606{
607 uint8_t mid = reg_val & 0xFF;
608 uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00);
609 msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did);
610}
611
612void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap)
613{
614 int i;
615 msg_pdbg2("=== Upper Map Section ===\n");
616 msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1);
617 msg_pdbg2("\n");
618
619 msg_pdbg2("--- Details ---\n");
620 msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL);
621 msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap));
622 msg_pdbg2("\n");
623
624 msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000625 for (i = 0; i < umap->VTL/2; i++) {
Stefan Taunerb3850962011-12-24 00:00:32 +0000626 uint32_t jid = umap->vscc_table[i].JID;
627 uint32_t vscc = umap->vscc_table[i].VSCC;
628 msg_pdbg2(" JID%d = 0x%08x\n", i, jid);
629 msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc);
630 msg_pdbg2(" "); /* indention */
631 prettyprint_rdid(jid);
632 msg_pdbg2(" "); /* indention */
633 prettyprint_ich_reg_vscc(vscc, 0);
634 }
635 msg_pdbg2("\n");
636}
637
638/* len is the length of dump in bytes */
639int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc)
640{
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000641 unsigned int i, max_count;
Stefan Taunerb3850962011-12-24 00:00:32 +0000642 uint8_t pch_bug_offset = 0;
643
644 if (dump == NULL || desc == NULL)
645 return ICH_RET_PARAM;
646
647 if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) {
648 if (dump[4] == DESCRIPTOR_MODE_SIGNATURE)
649 pch_bug_offset = 4;
650 else
651 return ICH_RET_ERR;
652 }
653
654 /* map */
655 if (len < (4 + pch_bug_offset) * 4 - 1)
656 return ICH_RET_OOB;
657 desc->content.FLVALSIG = dump[0 + pch_bug_offset];
658 desc->content.FLMAP0 = dump[1 + pch_bug_offset];
659 desc->content.FLMAP1 = dump[2 + pch_bug_offset];
660 desc->content.FLMAP2 = dump[3 + pch_bug_offset];
661
662 /* component */
663 if (len < (getFCBA(&desc->content) + 3 * 4 - 1))
664 return ICH_RET_OOB;
665 desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0];
666 desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
667 desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
668
669 /* region */
670 if (len < (getFRBA(&desc->content) + 5 * 4 - 1))
671 return ICH_RET_OOB;
672 desc->region.FLREGs[0] = dump[(getFRBA(&desc->content) >> 2) + 0];
673 desc->region.FLREGs[1] = dump[(getFRBA(&desc->content) >> 2) + 1];
674 desc->region.FLREGs[2] = dump[(getFRBA(&desc->content) >> 2) + 2];
675 desc->region.FLREGs[3] = dump[(getFRBA(&desc->content) >> 2) + 3];
676 desc->region.FLREGs[4] = dump[(getFRBA(&desc->content) >> 2) + 4];
677
678 /* master */
679 if (len < (getFMBA(&desc->content) + 3 * 4 - 1))
680 return ICH_RET_OOB;
681 desc->master.FLMSTR1 = dump[(getFMBA(&desc->content) >> 2) + 0];
682 desc->master.FLMSTR2 = dump[(getFMBA(&desc->content) >> 2) + 1];
683 desc->master.FLMSTR3 = dump[(getFMBA(&desc->content) >> 2) + 2];
684
685 /* upper map */
686 desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
687
688 /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
689 * "Identifies the 1s based number of DWORDS contained in the VSCC
690 * Table. Each SPI component entry in the table is 2 DWORDS long." So
691 * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
692 * check ensures that the maximum offset actually accessed is available.
693 */
694 if (len < (getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8) - 1))
695 return ICH_RET_OOB;
696
697 for (i = 0; i < desc->upper.VTL/2; i++) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000698 desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
699 desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
Stefan Taunerb3850962011-12-24 00:00:32 +0000700 }
701
702 /* MCH/PROC (aka. North) straps */
703 if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
704 return ICH_RET_OOB;
705
706 /* limit the range to be written */
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000707 max_count = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
708 for (i = 0; i < max_count; i++)
709 desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i];
Stefan Taunerb3850962011-12-24 00:00:32 +0000710
711 /* ICH/PCH (aka. South) straps */
712 if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
713 return ICH_RET_OOB;
714
715 /* limit the range to be written */
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000716 max_count = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
717 for (i = 0; i < max_count; i++)
718 desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i];
Stefan Taunerb3850962011-12-24 00:00:32 +0000719
720 return ICH_RET_OK;
721}
722
723#else /* ICH_DESCRIPTORS_FROM_DUMP */
724
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000725/** Returns the integer representation of the component density with index
726idx in bytes or 0 if a correct size can not be determined. */
727int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx)
728{
729 uint8_t size_enc;
730
731 switch(idx) {
732 case 0:
733 size_enc = desc->component.comp1_density;
734 break;
735 case 1:
736 if (desc->content.NC == 0)
737 return 0;
738 size_enc = desc->component.comp2_density;
739 break;
740 default:
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000741 msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000742 return 0;
743 }
744 if (size_enc > 5) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000745 msg_perr("Density of ICH SPI component with index %d is invalid. Encoded density is 0x%x.\n",
746 idx, size_enc);
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000747 return 0;
748 }
749 return (1 << (19 + size_enc));
750}
751
Stefan Tauner1e146392011-09-15 23:52:55 +0000752static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset, void *spibar)
753{
754 uint32_t control = 0;
755 control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS;
756 control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI;
757 mmio_le_writel(control, spibar + ICH9_REG_FDOC);
758 return mmio_le_readl(spibar + ICH9_REG_FDOD);
759}
760
761int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc)
762{
763 uint8_t i;
764 uint8_t nr;
765 struct ich_desc_region *r = &desc->region;
766
767 /* Test if bit-fields are working as expected.
768 * FIXME: Replace this with dynamic bitfield fixup
769 */
770 for (i = 0; i < 4; i++)
771 desc->region.FLREGs[i] = 0x5A << (i * 8);
772 if (r->reg0_base != 0x005A || r->reg0_limit != 0x0000 ||
773 r->reg1_base != 0x1A00 || r->reg1_limit != 0x0000 ||
774 r->reg2_base != 0x0000 || r->reg2_limit != 0x005A ||
775 r->reg3_base != 0x0000 || r->reg3_limit != 0x1A00) {
776 msg_pdbg("The combination of compiler and CPU architecture used"
777 "does not lay out bit-fields as expected, sorry.\n");
778 msg_pspew("r->reg0_base = 0x%04X (0x005A)\n", r->reg0_base);
779 msg_pspew("r->reg0_limit = 0x%04X (0x0000)\n", r->reg0_limit);
780 msg_pspew("r->reg1_base = 0x%04X (0x1A00)\n", r->reg1_base);
781 msg_pspew("r->reg1_limit = 0x%04X (0x0000)\n", r->reg1_limit);
782 msg_pspew("r->reg2_base = 0x%04X (0x0000)\n", r->reg2_base);
783 msg_pspew("r->reg2_limit = 0x%04X (0x005A)\n", r->reg2_limit);
784 msg_pspew("r->reg3_base = 0x%04X (0x0000)\n", r->reg3_base);
785 msg_pspew("r->reg3_limit = 0x%04X (0x1A00)\n", r->reg3_limit);
786 return ICH_RET_ERR;
787 }
788
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000789 msg_pdbg2("Reading flash descriptors mapped by the chipset via FDOC/FDOD...");
Stefan Tauner1e146392011-09-15 23:52:55 +0000790 /* content section */
791 desc->content.FLVALSIG = read_descriptor_reg(0, 0, spibar);
792 desc->content.FLMAP0 = read_descriptor_reg(0, 1, spibar);
793 desc->content.FLMAP1 = read_descriptor_reg(0, 2, spibar);
794 desc->content.FLMAP2 = read_descriptor_reg(0, 3, spibar);
795
796 /* component section */
797 desc->component.FLCOMP = read_descriptor_reg(1, 0, spibar);
798 desc->component.FLILL = read_descriptor_reg(1, 1, spibar);
799 desc->component.FLPB = read_descriptor_reg(1, 2, spibar);
800
801 /* region section */
802 nr = desc->content.NR + 1;
Stefan Tauner2abab942012-04-27 20:41:23 +0000803 if (nr > 5) {
Stefan Tauner1e146392011-09-15 23:52:55 +0000804 msg_pdbg2("%s: number of regions too high (%d) - failed\n",
805 __func__, nr);
806 return ICH_RET_ERR;
807 }
808 for (i = 0; i <= nr; i++)
809 desc->region.FLREGs[i] = read_descriptor_reg(2, i, spibar);
810
811 /* master section */
812 desc->master.FLMSTR1 = read_descriptor_reg(3, 0, spibar);
813 desc->master.FLMSTR2 = read_descriptor_reg(3, 1, spibar);
814 desc->master.FLMSTR3 = read_descriptor_reg(3, 2, spibar);
815
816 /* Accessing the strap section via FDOC/D is only possible on ICH8 and
817 * reading the upper map is impossible on all chipsets, so don't bother.
818 */
819
820 msg_pdbg2(" done.\n");
821 return ICH_RET_OK;
822}
Stefan Taunerb3850962011-12-24 00:00:32 +0000823#endif /* ICH_DESCRIPTORS_FROM_DUMP */
Stefan Tauner1e146392011-09-15 23:52:55 +0000824#endif /* defined(__i386__) || defined(__x86_64__) */