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