ich_descriptors.c 30 KB

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