ich_descriptors.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. /*
  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. #if defined(__i386__) || defined(__x86_64__)
  22. #include "ich_descriptors.h"
  23. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  24. #include <stdio.h>
  25. #define print(t, ...) printf(__VA_ARGS__)
  26. #define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a
  27. /* The upper map is located in the word before the 256B-long OEM section at the
  28. * end of the 4kB-long flash descriptor.
  29. */
  30. #define UPPER_MAP_OFFSET (4096 - 256 - 4)
  31. #define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0)
  32. #else /* ICH_DESCRIPTORS_FROM_DUMP */
  33. #include "flash.h" /* for msg_* */
  34. #include "programmer.h"
  35. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  36. #ifndef min
  37. #define min(a, b) (a < b) ? a : b
  38. #endif
  39. void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl)
  40. {
  41. print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF);
  42. print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF);
  43. print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF);
  44. print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF);
  45. print(verbosity, "EO=0x%x", (reg_val & VSCC_EO) >> VSCC_EO_OFF);
  46. if (print_vcl)
  47. print(verbosity, ", VCL=%d", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF);
  48. print(verbosity, "\n");
  49. }
  50. #define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0)
  51. #define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0)
  52. #define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0)
  53. #define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0)
  54. #define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0)
  55. void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc)
  56. {
  57. prettyprint_ich_descriptor_content(&desc->content);
  58. prettyprint_ich_descriptor_component(cs, desc);
  59. prettyprint_ich_descriptor_region(desc);
  60. prettyprint_ich_descriptor_master(&desc->master);
  61. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  62. if (cs >= CHIPSET_ICH8) {
  63. prettyprint_ich_descriptor_upper_map(&desc->upper);
  64. prettyprint_ich_descriptor_straps(cs, desc);
  65. }
  66. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  67. }
  68. void prettyprint_ich_descriptor_content(const struct ich_desc_content *cont)
  69. {
  70. msg_pdbg2("=== Content Section ===\n");
  71. msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG);
  72. msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0);
  73. msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1);
  74. msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2);
  75. msg_pdbg2("\n");
  76. msg_pdbg2("--- Details ---\n");
  77. msg_pdbg2("NR (Number of Regions): %5d\n", cont->NR + 1);
  78. msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n", getFRBA(cont));
  79. msg_pdbg2("NC (Number of Components): %5d\n", cont->NC + 1);
  80. msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n", getFCBA(cont));
  81. msg_pdbg2("ISL (ICH/PCH Strap Length): %5d\n", cont->ISL);
  82. msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address): 0x%03x\n", getFISBA(cont));
  83. msg_pdbg2("NM (Number of Masters): %5d\n", cont->NM + 1);
  84. msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n", getFMBA(cont));
  85. msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n", cont->MSL);
  86. msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n", getFMSBA(cont));
  87. msg_pdbg2("\n");
  88. }
  89. static const char *pprint_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx)
  90. {
  91. if (idx > 1) {
  92. msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
  93. return NULL;
  94. }
  95. if (desc->content.NC == 0 && idx > 0)
  96. return "unused";
  97. static const char * const size_str[] = {
  98. "512 kB", /* 0000 */
  99. "1 MB", /* 0001 */
  100. "2 MB", /* 0010 */
  101. "4 MB", /* 0011 */
  102. "8 MB", /* 0100 */
  103. "16 MB", /* 0101 */ /* Maximum up to Lynx Point (excl.) */
  104. "32 MB", /* 0110 */
  105. "64 MB", /* 0111 */
  106. };
  107. switch (cs) {
  108. case CHIPSET_ICH8:
  109. case CHIPSET_ICH9:
  110. case CHIPSET_ICH10:
  111. case CHIPSET_5_SERIES_IBEX_PEAK:
  112. case CHIPSET_6_SERIES_COUGAR_POINT:
  113. case CHIPSET_7_SERIES_PANTHER_POINT:
  114. case CHIPSET_BAYTRAIL: {
  115. uint8_t size_enc;
  116. if (idx == 0) {
  117. size_enc = desc->component.dens_old.comp1_density;
  118. } else {
  119. size_enc = desc->component.dens_old.comp2_density;
  120. }
  121. if (size_enc > 5)
  122. return "reserved";
  123. return size_str[size_enc];
  124. }
  125. case CHIPSET_8_SERIES_LYNX_POINT:
  126. case CHIPSET_8_SERIES_LYNX_POINT_LP:
  127. case CHIPSET_8_SERIES_WELLSBURG:
  128. case CHIPSET_9_SERIES_WILDCAT_POINT: {
  129. uint8_t size_enc;
  130. if (idx == 0) {
  131. size_enc = desc->component.dens_new.comp1_density;
  132. } else {
  133. size_enc = desc->component.dens_new.comp2_density;
  134. }
  135. if (size_enc > 7)
  136. return "reserved";
  137. return size_str[size_enc];
  138. }
  139. case CHIPSET_ICH_UNKNOWN:
  140. default:
  141. return "unknown";
  142. }
  143. }
  144. static const char *pprint_freq(enum ich_chipset cs, uint8_t value)
  145. {
  146. static const char * const freq_str[8] = {
  147. "20 MHz", /* 000 */
  148. "33 MHz", /* 001 */
  149. "reserved", /* 010 */
  150. "reserved", /* 011 */
  151. "50 MHz", /* 100 */ /* New since Ibex Peak */
  152. "reserved", /* 101 */
  153. "reserved", /* 110 */
  154. "reserved" /* 111 */
  155. };
  156. switch (cs) {
  157. case CHIPSET_ICH8:
  158. case CHIPSET_ICH9:
  159. case CHIPSET_ICH10:
  160. if (value > 1)
  161. return "reserved";
  162. case CHIPSET_5_SERIES_IBEX_PEAK:
  163. case CHIPSET_6_SERIES_COUGAR_POINT:
  164. case CHIPSET_7_SERIES_PANTHER_POINT:
  165. case CHIPSET_8_SERIES_LYNX_POINT:
  166. case CHIPSET_BAYTRAIL:
  167. case CHIPSET_8_SERIES_LYNX_POINT_LP:
  168. case CHIPSET_8_SERIES_WELLSBURG:
  169. case CHIPSET_9_SERIES_WILDCAT_POINT:
  170. return freq_str[value];
  171. case CHIPSET_ICH_UNKNOWN:
  172. default:
  173. return "unknown";
  174. }
  175. }
  176. void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc)
  177. {
  178. msg_pdbg2("=== Component Section ===\n");
  179. msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP);
  180. msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL );
  181. msg_pdbg2("\n");
  182. msg_pdbg2("--- Details ---\n");
  183. msg_pdbg2("Component 1 density: %s\n", pprint_density(cs, desc, 0));
  184. if (desc->content.NC)
  185. msg_pdbg2("Component 2 density: %s\n", pprint_density(cs, desc, 1));
  186. else
  187. msg_pdbg2("Component 2 is not used.\n");
  188. msg_pdbg2("Read Clock Frequency: %s\n", pprint_freq(cs, desc->component.modes.freq_read));
  189. msg_pdbg2("Read ID and Status Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_read_id));
  190. msg_pdbg2("Write and Erase Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_write));
  191. msg_pdbg2("Fast Read is %ssupported.\n", desc->component.modes.fastread ? "" : "not ");
  192. if (desc->component.modes.fastread)
  193. msg_pdbg2("Fast Read Clock Frequency: %s\n",
  194. pprint_freq(cs, desc->component.modes.freq_fastread));
  195. if (cs > CHIPSET_6_SERIES_COUGAR_POINT)
  196. msg_pdbg2("Dual Output Fast Read Support: %sabled\n",
  197. desc->component.modes.dual_output ? "dis" : "en");
  198. if (desc->component.FLILL == 0)
  199. msg_pdbg2("No forbidden opcodes.\n");
  200. else {
  201. msg_pdbg2("Invalid instruction 0: 0x%02x\n",
  202. desc->component.invalid_instr0);
  203. msg_pdbg2("Invalid instruction 1: 0x%02x\n",
  204. desc->component.invalid_instr1);
  205. msg_pdbg2("Invalid instruction 2: 0x%02x\n",
  206. desc->component.invalid_instr2);
  207. msg_pdbg2("Invalid instruction 3: 0x%02x\n",
  208. desc->component.invalid_instr3);
  209. }
  210. msg_pdbg2("\n");
  211. }
  212. static void pprint_freg(const struct ich_desc_region *reg, uint32_t i)
  213. {
  214. static const char *const region_names[5] = {
  215. "Descr.", "BIOS", "ME", "GbE", "Platf."
  216. };
  217. if (i >= 5) {
  218. msg_pdbg2("%s: region index too high.\n", __func__);
  219. return;
  220. }
  221. uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]);
  222. uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]);
  223. msg_pdbg2("Region %d (%-6s) ", i, region_names[i]);
  224. if (base > limit)
  225. msg_pdbg2("is unused.\n");
  226. else
  227. msg_pdbg2("0x%08x - 0x%08x\n", base, limit | 0x0fff);
  228. }
  229. void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc)
  230. {
  231. uint8_t i;
  232. uint8_t nr = desc->content.NR + 1;
  233. msg_pdbg2("=== Region Section ===\n");
  234. if (nr > 5) {
  235. msg_pdbg2("%s: number of regions too high (%d).\n", __func__,
  236. nr);
  237. return;
  238. }
  239. for (i = 0; i < 5; i++)
  240. msg_pdbg2("FLREG%d 0x%08x\n", i, desc->region.FLREGs[i]);
  241. msg_pdbg2("\n");
  242. msg_pdbg2("--- Details ---\n");
  243. for (i = 0; i < 5; i++)
  244. pprint_freg(&desc->region, i);
  245. msg_pdbg2("\n");
  246. }
  247. void prettyprint_ich_descriptor_master(const struct ich_desc_master *mstr)
  248. {
  249. msg_pdbg2("=== Master Section ===\n");
  250. msg_pdbg2("FLMSTR1 0x%08x\n", mstr->FLMSTR1);
  251. msg_pdbg2("FLMSTR2 0x%08x\n", mstr->FLMSTR2);
  252. msg_pdbg2("FLMSTR3 0x%08x\n", mstr->FLMSTR3);
  253. msg_pdbg2("\n");
  254. msg_pdbg2("--- Details ---\n");
  255. msg_pdbg2(" Descr. BIOS ME GbE Platf.\n");
  256. msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n",
  257. (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ',
  258. (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ',
  259. (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ',
  260. (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ',
  261. (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' ');
  262. msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n",
  263. (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ',
  264. (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ',
  265. (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ',
  266. (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ',
  267. (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' ');
  268. msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n",
  269. (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ',
  270. (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ',
  271. (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ',
  272. (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ',
  273. (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' ');
  274. msg_pdbg2("\n");
  275. }
  276. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  277. void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc)
  278. {
  279. static const char * const str_GPIO12[4] = {
  280. "GPIO12",
  281. "LAN PHY Power Control Function (Native Output)",
  282. "GLAN_DOCK# (Native Input)",
  283. "invalid configuration",
  284. };
  285. msg_pdbg2("--- MCH details ---\n");
  286. msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en");
  287. msg_pdbg2("\n");
  288. msg_pdbg2("--- ICH details ---\n");
  289. msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD);
  290. msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2);
  291. msg_pdbg2("ME SMBus Controller is connected to the %s.\n",
  292. desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins");
  293. msg_pdbg2("SPI CS1 is used for %s.\n",
  294. desc->south.ich8.SPICS1_LANPHYPC_SEL ?
  295. "LAN PHY Power Control Function" :
  296. "SPI Chip Select");
  297. msg_pdbg2("GPIO12 is used as %s.\n",
  298. str_GPIO12[desc->south.ich8.GPIO12_SEL]);
  299. msg_pdbg2("PCIe Port 6 is used for %s.\n",
  300. desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express");
  301. msg_pdbg2("%sn BMC Mode: "
  302. "Intel AMT SMBus Controller 1 is connected to %s.\n",
  303. desc->south.ich8.BMCMODE ? "I" : "Not i",
  304. desc->south.ich8.BMCMODE ? "SMLink" : "SMBus");
  305. msg_pdbg2("TCO is in %s Mode.\n",
  306. desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible");
  307. msg_pdbg2("ME A is %sabled.\n",
  308. desc->south.ich8.ME_DISABLE ? "dis" : "en");
  309. msg_pdbg2("\n");
  310. }
  311. static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off)
  312. {
  313. msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1);
  314. off *= 4;
  315. switch (conf){
  316. case 0:
  317. msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off);
  318. break;
  319. case 1:
  320. msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), "
  321. "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off);
  322. break;
  323. case 2:
  324. msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports "
  325. "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off);
  326. break;
  327. case 3:
  328. msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)",
  329. 1+off, 2+off, 4+off);
  330. break;
  331. }
  332. msg_pdbg2("\n");
  333. }
  334. void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s)
  335. {
  336. /* PCHSTRP4 */
  337. msg_pdbg2("Intel PHY is %s.\n",
  338. (s->ibex.PHYCON == 2) ? "connected" :
  339. (s->ibex.PHYCON == 0) ? "disconnected" : "reserved");
  340. msg_pdbg2("GbE MAC SMBus address is %sabled.\n",
  341. s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis");
  342. msg_pdbg2("GbE MAC SMBus address: 0x%02x\n",
  343. s->ibex.GBEMAC_SMBUS_ADDR);
  344. msg_pdbg2("GbE PHY SMBus address: 0x%02x\n",
  345. s->ibex.GBEPHY_SMBUS_ADDR);
  346. /* PCHSTRP5 */
  347. /* PCHSTRP6 */
  348. /* PCHSTRP7 */
  349. msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n",
  350. s->ibex.MESMA2UDID_VENDOR);
  351. msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n",
  352. s->ibex.MESMA2UDID_VENDOR);
  353. /* PCHSTRP8 */
  354. }
  355. void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s)
  356. {
  357. /* PCHSTRP11 */
  358. msg_pdbg2("SMLink1 GP Address is %sabled.\n",
  359. s->ibex.SML1GPAEN ? "en" : "dis");
  360. msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n",
  361. s->ibex.SML1GPA);
  362. msg_pdbg2("SMLink1 I2C Target address is %sabled.\n",
  363. s->ibex.SML1I2CAEN ? "en" : "dis");
  364. msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n",
  365. s->ibex.SML1I2CA);
  366. /* PCHSTRP12 */
  367. /* PCHSTRP13 */
  368. }
  369. void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s)
  370. {
  371. static const uint8_t dec_t209min[4] = {
  372. 100,
  373. 50,
  374. 5,
  375. 1
  376. };
  377. msg_pdbg2("--- PCH ---\n");
  378. /* PCHSTRP0 */
  379. msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2);
  380. msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
  381. s->ibex.SMB_EN ? "en" : "dis");
  382. msg_pdbg2("SMLink0 segment is %sabled.\n",
  383. s->ibex.SML0_EN ? "en" : "dis");
  384. msg_pdbg2("SMLink1 segment is %sabled.\n",
  385. s->ibex.SML1_EN ? "en" : "dis");
  386. msg_pdbg2("SMLink1 Frequency: %s\n",
  387. (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
  388. msg_pdbg2("Intel ME SMBus Frequency: %s\n",
  389. (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
  390. msg_pdbg2("SMLink0 Frequency: %s\n",
  391. (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
  392. msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
  393. "LAN_PHY_PWR_CTRL" : "general purpose output");
  394. msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1);
  395. msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
  396. s->ibex.DMI_REQID_DIS ? "en" : "dis");
  397. msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
  398. 1 << (6 + s->ibex.BBBS));
  399. /* PCHSTRP1 */
  400. msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
  401. /* PCHSTRP2 */
  402. msg_pdbg2("ME SMBus ASD address is %sabled.\n",
  403. s->ibex.MESMASDEN ? "en" : "dis");
  404. msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
  405. s->ibex.MESMASDA);
  406. msg_pdbg2("ME SMBus I2C address is %sabled.\n",
  407. s->ibex.MESMI2CEN ? "en" : "dis");
  408. msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
  409. s->ibex.MESMI2CA);
  410. /* PCHSTRP3 */
  411. prettyprint_ich_descriptor_pchstraps45678_56(s);
  412. /* PCHSTRP9 */
  413. prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
  414. prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
  415. msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
  416. s->ibex.PCIELR1 ? "" : "not ");
  417. msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
  418. s->ibex.PCIELR2 ? "" : "not ");
  419. msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
  420. s->ibex.DMILR ? "" : "not ");
  421. msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
  422. msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
  423. s->ibex.PHY_PCIE_EN ? "en" : "dis");
  424. /* PCHSTRP10 */
  425. msg_pdbg2("Management Engine will boot from %sflash.\n",
  426. s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
  427. msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5);
  428. msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n",
  429. s->ibex.VE_EN ? "en" : "dis");
  430. msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n",
  431. s->ibex.MMDDE ? "en" : "dis");
  432. msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n",
  433. s->ibex.MMADDR);
  434. msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7);
  435. msg_pdbg2("Integrated Clocking Configuration is %d.\n",
  436. (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL);
  437. msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
  438. "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
  439. prettyprint_ich_descriptor_pchstraps111213_56(s);
  440. /* PCHSTRP14 */
  441. msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n",
  442. s->ibex.VE_EN2 ? "en" : "dis");
  443. msg_pdbg2("Virtualization Engine will boot from %sflash.\n",
  444. s->ibex.VE_BOOT_FLASH ? "" : "ROM, then ");
  445. msg_pdbg2("Braidwood SSD functionality is %sabled.\n",
  446. s->ibex.BW_SSD ? "en" : "dis");
  447. msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n",
  448. s->ibex.NVMHCI_EN ? "en" : "dis");
  449. /* PCHSTRP15 */
  450. msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6);
  451. msg_pdbg2("Integrated wired LAN Solution is %sabled.\n",
  452. s->ibex.IWL_EN ? "en" : "dis");
  453. msg_pdbg2("t209 min Timing: %d ms\n",
  454. dec_t209min[s->ibex.t209min]);
  455. msg_pdbg2("\n");
  456. }
  457. void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s)
  458. {
  459. msg_pdbg2("--- PCH ---\n");
  460. /* PCHSTRP0 */
  461. msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1);
  462. msg_pdbg2("Intel ME SMBus Select is %sabled.\n",
  463. s->ibex.SMB_EN ? "en" : "dis");
  464. msg_pdbg2("SMLink0 segment is %sabled.\n",
  465. s->ibex.SML0_EN ? "en" : "dis");
  466. msg_pdbg2("SMLink1 segment is %sabled.\n",
  467. s->ibex.SML1_EN ? "en" : "dis");
  468. msg_pdbg2("SMLink1 Frequency: %s\n",
  469. (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved");
  470. msg_pdbg2("Intel ME SMBus Frequency: %s\n",
  471. (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved");
  472. msg_pdbg2("SMLink0 Frequency: %s\n",
  473. (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved");
  474. msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ?
  475. "LAN_PHY_PWR_CTRL" : "general purpose output");
  476. msg_pdbg2("LinkSec is %sabled.\n",
  477. s->cougar.LINKSEC_DIS ? "en" : "dis");
  478. msg_pdbg2("DMI RequesterID Checks are %sabled.\n",
  479. s->ibex.DMI_REQID_DIS ? "en" : "dis");
  480. msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n",
  481. 1 << (6 + s->ibex.BBBS));
  482. /* PCHSTRP1 */
  483. msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3);
  484. msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2);
  485. /* PCHSTRP2 */
  486. msg_pdbg2("ME SMBus ASD address is %sabled.\n",
  487. s->ibex.MESMASDEN ? "en" : "dis");
  488. msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n",
  489. s->ibex.MESMASDA);
  490. msg_pdbg2("ME SMBus MCTP Address is %sabled.\n",
  491. s->cougar.MESMMCTPAEN ? "en" : "dis");
  492. msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n",
  493. s->cougar.MESMMCTPA);
  494. msg_pdbg2("ME SMBus I2C address is %sabled.\n",
  495. s->ibex.MESMI2CEN ? "en" : "dis");
  496. msg_pdbg2("ME SMBus I2C target address: 0x%02x\n",
  497. s->ibex.MESMI2CA);
  498. /* PCHSTRP3 */
  499. prettyprint_ich_descriptor_pchstraps45678_56(s);
  500. /* PCHSTRP9 */
  501. prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0);
  502. prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1);
  503. msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n",
  504. s->ibex.PCIELR1 ? "" : "not ");
  505. msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n",
  506. s->ibex.PCIELR2 ? "" : "not ");
  507. msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n",
  508. s->ibex.DMILR ? "" : "not ");
  509. msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n",
  510. s->cougar.MDSMBE_EN ? "en" : "dis");
  511. msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n",
  512. s->cougar.MDSMBE_ADD);
  513. msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1);
  514. msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n",
  515. s->ibex.PHY_PCIE_EN ? "en" : "dis");
  516. msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n",
  517. s->cougar.SUB_DECODE_EN ? "en" : "dis");
  518. msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ?
  519. "PCHHOT#" : "SML1ALERT#");
  520. /* PCHSTRP10 */
  521. msg_pdbg2("Management Engine will boot from %sflash.\n",
  522. s->ibex.ME_BOOT_FLASH ? "" : "ROM, then ");
  523. msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n",
  524. s->cougar.MDSMBE_EN ? "en" : "dis");
  525. msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n",
  526. s->cougar.MDSMBE_ADD);
  527. msg_pdbg2("Integrated Clocking Configuration used: %d\n",
  528. s->cougar.ICC_SEL);
  529. msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a reset.\n",
  530. s->ibex.MER_CL1 ? "" : "not ");
  531. msg_pdbg2("ICC Profile is selected by %s.\n",
  532. s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
  533. msg_pdbg2("Deep SX is %ssupported on the platform.\n",
  534. s->cougar.Deep_SX_EN ? "not " : "");
  535. msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n",
  536. s->cougar.ME_DBG_LAN ? "en" : "dis");
  537. prettyprint_ich_descriptor_pchstraps111213_56(s);
  538. /* PCHSTRP14 */
  539. /* PCHSTRP15 */
  540. msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6);
  541. msg_pdbg2("Integrated wired LAN is %sabled.\n",
  542. s->cougar.IWL_EN ? "en" : "dis");
  543. msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
  544. msg_pdbg2("SMLink1 provides temperature from %s.\n",
  545. s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and DIMMs");
  546. msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
  547. "general purpose output" : "SLP_LAN#");
  548. /* PCHSTRP16 */
  549. /* PCHSTRP17 */
  550. msg_pdbg2("Integrated Clock: %s Clock Mode\n",
  551. s->cougar.ICML ? "Buffered Through" : "Full Integrated");
  552. msg_pdbg2("\n");
  553. }
  554. void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc)
  555. {
  556. unsigned int i, max_count;
  557. msg_pdbg2("=== Softstraps ===\n");
  558. if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
  559. max_count = sizeof(desc->north.STRPs) / 4 + 1;
  560. msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
  561. desc->content.MSL, max_count + 1);
  562. msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
  563. } else
  564. max_count = desc->content.MSL;
  565. msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
  566. for (i = 0; i < max_count; i++)
  567. msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
  568. msg_pdbg2("\n");
  569. if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
  570. max_count = sizeof(desc->south.STRPs) / 4;
  571. msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
  572. desc->content.ISL, max_count);
  573. msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
  574. } else
  575. max_count = desc->content.ISL;
  576. msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
  577. for (i = 0; i < max_count; i++)
  578. msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
  579. msg_pdbg2("\n");
  580. switch (cs) {
  581. case CHIPSET_ICH8:
  582. if (sizeof(desc->north.ich8) / 4 != desc->content.MSL)
  583. msg_pdbg2("Detailed North/MCH/PROC information is "
  584. "probably not reliable, printing anyway.\n");
  585. if (sizeof(desc->south.ich8) / 4 != desc->content.ISL)
  586. msg_pdbg2("Detailed South/ICH/PCH information is "
  587. "probably not reliable, printing anyway.\n");
  588. prettyprint_ich_descriptor_straps_ich8(desc);
  589. break;
  590. case CHIPSET_5_SERIES_IBEX_PEAK:
  591. /* PCH straps only. PROCSTRPs are unknown. */
  592. if (sizeof(desc->south.ibex) / 4 != desc->content.ISL)
  593. msg_pdbg2("Detailed South/ICH/PCH information is "
  594. "probably not reliable, printing anyway.\n");
  595. prettyprint_ich_descriptor_straps_ibex(&desc->south);
  596. break;
  597. case CHIPSET_6_SERIES_COUGAR_POINT:
  598. /* PCH straps only. PROCSTRP0 is "reserved". */
  599. if (sizeof(desc->south.cougar) / 4 != desc->content.ISL)
  600. msg_pdbg2("Detailed South/ICH/PCH information is "
  601. "probably not reliable, printing anyway.\n");
  602. prettyprint_ich_descriptor_straps_cougar(&desc->south);
  603. break;
  604. case CHIPSET_ICH_UNKNOWN:
  605. break;
  606. default:
  607. msg_pdbg2("The meaning of the descriptor straps are unknown yet.\n\n");
  608. break;
  609. }
  610. }
  611. void prettyprint_rdid(uint32_t reg_val)
  612. {
  613. uint8_t mid = reg_val & 0xFF;
  614. uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00);
  615. msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did);
  616. }
  617. void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap)
  618. {
  619. int i;
  620. msg_pdbg2("=== Upper Map Section ===\n");
  621. msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1);
  622. msg_pdbg2("\n");
  623. msg_pdbg2("--- Details ---\n");
  624. msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL);
  625. msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap));
  626. msg_pdbg2("\n");
  627. msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
  628. for (i = 0; i < umap->VTL/2; i++) {
  629. uint32_t jid = umap->vscc_table[i].JID;
  630. uint32_t vscc = umap->vscc_table[i].VSCC;
  631. msg_pdbg2(" JID%d = 0x%08x\n", i, jid);
  632. msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc);
  633. msg_pdbg2(" "); /* indention */
  634. prettyprint_rdid(jid);
  635. msg_pdbg2(" "); /* indention */
  636. prettyprint_ich_reg_vscc(vscc, 0, false);
  637. }
  638. msg_pdbg2("\n");
  639. }
  640. /* len is the length of dump in bytes */
  641. int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc)
  642. {
  643. unsigned int i, max_count;
  644. uint8_t pch_bug_offset = 0;
  645. if (dump == NULL || desc == NULL)
  646. return ICH_RET_PARAM;
  647. if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) {
  648. if (dump[4] == DESCRIPTOR_MODE_SIGNATURE)
  649. pch_bug_offset = 4;
  650. else
  651. return ICH_RET_ERR;
  652. }
  653. /* map */
  654. if (len < (4 + pch_bug_offset) * 4 - 1)
  655. return ICH_RET_OOB;
  656. desc->content.FLVALSIG = dump[0 + pch_bug_offset];
  657. desc->content.FLMAP0 = dump[1 + pch_bug_offset];
  658. desc->content.FLMAP1 = dump[2 + pch_bug_offset];
  659. desc->content.FLMAP2 = dump[3 + pch_bug_offset];
  660. /* component */
  661. if (len < (getFCBA(&desc->content) + 3 * 4 - 1))
  662. return ICH_RET_OOB;
  663. desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0];
  664. desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
  665. desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
  666. /* region */
  667. if (len < (getFRBA(&desc->content) + 5 * 4 - 1))
  668. return ICH_RET_OOB;
  669. desc->region.FLREGs[0] = dump[(getFRBA(&desc->content) >> 2) + 0];
  670. desc->region.FLREGs[1] = dump[(getFRBA(&desc->content) >> 2) + 1];
  671. desc->region.FLREGs[2] = dump[(getFRBA(&desc->content) >> 2) + 2];
  672. desc->region.FLREGs[3] = dump[(getFRBA(&desc->content) >> 2) + 3];
  673. desc->region.FLREGs[4] = dump[(getFRBA(&desc->content) >> 2) + 4];
  674. /* master */
  675. if (len < (getFMBA(&desc->content) + 3 * 4 - 1))
  676. return ICH_RET_OOB;
  677. desc->master.FLMSTR1 = dump[(getFMBA(&desc->content) >> 2) + 0];
  678. desc->master.FLMSTR2 = dump[(getFMBA(&desc->content) >> 2) + 1];
  679. desc->master.FLMSTR3 = dump[(getFMBA(&desc->content) >> 2) + 2];
  680. /* upper map */
  681. desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
  682. /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
  683. * "Identifies the 1s based number of DWORDS contained in the VSCC
  684. * Table. Each SPI component entry in the table is 2 DWORDS long." So
  685. * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
  686. * check ensures that the maximum offset actually accessed is available.
  687. */
  688. if (len < (getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8) - 1))
  689. return ICH_RET_OOB;
  690. for (i = 0; i < desc->upper.VTL/2; i++) {
  691. desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
  692. desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
  693. }
  694. /* MCH/PROC (aka. North) straps */
  695. if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
  696. return ICH_RET_OOB;
  697. /* limit the range to be written */
  698. max_count = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
  699. for (i = 0; i < max_count; i++)
  700. desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i];
  701. /* ICH/PCH (aka. South) straps */
  702. if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
  703. return ICH_RET_OOB;
  704. /* limit the range to be written */
  705. max_count = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
  706. for (i = 0; i < max_count; i++)
  707. desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i];
  708. return ICH_RET_OK;
  709. }
  710. #else /* ICH_DESCRIPTORS_FROM_DUMP */
  711. /** Returns the integer representation of the component density with index
  712. \em idx in bytes or -1 if the correct size can not be determined. */
  713. int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx)
  714. {
  715. if (idx > 1) {
  716. msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n");
  717. return -1;
  718. }
  719. if (desc->content.NC == 0 && idx > 0)
  720. return 0;
  721. uint8_t size_enc;
  722. uint8_t size_max;
  723. switch (cs) {
  724. case CHIPSET_ICH8:
  725. case CHIPSET_ICH9:
  726. case CHIPSET_ICH10:
  727. case CHIPSET_5_SERIES_IBEX_PEAK:
  728. case CHIPSET_6_SERIES_COUGAR_POINT:
  729. case CHIPSET_7_SERIES_PANTHER_POINT:
  730. case CHIPSET_BAYTRAIL:
  731. if (idx == 0) {
  732. size_enc = desc->component.dens_old.comp1_density;
  733. } else {
  734. size_enc = desc->component.dens_old.comp2_density;
  735. }
  736. size_max = 5;
  737. break;
  738. case CHIPSET_8_SERIES_LYNX_POINT:
  739. case CHIPSET_8_SERIES_LYNX_POINT_LP:
  740. case CHIPSET_8_SERIES_WELLSBURG:
  741. case CHIPSET_9_SERIES_WILDCAT_POINT:
  742. if (idx == 0) {
  743. size_enc = desc->component.dens_new.comp1_density;
  744. } else {
  745. size_enc = desc->component.dens_new.comp2_density;
  746. }
  747. size_max = 7;
  748. break;
  749. case CHIPSET_ICH_UNKNOWN:
  750. default:
  751. msg_pwarn("Density encoding is unknown on this chipset.\n");
  752. return -1;
  753. }
  754. if (size_enc > size_max) {
  755. msg_perr("Density of ICH SPI component with index %d is invalid.\n"
  756. "Encoded density is 0x%x while maximum allowed is 0x%x.\n",
  757. idx, size_enc, size_max);
  758. return -1;
  759. }
  760. return (1 << (19 + size_enc));
  761. }
  762. static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset, void *spibar)
  763. {
  764. uint32_t control = 0;
  765. control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS;
  766. control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI;
  767. mmio_le_writel(control, spibar + ICH9_REG_FDOC);
  768. return mmio_le_readl(spibar + ICH9_REG_FDOD);
  769. }
  770. int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc)
  771. {
  772. uint8_t i;
  773. uint8_t nr;
  774. struct ich_desc_region *r = &desc->region;
  775. /* Test if bit-fields are working as expected.
  776. * FIXME: Replace this with dynamic bitfield fixup
  777. */
  778. for (i = 0; i < 4; i++)
  779. desc->region.FLREGs[i] = 0x5A << (i * 8);
  780. if (r->reg0_base != 0x005A || r->reg0_limit != 0x0000 ||
  781. r->reg1_base != 0x1A00 || r->reg1_limit != 0x0000 ||
  782. r->reg2_base != 0x0000 || r->reg2_limit != 0x005A ||
  783. r->reg3_base != 0x0000 || r->reg3_limit != 0x1A00) {
  784. msg_pdbg("The combination of compiler and CPU architecture used"
  785. "does not lay out bit-fields as expected, sorry.\n");
  786. msg_pspew("r->reg0_base = 0x%04X (0x005A)\n", r->reg0_base);
  787. msg_pspew("r->reg0_limit = 0x%04X (0x0000)\n", r->reg0_limit);
  788. msg_pspew("r->reg1_base = 0x%04X (0x1A00)\n", r->reg1_base);
  789. msg_pspew("r->reg1_limit = 0x%04X (0x0000)\n", r->reg1_limit);
  790. msg_pspew("r->reg2_base = 0x%04X (0x0000)\n", r->reg2_base);
  791. msg_pspew("r->reg2_limit = 0x%04X (0x005A)\n", r->reg2_limit);
  792. msg_pspew("r->reg3_base = 0x%04X (0x0000)\n", r->reg3_base);
  793. msg_pspew("r->reg3_limit = 0x%04X (0x1A00)\n", r->reg3_limit);
  794. return ICH_RET_ERR;
  795. }
  796. msg_pdbg2("Reading flash descriptors mapped by the chipset via FDOC/FDOD...");
  797. /* content section */
  798. desc->content.FLVALSIG = read_descriptor_reg(0, 0, spibar);
  799. desc->content.FLMAP0 = read_descriptor_reg(0, 1, spibar);
  800. desc->content.FLMAP1 = read_descriptor_reg(0, 2, spibar);
  801. desc->content.FLMAP2 = read_descriptor_reg(0, 3, spibar);
  802. /* component section */
  803. desc->component.FLCOMP = read_descriptor_reg(1, 0, spibar);
  804. desc->component.FLILL = read_descriptor_reg(1, 1, spibar);
  805. desc->component.FLPB = read_descriptor_reg(1, 2, spibar);
  806. /* region section */
  807. nr = desc->content.NR + 1;
  808. if (nr > 5) {
  809. msg_pdbg2("%s: number of regions too high (%d) - failed\n",
  810. __func__, nr);
  811. return ICH_RET_ERR;
  812. }
  813. for (i = 0; i < 5; i++)
  814. desc->region.FLREGs[i] = read_descriptor_reg(2, i, spibar);
  815. /* master section */
  816. desc->master.FLMSTR1 = read_descriptor_reg(3, 0, spibar);
  817. desc->master.FLMSTR2 = read_descriptor_reg(3, 1, spibar);
  818. desc->master.FLMSTR3 = read_descriptor_reg(3, 2, spibar);
  819. /* Accessing the strap section via FDOC/D is only possible on ICH8 and
  820. * reading the upper map is impossible on all chipsets, so don't bother.
  821. */
  822. msg_pdbg2(" done.\n");
  823. return ICH_RET_OK;
  824. }
  825. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  826. #endif /* defined(__i386__) || defined(__x86_64__) */