blob: 714eda9955d213095c73f5b2b30d1c4442fe5480 [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 Tauner1e146392011-09-15 23:52:55 +000067void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity);
68
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 */
105 struct {
106 uint32_t comp1_density :3,
107 comp2_density :3,
108 :11,
109 freq_read :3,
110 fastread :1,
111 freq_fastread :3,
112 freq_write :3,
113 freq_read_id :3,
114 :2;
115 };
116 };
117 union { /* 0x04 */
118 uint32_t FLILL; /* Flash Invalid Instructions Register */
119 struct {
120 uint32_t invalid_instr0 :8,
121 invalid_instr1 :8,
122 invalid_instr2 :8,
123 invalid_instr3 :8;
124 };
125 };
126 union { /* 0x08 */
127 uint32_t FLPB; /* Flash Partition Boundary Register */
128 struct {
129 uint32_t FPBA :13, /* Flash Partition Boundary Addr */
130 :19;
131 };
132 };
133};
134
135struct ich_desc_region {
136 union {
137 uint32_t FLREGs[5];
138 struct {
139 struct { /* FLREG0 Flash Descriptor */
140 uint32_t reg0_base :13,
141 :3,
142 reg0_limit :13,
143 :3;
144 };
145 struct { /* FLREG1 BIOS */
146 uint32_t reg1_base :13,
147 :3,
148 reg1_limit :13,
149 :3;
150 };
151 struct { /* FLREG2 ME */
152 uint32_t reg2_base :13,
153 :3,
154 reg2_limit :13,
155 :3;
156 };
157 struct { /* FLREG3 GbE */
158 uint32_t reg3_base :13,
159 :3,
160 reg3_limit :13,
161 :3;
162 };
163 struct { /* FLREG4 Platform */
164 uint32_t reg4_base :13,
165 :3,
166 reg4_limit :13,
167 :3;
168 };
169 };
170 };
171};
172
173struct ich_desc_master {
174 union {
175 uint32_t FLMSTR1;
176 struct {
177 uint32_t BIOS_req_ID :16,
178 BIOS_descr_r :1,
179 BIOS_BIOS_r :1,
180 BIOS_ME_r :1,
181 BIOS_GbE_r :1,
182 BIOS_plat_r :1,
183 :3,
184 BIOS_descr_w :1,
185 BIOS_BIOS_w :1,
186 BIOS_ME_w :1,
187 BIOS_GbE_w :1,
188 BIOS_plat_w :1,
189 :3;
190 };
191 };
192 union {
193 uint32_t FLMSTR2;
194 struct {
195 uint32_t ME_req_ID :16,
196 ME_descr_r :1,
197 ME_BIOS_r :1,
198 ME_ME_r :1,
199 ME_GbE_r :1,
200 ME_plat_r :1,
201 :3,
202 ME_descr_w :1,
203 ME_BIOS_w :1,
204 ME_ME_w :1,
205 ME_GbE_w :1,
206 ME_plat_w :1,
207 :3;
208 };
209 };
210 union {
211 uint32_t FLMSTR3;
212 struct {
213 uint32_t GbE_req_ID :16,
214 GbE_descr_r :1,
215 GbE_BIOS_r :1,
216 GbE_ME_r :1,
217 GbE_GbE_r :1,
218 GbE_plat_r :1,
219 :3,
220 GbE_descr_w :1,
221 GbE_BIOS_w :1,
222 GbE_ME_w :1,
223 GbE_GbE_w :1,
224 GbE_plat_w :1,
225 :3;
226 };
227 };
228};
229
230struct ich_descriptors {
231 struct ich_desc_content content;
232 struct ich_desc_component component;
233 struct ich_desc_region region;
234 struct ich_desc_master master;
235};
236
237void prettyprint_ich_descriptors(enum ich_chipset, const struct ich_descriptors *desc);
238
239void prettyprint_ich_descriptor_content(const struct ich_desc_content *content);
240void prettyprint_ich_descriptor_component(const struct ich_descriptors *desc);
241void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc);
242void prettyprint_ich_descriptor_master(const struct ich_desc_master *master);
243
244int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc);
Stefan Taunerd0c5dc22011-10-20 12:57:14 +0000245int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx);
Stefan Tauner1e146392011-09-15 23:52:55 +0000246
247#endif /* __ICH_DESCRIPTORS_H__ */
248#endif /* defined(__i386__) || defined(__x86_64__) */