blob: 5717a0a87a0491a7e1ee539c4f0931554b664142 [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,
Patrick Rudolph16598742022-10-21 15:13:43 +020010 IFD_VERSION_1_5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070011 IFD_VERSION_2,
12};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070013
Bill XIEb3e15a22017-09-07 18:34:50 +080014/* port from flashrom */
15enum ich_chipset {
16 CHIPSET_ICH_UNKNOWN,
Bill XIEb3e15a22017-09-07 18:34:50 +080017 CHIPSET_ICH8,
18 CHIPSET_ICH9,
19 CHIPSET_ICH10,
Subrata Banik89db2252020-08-26 14:49:17 +053020 CHIPSET_PCH_UNKNOWN,
Bill XIEb3e15a22017-09-07 18:34:50 +080021 CHIPSET_5_SERIES_IBEX_PEAK,
22 CHIPSET_6_SERIES_COUGAR_POINT,
23 CHIPSET_7_SERIES_PANTHER_POINT,
24 CHIPSET_8_SERIES_LYNX_POINT,
25 CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture:
26 * Bay Trail, Avoton/Rangeley
27 */
28 CHIPSET_8_SERIES_LYNX_POINT_LP,
29 CHIPSET_8_SERIES_WELLSBURG,
30 CHIPSET_9_SERIES_WILDCAT_POINT,
31 CHIPSET_9_SERIES_WILDCAT_POINT_LP,
Subrata Banik8c082e52021-06-10 23:02:29 +053032 CHIPSET_N_J_SERIES_APOLLO_LAKE, /* Apollo Lake: N3xxx, J3xxx */
33 CHIPSET_N_J_SERIES_GEMINI_LAKE, /* Gemini Lake: N5xxx, J5xxx, N4xxx, J4xxx */
34 CHIPSET_N_SERIES_JASPER_LAKE, /* Jasper Lake: N6xxx, N51xx, N45xx */
35 CHIPSET_x6000_SERIES_ELKHART_LAKE, /* Elkhart Lake: x6000 */
Subrata Banik89db2252020-08-26 14:49:17 +053036 CHIPSET_100_200_SERIES_SUNRISE_POINT, /* 6th-7th gen Core i/o (LP) variants */
Subrata Banik8c082e52021-06-10 23:02:29 +053037 CHIPSET_300_SERIES_CANNON_POINT, /* 8th-9th gen Core i/o (LP) variants */
38 CHIPSET_400_SERIES_ICE_POINT, /* 10th gen Core i/o (LP) variants */
Subrata Banika5f47812020-09-29 11:43:01 +053039 CHIPSET_500_600_SERIES_TIGER_ALDER_POINT, /* 11th-12th gen Core i/o (LP)
40 * variants onwards */
Bill XIEb3e15a22017-09-07 18:34:50 +080041 CHIPSET_C620_SERIES_LEWISBURG,
Jeff Dalyabd4b962022-01-06 00:52:30 -050042 CHIPSET_DENVERTON,
Bill XIEb3e15a22017-09-07 18:34:50 +080043};
44
Andrey Petrov96ecb772016-10-31 19:31:54 -070045enum platform {
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070046 PLATFORM_APL,
47 PLATFORM_CNL,
Johnny Line273a022021-06-22 11:26:46 +080048 PLATFORM_LBG,
Lean Sheng Tan0faba3c2021-06-09 07:52:24 -070049 PLATFORM_EHL,
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070050 PLATFORM_GLK,
Aamir Bohra1018be22018-06-29 15:08:50 +053051 PLATFORM_ICL,
rkanabard64b0462019-08-30 11:40:08 +053052 PLATFORM_JSL,
Furquan Shaikh088b6e82018-03-21 10:42:37 -070053 PLATFORM_SKLKBL,
Ravi Sarawadi7d9d63b2019-10-22 13:45:36 -070054 PLATFORM_TGL,
Subrata Banik46f80732020-03-14 15:01:42 +053055 PLATFORM_ADL,
Wonkyu Kim3922aa52022-02-02 15:19:05 -080056 PLATFORM_IFD2,
Jeff Dalyabd4b962022-01-06 00:52:30 -050057 PLATFORM_DNV,
Subrata Banikca82e612022-01-20 18:51:21 +053058 PLATFORM_MTL,
Patrick Rudolph16598742022-10-21 15:13:43 +020059 PLATFORM_WBG
Andrey Petrov96ecb772016-10-31 19:31:54 -070060};
61
Chris Douglass03ce0142014-02-26 13:30:13 -050062#define LAYOUT_LINELEN 80
63
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070064enum spi_frequency {
65 SPI_FREQUENCY_20MHZ = 0,
66 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070067 SPI_FREQUENCY_48MHZ = 2,
68 SPI_FREQUENCY_50MHZ_30MHZ = 4,
69 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070070};
71
Subrata Banikd16ef4d2020-08-26 15:53:00 +053072enum spi_frequency_500_series {
73 SPI_FREQUENCY_100MHZ = 0,
74 SPI_FREQUENCY_50MHZ = 1,
75 SPI_FREQUENCY_500SERIES_33MHZ = 3,
76 SPI_FREQUENCY_25MHZ = 4,
77 SPI_FREQUENCY_14MHZ = 6,
78};
79
Subrata Banike5d39922020-08-26 16:01:42 +053080enum espi_frequency {
81 ESPI_FREQUENCY_20MHZ = 0,
82 ESPI_FREQUENCY_24MHZ = 1,
83 ESPI_FREQUENCY_30MHZ = 2,
84 ESPI_FREQUENCY_48MHZ = 3,
85 ESPI_FREQUENCY_60MHZ = 4,
86 ESPI_FREQUENCY_17MHZ = 6,
87};
88
89enum espi_frequency_500_series {
90 ESPI_FREQUENCY_500SERIES_20MHZ = 0,
91 ESPI_FREQUENCY_500SERIES_24MHZ = 1,
92 ESPI_FREQUENCY_500SERIES_25MHZ = 2,
93 ESPI_FREQUENCY_500SERIES_48MHZ = 3,
94 ESPI_FREQUENCY_500SERIES_60MHZ = 4,
95};
96
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070097enum component_density {
98 COMPONENT_DENSITY_512KB = 0,
99 COMPONENT_DENSITY_1MB = 1,
100 COMPONENT_DENSITY_2MB = 2,
101 COMPONENT_DENSITY_4MB = 3,
102 COMPONENT_DENSITY_8MB = 4,
103 COMPONENT_DENSITY_16MB = 5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700104 COMPONENT_DENSITY_32MB = 6,
105 COMPONENT_DENSITY_64MB = 7,
106 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -0700107};
108
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700109// flash descriptor
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100110struct __packed fdbar {
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700111 uint32_t flvalsig;
112 uint32_t flmap0;
113 uint32_t flmap1;
114 uint32_t flmap2;
Subrata Banikbd2da5a2020-08-26 15:43:51 +0530115 uint32_t flmap3; // Exist for 500 series onwards
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100116};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700117
118// regions
Jeff Daly3623eca2022-01-05 23:51:40 -0500119#define MAX_REGIONS 16
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700120#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +0800121
Duncan Laurie7775d672019-06-06 13:39:26 -0700122enum flash_regions {
123 REGION_DESC,
124 REGION_BIOS,
125 REGION_ME,
126 REGION_GBE,
127 REGION_PDR,
Jeff Daly3623eca2022-01-05 23:51:40 -0500128 REGION_DEV_EXP1,
129 REGION_BIOS2,
Duncan Laurie7775d672019-06-06 13:39:26 -0700130 REGION_EC = 8,
Jeff Daly3623eca2022-01-05 23:51:40 -0500131 REGION_DEV_EXP2,
132 REGION_IE,
133 REGION_10GB_0,
134 REGION_10GB_1,
135 REGION_PTT = 15,
Duncan Laurie7775d672019-06-06 13:39:26 -0700136};
137
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100138struct __packed frba {
Bill XIE4651d452017-09-12 11:54:48 +0800139 uint32_t flreg[MAX_REGIONS];
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100140};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700141
142// component section
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100143struct __packed fcba {
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700144 uint32_t flcomp;
145 uint32_t flill;
146 uint32_t flpb;
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100147};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700148
149// pch strap
Patrick Rudolph802cbee2020-05-25 12:18:11 +0200150#define MAX_PCHSTRP 1024
Bill XIE4651d452017-09-12 11:54:48 +0800151
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100152struct __packed fpsba {
Bill XIE4651d452017-09-12 11:54:48 +0800153 uint32_t pchstrp[MAX_PCHSTRP];
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100154};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700155
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700156/*
157 * WR / RD bits start at different locations within the flmstr regs, but
158 * otherwise have identical meaning.
159 */
160#define FLMSTR_WR_SHIFT_V1 24
161#define FLMSTR_WR_SHIFT_V2 20
162#define FLMSTR_RD_SHIFT_V1 16
163#define FLMSTR_RD_SHIFT_V2 8
164
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700165// master
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100166struct __packed fmba {
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700167 uint32_t flmstr1;
168 uint32_t flmstr2;
169 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700170 uint32_t flmstr4;
171 uint32_t flmstr5;
Jeff Dalyabd4b962022-01-06 00:52:30 -0500172 uint32_t flmstr6;
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100173};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700174
175// processor strap
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100176struct __packed fmsba {
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700177 uint32_t data[8];
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100178};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700179
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700180// ME VSCC
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100181struct vscc {
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700182 uint32_t jid;
183 uint32_t vscc;
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100184};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700185
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100186struct vtba {
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700187 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200188 /* FIXME: Rationale for the limit of 8.
189 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100190 struct vscc entry[8];
191};
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700192
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100193struct region {
Maximilian Brune347596a2023-03-05 20:55:32 +0100194 int base, limit, size, type;
Maximilian Bruneab0e6802023-03-05 04:34:40 +0100195};
Chris Douglass03ce0142014-02-26 13:30:13 -0500196
197struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800198 const char *pretty;
199 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800200 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600201 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500202};