blob: bccea277617130299c8f969688ca1cd99f8e75a6 [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#ifndef __ICH_DESCRIPTORS_H__
23#define __ICH_DESCRIPTORS_H__ 1
24
25#include <stdint.h>
Stefan Taunera8d838d2011-11-06 23:51:09 +000026#include "programmer.h" /* for enum ich_chipset */
Stefan Tauner1e146392011-09-15 23:52:55 +000027
28/* FIXME: Replace with generic return codes */
29#define ICH_RET_OK 0
30#define ICH_RET_ERR -1
31#define ICH_RET_WARN -2
32#define ICH_RET_PARAM -3
33#define ICH_RET_OOB -4
34
35#define ICH9_REG_FDOC 0xB0 /* 32 Bits Flash Descriptor Observability Control */
Nico Huberd54e4f42017-03-23 23:45:47 +010036#define PCH100_REG_FDOC 0xB4 /* New offset from Sunrise Point on */
Stefan Tauner1e146392011-09-15 23:52:55 +000037 /* 0-1: reserved */
38#define FDOC_FDSI_OFF 2 /* 2-11: Flash Descriptor Section Index */
39#define FDOC_FDSI (0x3f << FDOC_FDSI_OFF)
40#define FDOC_FDSS_OFF 12 /* 12-14: Flash Descriptor Section Select */
41#define FDOC_FDSS (0x3 << FDOC_FDSS_OFF)
42 /* 15-31: reserved */
43
44#define ICH9_REG_FDOD 0xB4 /* 32 Bits Flash Descriptor Observability Data */
Nico Huberd54e4f42017-03-23 23:45:47 +010045#define PCH100_REG_FDOD 0xB8 /* New offset from Sunrise Point on */
Stefan Tauner1e146392011-09-15 23:52:55 +000046
47/* Field locations and semantics for LVSCC, UVSCC and related words in the flash
48 * descriptor are equal therefore they all share the same macros below. */
49#define VSCC_BES_OFF 0 /* 0-1: Block/Sector Erase Size */
50#define VSCC_BES (0x3 << VSCC_BES_OFF)
51#define VSCC_WG_OFF 2 /* 2: Write Granularity */
52#define VSCC_WG (0x1 << VSCC_WG_OFF)
53#define VSCC_WSR_OFF 3 /* 3: Write Status Required */
54#define VSCC_WSR (0x1 << VSCC_WSR_OFF)
55#define VSCC_WEWS_OFF 4 /* 4: Write Enable on Write Status */
56#define VSCC_WEWS (0x1 << VSCC_WEWS_OFF)
57 /* 5-7: reserved */
58#define VSCC_EO_OFF 8 /* 8-15: Erase Opcode */
59#define VSCC_EO (0xff << VSCC_EO_OFF)
60 /* 16-22: reserved */
61#define VSCC_VCL_OFF 23 /* 23: Vendor Component Lock */
62#define VSCC_VCL (0x1 << VSCC_VCL_OFF)
63 /* 24-31: reserved */
64
Nico Huberfa622942017-03-24 17:25:37 +010065#define ICH_FREG_BASE(flreg) (((flreg) << 12) & 0x07fff000)
66#define ICH_FREG_LIMIT(flreg) ((((flreg) >> 4) & 0x07fff000) | 0x00000fff)
Stefan Tauner1e146392011-09-15 23:52:55 +000067
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000068void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl);
Stefan Tauner1e146392011-09-15 23:52:55 +000069
70struct ich_desc_content {
71 uint32_t FLVALSIG; /* 0x00 */
72 union { /* 0x04 */
73 uint32_t FLMAP0;
74 struct {
75 uint32_t FCBA :8, /* Flash Component Base Address */
76 NC :2, /* Number Of Components */
77 :6,
78 FRBA :8, /* Flash Region Base Address */
Nico Huberfa622942017-03-24 17:25:37 +010079 NR :3, /* Number Of Regions (reserved from Skylake on) */
Stefan Tauner1e146392011-09-15 23:52:55 +000080 :5;
81 };
82 };
83 union { /* 0x08 */
84 uint32_t FLMAP1;
85 struct {
86 uint32_t FMBA :8, /* Flash Master Base Address */
87 NM :3, /* Number Of Masters */
88 :5,
89 FISBA :8, /* Flash ICH Strap Base Address */
90 ISL :8; /* ICH Strap Length */
91 };
92 };
93 union { /* 0x0c */
94 uint32_t FLMAP2;
95 struct {
Nico Huber1dc3d422017-06-17 00:09:31 +020096 uint32_t FMSBA :8, /* Flash (G)MCH Strap Base Addr. */
97 MSL :8, /* MCH Strap Length */
98 ICCRIBA :8, /* ICC Reg. Init Base Addr. (new since Sandy Bridge) */
99 RIL :8; /* Register Init Length (new since Hawell) */
Stefan Tauner1e146392011-09-15 23:52:55 +0000100 };
101 };
102};
103
104struct ich_desc_component {
105 union { /* 0x00 */
106 uint32_t FLCOMP; /* Flash Components Register */
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000107 /* FLCOMP encoding on various generations:
108 *
109 * Chipset/Generation max_speed dual_output density
110 * [MHz] bits max. bits
111 * ICH8: 33 N/A 5 0:2, 3:5
112 * ICH9: 33 N/A 5 0:2, 3:5
113 * ICH10: 33 N/A 5 0:2, 3:5
114 * Ibex Peak/5: 50 N/A 5 0:2, 3:5
115 * Cougar Point/6: 50 30 5 0:2, 3:5
116 * Patsburg: 50 30 5 0:2, 3:5
117 * Panther Point/7 50 30 5 0:2, 3:5
118 * Lynx Point/8: 50 30 7 0:3, 4:7
Nico Huberfa622942017-03-24 17:25:37 +0100119 * Wildcat Point/9: 50 30 (multi I/O) 7 0:3, 4:7
120 * Sunrise Point/100: 48 30 7 0:3, 4:7
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000121 */
Stefan Tauner1e146392011-09-15 23:52:55 +0000122 struct {
Duncan Laurie823096e2014-08-20 15:39:38 +0000123 uint32_t :17,
Stefan Tauner1e146392011-09-15 23:52:55 +0000124 freq_read :3,
125 fastread :1,
126 freq_fastread :3,
127 freq_write :3,
128 freq_read_id :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000129 dual_output :1, /* new since Cougar Point/6 */
130 :1;
131 } modes;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000132 struct {
133 uint32_t comp1_density :3,
134 comp2_density :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000135 :26;
136 } dens_old;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000137 struct {
138 uint32_t comp1_density :4, /* new since Lynx Point/8 */
139 comp2_density :4,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000140 :24;
141 } dens_new;
Stefan Tauner1e146392011-09-15 23:52:55 +0000142 };
143 union { /* 0x04 */
144 uint32_t FLILL; /* Flash Invalid Instructions Register */
145 struct {
146 uint32_t invalid_instr0 :8,
147 invalid_instr1 :8,
148 invalid_instr2 :8,
149 invalid_instr3 :8;
150 };
151 };
152 union { /* 0x08 */
Nico Huberfa622942017-03-24 17:25:37 +0100153 uint32_t FLPB; /* Flash Partition Boundary Register, until Panther Point/7 */
Stefan Tauner1e146392011-09-15 23:52:55 +0000154 struct {
155 uint32_t FPBA :13, /* Flash Partition Boundary Addr */
156 :19;
157 };
Nico Huberfa622942017-03-24 17:25:37 +0100158 uint32_t FLILL1; /* Flash Invalid Instructions Register, new since Sunrise Point/100 */
Stefan Tauner1e146392011-09-15 23:52:55 +0000159 struct {
Nico Huberfa622942017-03-24 17:25:37 +0100160 uint32_t invalid_instr4 :8,
161 invalid_instr5 :8,
162 invalid_instr6 :8,
163 invalid_instr7 :8;
Stefan Tauner1e146392011-09-15 23:52:55 +0000164 };
165 };
166};
167
Nico Huberfa622942017-03-24 17:25:37 +0100168#define MAX_NUM_FLREGS 10 /* 16 on unsupported Lewisburg PCH */
169struct ich_desc_region {
170 /*
171 * Number of entries and width differ on various generations:
172 *
173 * Chipset/Generation #FLREGs width (bits)
174 * ICH8 .. Panther Point/7 5 13
175 * Lynx Point/8 .. Wildcat Point/9 7 15
176 * Sunrise Point/100 .. 10 15
177 */
178 union {
179 uint32_t FLREGs[MAX_NUM_FLREGS]; /* Flash Descriptor Regions */
180
181 /* only used for bit-field check */
182 struct {
183 uint32_t base :13,
184 :3,
185 limit :13,
186 :3;
187 } old_reg[MAX_NUM_FLREGS];
188 };
189};
190
191#define MAX_NUM_MASTERS 5 /* 6 on unsupported Lewisburg PCH */
Stefan Tauner1e146392011-09-15 23:52:55 +0000192struct ich_desc_master {
193 union {
Nico Huberfa622942017-03-24 17:25:37 +0100194 uint32_t FLMSTRs[MAX_NUM_MASTERS]; /* Flash Masters */
195 /* For pre-Skylake platforms */
Stefan Tauner1e146392011-09-15 23:52:55 +0000196 struct {
197 uint32_t BIOS_req_ID :16,
198 BIOS_descr_r :1,
199 BIOS_BIOS_r :1,
200 BIOS_ME_r :1,
201 BIOS_GbE_r :1,
202 BIOS_plat_r :1,
203 :3,
204 BIOS_descr_w :1,
205 BIOS_BIOS_w :1,
206 BIOS_ME_w :1,
207 BIOS_GbE_w :1,
208 BIOS_plat_w :1,
209 :3;
Stefan Tauner1e146392011-09-15 23:52:55 +0000210 uint32_t ME_req_ID :16,
211 ME_descr_r :1,
212 ME_BIOS_r :1,
213 ME_ME_r :1,
214 ME_GbE_r :1,
215 ME_plat_r :1,
216 :3,
217 ME_descr_w :1,
218 ME_BIOS_w :1,
219 ME_ME_w :1,
220 ME_GbE_w :1,
221 ME_plat_w :1,
222 :3;
Stefan Tauner1e146392011-09-15 23:52:55 +0000223 uint32_t GbE_req_ID :16,
224 GbE_descr_r :1,
225 GbE_BIOS_r :1,
226 GbE_ME_r :1,
227 GbE_GbE_r :1,
228 GbE_plat_r :1,
229 :3,
230 GbE_descr_w :1,
231 GbE_BIOS_w :1,
232 GbE_ME_w :1,
233 GbE_GbE_w :1,
234 GbE_plat_w :1,
235 :3;
236 };
Nico Huberfa622942017-03-24 17:25:37 +0100237 /* From Skylake on */
238 struct {
239 uint32_t :8,
240 read :12,
241 write :12;
242 } mstr[MAX_NUM_MASTERS];
Stefan Tauner1e146392011-09-15 23:52:55 +0000243 };
244};
245
Stefan Taunerb3850962011-12-24 00:00:32 +0000246struct ich_desc_north_strap {
247 union {
248 uint32_t STRPs[1]; /* current maximum: ich8 */
249 struct { /* ich8 */
250 struct { /* STRP2 (in the datasheet) */
251 uint32_t MDB :1,
252 :31;
253 };
254 } ich8;
255 };
256};
257
258struct ich_desc_south_strap {
259 union {
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000260 uint32_t STRPs[18]; /* current maximum: cougar point */
Stefan Taunerb3850962011-12-24 00:00:32 +0000261 struct { /* ich8 */
262 struct { /* STRP1 */
263 uint32_t ME_DISABLE :1,
264 :6,
265 TCOMODE :1,
266 ASD :7,
267 BMCMODE :1,
268 :3,
269 GLAN_PCIE_SEL :1,
270 GPIO12_SEL :2,
271 SPICS1_LANPHYPC_SEL :1,
272 MESM2SEL :1,
273 :1,
274 ASD2 :7;
275 };
276 } ich8;
277 struct { /* ibex peak */
278 struct { /* STRP0 */
279 uint32_t :1,
280 cs_ss2 :1,
281 :5,
282 SMB_EN :1,
283 SML0_EN :1,
284 SML1_EN :1,
285 SML1FRQ :2,
286 SMB0FRQ :2,
287 SML0FRQ :2,
288 :4,
289 LANPHYPC_GP12_SEL :1,
290 cs_ss1 :1,
291 :2,
292 DMI_REQID_DIS :1,
293 :4,
294 BBBS :2,
295 :1;
296 };
297 struct { /* STRP1 */
298 uint32_t cs_ss3 :4,
299 :28;
300 };
301 struct { /* STRP2 */
302 uint32_t :8,
303 MESMASDEN :1,
304 MESMASDA :7,
305 :8,
306 MESMI2CEN :1,
307 MESMI2CA :7;
308 };
309 struct { /* STRP3 */
310 uint32_t :32;
311 };
312 struct { /* STRP4 */
313 uint32_t PHYCON :2,
314 :6,
315 GBEMAC_SMBUS_ADDR_EN :1,
316 GBEMAC_SMBUS_ADDR :7,
317 :1,
318 GBEPHY_SMBUS_ADDR :7,
319 :8;
320 };
321 struct { /* STRP5 */
322 uint32_t :32;
323 };
324 struct { /* STRP6 */
325 uint32_t :32;
326 };
327 struct { /* STRP7 */
328 uint32_t MESMA2UDID_VENDOR :16,
329 MESMA2UDID_DEVICE :16;
330 };
331 struct { /* STRP8 */
332 uint32_t :32;
333 };
334 struct { /* STRP9 */
335 uint32_t PCIEPCS1 :2,
336 PCIEPCS2 :2,
337 PCIELR1 :1,
338 PCIELR2 :1,
339 DMILR :1,
340 :1,
341 PHY_PCIEPORTSEL :3,
342 PHY_PCIE_EN :1,
343 :20;
344 };
345 struct { /* STRP10 */
346 uint32_t :1,
347 ME_BOOT_FLASH :1,
348 cs_ss5 :1,
349 VE_EN :1,
350 :4,
351 MMDDE :1,
352 MMADDR :7,
353 cs_ss7 :1,
354 :1,
355 ICC_SEL :3,
356 MER_CL1 :1,
357 :10;
358 };
359 struct { /* STRP11 */
360 uint32_t SML1GPAEN :1,
361 SML1GPA :7,
362 :16,
363 SML1I2CAEN :1,
364 SML1I2CA :7;
365 };
366 struct { /* STRP12 */
367 uint32_t :32;
368 };
369 struct { /* STRP13 */
370 uint32_t :32;
371 };
372 struct { /* STRP14 */
373 uint32_t :8,
374 VE_EN2 :1,
375 :5,
376 VE_BOOT_FLASH :1,
377 :1,
378 BW_SSD :1,
379 NVMHCI_EN :1,
380 :14;
381 };
382 struct { /* STRP15 */
383 uint32_t :3,
384 cs_ss6 :2,
385 :1,
386 IWL_EN :1,
387 :1,
388 t209min :2,
389 :22;
390 };
391 } ibex;
392 struct { /* cougar point */
393 struct { /* STRP0 */
394 uint32_t :1,
395 cs_ss1 :1,
396 :5,
397 SMB_EN :1,
398 SML0_EN :1,
399 SML1_EN :1,
400 SML1FRQ :2,
401 SMB0FRQ :2,
402 SML0FRQ :2,
403 :4,
404 LANPHYPC_GP12_SEL :1,
405 LINKSEC_DIS :1,
406 :2,
407 DMI_REQID_DIS :1,
408 :4,
409 BBBS :2,
410 :1;
411 };
412 struct { /* STRP1 */
413 uint32_t cs_ss3 :4,
414 :4,
415 cs_ss2 :1,
416 :28;
417 };
418 struct { /* STRP2 */
419 uint32_t :8,
420 MESMASDEN :1,
421 MESMASDA :7,
422 MESMMCTPAEN :1,
423 MESMMCTPA :7,
424 MESMI2CEN :1,
425 MESMI2CA :7;
426 };
427 struct { /* STRP3 */
428 uint32_t :32;
429 };
430 struct { /* STRP4 */
431 uint32_t PHYCON :2,
432 :6,
433 GBEMAC_SMBUS_ADDR_EN :1,
434 GBEMAC_SMBUS_ADDR :7,
435 :1,
436 GBEPHY_SMBUS_ADDR :7,
437 :8;
438 };
439 struct { /* STRP5 */
440 uint32_t :32;
441 };
442 struct { /* STRP6 */
443 uint32_t :32;
444 };
445 struct { /* STRP7 */
446 uint32_t MESMA2UDID_VENDOR :16,
447 MESMA2UDID_DEVICE :16;
448 };
449 struct { /* STRP8 */
450 uint32_t :32;
451 };
452 struct { /* STRP9 */
453 uint32_t PCIEPCS1 :2,
454 PCIEPCS2 :2,
455 PCIELR1 :1,
456 PCIELR2 :1,
457 DMILR :1,
458 cs_ss4 :1,
459 PHY_PCIEPORTSEL :3,
460 PHY_PCIE_EN :1,
461 :2,
462 SUB_DECODE_EN :1,
463 :7,
464 PCHHOT_SML1ALERT_SEL :1,
465 :9;
466 };
467 struct { /* STRP10 */
468 uint32_t :1,
469 ME_BOOT_FLASH :1,
470 :6,
471 MDSMBE_EN :1,
472 MDSMBE_ADD :7,
473 :2,
474 ICC_SEL :3,
475 MER_CL1 :1,
476 ICC_PRO_SEL :1,
477 Deep_SX_EN :1,
478 ME_DBG_LAN :1,
479 :7;
480 };
481 struct { /* STRP11 */
482 uint32_t SML1GPAEN :1,
483 SML1GPA :7,
484 :16,
485 SML1I2CAEN :1,
486 SML1I2CA :7;
487 };
488 struct { /* STRP12 */
489 uint32_t :32;
490 };
491 struct { /* STRP13 */
492 uint32_t :32;
493 };
494 struct { /* STRP14 */
495 uint32_t :32;
496 };
497 struct { /* STRP15 */
498 uint32_t cs_ss6 :6,
499 IWL_EN :1,
500 cs_ss5 :2,
501 :4,
502 SMLINK1_THERM_SEL :1,
503 SLP_LAN_GP29_SEL :1,
504 :16;
505 };
506 struct { /* STRP16 */
507 uint32_t :32;
508 };
509 struct { /* STRP17 */
510 uint32_t ICML :1,
511 cs_ss7 :1,
512 :30;
513 };
514 } cougar;
515 };
516};
517
518struct ich_desc_upper_map {
519 union {
520 uint32_t FLUMAP1; /* Flash Upper Map 1 */
521 struct {
522 uint32_t VTBA :8, /* ME VSCC Table Base Address */
523 VTL :8, /* ME VSCC Table Length */
524 :16;
525 };
526 };
527 struct {
528 union { /* JEDEC-ID Register */
529 uint32_t JID;
530 struct {
531 uint32_t vid :8, /* Vendor ID */
532 cid0 :8, /* Component ID 0 */
533 cid1 :8, /* Component ID 1 */
534 :8;
535 };
536 };
537 union { /* Vendor Specific Component Capabilities */
538 uint32_t VSCC;
539 struct {
540 uint32_t ubes :2, /* Upper Block/Sector Erase Size */
541 uwg :1, /* Upper Write Granularity */
542 uwsr :1, /* Upper Write Status Required */
543 uwews :1, /* Upper Write Enable on Write Status */
544 :3,
545 ueo :8, /* Upper Erase Opcode */
546 lbes :2, /* Lower Block/Sector Erase Size */
547 lwg :1, /* Lower Write Granularity */
548 lwsr :1, /* Lower Write Status Required */
549 lwews :1, /* Lower Write Enable on Write Status */
550 :3,
551 leo :16; /* Lower Erase Opcode */
552 };
553 };
554 } vscc_table[128];
555};
Stefan Taunerb3850962011-12-24 00:00:32 +0000556
Stefan Tauner1e146392011-09-15 23:52:55 +0000557struct ich_descriptors {
558 struct ich_desc_content content;
559 struct ich_desc_component component;
560 struct ich_desc_region region;
561 struct ich_desc_master master;
Stefan Taunerb3850962011-12-24 00:00:32 +0000562 struct ich_desc_north_strap north;
563 struct ich_desc_south_strap south;
564 struct ich_desc_upper_map upper;
Stefan Tauner1e146392011-09-15 23:52:55 +0000565};
566
Nico Huberfa622942017-03-24 17:25:37 +0100567ssize_t ich_number_of_regions(enum ich_chipset cs, const struct ich_desc_content *content);
568ssize_t ich_number_of_masters(enum ich_chipset cs, const struct ich_desc_content *content);
569
Stefan Taunerb3850962011-12-24 00:00:32 +0000570void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000571
Nico Huberfa622942017-03-24 17:25:37 +0100572void prettyprint_ich_descriptor_content(enum ich_chipset cs, const struct ich_desc_content *content);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000573void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc);
Nico Huberfa622942017-03-24 17:25:37 +0100574void prettyprint_ich_descriptor_region(enum ich_chipset cs, const struct ich_descriptors *desc);
575void prettyprint_ich_descriptor_master(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000576
Stefan Taunerb3850962011-12-24 00:00:32 +0000577void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap);
578void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc);
Nico Huberfa622942017-03-24 17:25:37 +0100579int read_ich_descriptors_from_dump(const uint32_t *dump, size_t len, enum ich_chipset *cs, struct ich_descriptors *desc);
Stefan Taunerb3850962011-12-24 00:00:32 +0000580
Nico Huberd54e4f42017-03-23 23:45:47 +0100581int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000582int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx);
Stefan Tauner1e146392011-09-15 23:52:55 +0000583
Nico Huber305f4172013-06-14 11:55:26 +0200584int layout_from_ich_descriptors(struct ich_layout *, const void *dump, size_t len);
585
Stefan Tauner1e146392011-09-15 23:52:55 +0000586#endif /* __ICH_DESCRIPTORS_H__ */