ich_descriptors.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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. #ifndef __ICH_DESCRIPTORS_H__
  23. #define __ICH_DESCRIPTORS_H__ 1
  24. #include <stdint.h>
  25. #include "programmer.h" /* for enum ich_chipset */
  26. /* FIXME: Replace with generic return codes */
  27. #define ICH_RET_OK 0
  28. #define ICH_RET_ERR -1
  29. #define ICH_RET_WARN -2
  30. #define ICH_RET_PARAM -3
  31. #define ICH_RET_OOB -4
  32. #define ICH9_REG_FDOC 0xB0 /* 32 Bits Flash Descriptor Observability Control */
  33. #define PCH100_REG_FDOC 0xB4 /* 32 bits FDOC in PCH */
  34. /* 0-1: reserved */
  35. #define FDOC_FDSI_OFF 2 /* 2-11: Flash Descriptor Section Index */
  36. #define FDOC_FDSI (0x3f << FDOC_FDSI_OFF)
  37. #define FDOC_FDSS_OFF 12 /* 12-14: Flash Descriptor Section Select */
  38. #define FDOC_FDSS (0x3 << FDOC_FDSS_OFF)
  39. /* 15-31: reserved */
  40. #define ICH9_REG_FDOD 0xB4 /* 32 Bits Flash Descriptor Observability Data */
  41. #define PCH100_REG_FDOD 0xB8 /* 32 bits FDOD in PCH */
  42. /* Field locations and semantics for LVSCC, UVSCC and related words in the flash
  43. * descriptor are equal therefore they all share the same macros below. */
  44. #define VSCC_BES_OFF 0 /* 0-1: Block/Sector Erase Size */
  45. #define VSCC_BES (0x3 << VSCC_BES_OFF)
  46. #define VSCC_WG_OFF 2 /* 2: Write Granularity */
  47. #define VSCC_WG (0x1 << VSCC_WG_OFF)
  48. #define VSCC_WSR_OFF 3 /* 3: Write Status Required */
  49. #define VSCC_WSR (0x1 << VSCC_WSR_OFF)
  50. #define VSCC_WEWS_OFF 4 /* 4: Write Enable on Write Status */
  51. #define VSCC_WEWS (0x1 << VSCC_WEWS_OFF)
  52. /* 5-7: reserved */
  53. #define VSCC_EO_OFF 8 /* 8-15: Erase Opcode */
  54. #define VSCC_EO (0xff << VSCC_EO_OFF)
  55. /* 16-22: reserved */
  56. #define VSCC_VCL_OFF 23 /* 23: Vendor Component Lock */
  57. #define VSCC_VCL (0x1 << VSCC_VCL_OFF)
  58. /* 24-31: reserved */
  59. #define ICH_FREG_BASE(flreg) (((flreg) << 12) & 0x01fff000)
  60. #define ICH_FREG_LIMIT(flreg) (((flreg) >> 4) & 0x01fff000)
  61. void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity);
  62. struct ich_desc_content {
  63. uint32_t FLVALSIG; /* 0x00 */
  64. union { /* 0x04 */
  65. uint32_t FLMAP0;
  66. struct {
  67. uint32_t FCBA :8, /* Flash Component Base Address */
  68. NC :2, /* Number Of Components */
  69. :6,
  70. FRBA :8, /* Flash Region Base Address */
  71. NR :3, /* Number Of Regions */
  72. :5;
  73. };
  74. };
  75. union { /* 0x08 */
  76. uint32_t FLMAP1;
  77. struct {
  78. uint32_t FMBA :8, /* Flash Master Base Address */
  79. NM :3, /* Number Of Masters */
  80. :5,
  81. FISBA :8, /* Flash ICH Strap Base Address */
  82. ISL :8; /* ICH Strap Length */
  83. };
  84. };
  85. union { /* 0x0c */
  86. uint32_t FLMAP2;
  87. struct {
  88. uint32_t FMSBA :8, /* Flash (G)MCH Strap Base Addr. */
  89. MSL :8, /* MCH Strap Length */
  90. :16;
  91. };
  92. };
  93. };
  94. struct ich_desc_component {
  95. union { /* 0x00 */
  96. uint32_t FLCOMP; /* Flash Components Register */
  97. struct {
  98. uint32_t comp1_density :3,
  99. comp2_density :3,
  100. :11,
  101. freq_read :3,
  102. fastread :1,
  103. freq_fastread :3,
  104. freq_write :3,
  105. freq_read_id :3,
  106. :2;
  107. };
  108. };
  109. union { /* 0x04 */
  110. uint32_t FLILL; /* Flash Invalid Instructions Register */
  111. struct {
  112. uint32_t invalid_instr0 :8,
  113. invalid_instr1 :8,
  114. invalid_instr2 :8,
  115. invalid_instr3 :8;
  116. };
  117. };
  118. union { /* 0x08 */
  119. uint32_t FLPB; /* Flash Partition Boundary Register */
  120. struct {
  121. uint32_t FPBA :13, /* Flash Partition Boundary Addr */
  122. :19;
  123. };
  124. };
  125. };
  126. struct ich_desc_region {
  127. union {
  128. uint32_t FLREGs[5];
  129. struct {
  130. struct { /* FLREG0 Flash Descriptor */
  131. uint32_t reg0_base :13,
  132. :3,
  133. reg0_limit :13,
  134. :3;
  135. };
  136. struct { /* FLREG1 BIOS */
  137. uint32_t reg1_base :13,
  138. :3,
  139. reg1_limit :13,
  140. :3;
  141. };
  142. struct { /* FLREG2 ME */
  143. uint32_t reg2_base :13,
  144. :3,
  145. reg2_limit :13,
  146. :3;
  147. };
  148. struct { /* FLREG3 GbE */
  149. uint32_t reg3_base :13,
  150. :3,
  151. reg3_limit :13,
  152. :3;
  153. };
  154. struct { /* FLREG4 Platform */
  155. uint32_t reg4_base :13,
  156. :3,
  157. reg4_limit :13,
  158. :3;
  159. };
  160. };
  161. };
  162. };
  163. struct ich_desc_master {
  164. union {
  165. uint32_t FLMSTR1;
  166. struct {
  167. uint32_t BIOS_req_ID :16,
  168. BIOS_descr_r :1,
  169. BIOS_BIOS_r :1,
  170. BIOS_ME_r :1,
  171. BIOS_GbE_r :1,
  172. BIOS_plat_r :1,
  173. :3,
  174. BIOS_descr_w :1,
  175. BIOS_BIOS_w :1,
  176. BIOS_ME_w :1,
  177. BIOS_GbE_w :1,
  178. BIOS_plat_w :1,
  179. :3;
  180. };
  181. };
  182. union {
  183. uint32_t FLMSTR2;
  184. struct {
  185. uint32_t ME_req_ID :16,
  186. ME_descr_r :1,
  187. ME_BIOS_r :1,
  188. ME_ME_r :1,
  189. ME_GbE_r :1,
  190. ME_plat_r :1,
  191. :3,
  192. ME_descr_w :1,
  193. ME_BIOS_w :1,
  194. ME_ME_w :1,
  195. ME_GbE_w :1,
  196. ME_plat_w :1,
  197. :3;
  198. };
  199. };
  200. union {
  201. uint32_t FLMSTR3;
  202. struct {
  203. uint32_t GbE_req_ID :16,
  204. GbE_descr_r :1,
  205. GbE_BIOS_r :1,
  206. GbE_ME_r :1,
  207. GbE_GbE_r :1,
  208. GbE_plat_r :1,
  209. :3,
  210. GbE_descr_w :1,
  211. GbE_BIOS_w :1,
  212. GbE_ME_w :1,
  213. GbE_GbE_w :1,
  214. GbE_plat_w :1,
  215. :3;
  216. };
  217. };
  218. };
  219. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  220. struct ich_desc_north_strap {
  221. union {
  222. uint32_t STRPs[1]; /* current maximum: ich8 */
  223. struct { /* ich8 */
  224. struct { /* STRP2 (in the datasheet) */
  225. uint32_t MDB :1,
  226. :31;
  227. };
  228. } ich8;
  229. };
  230. };
  231. struct ich_desc_south_strap {
  232. union {
  233. uint32_t STRPs[16]; /* current maximum: ibex peak */
  234. struct { /* ich8 */
  235. struct { /* STRP1 */
  236. uint32_t ME_DISABLE :1,
  237. :6,
  238. TCOMODE :1,
  239. ASD :7,
  240. BMCMODE :1,
  241. :3,
  242. GLAN_PCIE_SEL :1,
  243. GPIO12_SEL :2,
  244. SPICS1_LANPHYPC_SEL :1,
  245. MESM2SEL :1,
  246. :1,
  247. ASD2 :7;
  248. };
  249. } ich8;
  250. struct { /* ibex peak */
  251. struct { /* STRP0 */
  252. uint32_t :1,
  253. cs_ss2 :1,
  254. :5,
  255. SMB_EN :1,
  256. SML0_EN :1,
  257. SML1_EN :1,
  258. SML1FRQ :2,
  259. SMB0FRQ :2,
  260. SML0FRQ :2,
  261. :4,
  262. LANPHYPC_GP12_SEL :1,
  263. cs_ss1 :1,
  264. :2,
  265. DMI_REQID_DIS :1,
  266. :4,
  267. BBBS :2,
  268. :1;
  269. };
  270. struct { /* STRP1 */
  271. uint32_t cs_ss3 :4,
  272. :28;
  273. };
  274. struct { /* STRP2 */
  275. uint32_t :8,
  276. MESMASDEN :1,
  277. MESMASDA :7,
  278. :8,
  279. MESMI2CEN :1,
  280. MESMI2CA :7;
  281. };
  282. struct { /* STRP3 */
  283. uint32_t :32;
  284. };
  285. struct { /* STRP4 */
  286. uint32_t PHYCON :2,
  287. :6,
  288. GBEMAC_SMBUS_ADDR_EN :1,
  289. GBEMAC_SMBUS_ADDR :7,
  290. :1,
  291. GBEPHY_SMBUS_ADDR :7,
  292. :8;
  293. };
  294. struct { /* STRP5 */
  295. uint32_t :32;
  296. };
  297. struct { /* STRP6 */
  298. uint32_t :32;
  299. };
  300. struct { /* STRP7 */
  301. uint32_t MESMA2UDID_VENDOR :16,
  302. MESMA2UDID_DEVICE :16;
  303. };
  304. struct { /* STRP8 */
  305. uint32_t :32;
  306. };
  307. struct { /* STRP9 */
  308. uint32_t PCIEPCS1 :2,
  309. PCIEPCS2 :2,
  310. PCIELR1 :1,
  311. PCIELR2 :1,
  312. DMILR :1,
  313. :1,
  314. PHY_PCIEPORTSEL :3,
  315. PHY_PCIE_EN :1,
  316. :20;
  317. };
  318. struct { /* STRP10 */
  319. uint32_t :1,
  320. ME_BOOT_FLASH :1,
  321. cs_ss5 :1,
  322. VE_EN :1,
  323. :4,
  324. MMDDE :1,
  325. MMADDR :7,
  326. cs_ss7 :1,
  327. :1,
  328. ICC_SEL :3,
  329. MER_CL1 :1,
  330. :10;
  331. };
  332. struct { /* STRP11 */
  333. uint32_t SML1GPAEN :1,
  334. SML1GPA :7,
  335. :16,
  336. SML1I2CAEN :1,
  337. SML1I2CA :7;
  338. };
  339. struct { /* STRP12 */
  340. uint32_t :32;
  341. };
  342. struct { /* STRP13 */
  343. uint32_t :32;
  344. };
  345. struct { /* STRP14 */
  346. uint32_t :8,
  347. VE_EN2 :1,
  348. :5,
  349. VE_BOOT_FLASH :1,
  350. :1,
  351. BW_SSD :1,
  352. NVMHCI_EN :1,
  353. :14;
  354. };
  355. struct { /* STRP15 */
  356. uint32_t :3,
  357. cs_ss6 :2,
  358. :1,
  359. IWL_EN :1,
  360. :1,
  361. t209min :2,
  362. :22;
  363. };
  364. } ibex;
  365. struct { /* cougar point */
  366. struct { /* STRP0 */
  367. uint32_t :1,
  368. cs_ss1 :1,
  369. :5,
  370. SMB_EN :1,
  371. SML0_EN :1,
  372. SML1_EN :1,
  373. SML1FRQ :2,
  374. SMB0FRQ :2,
  375. SML0FRQ :2,
  376. :4,
  377. LANPHYPC_GP12_SEL :1,
  378. LINKSEC_DIS :1,
  379. :2,
  380. DMI_REQID_DIS :1,
  381. :4,
  382. BBBS :2,
  383. :1;
  384. };
  385. struct { /* STRP1 */
  386. uint32_t cs_ss3 :4,
  387. :4,
  388. cs_ss2 :1,
  389. :28;
  390. };
  391. struct { /* STRP2 */
  392. uint32_t :8,
  393. MESMASDEN :1,
  394. MESMASDA :7,
  395. MESMMCTPAEN :1,
  396. MESMMCTPA :7,
  397. MESMI2CEN :1,
  398. MESMI2CA :7;
  399. };
  400. struct { /* STRP3 */
  401. uint32_t :32;
  402. };
  403. struct { /* STRP4 */
  404. uint32_t PHYCON :2,
  405. :6,
  406. GBEMAC_SMBUS_ADDR_EN :1,
  407. GBEMAC_SMBUS_ADDR :7,
  408. :1,
  409. GBEPHY_SMBUS_ADDR :7,
  410. :8;
  411. };
  412. struct { /* STRP5 */
  413. uint32_t :32;
  414. };
  415. struct { /* STRP6 */
  416. uint32_t :32;
  417. };
  418. struct { /* STRP7 */
  419. uint32_t MESMA2UDID_VENDOR :16,
  420. MESMA2UDID_DEVICE :16;
  421. };
  422. struct { /* STRP8 */
  423. uint32_t :32;
  424. };
  425. struct { /* STRP9 */
  426. uint32_t PCIEPCS1 :2,
  427. PCIEPCS2 :2,
  428. PCIELR1 :1,
  429. PCIELR2 :1,
  430. DMILR :1,
  431. cs_ss4 :1,
  432. PHY_PCIEPORTSEL :3,
  433. PHY_PCIE_EN :1,
  434. :2,
  435. SUB_DECODE_EN :1,
  436. :7,
  437. PCHHOT_SML1ALERT_SEL :1,
  438. :9;
  439. };
  440. struct { /* STRP10 */
  441. uint32_t :1,
  442. ME_BOOT_FLASH :1,
  443. :6,
  444. MDSMBE_EN :1,
  445. MDSMBE_ADD :7,
  446. :2,
  447. ICC_SEL :3,
  448. MER_CL1 :1,
  449. ICC_PRO_SEL :1,
  450. Deep_SX_EN :1,
  451. ME_DBG_LAN :1,
  452. :7;
  453. };
  454. struct { /* STRP11 */
  455. uint32_t SML1GPAEN :1,
  456. SML1GPA :7,
  457. :16,
  458. SML1I2CAEN :1,
  459. SML1I2CA :7;
  460. };
  461. struct { /* STRP12 */
  462. uint32_t :32;
  463. };
  464. struct { /* STRP13 */
  465. uint32_t :32;
  466. };
  467. struct { /* STRP14 */
  468. uint32_t :32;
  469. };
  470. struct { /* STRP15 */
  471. uint32_t cs_ss6 :6,
  472. IWL_EN :1,
  473. cs_ss5 :2,
  474. :4,
  475. SMLINK1_THERM_SEL :1,
  476. SLP_LAN_GP29_SEL :1,
  477. :16;
  478. };
  479. struct { /* STRP16 */
  480. uint32_t :32;
  481. };
  482. struct { /* STRP17 */
  483. uint32_t ICML :1,
  484. cs_ss7 :1,
  485. :30;
  486. };
  487. } cougar;
  488. };
  489. };
  490. struct ich_desc_upper_map {
  491. union {
  492. uint32_t FLUMAP1; /* Flash Upper Map 1 */
  493. struct {
  494. uint32_t VTBA :8, /* ME VSCC Table Base Address */
  495. VTL :8, /* ME VSCC Table Length */
  496. :16;
  497. };
  498. };
  499. struct {
  500. union { /* JEDEC-ID Register */
  501. uint32_t JID;
  502. struct {
  503. uint32_t vid :8, /* Vendor ID */
  504. cid0 :8, /* Component ID 0 */
  505. cid1 :8, /* Component ID 1 */
  506. :8;
  507. };
  508. };
  509. union { /* Vendor Specific Component Capabilities */
  510. uint32_t VSCC;
  511. struct {
  512. uint32_t ubes :2, /* Upper Block/Sector Erase Size */
  513. uwg :1, /* Upper Write Granularity */
  514. uwsr :1, /* Upper Write Status Required */
  515. uwews :1, /* Upper Write Enable on Write Status */
  516. :3,
  517. ueo :8, /* Upper Erase Opcode */
  518. lbes :2, /* Lower Block/Sector Erase Size */
  519. lwg :1, /* Lower Write Granularity */
  520. lwsr :1, /* Lower Write Status Required */
  521. lwews :1, /* Lower Write Enable on Write Status */
  522. :3,
  523. leo :16; /* Lower Erase Opcode */
  524. };
  525. };
  526. } vscc_table[128];
  527. };
  528. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  529. struct ich_descriptors {
  530. struct ich_desc_content content;
  531. struct ich_desc_component component;
  532. struct ich_desc_region region;
  533. struct ich_desc_master master;
  534. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  535. struct ich_desc_north_strap north;
  536. struct ich_desc_south_strap south;
  537. struct ich_desc_upper_map upper;
  538. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  539. };
  540. void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc);
  541. void prettyprint_ich_descriptor_content(const struct ich_desc_content *content);
  542. void prettyprint_ich_descriptor_component(const struct ich_descriptors *desc);
  543. void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc);
  544. void prettyprint_ich_descriptor_master(const struct ich_desc_master *master);
  545. #ifdef ICH_DESCRIPTORS_FROM_DUMP
  546. void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap);
  547. void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc);
  548. int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc);
  549. #else /* ICH_DESCRIPTORS_FROM_DUMP */
  550. int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc,
  551. int chipset);
  552. int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx);
  553. #endif /* ICH_DESCRIPTORS_FROM_DUMP */
  554. #endif /* __ICH_DESCRIPTORS_H__ */
  555. #endif /* defined(__i386__) || defined(__x86_64__) */