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