blob: ecf44bf8e37d7892731ff7c416a428f2f46be7cb [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 */
36 /* 0-1: reserved */
37#define FDOC_FDSI_OFF 2 /* 2-11: Flash Descriptor Section Index */
38#define FDOC_FDSI (0x3f << FDOC_FDSI_OFF)
39#define FDOC_FDSS_OFF 12 /* 12-14: Flash Descriptor Section Select */
40#define FDOC_FDSS (0x3 << FDOC_FDSS_OFF)
41 /* 15-31: reserved */
42
43#define ICH9_REG_FDOD 0xB4 /* 32 Bits Flash Descriptor Observability Data */
44
45/* Field locations and semantics for LVSCC, UVSCC and related words in the flash
46 * descriptor are equal therefore they all share the same macros below. */
47#define VSCC_BES_OFF 0 /* 0-1: Block/Sector Erase Size */
48#define VSCC_BES (0x3 << VSCC_BES_OFF)
49#define VSCC_WG_OFF 2 /* 2: Write Granularity */
50#define VSCC_WG (0x1 << VSCC_WG_OFF)
51#define VSCC_WSR_OFF 3 /* 3: Write Status Required */
52#define VSCC_WSR (0x1 << VSCC_WSR_OFF)
53#define VSCC_WEWS_OFF 4 /* 4: Write Enable on Write Status */
54#define VSCC_WEWS (0x1 << VSCC_WEWS_OFF)
55 /* 5-7: reserved */
56#define VSCC_EO_OFF 8 /* 8-15: Erase Opcode */
57#define VSCC_EO (0xff << VSCC_EO_OFF)
58 /* 16-22: reserved */
59#define VSCC_VCL_OFF 23 /* 23: Vendor Component Lock */
60#define VSCC_VCL (0x1 << VSCC_VCL_OFF)
61 /* 24-31: reserved */
62
63#define ICH_FREG_BASE(flreg) (((flreg) << 12) & 0x01fff000)
64#define ICH_FREG_LIMIT(flreg) (((flreg) >> 4) & 0x01fff000)
65
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +000066void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl);
Stefan Tauner1e146392011-09-15 23:52:55 +000067
68struct ich_desc_content {
69 uint32_t FLVALSIG; /* 0x00 */
70 union { /* 0x04 */
71 uint32_t FLMAP0;
72 struct {
73 uint32_t FCBA :8, /* Flash Component Base Address */
74 NC :2, /* Number Of Components */
75 :6,
76 FRBA :8, /* Flash Region Base Address */
77 NR :3, /* Number Of Regions */
78 :5;
79 };
80 };
81 union { /* 0x08 */
82 uint32_t FLMAP1;
83 struct {
84 uint32_t FMBA :8, /* Flash Master Base Address */
85 NM :3, /* Number Of Masters */
86 :5,
87 FISBA :8, /* Flash ICH Strap Base Address */
88 ISL :8; /* ICH Strap Length */
89 };
90 };
91 union { /* 0x0c */
92 uint32_t FLMAP2;
93 struct {
94 uint32_t FMSBA :8, /* Flash (G)MCH Strap Base Addr. */
95 MSL :8, /* MCH Strap Length */
96 :16;
97 };
98 };
99};
100
101struct ich_desc_component {
102 union { /* 0x00 */
103 uint32_t FLCOMP; /* Flash Components Register */
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000104 /* FLCOMP encoding on various generations:
105 *
106 * Chipset/Generation max_speed dual_output density
107 * [MHz] bits max. bits
108 * ICH8: 33 N/A 5 0:2, 3:5
109 * ICH9: 33 N/A 5 0:2, 3:5
110 * ICH10: 33 N/A 5 0:2, 3:5
111 * Ibex Peak/5: 50 N/A 5 0:2, 3:5
112 * Cougar Point/6: 50 30 5 0:2, 3:5
113 * Patsburg: 50 30 5 0:2, 3:5
114 * Panther Point/7 50 30 5 0:2, 3:5
115 * Lynx Point/8: 50 30 7 0:3, 4:7
116 * Wildcat Point/9: 50 ?? (multi I/O) ? ?:?, ?:?
117 */
Stefan Tauner1e146392011-09-15 23:52:55 +0000118 struct {
Duncan Laurie823096e2014-08-20 15:39:38 +0000119 uint32_t :17,
Stefan Tauner1e146392011-09-15 23:52:55 +0000120 freq_read :3,
121 fastread :1,
122 freq_fastread :3,
123 freq_write :3,
124 freq_read_id :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000125 dual_output :1, /* new since Cougar Point/6 */
126 :1;
127 } modes;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000128 struct {
129 uint32_t comp1_density :3,
130 comp2_density :3,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000131 :26;
132 } dens_old;
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000133 struct {
134 uint32_t comp1_density :4, /* new since Lynx Point/8 */
135 comp2_density :4,
Tai-Hong Wu60dead42015-01-05 23:00:14 +0000136 :24;
137 } dens_new;
Stefan Tauner1e146392011-09-15 23:52:55 +0000138 };
139 union { /* 0x04 */
140 uint32_t FLILL; /* Flash Invalid Instructions Register */
141 struct {
142 uint32_t invalid_instr0 :8,
143 invalid_instr1 :8,
144 invalid_instr2 :8,
145 invalid_instr3 :8;
146 };
147 };
148 union { /* 0x08 */
149 uint32_t FLPB; /* Flash Partition Boundary Register */
150 struct {
151 uint32_t FPBA :13, /* Flash Partition Boundary Addr */
152 :19;
153 };
154 };
155};
156
157struct ich_desc_region {
158 union {
159 uint32_t FLREGs[5];
160 struct {
161 struct { /* FLREG0 Flash Descriptor */
162 uint32_t reg0_base :13,
163 :3,
164 reg0_limit :13,
165 :3;
166 };
167 struct { /* FLREG1 BIOS */
168 uint32_t reg1_base :13,
169 :3,
170 reg1_limit :13,
171 :3;
172 };
173 struct { /* FLREG2 ME */
174 uint32_t reg2_base :13,
175 :3,
176 reg2_limit :13,
177 :3;
178 };
179 struct { /* FLREG3 GbE */
180 uint32_t reg3_base :13,
181 :3,
182 reg3_limit :13,
183 :3;
184 };
185 struct { /* FLREG4 Platform */
186 uint32_t reg4_base :13,
187 :3,
188 reg4_limit :13,
189 :3;
190 };
191 };
192 };
193};
194
195struct ich_desc_master {
196 union {
197 uint32_t FLMSTR1;
198 struct {
199 uint32_t BIOS_req_ID :16,
200 BIOS_descr_r :1,
201 BIOS_BIOS_r :1,
202 BIOS_ME_r :1,
203 BIOS_GbE_r :1,
204 BIOS_plat_r :1,
205 :3,
206 BIOS_descr_w :1,
207 BIOS_BIOS_w :1,
208 BIOS_ME_w :1,
209 BIOS_GbE_w :1,
210 BIOS_plat_w :1,
211 :3;
212 };
213 };
214 union {
215 uint32_t FLMSTR2;
216 struct {
217 uint32_t ME_req_ID :16,
218 ME_descr_r :1,
219 ME_BIOS_r :1,
220 ME_ME_r :1,
221 ME_GbE_r :1,
222 ME_plat_r :1,
223 :3,
224 ME_descr_w :1,
225 ME_BIOS_w :1,
226 ME_ME_w :1,
227 ME_GbE_w :1,
228 ME_plat_w :1,
229 :3;
230 };
231 };
232 union {
233 uint32_t FLMSTR3;
234 struct {
235 uint32_t GbE_req_ID :16,
236 GbE_descr_r :1,
237 GbE_BIOS_r :1,
238 GbE_ME_r :1,
239 GbE_GbE_r :1,
240 GbE_plat_r :1,
241 :3,
242 GbE_descr_w :1,
243 GbE_BIOS_w :1,
244 GbE_ME_w :1,
245 GbE_GbE_w :1,
246 GbE_plat_w :1,
247 :3;
248 };
249 };
250};
251
Stefan Taunerb3850962011-12-24 00:00:32 +0000252struct ich_desc_north_strap {
253 union {
254 uint32_t STRPs[1]; /* current maximum: ich8 */
255 struct { /* ich8 */
256 struct { /* STRP2 (in the datasheet) */
257 uint32_t MDB :1,
258 :31;
259 };
260 } ich8;
261 };
262};
263
264struct ich_desc_south_strap {
265 union {
Stefan Taunerd94d25d2012-07-28 03:17:15 +0000266 uint32_t STRPs[18]; /* current maximum: cougar point */
Stefan Taunerb3850962011-12-24 00:00:32 +0000267 struct { /* ich8 */
268 struct { /* STRP1 */
269 uint32_t ME_DISABLE :1,
270 :6,
271 TCOMODE :1,
272 ASD :7,
273 BMCMODE :1,
274 :3,
275 GLAN_PCIE_SEL :1,
276 GPIO12_SEL :2,
277 SPICS1_LANPHYPC_SEL :1,
278 MESM2SEL :1,
279 :1,
280 ASD2 :7;
281 };
282 } ich8;
283 struct { /* ibex peak */
284 struct { /* STRP0 */
285 uint32_t :1,
286 cs_ss2 :1,
287 :5,
288 SMB_EN :1,
289 SML0_EN :1,
290 SML1_EN :1,
291 SML1FRQ :2,
292 SMB0FRQ :2,
293 SML0FRQ :2,
294 :4,
295 LANPHYPC_GP12_SEL :1,
296 cs_ss1 :1,
297 :2,
298 DMI_REQID_DIS :1,
299 :4,
300 BBBS :2,
301 :1;
302 };
303 struct { /* STRP1 */
304 uint32_t cs_ss3 :4,
305 :28;
306 };
307 struct { /* STRP2 */
308 uint32_t :8,
309 MESMASDEN :1,
310 MESMASDA :7,
311 :8,
312 MESMI2CEN :1,
313 MESMI2CA :7;
314 };
315 struct { /* STRP3 */
316 uint32_t :32;
317 };
318 struct { /* STRP4 */
319 uint32_t PHYCON :2,
320 :6,
321 GBEMAC_SMBUS_ADDR_EN :1,
322 GBEMAC_SMBUS_ADDR :7,
323 :1,
324 GBEPHY_SMBUS_ADDR :7,
325 :8;
326 };
327 struct { /* STRP5 */
328 uint32_t :32;
329 };
330 struct { /* STRP6 */
331 uint32_t :32;
332 };
333 struct { /* STRP7 */
334 uint32_t MESMA2UDID_VENDOR :16,
335 MESMA2UDID_DEVICE :16;
336 };
337 struct { /* STRP8 */
338 uint32_t :32;
339 };
340 struct { /* STRP9 */
341 uint32_t PCIEPCS1 :2,
342 PCIEPCS2 :2,
343 PCIELR1 :1,
344 PCIELR2 :1,
345 DMILR :1,
346 :1,
347 PHY_PCIEPORTSEL :3,
348 PHY_PCIE_EN :1,
349 :20;
350 };
351 struct { /* STRP10 */
352 uint32_t :1,
353 ME_BOOT_FLASH :1,
354 cs_ss5 :1,
355 VE_EN :1,
356 :4,
357 MMDDE :1,
358 MMADDR :7,
359 cs_ss7 :1,
360 :1,
361 ICC_SEL :3,
362 MER_CL1 :1,
363 :10;
364 };
365 struct { /* STRP11 */
366 uint32_t SML1GPAEN :1,
367 SML1GPA :7,
368 :16,
369 SML1I2CAEN :1,
370 SML1I2CA :7;
371 };
372 struct { /* STRP12 */
373 uint32_t :32;
374 };
375 struct { /* STRP13 */
376 uint32_t :32;
377 };
378 struct { /* STRP14 */
379 uint32_t :8,
380 VE_EN2 :1,
381 :5,
382 VE_BOOT_FLASH :1,
383 :1,
384 BW_SSD :1,
385 NVMHCI_EN :1,
386 :14;
387 };
388 struct { /* STRP15 */
389 uint32_t :3,
390 cs_ss6 :2,
391 :1,
392 IWL_EN :1,
393 :1,
394 t209min :2,
395 :22;
396 };
397 } ibex;
398 struct { /* cougar point */
399 struct { /* STRP0 */
400 uint32_t :1,
401 cs_ss1 :1,
402 :5,
403 SMB_EN :1,
404 SML0_EN :1,
405 SML1_EN :1,
406 SML1FRQ :2,
407 SMB0FRQ :2,
408 SML0FRQ :2,
409 :4,
410 LANPHYPC_GP12_SEL :1,
411 LINKSEC_DIS :1,
412 :2,
413 DMI_REQID_DIS :1,
414 :4,
415 BBBS :2,
416 :1;
417 };
418 struct { /* STRP1 */
419 uint32_t cs_ss3 :4,
420 :4,
421 cs_ss2 :1,
422 :28;
423 };
424 struct { /* STRP2 */
425 uint32_t :8,
426 MESMASDEN :1,
427 MESMASDA :7,
428 MESMMCTPAEN :1,
429 MESMMCTPA :7,
430 MESMI2CEN :1,
431 MESMI2CA :7;
432 };
433 struct { /* STRP3 */
434 uint32_t :32;
435 };
436 struct { /* STRP4 */
437 uint32_t PHYCON :2,
438 :6,
439 GBEMAC_SMBUS_ADDR_EN :1,
440 GBEMAC_SMBUS_ADDR :7,
441 :1,
442 GBEPHY_SMBUS_ADDR :7,
443 :8;
444 };
445 struct { /* STRP5 */
446 uint32_t :32;
447 };
448 struct { /* STRP6 */
449 uint32_t :32;
450 };
451 struct { /* STRP7 */
452 uint32_t MESMA2UDID_VENDOR :16,
453 MESMA2UDID_DEVICE :16;
454 };
455 struct { /* STRP8 */
456 uint32_t :32;
457 };
458 struct { /* STRP9 */
459 uint32_t PCIEPCS1 :2,
460 PCIEPCS2 :2,
461 PCIELR1 :1,
462 PCIELR2 :1,
463 DMILR :1,
464 cs_ss4 :1,
465 PHY_PCIEPORTSEL :3,
466 PHY_PCIE_EN :1,
467 :2,
468 SUB_DECODE_EN :1,
469 :7,
470 PCHHOT_SML1ALERT_SEL :1,
471 :9;
472 };
473 struct { /* STRP10 */
474 uint32_t :1,
475 ME_BOOT_FLASH :1,
476 :6,
477 MDSMBE_EN :1,
478 MDSMBE_ADD :7,
479 :2,
480 ICC_SEL :3,
481 MER_CL1 :1,
482 ICC_PRO_SEL :1,
483 Deep_SX_EN :1,
484 ME_DBG_LAN :1,
485 :7;
486 };
487 struct { /* STRP11 */
488 uint32_t SML1GPAEN :1,
489 SML1GPA :7,
490 :16,
491 SML1I2CAEN :1,
492 SML1I2CA :7;
493 };
494 struct { /* STRP12 */
495 uint32_t :32;
496 };
497 struct { /* STRP13 */
498 uint32_t :32;
499 };
500 struct { /* STRP14 */
501 uint32_t :32;
502 };
503 struct { /* STRP15 */
504 uint32_t cs_ss6 :6,
505 IWL_EN :1,
506 cs_ss5 :2,
507 :4,
508 SMLINK1_THERM_SEL :1,
509 SLP_LAN_GP29_SEL :1,
510 :16;
511 };
512 struct { /* STRP16 */
513 uint32_t :32;
514 };
515 struct { /* STRP17 */
516 uint32_t ICML :1,
517 cs_ss7 :1,
518 :30;
519 };
520 } cougar;
521 };
522};
523
524struct ich_desc_upper_map {
525 union {
526 uint32_t FLUMAP1; /* Flash Upper Map 1 */
527 struct {
528 uint32_t VTBA :8, /* ME VSCC Table Base Address */
529 VTL :8, /* ME VSCC Table Length */
530 :16;
531 };
532 };
533 struct {
534 union { /* JEDEC-ID Register */
535 uint32_t JID;
536 struct {
537 uint32_t vid :8, /* Vendor ID */
538 cid0 :8, /* Component ID 0 */
539 cid1 :8, /* Component ID 1 */
540 :8;
541 };
542 };
543 union { /* Vendor Specific Component Capabilities */
544 uint32_t VSCC;
545 struct {
546 uint32_t ubes :2, /* Upper Block/Sector Erase Size */
547 uwg :1, /* Upper Write Granularity */
548 uwsr :1, /* Upper Write Status Required */
549 uwews :1, /* Upper Write Enable on Write Status */
550 :3,
551 ueo :8, /* Upper Erase Opcode */
552 lbes :2, /* Lower Block/Sector Erase Size */
553 lwg :1, /* Lower Write Granularity */
554 lwsr :1, /* Lower Write Status Required */
555 lwews :1, /* Lower Write Enable on Write Status */
556 :3,
557 leo :16; /* Lower Erase Opcode */
558 };
559 };
560 } vscc_table[128];
561};
Stefan Taunerb3850962011-12-24 00:00:32 +0000562
Stefan Tauner1e146392011-09-15 23:52:55 +0000563struct ich_descriptors {
564 struct ich_desc_content content;
565 struct ich_desc_component component;
566 struct ich_desc_region region;
567 struct ich_desc_master master;
Stefan Taunerb3850962011-12-24 00:00:32 +0000568 struct ich_desc_north_strap north;
569 struct ich_desc_south_strap south;
570 struct ich_desc_upper_map upper;
Stefan Tauner1e146392011-09-15 23:52:55 +0000571};
572
Stefan Taunerb3850962011-12-24 00:00:32 +0000573void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000574
575void prettyprint_ich_descriptor_content(const struct ich_desc_content *content);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000576void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc);
Stefan Tauner1e146392011-09-15 23:52:55 +0000577void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc);
578void prettyprint_ich_descriptor_master(const struct ich_desc_master *master);
579
Stefan Taunerb3850962011-12-24 00:00:32 +0000580void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap);
581void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc);
582int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc);
583
Stefan Tauner1e146392011-09-15 23:52:55 +0000584int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc);
Stefan Tauner2ba9f6e2014-08-20 15:39:19 +0000585int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx);
Stefan Tauner1e146392011-09-15 23:52:55 +0000586
Nico Huber305f4172013-06-14 11:55:26 +0200587int layout_from_ich_descriptors(struct ich_layout *, const void *dump, size_t len);
588
Stefan Tauner1e146392011-09-15 23:52:55 +0000589#endif /* __ICH_DESCRIPTORS_H__ */