blob: 4e2ad0a3e64da11cca52bf8a6efed970a9dbbcca [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>
27
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
66/* Used to select the right descriptor printing function.
67 * Currently only ICH8 and Ibex Peak are supported.
68 */
69enum ich_chipset {
70 CHIPSET_ICH_UNKNOWN,
71 CHIPSET_ICH7 = 7,
72 CHIPSET_ICH8,
73 CHIPSET_ICH9,
74 CHIPSET_ICH10,
75 CHIPSET_5_SERIES_IBEX_PEAK,
76 CHIPSET_6_SERIES_COUGAR_POINT,
77 CHIPSET_7_SERIES_PANTHER_POINT
78};
79
80void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity);
81
82struct ich_desc_content {
83 uint32_t FLVALSIG; /* 0x00 */
84 union { /* 0x04 */
85 uint32_t FLMAP0;
86 struct {
87 uint32_t FCBA :8, /* Flash Component Base Address */
88 NC :2, /* Number Of Components */
89 :6,
90 FRBA :8, /* Flash Region Base Address */
91 NR :3, /* Number Of Regions */
92 :5;
93 };
94 };
95 union { /* 0x08 */
96 uint32_t FLMAP1;
97 struct {
98 uint32_t FMBA :8, /* Flash Master Base Address */
99 NM :3, /* Number Of Masters */
100 :5,
101 FISBA :8, /* Flash ICH Strap Base Address */
102 ISL :8; /* ICH Strap Length */
103 };
104 };
105 union { /* 0x0c */
106 uint32_t FLMAP2;
107 struct {
108 uint32_t FMSBA :8, /* Flash (G)MCH Strap Base Addr. */
109 MSL :8, /* MCH Strap Length */
110 :16;
111 };
112 };
113};
114
115struct ich_desc_component {
116 union { /* 0x00 */
117 uint32_t FLCOMP; /* Flash Components Register */
118 struct {
119 uint32_t comp1_density :3,
120 comp2_density :3,
121 :11,
122 freq_read :3,
123 fastread :1,
124 freq_fastread :3,
125 freq_write :3,
126 freq_read_id :3,
127 :2;
128 };
129 };
130 union { /* 0x04 */
131 uint32_t FLILL; /* Flash Invalid Instructions Register */
132 struct {
133 uint32_t invalid_instr0 :8,
134 invalid_instr1 :8,
135 invalid_instr2 :8,
136 invalid_instr3 :8;
137 };
138 };
139 union { /* 0x08 */
140 uint32_t FLPB; /* Flash Partition Boundary Register */
141 struct {
142 uint32_t FPBA :13, /* Flash Partition Boundary Addr */
143 :19;
144 };
145 };
146};
147
148struct ich_desc_region {
149 union {
150 uint32_t FLREGs[5];
151 struct {
152 struct { /* FLREG0 Flash Descriptor */
153 uint32_t reg0_base :13,
154 :3,
155 reg0_limit :13,
156 :3;
157 };
158 struct { /* FLREG1 BIOS */
159 uint32_t reg1_base :13,
160 :3,
161 reg1_limit :13,
162 :3;
163 };
164 struct { /* FLREG2 ME */
165 uint32_t reg2_base :13,
166 :3,
167 reg2_limit :13,
168 :3;
169 };
170 struct { /* FLREG3 GbE */
171 uint32_t reg3_base :13,
172 :3,
173 reg3_limit :13,
174 :3;
175 };
176 struct { /* FLREG4 Platform */
177 uint32_t reg4_base :13,
178 :3,
179 reg4_limit :13,
180 :3;
181 };
182 };
183 };
184};
185
186struct ich_desc_master {
187 union {
188 uint32_t FLMSTR1;
189 struct {
190 uint32_t BIOS_req_ID :16,
191 BIOS_descr_r :1,
192 BIOS_BIOS_r :1,
193 BIOS_ME_r :1,
194 BIOS_GbE_r :1,
195 BIOS_plat_r :1,
196 :3,
197 BIOS_descr_w :1,
198 BIOS_BIOS_w :1,
199 BIOS_ME_w :1,
200 BIOS_GbE_w :1,
201 BIOS_plat_w :1,
202 :3;
203 };
204 };
205 union {
206 uint32_t FLMSTR2;
207 struct {
208 uint32_t ME_req_ID :16,
209 ME_descr_r :1,
210 ME_BIOS_r :1,
211 ME_ME_r :1,
212 ME_GbE_r :1,
213 ME_plat_r :1,
214 :3,
215 ME_descr_w :1,
216 ME_BIOS_w :1,
217 ME_ME_w :1,
218 ME_GbE_w :1,
219 ME_plat_w :1,
220 :3;
221 };
222 };
223 union {
224 uint32_t FLMSTR3;
225 struct {
226 uint32_t GbE_req_ID :16,
227 GbE_descr_r :1,
228 GbE_BIOS_r :1,
229 GbE_ME_r :1,
230 GbE_GbE_r :1,
231 GbE_plat_r :1,
232 :3,
233 GbE_descr_w :1,
234 GbE_BIOS_w :1,
235 GbE_ME_w :1,
236 GbE_GbE_w :1,
237 GbE_plat_w :1,
238 :3;
239 };
240 };
241};
242
243struct ich_descriptors {
244 struct ich_desc_content content;
245 struct ich_desc_component component;
246 struct ich_desc_region region;
247 struct ich_desc_master master;
248};
249
250void prettyprint_ich_descriptors(enum ich_chipset, const struct ich_descriptors *desc);
251
252void prettyprint_ich_descriptor_content(const struct ich_desc_content *content);
253void prettyprint_ich_descriptor_component(const struct ich_descriptors *desc);
254void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc);
255void prettyprint_ich_descriptor_master(const struct ich_desc_master *master);
256
257int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc);
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000258int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx);
Stefan Tauner1e146392011-09-15 23:52:55 +0000259
260#endif /* __ICH_DESCRIPTORS_H__ */
261#endif /* defined(__i386__) || defined(__x86_64__) */