blob: fb3de2fb39fba7a47b76898552d5bad32548bfdf [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 Banik89db2252020-08-26 14:49:17 +053038 CHIPSET_N_J_SERIES, /* Gemini Lake: N5xxx, J5xxx, N4xxx, J4xxx */
39 CHIPSET_100_200_SERIES_SUNRISE_POINT, /* 6th-7th gen Core i/o (LP) variants */
40 CHIPSET_300_400_SERIES_CANNON_ICE_POINT, /* 8th-10th gen Core i/o (LP) variants */
41 CHIPSET_500_SERIES_TIGER_POINT, /* 11th gen Core i/o (LP) variants onwards */
Bill XIEb3e15a22017-09-07 18:34:50 +080042 CHIPSET_C620_SERIES_LEWISBURG,
43};
44
Andrey Petrov96ecb772016-10-31 19:31:54 -070045enum platform {
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070046 PLATFORM_APL,
47 PLATFORM_CNL,
48 PLATFORM_GLK,
Aamir Bohra1018be22018-06-29 15:08:50 +053049 PLATFORM_ICL,
rkanabard64b0462019-08-30 11:40:08 +053050 PLATFORM_JSL,
Furquan Shaikh088b6e82018-03-21 10:42:37 -070051 PLATFORM_SKLKBL,
Ravi Sarawadi7d9d63b2019-10-22 13:45:36 -070052 PLATFORM_TGL,
Subrata Banik46f80732020-03-14 15:01:42 +053053 PLATFORM_ADL,
Andrey Petrov96ecb772016-10-31 19:31:54 -070054};
55
Chris Douglass03ce0142014-02-26 13:30:13 -050056#define LAYOUT_LINELEN 80
57
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070058enum spi_frequency {
59 SPI_FREQUENCY_20MHZ = 0,
60 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070061 SPI_FREQUENCY_48MHZ = 2,
62 SPI_FREQUENCY_50MHZ_30MHZ = 4,
63 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070064};
65
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070066enum component_density {
67 COMPONENT_DENSITY_512KB = 0,
68 COMPONENT_DENSITY_1MB = 1,
69 COMPONENT_DENSITY_2MB = 2,
70 COMPONENT_DENSITY_4MB = 3,
71 COMPONENT_DENSITY_8MB = 4,
72 COMPONENT_DENSITY_16MB = 5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070073 COMPONENT_DENSITY_32MB = 6,
74 COMPONENT_DENSITY_64MB = 7,
75 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070076};
77
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070078// flash descriptor
79typedef struct {
80 uint32_t flvalsig;
81 uint32_t flmap0;
82 uint32_t flmap1;
83 uint32_t flmap2;
Subrata Banikbd2da5a2020-08-26 15:43:51 +053084 uint32_t flmap3; // Exist for 500 series onwards
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070085} __attribute__((packed)) fdbar_t;
86
87// regions
Duncan Laurie1f7fd722015-06-22 11:14:48 -070088#define MAX_REGIONS 9
89#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +080090
Duncan Laurie7775d672019-06-06 13:39:26 -070091enum flash_regions {
92 REGION_DESC,
93 REGION_BIOS,
94 REGION_ME,
95 REGION_GBE,
96 REGION_PDR,
97 REGION_EC = 8,
98};
99
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700100typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800101 uint32_t flreg[MAX_REGIONS];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700102} __attribute__((packed)) frba_t;
103
104// component section
105typedef struct {
106 uint32_t flcomp;
107 uint32_t flill;
108 uint32_t flpb;
109} __attribute__((packed)) fcba_t;
110
111// pch strap
Patrick Rudolph802cbee2020-05-25 12:18:11 +0200112#define MAX_PCHSTRP 1024
Bill XIE4651d452017-09-12 11:54:48 +0800113
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700114typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800115 uint32_t pchstrp[MAX_PCHSTRP];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700116} __attribute__((packed)) fpsba_t;
117
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700118/*
119 * WR / RD bits start at different locations within the flmstr regs, but
120 * otherwise have identical meaning.
121 */
122#define FLMSTR_WR_SHIFT_V1 24
123#define FLMSTR_WR_SHIFT_V2 20
124#define FLMSTR_RD_SHIFT_V1 16
125#define FLMSTR_RD_SHIFT_V2 8
126
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700127// master
128typedef struct {
129 uint32_t flmstr1;
130 uint32_t flmstr2;
131 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700132 uint32_t flmstr4;
133 uint32_t flmstr5;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700134} __attribute__((packed)) fmba_t;
135
136// processor strap
137typedef struct {
138 uint32_t data[8];
139} __attribute__((packed)) fmsba_t;
140
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700141// ME VSCC
142typedef struct {
143 uint32_t jid;
144 uint32_t vscc;
145} vscc_t;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700146
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700147typedef struct {
148 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200149 /* FIXME: Rationale for the limit of 8.
150 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700151 vscc_t entry[8];
152} vtba_t;
153
154typedef struct {
155 int base, limit, size;
156} region_t;
Chris Douglass03ce0142014-02-26 13:30:13 -0500157
158struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800159 const char *pretty;
160 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800161 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600162 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500163};