ich_descriptors.h 13 KB

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