blob: 15e207d9aaa32163099b3a79ea848932f013fdb8 [file] [log] [blame]
Patrick Georgiea063cb2020-05-08 19:28:13 +02001/* ifdtool - dump Intel Firmware Descriptor information */
Patrick Georgi7333a112020-05-08 20:48:04 +02002/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer1c795ad12011-10-14 12:49:41 -07003
4#include <stdint.h>
Bill XIEb3e15a22017-09-07 18:34:50 +08005#include <stdbool.h>
Duncan Laurie1f7fd722015-06-22 11:14:48 -07006#define IFDTOOL_VERSION "1.2"
7
8enum ifd_version {
9 IFD_VERSION_1,
10 IFD_VERSION_2,
11};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070012
Bill XIEb3e15a22017-09-07 18:34:50 +080013/* port from flashrom */
14enum ich_chipset {
15 CHIPSET_ICH_UNKNOWN,
16 CHIPSET_ICH,
17 CHIPSET_ICH2345,
18 CHIPSET_ICH6,
19 CHIPSET_POULSBO, /* SCH U* */
20 CHIPSET_TUNNEL_CREEK, /* Atom E6xx */
21 CHIPSET_CENTERTON, /* Atom S1220 S1240 S1260 */
22 CHIPSET_ICH7,
23 CHIPSET_ICH8,
24 CHIPSET_ICH9,
25 CHIPSET_ICH10,
Subrata Banik89db2252020-08-26 14:49:17 +053026 CHIPSET_PCH_UNKNOWN,
Bill XIEb3e15a22017-09-07 18:34:50 +080027 CHIPSET_5_SERIES_IBEX_PEAK,
28 CHIPSET_6_SERIES_COUGAR_POINT,
29 CHIPSET_7_SERIES_PANTHER_POINT,
30 CHIPSET_8_SERIES_LYNX_POINT,
31 CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture:
32 * Bay Trail, Avoton/Rangeley
33 */
34 CHIPSET_8_SERIES_LYNX_POINT_LP,
35 CHIPSET_8_SERIES_WELLSBURG,
36 CHIPSET_9_SERIES_WILDCAT_POINT,
37 CHIPSET_9_SERIES_WILDCAT_POINT_LP,
Subrata Banik8c082e52021-06-10 23:02:29 +053038 CHIPSET_N_J_SERIES_APOLLO_LAKE, /* Apollo Lake: N3xxx, J3xxx */
39 CHIPSET_N_J_SERIES_GEMINI_LAKE, /* Gemini Lake: N5xxx, J5xxx, N4xxx, J4xxx */
40 CHIPSET_N_SERIES_JASPER_LAKE, /* Jasper Lake: N6xxx, N51xx, N45xx */
41 CHIPSET_x6000_SERIES_ELKHART_LAKE, /* Elkhart Lake: x6000 */
Subrata Banik89db2252020-08-26 14:49:17 +053042 CHIPSET_100_200_SERIES_SUNRISE_POINT, /* 6th-7th gen Core i/o (LP) variants */
Subrata Banik8c082e52021-06-10 23:02:29 +053043 CHIPSET_300_SERIES_CANNON_POINT, /* 8th-9th gen Core i/o (LP) variants */
44 CHIPSET_400_SERIES_ICE_POINT, /* 10th gen Core i/o (LP) variants */
Subrata Banika5f47812020-09-29 11:43:01 +053045 CHIPSET_500_600_SERIES_TIGER_ALDER_POINT, /* 11th-12th gen Core i/o (LP)
46 * variants onwards */
Bill XIEb3e15a22017-09-07 18:34:50 +080047 CHIPSET_C620_SERIES_LEWISBURG,
48};
49
Andrey Petrov96ecb772016-10-31 19:31:54 -070050enum platform {
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070051 PLATFORM_APL,
52 PLATFORM_CNL,
Johnny Line273a022021-06-22 11:26:46 +080053 PLATFORM_LBG,
Lean Sheng Tan0faba3c2021-06-09 07:52:24 -070054 PLATFORM_EHL,
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070055 PLATFORM_GLK,
Aamir Bohra1018be22018-06-29 15:08:50 +053056 PLATFORM_ICL,
rkanabard64b0462019-08-30 11:40:08 +053057 PLATFORM_JSL,
Furquan Shaikh088b6e82018-03-21 10:42:37 -070058 PLATFORM_SKLKBL,
Ravi Sarawadi7d9d63b2019-10-22 13:45:36 -070059 PLATFORM_TGL,
Subrata Banik46f80732020-03-14 15:01:42 +053060 PLATFORM_ADL,
Wonkyu Kim3922aa52022-02-02 15:19:05 -080061 PLATFORM_IFD2,
Andrey Petrov96ecb772016-10-31 19:31:54 -070062};
63
Chris Douglass03ce0142014-02-26 13:30:13 -050064#define LAYOUT_LINELEN 80
65
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070066enum spi_frequency {
67 SPI_FREQUENCY_20MHZ = 0,
68 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070069 SPI_FREQUENCY_48MHZ = 2,
70 SPI_FREQUENCY_50MHZ_30MHZ = 4,
71 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070072};
73
Subrata Banikd16ef4d2020-08-26 15:53:00 +053074enum spi_frequency_500_series {
75 SPI_FREQUENCY_100MHZ = 0,
76 SPI_FREQUENCY_50MHZ = 1,
77 SPI_FREQUENCY_500SERIES_33MHZ = 3,
78 SPI_FREQUENCY_25MHZ = 4,
79 SPI_FREQUENCY_14MHZ = 6,
80};
81
Subrata Banike5d39922020-08-26 16:01:42 +053082enum espi_frequency {
83 ESPI_FREQUENCY_20MHZ = 0,
84 ESPI_FREQUENCY_24MHZ = 1,
85 ESPI_FREQUENCY_30MHZ = 2,
86 ESPI_FREQUENCY_48MHZ = 3,
87 ESPI_FREQUENCY_60MHZ = 4,
88 ESPI_FREQUENCY_17MHZ = 6,
89};
90
91enum espi_frequency_500_series {
92 ESPI_FREQUENCY_500SERIES_20MHZ = 0,
93 ESPI_FREQUENCY_500SERIES_24MHZ = 1,
94 ESPI_FREQUENCY_500SERIES_25MHZ = 2,
95 ESPI_FREQUENCY_500SERIES_48MHZ = 3,
96 ESPI_FREQUENCY_500SERIES_60MHZ = 4,
97};
98
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070099enum component_density {
100 COMPONENT_DENSITY_512KB = 0,
101 COMPONENT_DENSITY_1MB = 1,
102 COMPONENT_DENSITY_2MB = 2,
103 COMPONENT_DENSITY_4MB = 3,
104 COMPONENT_DENSITY_8MB = 4,
105 COMPONENT_DENSITY_16MB = 5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700106 COMPONENT_DENSITY_32MB = 6,
107 COMPONENT_DENSITY_64MB = 7,
108 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -0700109};
110
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700111// flash descriptor
112typedef struct {
113 uint32_t flvalsig;
114 uint32_t flmap0;
115 uint32_t flmap1;
116 uint32_t flmap2;
Subrata Banikbd2da5a2020-08-26 15:43:51 +0530117 uint32_t flmap3; // Exist for 500 series onwards
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700118} __attribute__((packed)) fdbar_t;
119
120// regions
Jeff Daly3623eca2022-01-05 23:51:40 -0500121#define MAX_REGIONS 16
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700122#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +0800123
Duncan Laurie7775d672019-06-06 13:39:26 -0700124enum flash_regions {
125 REGION_DESC,
126 REGION_BIOS,
127 REGION_ME,
128 REGION_GBE,
129 REGION_PDR,
Jeff Daly3623eca2022-01-05 23:51:40 -0500130 REGION_DEV_EXP1,
131 REGION_BIOS2,
Duncan Laurie7775d672019-06-06 13:39:26 -0700132 REGION_EC = 8,
Jeff Daly3623eca2022-01-05 23:51:40 -0500133 REGION_DEV_EXP2,
134 REGION_IE,
135 REGION_10GB_0,
136 REGION_10GB_1,
137 REGION_PTT = 15,
Duncan Laurie7775d672019-06-06 13:39:26 -0700138};
139
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700140typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800141 uint32_t flreg[MAX_REGIONS];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700142} __attribute__((packed)) frba_t;
143
144// component section
145typedef struct {
146 uint32_t flcomp;
147 uint32_t flill;
148 uint32_t flpb;
149} __attribute__((packed)) fcba_t;
150
151// pch strap
Patrick Rudolph802cbee2020-05-25 12:18:11 +0200152#define MAX_PCHSTRP 1024
Bill XIE4651d452017-09-12 11:54:48 +0800153
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700154typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800155 uint32_t pchstrp[MAX_PCHSTRP];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700156} __attribute__((packed)) fpsba_t;
157
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700158/*
159 * WR / RD bits start at different locations within the flmstr regs, but
160 * otherwise have identical meaning.
161 */
162#define FLMSTR_WR_SHIFT_V1 24
163#define FLMSTR_WR_SHIFT_V2 20
164#define FLMSTR_RD_SHIFT_V1 16
165#define FLMSTR_RD_SHIFT_V2 8
166
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700167// master
168typedef struct {
169 uint32_t flmstr1;
170 uint32_t flmstr2;
171 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700172 uint32_t flmstr4;
173 uint32_t flmstr5;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700174} __attribute__((packed)) fmba_t;
175
176// processor strap
177typedef struct {
178 uint32_t data[8];
179} __attribute__((packed)) fmsba_t;
180
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700181// ME VSCC
182typedef struct {
183 uint32_t jid;
184 uint32_t vscc;
185} vscc_t;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700186
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700187typedef struct {
188 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200189 /* FIXME: Rationale for the limit of 8.
190 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700191 vscc_t entry[8];
192} vtba_t;
193
194typedef struct {
195 int base, limit, size;
196} region_t;
Chris Douglass03ce0142014-02-26 13:30:13 -0500197
198struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800199 const char *pretty;
200 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800201 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600202 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500203};