blob: 920e098c99fd5cf6699aa43cb8c7edc0a1970dd1 [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
65#define ICH_FREG_BASE(flreg) (((flreg) << 12) & 0x01fff000)
Nico Huber0bb3f712017-03-29 16:44:33 +020066#define ICH_FREG_LIMIT(flreg) ((((flreg) >> 4) & 0x01fff000) | 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 */
79 NR :3, /* Number Of Regions */
80 :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
119 * Wildcat Point/9: 50 ?? (multi I/O) ? ?:?, ?:?
120 */
Stefan Tauner1e146392011-09-15 23:52:55 +0000121 struct {
Duncan Laurie823096e2014-08-20 15:39:38 +0000122 uint32_t :17,
Stefan Tauner1e146392011-09-15 23:52:55 +0000123 freq_read :3,
124 fastread :1,
125 freq_fastread :3,
126 freq_write :3,
127 freq_read_id :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000128 dual_output :1, /* new since Cougar Point/6 */
129 :1;
130 } modes;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000131 struct {
132 uint32_t comp1_density :3,
133 comp2_density :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000134 :26;
135 } dens_old;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000136 struct {
137 uint32_t comp1_density :4, /* new since Lynx Point/8 */
138 comp2_density :4,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000139 :24;
140 } dens_new;
Stefan Tauner1e146392011-09-15 23:52:55 +0000141 };
142 union { /* 0x04 */
143 uint32_t FLILL; /* Flash Invalid Instructions Register */
144 struct {
145 uint32_t invalid_instr0 :8,
146 invalid_instr1 :8,
147 invalid_instr2 :8,
148 invalid_instr3 :8;
149 };
150 };
151 union { /* 0x08 */
152 uint32_t FLPB; /* Flash Partition Boundary Register */
153 struct {
154 uint32_t FPBA :13, /* Flash Partition Boundary Addr */
155 :19;
156 };
157 };
158};
159
160struct ich_desc_region {
161 union {
162 uint32_t FLREGs[5];
163 struct {
164 struct { /* FLREG0 Flash Descriptor */
165 uint32_t reg0_base :13,
166 :3,
167 reg0_limit :13,
168 :3;
169 };
170 struct { /* FLREG1 BIOS */
171 uint32_t reg1_base :13,
172 :3,
173 reg1_limit :13,
174 :3;
175 };
176 struct { /* FLREG2 ME */
177 uint32_t reg2_base :13,
178 :3,
179 reg2_limit :13,
180 :3;
181 };
182 struct { /* FLREG3 GbE */
183 uint32_t reg3_base :13,
184 :3,
185 reg3_limit :13,
186 :3;
187 };
188 struct { /* FLREG4 Platform */
189 uint32_t reg4_base :13,
190 :3,
191 reg4_limit :13,
192 :3;
193 };
194 };
195 };
196};
197
198struct ich_desc_master {
199 union {
200 uint32_t FLMSTR1;
201 struct {
202 uint32_t BIOS_req_ID :16,
203 BIOS_descr_r :1,
204 BIOS_BIOS_r :1,
205 BIOS_ME_r :1,
206 BIOS_GbE_r :1,
207 BIOS_plat_r :1,
208 :3,
209 BIOS_descr_w :1,
210 BIOS_BIOS_w :1,
211 BIOS_ME_w :1,
212 BIOS_GbE_w :1,
213 BIOS_plat_w :1,
214 :3;
215 };
216 };
217 union {
218 uint32_t FLMSTR2;
219 struct {
220 uint32_t ME_req_ID :16,
221 ME_descr_r :1,
222 ME_BIOS_r :1,
223 ME_ME_r :1,
224 ME_GbE_r :1,
225 ME_plat_r :1,
226 :3,
227 ME_descr_w :1,
228 ME_BIOS_w :1,
229 ME_ME_w :1,
230 ME_GbE_w :1,
231 ME_plat_w :1,
232 :3;
233 };
234 };
235 union {
236 uint32_t FLMSTR3;
237 struct {
238 uint32_t GbE_req_ID :16,
239 GbE_descr_r :1,
240 GbE_BIOS_r :1,
241 GbE_ME_r :1,
242 GbE_GbE_r :1,
243 GbE_plat_r :1,
244 :3,
245 GbE_descr_w :1,
246 GbE_BIOS_w :1,
247 GbE_ME_w :1,
248 GbE_GbE_w :1,
249 GbE_plat_w :1,
250 :3;
251 };
252 };
253};
254
Stefan Taunerb3850962011-12-24 00:00:32 +0000255struct ich_desc_north_strap {
256 union {
257 uint32_t STRPs[1]; /* current maximum: ich8 */
258 struct { /* ich8 */
259 struct { /* STRP2 (in the datasheet) */
260 uint32_t MDB :1,
261 :31;
262 };
263 } ich8;
264 };
265};
266
267struct ich_desc_south_strap {
268 union {
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000269 uint32_t STRPs[18]; /* current maximum: cougar point */
Stefan Taunerb3850962011-12-24 00:00:32 +0000270 struct { /* ich8 */
271 struct { /* STRP1 */
272 uint32_t ME_DISABLE :1,
273 :6,
274 TCOMODE :1,
275 ASD :7,
276 BMCMODE :1,
277 :3,
278 GLAN_PCIE_SEL :1,
279 GPIO12_SEL :2,
280 SPICS1_LANPHYPC_SEL :1,
281 MESM2SEL :1,
282 :1,
283 ASD2 :7;
284 };
285 } ich8;
286 struct { /* ibex peak */
287 struct { /* STRP0 */
288 uint32_t :1,
289 cs_ss2 :1,
290 :5,
291 SMB_EN :1,
292 SML0_EN :1,
293 SML1_EN :1,
294 SML1FRQ :2,
295 SMB0FRQ :2,
296 SML0FRQ :2,
297 :4,
298 LANPHYPC_GP12_SEL :1,
299 cs_ss1 :1,
300 :2,
301 DMI_REQID_DIS :1,
302 :4,
303 BBBS :2,
304 :1;
305 };
306 struct { /* STRP1 */
307 uint32_t cs_ss3 :4,
308 :28;
309 };
310 struct { /* STRP2 */
311 uint32_t :8,
312 MESMASDEN :1,
313 MESMASDA :7,
314 :8,
315 MESMI2CEN :1,
316 MESMI2CA :7;
317 };
318 struct { /* STRP3 */
319 uint32_t :32;
320 };
321 struct { /* STRP4 */
322 uint32_t PHYCON :2,
323 :6,
324 GBEMAC_SMBUS_ADDR_EN :1,
325 GBEMAC_SMBUS_ADDR :7,
326 :1,
327 GBEPHY_SMBUS_ADDR :7,
328 :8;
329 };
330 struct { /* STRP5 */
331 uint32_t :32;
332 };
333 struct { /* STRP6 */
334 uint32_t :32;
335 };
336 struct { /* STRP7 */
337 uint32_t MESMA2UDID_VENDOR :16,
338 MESMA2UDID_DEVICE :16;
339 };
340 struct { /* STRP8 */
341 uint32_t :32;
342 };
343 struct { /* STRP9 */
344 uint32_t PCIEPCS1 :2,
345 PCIEPCS2 :2,
346 PCIELR1 :1,
347 PCIELR2 :1,
348 DMILR :1,
349 :1,
350 PHY_PCIEPORTSEL :3,
351 PHY_PCIE_EN :1,
352 :20;
353 };
354 struct { /* STRP10 */
355 uint32_t :1,
356 ME_BOOT_FLASH :1,
357 cs_ss5 :1,
358 VE_EN :1,
359 :4,
360 MMDDE :1,
361 MMADDR :7,
362 cs_ss7 :1,
363 :1,
364 ICC_SEL :3,
365 MER_CL1 :1,
366 :10;
367 };
368 struct { /* STRP11 */
369 uint32_t SML1GPAEN :1,
370 SML1GPA :7,
371 :16,
372 SML1I2CAEN :1,
373 SML1I2CA :7;
374 };
375 struct { /* STRP12 */
376 uint32_t :32;
377 };
378 struct { /* STRP13 */
379 uint32_t :32;
380 };
381 struct { /* STRP14 */
382 uint32_t :8,
383 VE_EN2 :1,
384 :5,
385 VE_BOOT_FLASH :1,
386 :1,
387 BW_SSD :1,
388 NVMHCI_EN :1,
389 :14;
390 };
391 struct { /* STRP15 */
392 uint32_t :3,
393 cs_ss6 :2,
394 :1,
395 IWL_EN :1,
396 :1,
397 t209min :2,
398 :22;
399 };
400 } ibex;
401 struct { /* cougar point */
402 struct { /* STRP0 */
403 uint32_t :1,
404 cs_ss1 :1,
405 :5,
406 SMB_EN :1,
407 SML0_EN :1,
408 SML1_EN :1,
409 SML1FRQ :2,
410 SMB0FRQ :2,
411 SML0FRQ :2,
412 :4,
413 LANPHYPC_GP12_SEL :1,
414 LINKSEC_DIS :1,
415 :2,
416 DMI_REQID_DIS :1,
417 :4,
418 BBBS :2,
419 :1;
420 };
421 struct { /* STRP1 */
422 uint32_t cs_ss3 :4,
423 :4,
424 cs_ss2 :1,
425 :28;
426 };
427 struct { /* STRP2 */
428 uint32_t :8,
429 MESMASDEN :1,
430 MESMASDA :7,
431 MESMMCTPAEN :1,
432 MESMMCTPA :7,
433 MESMI2CEN :1,
434 MESMI2CA :7;
435 };
436 struct { /* STRP3 */
437 uint32_t :32;
438 };
439 struct { /* STRP4 */
440 uint32_t PHYCON :2,
441 :6,
442 GBEMAC_SMBUS_ADDR_EN :1,
443 GBEMAC_SMBUS_ADDR :7,
444 :1,
445 GBEPHY_SMBUS_ADDR :7,
446 :8;
447 };
448 struct { /* STRP5 */
449 uint32_t :32;
450 };
451 struct { /* STRP6 */
452 uint32_t :32;
453 };
454 struct { /* STRP7 */
455 uint32_t MESMA2UDID_VENDOR :16,
456 MESMA2UDID_DEVICE :16;
457 };
458 struct { /* STRP8 */
459 uint32_t :32;
460 };
461 struct { /* STRP9 */
462 uint32_t PCIEPCS1 :2,
463 PCIEPCS2 :2,
464 PCIELR1 :1,
465 PCIELR2 :1,
466 DMILR :1,
467 cs_ss4 :1,
468 PHY_PCIEPORTSEL :3,
469 PHY_PCIE_EN :1,
470 :2,
471 SUB_DECODE_EN :1,
472 :7,
473 PCHHOT_SML1ALERT_SEL :1,
474 :9;
475 };
476 struct { /* STRP10 */
477 uint32_t :1,
478 ME_BOOT_FLASH :1,
479 :6,
480 MDSMBE_EN :1,
481 MDSMBE_ADD :7,
482 :2,
483 ICC_SEL :3,
484 MER_CL1 :1,
485 ICC_PRO_SEL :1,
486 Deep_SX_EN :1,
487 ME_DBG_LAN :1,
488 :7;
489 };
490 struct { /* STRP11 */
491 uint32_t SML1GPAEN :1,
492 SML1GPA :7,
493 :16,
494 SML1I2CAEN :1,
495 SML1I2CA :7;
496 };
497 struct { /* STRP12 */
498 uint32_t :32;
499 };
500 struct { /* STRP13 */
501 uint32_t :32;
502 };
503 struct { /* STRP14 */
504 uint32_t :32;
505 };
506 struct { /* STRP15 */
507 uint32_t cs_ss6 :6,
508 IWL_EN :1,
509 cs_ss5 :2,
510 :4,
511 SMLINK1_THERM_SEL :1,
512 SLP_LAN_GP29_SEL :1,
513 :16;
514 };
515 struct { /* STRP16 */
516 uint32_t :32;
517 };
518 struct { /* STRP17 */
519 uint32_t ICML :1,
520 cs_ss7 :1,
521 :30;
522 };
523 } cougar;
524 };
525};
526
527struct ich_desc_upper_map {
528 union {
529 uint32_t FLUMAP1; /* Flash Upper Map 1 */
530 struct {
531 uint32_t VTBA :8, /* ME VSCC Table Base Address */
532 VTL :8, /* ME VSCC Table Length */
533 :16;
534 };
535 };
536 struct {
537 union { /* JEDEC-ID Register */
538 uint32_t JID;
539 struct {
540 uint32_t vid :8, /* Vendor ID */
541 cid0 :8, /* Component ID 0 */
542 cid1 :8, /* Component ID 1 */
543 :8;
544 };
545 };
546 union { /* Vendor Specific Component Capabilities */
547 uint32_t VSCC;
548 struct {
549 uint32_t ubes :2, /* Upper Block/Sector Erase Size */
550 uwg :1, /* Upper Write Granularity */
551 uwsr :1, /* Upper Write Status Required */
552 uwews :1, /* Upper Write Enable on Write Status */
553 :3,
554 ueo :8, /* Upper Erase Opcode */
555 lbes :2, /* Lower Block/Sector Erase Size */
556 lwg :1, /* Lower Write Granularity */
557 lwsr :1, /* Lower Write Status Required */
558 lwews :1, /* Lower Write Enable on Write Status */
559 :3,
560 leo :16; /* Lower Erase Opcode */
561 };
562 };
563 } vscc_table[128];
564};
Stefan Taunerb3850962011-12-24 00:00:32 +0000565
Stefan Tauner1e146392011-09-15 23:52:55 +0000566struct ich_descriptors {
567 struct ich_desc_content content;
568 struct ich_desc_component component;
569 struct ich_desc_region region;
570 struct ich_desc_master master;
Stefan Taunerb3850962011-12-24 00:00:32 +0000571 struct ich_desc_north_strap north;
572 struct ich_desc_south_strap south;
573 struct ich_desc_upper_map upper;
Stefan Tauner1e146392011-09-15 23:52:55 +0000574};
575
Stefan Taunerb3850962011-12-24 00:00:32 +0000576void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000577
578void prettyprint_ich_descriptor_content(const struct ich_desc_content *content);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000579void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000580void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc);
581void prettyprint_ich_descriptor_master(const struct ich_desc_master *master);
582
Stefan Taunerb3850962011-12-24 00:00:32 +0000583void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap);
584void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc);
585int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc);
586
Nico Huberd54e4f42017-03-23 23:45:47 +0100587int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000588int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx);
Stefan Tauner1e146392011-09-15 23:52:55 +0000589
Nico Huber305f4172013-06-14 11:55:26 +0200590int layout_from_ich_descriptors(struct ich_layout *, const void *dump, size_t len);
591
Stefan Tauner1e146392011-09-15 23:52:55 +0000592#endif /* __ICH_DESCRIPTORS_H__ */