blob: a0b2c9ae60230225cd744368563b62a0f077606e [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
Stefan Tauner1e146392011-09-15 23:52:55 +000022#include "ich_descriptors.h"
Stefan Taunerb3850962011-12-24 00:00:32 +000023
Nico Huberad186312016-05-02 15:15:29 +020024#ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY
Stefan Taunerb3850962011-12-24 00:00:32 +000025#include <stdio.h>
26#define print(t, ...) printf(__VA_ARGS__)
Nico Huberad186312016-05-02 15:15:29 +020027#endif
28
Stefan Taunerb3850962011-12-24 00:00:32 +000029#define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a
30/* The upper map is located in the word before the 256B-long OEM section at the
31 * end of the 4kB-long flash descriptor.
32 */
33#define UPPER_MAP_OFFSET (4096 - 256 - 4)
34#define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0)
35
Nico Huberad186312016-05-02 15:15:29 +020036#include <string.h>
Stefan Tauner1e146392011-09-15 23:52:55 +000037#include "flash.h" /* for msg_* */
38#include "programmer.h"
39
Stefan Taunerb3850962011-12-24 00:00:32 +000040#ifndef min
41#define min(a, b) (a < b) ? a : b
42#endif
43
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000044void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl)
Stefan Tauner1e146392011-09-15 23:52:55 +000045{
46 print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF);
47 print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF);
48 print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF);
49 print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000050 print(verbosity, "EO=0x%x", (reg_val & VSCC_EO) >> VSCC_EO_OFF);
51 if (print_vcl)
52 print(verbosity, ", VCL=%d", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF);
53 print(verbosity, "\n");
Stefan Tauner1e146392011-09-15 23:52:55 +000054}
55
56#define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0)
57#define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0)
58#define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0)
59#define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0)
60#define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0)
61
62void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc)
63{
64 prettyprint_ich_descriptor_content(&desc->content);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000065 prettyprint_ich_descriptor_component(cs, desc);
Stefan Tauner1e146392011-09-15 23:52:55 +000066 prettyprint_ich_descriptor_region(desc);
67 prettyprint_ich_descriptor_master(&desc->master);
Nico Huberad186312016-05-02 15:15:29 +020068#ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY
Stefan Taunerb3850962011-12-24 00:00:32 +000069 if (cs >= CHIPSET_ICH8) {
70 prettyprint_ich_descriptor_upper_map(&desc->upper);
71 prettyprint_ich_descriptor_straps(cs, desc);
72 }
Nico Huberad186312016-05-02 15:15:29 +020073#endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */
Stefan Tauner1e146392011-09-15 23:52:55 +000074}
75
76void prettyprint_ich_descriptor_content(const struct ich_desc_content *cont)
77{
78 msg_pdbg2("=== Content Section ===\n");
79 msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG);
80 msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0);
81 msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1);
82 msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2);
83 msg_pdbg2("\n");
84
85 msg_pdbg2("--- Details ---\n");
Stefan Taunera1a14ec2012-08-13 08:45:13 +000086 msg_pdbg2("NR (Number of Regions): %5d\n", cont->NR + 1);
87 msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n", getFRBA(cont));
88 msg_pdbg2("NC (Number of Components): %5d\n", cont->NC + 1);
89 msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n", getFCBA(cont));
90 msg_pdbg2("ISL (ICH/PCH Strap Length): %5d\n", cont->ISL);
91 msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address): 0x%03x\n", getFISBA(cont));
92 msg_pdbg2("NM (Number of Masters): %5d\n", cont->NM + 1);
93 msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n", getFMBA(cont));
94 msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n", cont->MSL);
95 msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n", getFMSBA(cont));
Stefan Tauner1e146392011-09-15 23:52:55 +000096 msg_pdbg2("\n");
97}
98
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000099static const char *pprint_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx)
100{
101 if (idx > 1) {
102 msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
103 return NULL;
104 }
105
106 if (desc->content.NC == 0 && idx > 0)
107 return "unused";
108
109 static const char * const size_str[] = {
110 "512 kB", /* 0000 */
111 "1 MB", /* 0001 */
112 "2 MB", /* 0010 */
113 "4 MB", /* 0011 */
114 "8 MB", /* 0100 */
115 "16 MB", /* 0101 */ /* Maximum up to Lynx Point (excl.) */
116 "32 MB", /* 0110 */
117 "64 MB", /* 0111 */
118 };
119
120 switch (cs) {
121 case CHIPSET_ICH8:
122 case CHIPSET_ICH9:
123 case CHIPSET_ICH10:
124 case CHIPSET_5_SERIES_IBEX_PEAK:
125 case CHIPSET_6_SERIES_COUGAR_POINT:
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000126 case CHIPSET_7_SERIES_PANTHER_POINT:
127 case CHIPSET_BAYTRAIL: {
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000128 uint8_t size_enc;
129 if (idx == 0) {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000130 size_enc = desc->component.dens_old.comp1_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000131 } else {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000132 size_enc = desc->component.dens_old.comp2_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000133 }
134 if (size_enc > 5)
135 return "reserved";
136 return size_str[size_enc];
137 }
138 case CHIPSET_8_SERIES_LYNX_POINT:
139 case CHIPSET_8_SERIES_LYNX_POINT_LP:
Duncan Laurie823096e2014-08-20 15:39:38 +0000140 case CHIPSET_8_SERIES_WELLSBURG:
141 case CHIPSET_9_SERIES_WILDCAT_POINT: {
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000142 uint8_t size_enc;
143 if (idx == 0) {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000144 size_enc = desc->component.dens_new.comp1_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000145 } else {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000146 size_enc = desc->component.dens_new.comp2_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000147 }
148 if (size_enc > 7)
149 return "reserved";
150 return size_str[size_enc];
151 }
152 case CHIPSET_ICH_UNKNOWN:
153 default:
154 return "unknown";
155 }
156}
157
158static const char *pprint_freq(enum ich_chipset cs, uint8_t value)
Stefan Tauner1e146392011-09-15 23:52:55 +0000159{
160 static const char * const freq_str[8] = {
161 "20 MHz", /* 000 */
162 "33 MHz", /* 001 */
163 "reserved", /* 010 */
164 "reserved", /* 011 */
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000165 "50 MHz", /* 100 */ /* New since Ibex Peak */
Stefan Tauner1e146392011-09-15 23:52:55 +0000166 "reserved", /* 101 */
167 "reserved", /* 110 */
168 "reserved" /* 111 */
169 };
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000170
171 switch (cs) {
172 case CHIPSET_ICH8:
173 case CHIPSET_ICH9:
174 case CHIPSET_ICH10:
175 if (value > 1)
176 return "reserved";
177 case CHIPSET_5_SERIES_IBEX_PEAK:
178 case CHIPSET_6_SERIES_COUGAR_POINT:
179 case CHIPSET_7_SERIES_PANTHER_POINT:
180 case CHIPSET_8_SERIES_LYNX_POINT:
Duncan Laurie4095ed72014-08-20 15:39:32 +0000181 case CHIPSET_BAYTRAIL:
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000182 case CHIPSET_8_SERIES_LYNX_POINT_LP:
183 case CHIPSET_8_SERIES_WELLSBURG:
Duncan Laurie823096e2014-08-20 15:39:38 +0000184 case CHIPSET_9_SERIES_WILDCAT_POINT:
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000185 return freq_str[value];
186 case CHIPSET_ICH_UNKNOWN:
187 default:
188 return "unknown";
189 }
190}
191
192void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc)
193{
Stefan Tauner1e146392011-09-15 23:52:55 +0000194
195 msg_pdbg2("=== Component Section ===\n");
196 msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP);
197 msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL );
198 msg_pdbg2("\n");
199
200 msg_pdbg2("--- Details ---\n");
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000201 msg_pdbg2("Component 1 density: %s\n", pprint_density(cs, desc, 0));
Stefan Tauner1e146392011-09-15 23:52:55 +0000202 if (desc->content.NC)
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000203 msg_pdbg2("Component 2 density: %s\n", pprint_density(cs, desc, 1));
Stefan Tauner1e146392011-09-15 23:52:55 +0000204 else
205 msg_pdbg2("Component 2 is not used.\n");
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000206 msg_pdbg2("Read Clock Frequency: %s\n", pprint_freq(cs, desc->component.modes.freq_read));
207 msg_pdbg2("Read ID and Status Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_read_id));
208 msg_pdbg2("Write and Erase Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_write));
209 msg_pdbg2("Fast Read is %ssupported.\n", desc->component.modes.fastread ? "" : "not ");
210 if (desc->component.modes.fastread)
Stefan Tauner1e146392011-09-15 23:52:55 +0000211 msg_pdbg2("Fast Read Clock Frequency: %s\n",
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000212 pprint_freq(cs, desc->component.modes.freq_fastread));
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000213 if (cs > CHIPSET_6_SERIES_COUGAR_POINT)
214 msg_pdbg2("Dual Output Fast Read Support: %sabled\n",
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000215 desc->component.modes.dual_output ? "dis" : "en");
Stefan Tauner1e146392011-09-15 23:52:55 +0000216 if (desc->component.FLILL == 0)
217 msg_pdbg2("No forbidden opcodes.\n");
218 else {
219 msg_pdbg2("Invalid instruction 0: 0x%02x\n",
220 desc->component.invalid_instr0);
221 msg_pdbg2("Invalid instruction 1: 0x%02x\n",
222 desc->component.invalid_instr1);
223 msg_pdbg2("Invalid instruction 2: 0x%02x\n",
224 desc->component.invalid_instr2);
225 msg_pdbg2("Invalid instruction 3: 0x%02x\n",
226 desc->component.invalid_instr3);
227 }
228 msg_pdbg2("\n");
229}
230
231static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
232{
233 static const char *const region_names[5] = {
234 "Descr.", "BIOS", "ME", "GbE", "Platf."
235 };
236 if (i >= 5) {
237 msg_pdbg2("%s: region index too high.\n", __func__);
238 return;
239 }
240 uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]);
241 uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]);
242 msg_pdbg2("Region %d (%-6s) ", i, region_names[i]);
243 if (base > limit)
244 msg_pdbg2("is unused.\n");
245 else
246 msg_pdbg2("0x%08x - 0x%08x\n", base, limit | 0x0fff);
247}
248
249void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc)
250{
251 uint8_t i;
252 uint8_t nr = desc->content.NR + 1;
253 msg_pdbg2("=== Region Section ===\n");
Stefan Tauner2abab942012-04-27 20:41:23 +0000254 if (nr > 5) {
Stefan Tauner1e146392011-09-15 23:52:55 +0000255 msg_pdbg2("%s: number of regions too high (%d).\n", __func__,
256 nr);
257 return;
258 }
Stefan Tauner0554ca52013-07-25 22:54:25 +0000259 for (i = 0; i < 5; i++)
Stefan Tauner1e146392011-09-15 23:52:55 +0000260 msg_pdbg2("FLREG%d 0x%08x\n", i, desc->region.FLREGs[i]);
261 msg_pdbg2("\n");
262
263 msg_pdbg2("--- Details ---\n");
Stefan Tauner0554ca52013-07-25 22:54:25 +0000264 for (i = 0; i < 5; i++)
Stefan Tauner1e146392011-09-15 23:52:55 +0000265 pprint_freg(&desc->region, i);
266 msg_pdbg2("\n");
267}
268
269void prettyprint_ich_descriptor_master(const struct ich_desc_master *mstr)
270{
271 msg_pdbg2("=== Master Section ===\n");
272 msg_pdbg2("FLMSTR1 0x%08x\n", mstr->FLMSTR1);
273 msg_pdbg2("FLMSTR2 0x%08x\n", mstr->FLMSTR2);
274 msg_pdbg2("FLMSTR3 0x%08x\n", mstr->FLMSTR3);
275 msg_pdbg2("\n");
276
277 msg_pdbg2("--- Details ---\n");
278 msg_pdbg2(" Descr. BIOS ME GbE Platf.\n");
279 msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n",
280 (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
281 (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
282 (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
283 (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
284 (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ');
285 msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n",
286 (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
287 (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
288 (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
289 (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
290 (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ');
291 msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n",
292 (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
293 (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
294 (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
295 (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
296 (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ');
297 msg_pdbg2("\n");
298}
299
Stefan Taunerb3850962011-12-24 00:00:32 +0000300void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc)
301{
302 static const char * const str_GPIO12[4] = {
303 "GPIO12",
304 "LAN PHY Power Control Function (Native Output)",
305 "GLAN_DOCK# (Native Input)",
306 "invalid configuration",
307 };
308
309 msg_pdbg2("--- MCH details ---\n");
310 msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en");
311 msg_pdbg2("\n");
312
313 msg_pdbg2("--- ICH details ---\n");
314 msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD);
315 msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2);
316 msg_pdbg2("ME SMBus Controller is connected to the %s.\n",
317 desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins");
318 msg_pdbg2("SPI CS1 is used for %s.\n",
319 desc->south.ich8.SPICS1_LANPHYPC_SEL ?
320 "LAN PHY Power Control Function" :
321 "SPI Chip Select");
322 msg_pdbg2("GPIO12 is used as %s.\n",
323 str_GPIO12[desc->south.ich8.GPIO12_SEL]);
324 msg_pdbg2("PCIe Port 6 is used for %s.\n",
325 desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express");
326 msg_pdbg2("%sn BMC Mode: "
327 "Intel AMT SMBus Controller 1 is connected to %s.\n",
328 desc->south.ich8.BMCMODE ? "I" : "Not i",
329 desc->south.ich8.BMCMODE ? "SMLink" : "SMBus");
330 msg_pdbg2("TCO is in %s Mode.\n",
331 desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible");
332 msg_pdbg2("ME A is %sabled.\n",
333 desc->south.ich8.ME_DISABLE ? "dis" : "en");
334 msg_pdbg2("\n");
335}
336
337static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off)
338{
339 msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1);
340
341 off *= 4;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000342 switch (conf){
Stefan Taunerb3850962011-12-24 00:00:32 +0000343 case 0:
344 msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off);
345 break;
346 case 1:
347 msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), "
348 "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off);
349 break;
350 case 2:
351 msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports "
352 "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off);
353 break;
354 case 3:
355 msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)",
356 1+off, 2+off, 4+off);
357 break;
358 }
359 msg_pdbg2("\n");
360}
361
362void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s)
363{
364 /* PCHSTRP4 */
365 msg_pdbg2("Intel PHY is %s.\n",
366 (s->ibex.PHYCON == 2) ? "connected" :
367 (s->ibex.PHYCON == 0) ? "disconnected" : "reserved");
368 msg_pdbg2("GbE MAC SMBus address is %sabled.\n",
369 s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis");
370 msg_pdbg2("GbE MAC SMBus address: 0x%02x\n",
371 s->ibex.GBEMAC_SMBUS_ADDR);
372 msg_pdbg2("GbE PHY SMBus address: 0x%02x\n",
373 s->ibex.GBEPHY_SMBUS_ADDR);
374
375 /* PCHSTRP5 */
376 /* PCHSTRP6 */
377 /* PCHSTRP7 */
378 msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n",
379 s->ibex.MESMA2UDID_VENDOR);
380 msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n",
381 s->ibex.MESMA2UDID_VENDOR);
382
383 /* PCHSTRP8 */
384}
385
386void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s)
387{
388 /* PCHSTRP11 */
389 msg_pdbg2("SMLink1 GP Address is %sabled.\n",
390 s->ibex.SML1GPAEN ? "en" : "dis");
391 msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n",
392 s->ibex.SML1GPA);
393 msg_pdbg2("SMLink1 I2C Target address is %sabled.\n",
394 s->ibex.SML1I2CAEN ? "en" : "dis");
395 msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n",
396 s->ibex.SML1I2CA);
397
398 /* PCHSTRP12 */
399 /* PCHSTRP13 */
400}
401
402void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s)
403{
Stefan Tauner67d163d2013-01-15 17:37:48 +0000404 static const uint8_t dec_t209min[4] = {
Stefan Taunerb3850962011-12-24 00:00:32 +0000405 100,
406 50,
407 5,
408 1
409 };
410
411 msg_pdbg2("--- PCH ---\n");
412
413 /* PCHSTRP0 */
414 msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2);
415 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
416 s->ibex.SMB_EN ? "en" : "dis");
417 msg_pdbg2("SMLink0 segment is %sabled.\n",
418 s->ibex.SML0_EN ? "en" : "dis");
419 msg_pdbg2("SMLink1 segment is %sabled.\n",
420 s->ibex.SML1_EN ? "en" : "dis");
421 msg_pdbg2("SMLink1 Frequency: %s\n",
422 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
423 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
424 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
425 msg_pdbg2("SMLink0 Frequency: %s\n",
426 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
427 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
428 "LAN_PHY_PWR_CTRL" : "general purpose output");
429 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1);
430 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
431 s->ibex.DMI_REQID_DIS ? "en" : "dis");
432 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
433 1 << (6 + s->ibex.BBBS));
434
435 /* PCHSTRP1 */
436 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
437
438 /* PCHSTRP2 */
439 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
440 s->ibex.MESMASDEN ? "en" : "dis");
441 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
442 s->ibex.MESMASDA);
443 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
444 s->ibex.MESMI2CEN ? "en" : "dis");
445 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
446 s->ibex.MESMI2CA);
447
448 /* PCHSTRP3 */
449 prettyprint_ich_descriptor_pchstraps45678_56(s);
450 /* PCHSTRP9 */
451 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
452 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
453 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
454 s->ibex.PCIELR1 ? "" : "not ");
455 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
456 s->ibex.PCIELR2 ? "" : "not ");
457 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
458 s->ibex.DMILR ? "" : "not ");
459 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
460 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
461 s->ibex.PHY_PCIE_EN ? "en" : "dis");
462
463 /* PCHSTRP10 */
464 msg_pdbg2("Management Engine will boot from %sflash.\n",
465 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
466 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5);
467 msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n",
468 s->ibex.VE_EN ? "en" : "dis");
469 msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n",
470 s->ibex.MMDDE ? "en" : "dis");
471 msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n",
472 s->ibex.MMADDR);
473 msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7);
474 msg_pdbg2("Integrated Clocking Configuration is %d.\n",
475 (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL);
476 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
477 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
478
479 prettyprint_ich_descriptor_pchstraps111213_56(s);
480
481 /* PCHSTRP14 */
482 msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n",
483 s->ibex.VE_EN2 ? "en" : "dis");
484 msg_pdbg2("Virtualization Engine will boot from %sflash.\n",
485 s->ibex.VE_BOOT_FLASH ? "" : "ROM, then ");
486 msg_pdbg2("Braidwood SSD functionality is %sabled.\n",
487 s->ibex.BW_SSD ? "en" : "dis");
488 msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n",
489 s->ibex.NVMHCI_EN ? "en" : "dis");
490
491 /* PCHSTRP15 */
492 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6);
493 msg_pdbg2("Integrated wired LAN Solution is %sabled.\n",
494 s->ibex.IWL_EN ? "en" : "dis");
495 msg_pdbg2("t209 min Timing: %d ms\n",
496 dec_t209min[s->ibex.t209min]);
497 msg_pdbg2("\n");
498}
499
500void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s)
501{
502 msg_pdbg2("--- PCH ---\n");
503
504 /* PCHSTRP0 */
505 msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1);
506 msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
507 s->ibex.SMB_EN ? "en" : "dis");
508 msg_pdbg2("SMLink0 segment is %sabled.\n",
509 s->ibex.SML0_EN ? "en" : "dis");
510 msg_pdbg2("SMLink1 segment is %sabled.\n",
511 s->ibex.SML1_EN ? "en" : "dis");
512 msg_pdbg2("SMLink1 Frequency: %s\n",
513 (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
514 msg_pdbg2("Intel ME SMBus Frequency: %s\n",
515 (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
516 msg_pdbg2("SMLink0 Frequency: %s\n",
517 (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
518 msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
519 "LAN_PHY_PWR_CTRL" : "general purpose output");
520 msg_pdbg2("LinkSec is %sabled.\n",
521 s->cougar.LINKSEC_DIS ? "en" : "dis");
522 msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
523 s->ibex.DMI_REQID_DIS ? "en" : "dis");
524 msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
525 1 << (6 + s->ibex.BBBS));
526
527 /* PCHSTRP1 */
528 msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
529 msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2);
530
531 /* PCHSTRP2 */
532 msg_pdbg2("ME SMBus ASD address is %sabled.\n",
533 s->ibex.MESMASDEN ? "en" : "dis");
534 msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
535 s->ibex.MESMASDA);
536 msg_pdbg2("ME SMBus MCTP Address is %sabled.\n",
537 s->cougar.MESMMCTPAEN ? "en" : "dis");
538 msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n",
539 s->cougar.MESMMCTPA);
540 msg_pdbg2("ME SMBus I2C address is %sabled.\n",
541 s->ibex.MESMI2CEN ? "en" : "dis");
542 msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
543 s->ibex.MESMI2CA);
544
545 /* PCHSTRP3 */
546 prettyprint_ich_descriptor_pchstraps45678_56(s);
547 /* PCHSTRP9 */
548 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
549 prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
550 msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
551 s->ibex.PCIELR1 ? "" : "not ");
552 msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
553 s->ibex.PCIELR2 ? "" : "not ");
554 msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
555 s->ibex.DMILR ? "" : "not ");
556 msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n",
557 s->cougar.MDSMBE_EN ? "en" : "dis");
558 msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n",
559 s->cougar.MDSMBE_ADD);
560 msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
561 msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
562 s->ibex.PHY_PCIE_EN ? "en" : "dis");
563 msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n",
564 s->cougar.SUB_DECODE_EN ? "en" : "dis");
565 msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ?
566 "PCHHOT#" : "SML1ALERT#");
567
568 /* PCHSTRP10 */
569 msg_pdbg2("Management Engine will boot from %sflash.\n",
570 s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
571
572 msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n",
573 s->cougar.MDSMBE_EN ? "en" : "dis");
574 msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n",
575 s->cougar.MDSMBE_ADD);
576
577 msg_pdbg2("Integrated Clocking Configuration used: %d\n",
578 s->cougar.ICC_SEL);
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000579 msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a reset.\n",
580 s->ibex.MER_CL1 ? "" : "not ");
Stefan Taunerb3850962011-12-24 00:00:32 +0000581 msg_pdbg2("ICC Profile is selected by %s.\n",
582 s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
583 msg_pdbg2("Deep SX is %ssupported on the platform.\n",
584 s->cougar.Deep_SX_EN ? "not " : "");
585 msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n",
586 s->cougar.ME_DBG_LAN ? "en" : "dis");
587
588 prettyprint_ich_descriptor_pchstraps111213_56(s);
589
590 /* PCHSTRP14 */
591 /* PCHSTRP15 */
592 msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6);
593 msg_pdbg2("Integrated wired LAN is %sabled.\n",
594 s->cougar.IWL_EN ? "en" : "dis");
595 msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
596 msg_pdbg2("SMLink1 provides temperature from %s.\n",
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000597 s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and DIMMs");
Stefan Taunerb3850962011-12-24 00:00:32 +0000598 msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
599 "general purpose output" : "SLP_LAN#");
600
601 /* PCHSTRP16 */
602 /* PCHSTRP17 */
603 msg_pdbg2("Integrated Clock: %s Clock Mode\n",
604 s->cougar.ICML ? "Buffered Through" : "Full Integrated");
605 msg_pdbg2("\n");
606}
607
608void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc)
609{
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000610 unsigned int i, max_count;
Stefan Taunerb3850962011-12-24 00:00:32 +0000611 msg_pdbg2("=== Softstraps ===\n");
612
613 if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000614 max_count = sizeof(desc->north.STRPs) / 4 + 1;
615 msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
616 desc->content.MSL, max_count + 1);
617 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
Stefan Taunerb3850962011-12-24 00:00:32 +0000618 } else
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000619 max_count = desc->content.MSL;
Stefan Taunerb3850962011-12-24 00:00:32 +0000620
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000621 msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
622 for (i = 0; i < max_count; i++)
Stefan Taunerb3850962011-12-24 00:00:32 +0000623 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
624 msg_pdbg2("\n");
625
626 if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000627 max_count = sizeof(desc->south.STRPs) / 4;
628 msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
629 desc->content.ISL, max_count);
630 msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
Stefan Taunerb3850962011-12-24 00:00:32 +0000631 } else
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000632 max_count = desc->content.ISL;
Stefan Taunerb3850962011-12-24 00:00:32 +0000633
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000634 msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
635 for (i = 0; i < max_count; i++)
Stefan Taunerb3850962011-12-24 00:00:32 +0000636 msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
637 msg_pdbg2("\n");
638
639 switch (cs) {
640 case CHIPSET_ICH8:
641 if (sizeof(desc->north.ich8) / 4 != desc->content.MSL)
642 msg_pdbg2("Detailed North/MCH/PROC information is "
643 "probably not reliable, printing anyway.\n");
644 if (sizeof(desc->south.ich8) / 4 != desc->content.ISL)
645 msg_pdbg2("Detailed South/ICH/PCH information is "
646 "probably not reliable, printing anyway.\n");
647 prettyprint_ich_descriptor_straps_ich8(desc);
648 break;
649 case CHIPSET_5_SERIES_IBEX_PEAK:
650 /* PCH straps only. PROCSTRPs are unknown. */
651 if (sizeof(desc->south.ibex) / 4 != desc->content.ISL)
652 msg_pdbg2("Detailed South/ICH/PCH information is "
653 "probably not reliable, printing anyway.\n");
654 prettyprint_ich_descriptor_straps_ibex(&desc->south);
655 break;
656 case CHIPSET_6_SERIES_COUGAR_POINT:
657 /* PCH straps only. PROCSTRP0 is "reserved". */
658 if (sizeof(desc->south.cougar) / 4 != desc->content.ISL)
659 msg_pdbg2("Detailed South/ICH/PCH information is "
660 "probably not reliable, printing anyway.\n");
661 prettyprint_ich_descriptor_straps_cougar(&desc->south);
662 break;
663 case CHIPSET_ICH_UNKNOWN:
664 break;
665 default:
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000666 msg_pdbg2("The meaning of the descriptor straps are unknown yet.\n\n");
Stefan Taunerb3850962011-12-24 00:00:32 +0000667 break;
668 }
669}
670
671void prettyprint_rdid(uint32_t reg_val)
672{
673 uint8_t mid = reg_val & 0xFF;
674 uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00);
675 msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did);
676}
677
678void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap)
679{
680 int i;
681 msg_pdbg2("=== Upper Map Section ===\n");
682 msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1);
683 msg_pdbg2("\n");
684
685 msg_pdbg2("--- Details ---\n");
686 msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL);
687 msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap));
688 msg_pdbg2("\n");
689
690 msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000691 for (i = 0; i < umap->VTL/2; i++) {
Stefan Taunerb3850962011-12-24 00:00:32 +0000692 uint32_t jid = umap->vscc_table[i].JID;
693 uint32_t vscc = umap->vscc_table[i].VSCC;
694 msg_pdbg2(" JID%d = 0x%08x\n", i, jid);
695 msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc);
696 msg_pdbg2(" "); /* indention */
697 prettyprint_rdid(jid);
698 msg_pdbg2(" "); /* indention */
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000699 prettyprint_ich_reg_vscc(vscc, 0, false);
Stefan Taunerb3850962011-12-24 00:00:32 +0000700 }
701 msg_pdbg2("\n");
702}
703
704/* len is the length of dump in bytes */
705int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc)
706{
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000707 unsigned int i, max_count;
Stefan Taunerb3850962011-12-24 00:00:32 +0000708 uint8_t pch_bug_offset = 0;
709
710 if (dump == NULL || desc == NULL)
711 return ICH_RET_PARAM;
712
713 if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) {
714 if (dump[4] == DESCRIPTOR_MODE_SIGNATURE)
715 pch_bug_offset = 4;
716 else
717 return ICH_RET_ERR;
718 }
719
720 /* map */
Nico Huber9e14aed2017-03-28 17:08:46 +0200721 if (len < (4 + pch_bug_offset) * 4)
Stefan Taunerb3850962011-12-24 00:00:32 +0000722 return ICH_RET_OOB;
723 desc->content.FLVALSIG = dump[0 + pch_bug_offset];
724 desc->content.FLMAP0 = dump[1 + pch_bug_offset];
725 desc->content.FLMAP1 = dump[2 + pch_bug_offset];
726 desc->content.FLMAP2 = dump[3 + pch_bug_offset];
727
728 /* component */
Nico Huber9e14aed2017-03-28 17:08:46 +0200729 if (len < getFCBA(&desc->content) + 3 * 4)
Stefan Taunerb3850962011-12-24 00:00:32 +0000730 return ICH_RET_OOB;
731 desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0];
732 desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
733 desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
734
735 /* region */
Nico Huber9e14aed2017-03-28 17:08:46 +0200736 if (len < getFRBA(&desc->content) + 5 * 4)
Stefan Taunerb3850962011-12-24 00:00:32 +0000737 return ICH_RET_OOB;
738 desc->region.FLREGs[0] = dump[(getFRBA(&desc->content) >> 2) + 0];
739 desc->region.FLREGs[1] = dump[(getFRBA(&desc->content) >> 2) + 1];
740 desc->region.FLREGs[2] = dump[(getFRBA(&desc->content) >> 2) + 2];
741 desc->region.FLREGs[3] = dump[(getFRBA(&desc->content) >> 2) + 3];
742 desc->region.FLREGs[4] = dump[(getFRBA(&desc->content) >> 2) + 4];
743
744 /* master */
Nico Huber9e14aed2017-03-28 17:08:46 +0200745 if (len < getFMBA(&desc->content) + 3 * 4)
Stefan Taunerb3850962011-12-24 00:00:32 +0000746 return ICH_RET_OOB;
747 desc->master.FLMSTR1 = dump[(getFMBA(&desc->content) >> 2) + 0];
748 desc->master.FLMSTR2 = dump[(getFMBA(&desc->content) >> 2) + 1];
749 desc->master.FLMSTR3 = dump[(getFMBA(&desc->content) >> 2) + 2];
750
751 /* upper map */
752 desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
753
754 /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
755 * "Identifies the 1s based number of DWORDS contained in the VSCC
756 * Table. Each SPI component entry in the table is 2 DWORDS long." So
757 * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
758 * check ensures that the maximum offset actually accessed is available.
759 */
Nico Huber9e14aed2017-03-28 17:08:46 +0200760 if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8))
Stefan Taunerb3850962011-12-24 00:00:32 +0000761 return ICH_RET_OOB;
762
763 for (i = 0; i < desc->upper.VTL/2; i++) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000764 desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
765 desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
Stefan Taunerb3850962011-12-24 00:00:32 +0000766 }
767
768 /* MCH/PROC (aka. North) straps */
769 if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
770 return ICH_RET_OOB;
771
772 /* limit the range to be written */
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000773 max_count = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
774 for (i = 0; i < max_count; i++)
775 desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i];
Stefan Taunerb3850962011-12-24 00:00:32 +0000776
777 /* ICH/PCH (aka. South) straps */
778 if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
779 return ICH_RET_OOB;
780
781 /* limit the range to be written */
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000782 max_count = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
783 for (i = 0; i < max_count; i++)
784 desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i];
Stefan Taunerb3850962011-12-24 00:00:32 +0000785
786 return ICH_RET_OK;
787}
788
Nico Huberad186312016-05-02 15:15:29 +0200789#ifndef ICH_DESCRIPTORS_FROM_DUMP_ONLY
Stefan Taunerb3850962011-12-24 00:00:32 +0000790
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000791/** Returns the integer representation of the component density with index
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000792\em idx in bytes or -1 if the correct size can not be determined. */
793int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx)
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000794{
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000795 if (idx > 1) {
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000796 msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000797 return -1;
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000798 }
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000799
800 if (desc->content.NC == 0 && idx > 0)
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000801 return 0;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000802
803 uint8_t size_enc;
804 uint8_t size_max;
805
806 switch (cs) {
807 case CHIPSET_ICH8:
808 case CHIPSET_ICH9:
809 case CHIPSET_ICH10:
810 case CHIPSET_5_SERIES_IBEX_PEAK:
811 case CHIPSET_6_SERIES_COUGAR_POINT:
812 case CHIPSET_7_SERIES_PANTHER_POINT:
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000813 case CHIPSET_BAYTRAIL:
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000814 if (idx == 0) {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000815 size_enc = desc->component.dens_old.comp1_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000816 } else {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000817 size_enc = desc->component.dens_old.comp2_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000818 }
819 size_max = 5;
820 break;
821 case CHIPSET_8_SERIES_LYNX_POINT:
822 case CHIPSET_8_SERIES_LYNX_POINT_LP:
823 case CHIPSET_8_SERIES_WELLSBURG:
Duncan Laurie823096e2014-08-20 15:39:38 +0000824 case CHIPSET_9_SERIES_WILDCAT_POINT:
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000825 if (idx == 0) {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000826 size_enc = desc->component.dens_new.comp1_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000827 } else {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000828 size_enc = desc->component.dens_new.comp2_density;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000829 }
830 size_max = 7;
831 break;
832 case CHIPSET_ICH_UNKNOWN:
833 default:
834 msg_pwarn("Density encoding is unknown on this chipset.\n");
835 return -1;
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000836 }
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000837
838 if (size_enc > size_max) {
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000839 msg_perr("Density of ICH SPI component with index %d is invalid.\n"
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000840 "Encoded density is 0x%x while maximum allowed is 0x%x.\n",
841 idx, size_enc, size_max);
842 return -1;
843 }
844
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000845 return (1 << (19 + size_enc));
846}
847
Stefan Tauner1e146392011-09-15 23:52:55 +0000848static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset, void *spibar)
849{
850 uint32_t control = 0;
851 control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS;
852 control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI;
853 mmio_le_writel(control, spibar + ICH9_REG_FDOC);
854 return mmio_le_readl(spibar + ICH9_REG_FDOD);
855}
856
857int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc)
858{
859 uint8_t i;
860 uint8_t nr;
861 struct ich_desc_region *r = &desc->region;
862
863 /* Test if bit-fields are working as expected.
864 * FIXME: Replace this with dynamic bitfield fixup
865 */
866 for (i = 0; i < 4; i++)
867 desc->region.FLREGs[i] = 0x5A << (i * 8);
868 if (r->reg0_base != 0x005A || r->reg0_limit != 0x0000 ||
869 r->reg1_base != 0x1A00 || r->reg1_limit != 0x0000 ||
870 r->reg2_base != 0x0000 || r->reg2_limit != 0x005A ||
871 r->reg3_base != 0x0000 || r->reg3_limit != 0x1A00) {
872 msg_pdbg("The combination of compiler and CPU architecture used"
873 "does not lay out bit-fields as expected, sorry.\n");
874 msg_pspew("r->reg0_base = 0x%04X (0x005A)\n", r->reg0_base);
875 msg_pspew("r->reg0_limit = 0x%04X (0x0000)\n", r->reg0_limit);
876 msg_pspew("r->reg1_base = 0x%04X (0x1A00)\n", r->reg1_base);
877 msg_pspew("r->reg1_limit = 0x%04X (0x0000)\n", r->reg1_limit);
878 msg_pspew("r->reg2_base = 0x%04X (0x0000)\n", r->reg2_base);
879 msg_pspew("r->reg2_limit = 0x%04X (0x005A)\n", r->reg2_limit);
880 msg_pspew("r->reg3_base = 0x%04X (0x0000)\n", r->reg3_base);
881 msg_pspew("r->reg3_limit = 0x%04X (0x1A00)\n", r->reg3_limit);
882 return ICH_RET_ERR;
883 }
884
Stefan Taunera1a14ec2012-08-13 08:45:13 +0000885 msg_pdbg2("Reading flash descriptors mapped by the chipset via FDOC/FDOD...");
Stefan Tauner1e146392011-09-15 23:52:55 +0000886 /* content section */
887 desc->content.FLVALSIG = read_descriptor_reg(0, 0, spibar);
888 desc->content.FLMAP0 = read_descriptor_reg(0, 1, spibar);
889 desc->content.FLMAP1 = read_descriptor_reg(0, 2, spibar);
890 desc->content.FLMAP2 = read_descriptor_reg(0, 3, spibar);
891
892 /* component section */
893 desc->component.FLCOMP = read_descriptor_reg(1, 0, spibar);
894 desc->component.FLILL = read_descriptor_reg(1, 1, spibar);
895 desc->component.FLPB = read_descriptor_reg(1, 2, spibar);
896
897 /* region section */
898 nr = desc->content.NR + 1;
Stefan Tauner2abab942012-04-27 20:41:23 +0000899 if (nr > 5) {
Stefan Tauner1e146392011-09-15 23:52:55 +0000900 msg_pdbg2("%s: number of regions too high (%d) - failed\n",
901 __func__, nr);
902 return ICH_RET_ERR;
903 }
Stefan Tauner0554ca52013-07-25 22:54:25 +0000904 for (i = 0; i < 5; i++)
Stefan Tauner1e146392011-09-15 23:52:55 +0000905 desc->region.FLREGs[i] = read_descriptor_reg(2, i, spibar);
906
907 /* master section */
908 desc->master.FLMSTR1 = read_descriptor_reg(3, 0, spibar);
909 desc->master.FLMSTR2 = read_descriptor_reg(3, 1, spibar);
910 desc->master.FLMSTR3 = read_descriptor_reg(3, 2, spibar);
911
912 /* Accessing the strap section via FDOC/D is only possible on ICH8 and
913 * reading the upper map is impossible on all chipsets, so don't bother.
914 */
915
916 msg_pdbg2(" done.\n");
917 return ICH_RET_OK;
918}
Nico Huberad186312016-05-02 15:15:29 +0200919#endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */