chipset_enable.c 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855
  1. /*
  2. * This file is part of the flashrom project.
  3. *
  4. * Copyright (C) 2000 Silicon Integrated System Corporation
  5. * Copyright (C) 2005-2009 coresystems GmbH
  6. * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
  7. * Copyright (C) 2007,2008,2009 Carl-Daniel Hailfinger
  8. * Copyright (C) 2009 Kontron Modular Computers GmbH
  9. * Copyright (C) 2011, 2012 Stefan Tauner
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; version 2 of the License.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. /*
  25. * Contains the chipset specific flash enables.
  26. */
  27. #define _LARGEFILE64_SOURCE
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <unistd.h>
  31. #include <inttypes.h>
  32. #include <errno.h>
  33. #include "flash.h"
  34. #include "programmer.h"
  35. #include "hwaccess.h"
  36. #define NOT_DONE_YET 1
  37. #if defined(__i386__) || defined(__x86_64__)
  38. static int enable_flash_ali_m1533(struct pci_dev *dev, const char *name)
  39. {
  40. uint8_t tmp;
  41. /*
  42. * ROM Write enable, 0xFFFC0000-0xFFFDFFFF and
  43. * 0xFFFE0000-0xFFFFFFFF ROM select enable.
  44. */
  45. tmp = pci_read_byte(dev, 0x47);
  46. tmp |= 0x46;
  47. rpci_write_byte(dev, 0x47, tmp);
  48. return 0;
  49. }
  50. static int enable_flash_rdc_r8610(struct pci_dev *dev, const char *name)
  51. {
  52. uint8_t tmp;
  53. /* enable ROMCS for writes */
  54. tmp = pci_read_byte(dev, 0x43);
  55. tmp |= 0x80;
  56. pci_write_byte(dev, 0x43, tmp);
  57. /* read the bootstrapping register */
  58. tmp = pci_read_byte(dev, 0x40) & 0x3;
  59. switch (tmp) {
  60. case 3:
  61. internal_buses_supported = BUS_FWH;
  62. break;
  63. case 2:
  64. internal_buses_supported = BUS_LPC;
  65. break;
  66. default:
  67. internal_buses_supported = BUS_PARALLEL;
  68. break;
  69. }
  70. return 0;
  71. }
  72. static int enable_flash_sis85c496(struct pci_dev *dev, const char *name)
  73. {
  74. uint8_t tmp;
  75. tmp = pci_read_byte(dev, 0xd0);
  76. tmp |= 0xf8;
  77. rpci_write_byte(dev, 0xd0, tmp);
  78. return 0;
  79. }
  80. static int enable_flash_sis_mapping(struct pci_dev *dev, const char *name)
  81. {
  82. #define SIS_MAPREG 0x40
  83. uint8_t new, newer;
  84. /* Extended BIOS enable = 1, Lower BIOS Enable = 1 */
  85. /* This is 0xFFF8000~0xFFFF0000 decoding on SiS 540/630. */
  86. new = pci_read_byte(dev, SIS_MAPREG);
  87. new &= (~0x04); /* No idea why we clear bit 2. */
  88. new |= 0xb; /* 0x3 for some chipsets, bit 7 seems to be don't care. */
  89. rpci_write_byte(dev, SIS_MAPREG, new);
  90. newer = pci_read_byte(dev, SIS_MAPREG);
  91. if (newer != new) { /* FIXME: share this with other code? */
  92. msg_pinfo("Setting register 0x%x to 0x%02x on %s failed (WARNING ONLY).\n",
  93. SIS_MAPREG, new, name);
  94. msg_pinfo("Stuck at 0x%02x.\n", newer);
  95. return -1;
  96. }
  97. return 0;
  98. }
  99. static struct pci_dev *find_southbridge(uint16_t vendor, const char *name)
  100. {
  101. struct pci_dev *sbdev;
  102. sbdev = pci_dev_find_vendorclass(vendor, 0x0601);
  103. if (!sbdev)
  104. sbdev = pci_dev_find_vendorclass(vendor, 0x0680);
  105. if (!sbdev)
  106. sbdev = pci_dev_find_vendorclass(vendor, 0x0000);
  107. if (!sbdev)
  108. msg_perr("No southbridge found for %s!\n", name);
  109. if (sbdev)
  110. msg_pdbg("Found southbridge %04x:%04x at %02x:%02x:%01x\n",
  111. sbdev->vendor_id, sbdev->device_id,
  112. sbdev->bus, sbdev->dev, sbdev->func);
  113. return sbdev;
  114. }
  115. static int enable_flash_sis501(struct pci_dev *dev, const char *name)
  116. {
  117. uint8_t tmp;
  118. int ret = 0;
  119. struct pci_dev *sbdev;
  120. sbdev = find_southbridge(dev->vendor_id, name);
  121. if (!sbdev)
  122. return -1;
  123. ret = enable_flash_sis_mapping(sbdev, name);
  124. tmp = sio_read(0x22, 0x80);
  125. tmp &= (~0x20);
  126. tmp |= 0x4;
  127. sio_write(0x22, 0x80, tmp);
  128. tmp = sio_read(0x22, 0x70);
  129. tmp &= (~0x20);
  130. tmp |= 0x4;
  131. sio_write(0x22, 0x70, tmp);
  132. return ret;
  133. }
  134. static int enable_flash_sis5511(struct pci_dev *dev, const char *name)
  135. {
  136. uint8_t tmp;
  137. int ret = 0;
  138. struct pci_dev *sbdev;
  139. sbdev = find_southbridge(dev->vendor_id, name);
  140. if (!sbdev)
  141. return -1;
  142. ret = enable_flash_sis_mapping(sbdev, name);
  143. tmp = sio_read(0x22, 0x50);
  144. tmp &= (~0x20);
  145. tmp |= 0x4;
  146. sio_write(0x22, 0x50, tmp);
  147. return ret;
  148. }
  149. static int enable_flash_sis5x0(struct pci_dev *dev, const char *name, uint8_t dis_mask, uint8_t en_mask)
  150. {
  151. #define SIS_REG 0x45
  152. uint8_t new, newer;
  153. int ret = 0;
  154. struct pci_dev *sbdev;
  155. sbdev = find_southbridge(dev->vendor_id, name);
  156. if (!sbdev)
  157. return -1;
  158. ret = enable_flash_sis_mapping(sbdev, name);
  159. new = pci_read_byte(sbdev, SIS_REG);
  160. new &= (~dis_mask);
  161. new |= en_mask;
  162. rpci_write_byte(sbdev, SIS_REG, new);
  163. newer = pci_read_byte(sbdev, SIS_REG);
  164. if (newer != new) { /* FIXME: share this with other code? */
  165. msg_pinfo("Setting register 0x%x to 0x%02x on %s failed (WARNING ONLY).\n", SIS_REG, new, name);
  166. msg_pinfo("Stuck at 0x%02x\n", newer);
  167. ret = -1;
  168. }
  169. return ret;
  170. }
  171. static int enable_flash_sis530(struct pci_dev *dev, const char *name)
  172. {
  173. return enable_flash_sis5x0(dev, name, 0x20, 0x04);
  174. }
  175. static int enable_flash_sis540(struct pci_dev *dev, const char *name)
  176. {
  177. return enable_flash_sis5x0(dev, name, 0x80, 0x40);
  178. }
  179. /* Datasheet:
  180. * - Name: 82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4)
  181. * - URL: http://www.intel.com/design/intarch/datashts/290562.htm
  182. * - PDF: http://www.intel.com/design/intarch/datashts/29056201.pdf
  183. * - Order Number: 290562-001
  184. */
  185. static int enable_flash_piix4(struct pci_dev *dev, const char *name)
  186. {
  187. uint16_t old, new;
  188. uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */
  189. internal_buses_supported = BUS_PARALLEL;
  190. old = pci_read_word(dev, xbcs);
  191. /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to
  192. * FFF00000-FFF7FFFF are forwarded to ISA).
  193. * Note: This bit is reserved on PIIX/PIIX3/MPIIX.
  194. * Set bit 7: Extended BIOS Enable (PCI master accesses to
  195. * FFF80000-FFFDFFFF are forwarded to ISA).
  196. * Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to
  197. * the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top
  198. * of 1 Mbyte, or the aliases at the top of 4 Gbyte
  199. * (FFFE0000-FFFEFFFF) result in the generation of BIOSCS#.
  200. * Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA.
  201. * Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable).
  202. */
  203. if (dev->device_id == 0x122e || dev->device_id == 0x7000
  204. || dev->device_id == 0x1234)
  205. new = old | 0x00c4; /* PIIX/PIIX3/MPIIX: Bit 9 is reserved. */
  206. else
  207. new = old | 0x02c4;
  208. if (new == old)
  209. return 0;
  210. rpci_write_word(dev, xbcs, new);
  211. if (pci_read_word(dev, xbcs) != new) { /* FIXME: share this with other code? */
  212. msg_pinfo("Setting register 0x%04x to 0x%04x on %s failed (WARNING ONLY).\n", xbcs, new, name);
  213. return -1;
  214. }
  215. return 0;
  216. }
  217. /* Handle BIOS_CNTL (aka. BCR). Disable locks and enable writes. The register can either be in PCI config space
  218. * at the offset given by 'bios_cntl' or at the memory-mapped address 'addr'.
  219. *
  220. * Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, in Poulsbo, Tunnel Creek and other Atom
  221. * chipsets/SoCs it is even 32b, but just treating it as 8 bit wide seems to work fine in practice. */
  222. static int enable_flash_ich_bios_cntl_common(enum ich_chipset ich_generation, void *addr,
  223. struct pci_dev *dev, uint8_t bios_cntl)
  224. {
  225. uint8_t old, new, wanted;
  226. switch (ich_generation) {
  227. case CHIPSET_ICH_UNKNOWN:
  228. return ERROR_FATAL;
  229. /* Non-SPI-capable */
  230. case CHIPSET_ICH:
  231. case CHIPSET_ICH2345:
  232. break;
  233. /* Some Atom chipsets are special: The second byte of BIOS_CNTL (D9h) contains a prefetch bit similar to
  234. * what other SPI-capable chipsets have at DCh. Others like Bay Trail use a memmapped register.
  235. * The Tunnel Creek datasheet contains a lot of details about the SPI controller, among other things it
  236. * mentions that the prefetching and caching does only happen for direct memory reads.
  237. * Therefore - at least for Tunnel Creek - it should not matter to flashrom because we use the
  238. * programmed access only and not memory mapping. */
  239. case CHIPSET_TUNNEL_CREEK:
  240. case CHIPSET_POULSBO:
  241. case CHIPSET_CENTERTON:
  242. old = pci_read_byte(dev, bios_cntl + 1);
  243. msg_pdbg("BIOS Prefetch Enable: %sabled, ", (old & 1) ? "en" : "dis");
  244. break;
  245. case CHIPSET_BAYTRAIL:
  246. case CHIPSET_ICH7:
  247. default: /* Future version might behave the same */
  248. if (ich_generation == CHIPSET_BAYTRAIL)
  249. old = (mmio_readl(addr) >> 2) & 0x3;
  250. else
  251. old = (pci_read_byte(dev, bios_cntl) >> 2) & 0x3;
  252. msg_pdbg("SPI Read Configuration: ");
  253. if (old == 3)
  254. msg_pdbg("invalid prefetching/caching settings, ");
  255. else
  256. msg_pdbg("prefetching %sabled, caching %sabled, ",
  257. (old & 0x2) ? "en" : "dis",
  258. (old & 0x1) ? "dis" : "en");
  259. }
  260. if (ich_generation == CHIPSET_BAYTRAIL)
  261. wanted = old = mmio_readl(addr);
  262. else
  263. wanted = old = pci_read_byte(dev, bios_cntl);
  264. /*
  265. * Quote from the 6 Series datasheet (Document Number: 324645-004):
  266. * "Bit 5: SMM BIOS Write Protect Disable (SMM_BWP)
  267. * 1 = BIOS region SMM protection is enabled.
  268. * The BIOS Region is not writable unless all processors are in SMM."
  269. * In earlier chipsets this bit is reserved.
  270. *
  271. * Try to unset it in any case.
  272. * It won't hurt and makes sense in some cases according to Stefan Reinauer.
  273. *
  274. * At least in Centerton aforementioned bit is located at bit 7. It is unspecified in all other Atom
  275. * and Desktop chipsets before Ibex Peak/5 Series, but we reset bit 5 anyway.
  276. */
  277. int smm_bwp_bit;
  278. if (ich_generation == CHIPSET_CENTERTON)
  279. smm_bwp_bit = 7;
  280. else
  281. smm_bwp_bit = 5;
  282. wanted &= ~(1 << smm_bwp_bit);
  283. /* Tunnel Creek has a cache disable at bit 2 of the lowest BIOS_CNTL byte. */
  284. if (ich_generation == CHIPSET_TUNNEL_CREEK)
  285. wanted |= (1 << 2);
  286. wanted |= (1 << 0); /* Set BIOS Write Enable */
  287. wanted &= ~(1 << 1); /* Disable lock (futile) */
  288. /* Only write the register if it's necessary */
  289. if (wanted != old) {
  290. if (ich_generation == CHIPSET_BAYTRAIL) {
  291. rmmio_writel(wanted, addr);
  292. new = mmio_readl(addr);
  293. } else {
  294. rpci_write_byte(dev, bios_cntl, wanted);
  295. new = pci_read_byte(dev, bios_cntl);
  296. }
  297. } else
  298. new = old;
  299. msg_pdbg("\nBIOS_CNTL = 0x%02x: ", new);
  300. msg_pdbg("BIOS Lock Enable: %sabled, ", (new & (1 << 1)) ? "en" : "dis");
  301. msg_pdbg("BIOS Write Enable: %sabled\n", (new & (1 << 0)) ? "en" : "dis");
  302. if (new & (1 << smm_bwp_bit))
  303. msg_pwarn("Warning: BIOS region SMM protection is enabled!\n");
  304. if (new != wanted)
  305. msg_pwarn("Warning: Setting Bios Control at 0x%x from 0x%02x to 0x%02x failed.\n"
  306. "New value is 0x%02x.\n", bios_cntl, old, wanted, new);
  307. /* Return an error if we could not set the write enable only. */
  308. if (!(new & (1 << 0)))
  309. return -1;
  310. return 0;
  311. }
  312. static int enable_flash_ich_bios_cntl_config_space(struct pci_dev *dev, enum ich_chipset ich_generation,
  313. uint8_t bios_cntl)
  314. {
  315. return enable_flash_ich_bios_cntl_common(ich_generation, NULL, dev, bios_cntl);
  316. }
  317. static int enable_flash_ich_bios_cntl_memmapped(enum ich_chipset ich_generation, void *addr)
  318. {
  319. return enable_flash_ich_bios_cntl_common(ich_generation, addr, NULL, 0);
  320. }
  321. static int enable_flash_ich_fwh_decode(struct pci_dev *dev, enum ich_chipset ich_generation)
  322. {
  323. uint8_t fwh_sel1 = 0, fwh_sel2 = 0, fwh_dec_en_lo = 0, fwh_dec_en_hi = 0; /* silence compilers */
  324. bool implemented = 0;
  325. void *ilb = NULL; /* Only for Baytrail */
  326. switch (ich_generation) {
  327. case CHIPSET_ICH:
  328. /* FIXME: Unlike later chipsets, ICH and ICH-0 do only support mapping of the top-most 4MB
  329. * and therefore do only feature FWH_DEC_EN (E3h, different default too) and FWH_SEL (E8h). */
  330. break;
  331. case CHIPSET_ICH2345:
  332. fwh_sel1 = 0xe8;
  333. fwh_sel2 = 0xee;
  334. fwh_dec_en_lo = 0xf0;
  335. fwh_dec_en_hi = 0xe3;
  336. implemented = 1;
  337. break;
  338. case CHIPSET_POULSBO:
  339. case CHIPSET_TUNNEL_CREEK:
  340. /* FIXME: Similar to ICH and ICH-0, Tunnel Creek and Poulsbo do only feature one register each,
  341. * FWH_DEC_EN (D7h) and FWH_SEL (D0h). */
  342. break;
  343. case CHIPSET_CENTERTON:
  344. /* FIXME: Similar to above FWH_DEC_EN (D4h) and FWH_SEL (D0h). */
  345. break;
  346. case CHIPSET_BAYTRAIL: {
  347. uint32_t ilb_base = pci_read_long(dev, 0x50) & 0xfffffe00; /* bits 31:9 */
  348. if (ilb_base == 0) {
  349. msg_perr("Error: Invalid ILB_BASE_ADDRESS\n");
  350. return ERROR_FATAL;
  351. }
  352. ilb = rphysmap("BYT IBASE", ilb_base, 512);
  353. fwh_sel1 = 0x18;
  354. fwh_dec_en_lo = 0xd8;
  355. fwh_dec_en_hi = 0xd9;
  356. implemented = 1;
  357. break;
  358. }
  359. case CHIPSET_ICH6:
  360. case CHIPSET_ICH7:
  361. default: /* Future version might behave the same */
  362. fwh_sel1 = 0xd0;
  363. fwh_sel2 = 0xd4;
  364. fwh_dec_en_lo = 0xd8;
  365. fwh_dec_en_hi = 0xd9;
  366. implemented = 1;
  367. break;
  368. }
  369. char *idsel = extract_programmer_param("fwh_idsel");
  370. if (idsel && strlen(idsel)) {
  371. if (!implemented) {
  372. msg_perr("Error: fwh_idsel= specified, but (yet) unsupported on this chipset.\n");
  373. goto idsel_garbage_out;
  374. }
  375. errno = 0;
  376. /* Base 16, nothing else makes sense. */
  377. uint64_t fwh_idsel = (uint64_t)strtoull(idsel, NULL, 16);
  378. if (errno) {
  379. msg_perr("Error: fwh_idsel= specified, but value could not be converted.\n");
  380. goto idsel_garbage_out;
  381. }
  382. uint64_t fwh_mask = 0xffffffff;
  383. if (fwh_sel2 > 0)
  384. fwh_mask |= (0xffffULL << 32);
  385. if (fwh_idsel & ~fwh_mask) {
  386. msg_perr("Error: fwh_idsel= specified, but value had unused bits set.\n");
  387. goto idsel_garbage_out;
  388. }
  389. uint64_t fwh_idsel_old;
  390. if (ich_generation == CHIPSET_BAYTRAIL) {
  391. fwh_idsel_old = mmio_readl(ilb + fwh_sel1);
  392. rmmio_writel(fwh_idsel, ilb + fwh_sel1);
  393. } else {
  394. fwh_idsel_old = (uint64_t)pci_read_long(dev, fwh_sel1) << 16;
  395. rpci_write_long(dev, fwh_sel1, (fwh_idsel >> 16) & 0xffffffff);
  396. if (fwh_sel2 > 0) {
  397. fwh_idsel_old |= pci_read_word(dev, fwh_sel2);
  398. rpci_write_word(dev, fwh_sel2, fwh_idsel & 0xffff);
  399. }
  400. }
  401. msg_pdbg("Setting IDSEL from 0x%012" PRIx64 " to 0x%012" PRIx64 " for top 16 MB.\n",
  402. fwh_idsel_old, fwh_idsel);
  403. /* FIXME: Decode settings are not changed. */
  404. } else if (idsel) {
  405. msg_perr("Error: fwh_idsel= specified, but no value given.\n");
  406. idsel_garbage_out:
  407. free(idsel);
  408. return ERROR_FATAL;
  409. }
  410. free(idsel);
  411. if (!implemented) {
  412. msg_pdbg2("FWH IDSEL handling is not implemented on this chipset.\n");
  413. return 0;
  414. }
  415. /* Ignore all legacy ranges below 1 MB.
  416. * We currently only support flashing the chip which responds to
  417. * IDSEL=0. To support IDSEL!=0, flashbase and decode size calculations
  418. * have to be adjusted.
  419. */
  420. int max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0;
  421. bool contiguous = 1;
  422. uint32_t fwh_conf;
  423. if (ich_generation == CHIPSET_BAYTRAIL)
  424. fwh_conf = mmio_readl(ilb + fwh_sel1);
  425. else
  426. fwh_conf = pci_read_long(dev, fwh_sel1);
  427. int i;
  428. /* FWH_SEL1 */
  429. for (i = 7; i >= 0; i--) {
  430. int tmp = (fwh_conf >> (i * 4)) & 0xf;
  431. msg_pdbg("0x%08x/0x%08x FWH IDSEL: 0x%x\n",
  432. (0x1ff8 + i) * 0x80000,
  433. (0x1ff0 + i) * 0x80000,
  434. tmp);
  435. if ((tmp == 0) && contiguous) {
  436. max_decode_fwh_idsel = (8 - i) * 0x80000;
  437. } else {
  438. contiguous = 0;
  439. }
  440. }
  441. if (fwh_sel2 > 0) {
  442. /* FWH_SEL2 */
  443. fwh_conf = pci_read_word(dev, fwh_sel2);
  444. for (i = 3; i >= 0; i--) {
  445. int tmp = (fwh_conf >> (i * 4)) & 0xf;
  446. msg_pdbg("0x%08x/0x%08x FWH IDSEL: 0x%x\n",
  447. (0xff4 + i) * 0x100000,
  448. (0xff0 + i) * 0x100000,
  449. tmp);
  450. if ((tmp == 0) && contiguous) {
  451. max_decode_fwh_idsel = (8 - i) * 0x100000;
  452. } else {
  453. contiguous = 0;
  454. }
  455. }
  456. }
  457. contiguous = 1;
  458. /* FWH_DEC_EN1 */
  459. fwh_conf = pci_read_byte(dev, fwh_dec_en_hi);
  460. fwh_conf <<= 8;
  461. fwh_conf |= pci_read_byte(dev, fwh_dec_en_lo);
  462. for (i = 7; i >= 0; i--) {
  463. int tmp = (fwh_conf >> (i + 0x8)) & 0x1;
  464. msg_pdbg("0x%08x/0x%08x FWH decode %sabled\n",
  465. (0x1ff8 + i) * 0x80000,
  466. (0x1ff0 + i) * 0x80000,
  467. tmp ? "en" : "dis");
  468. if ((tmp == 1) && contiguous) {
  469. max_decode_fwh_decode = (8 - i) * 0x80000;
  470. } else {
  471. contiguous = 0;
  472. }
  473. }
  474. for (i = 3; i >= 0; i--) {
  475. int tmp = (fwh_conf >> i) & 0x1;
  476. msg_pdbg("0x%08x/0x%08x FWH decode %sabled\n",
  477. (0xff4 + i) * 0x100000,
  478. (0xff0 + i) * 0x100000,
  479. tmp ? "en" : "dis");
  480. if ((tmp == 1) && contiguous) {
  481. max_decode_fwh_decode = (8 - i) * 0x100000;
  482. } else {
  483. contiguous = 0;
  484. }
  485. }
  486. max_rom_decode.fwh = min(max_decode_fwh_idsel, max_decode_fwh_decode);
  487. msg_pdbg("Maximum FWH chip size: 0x%x bytes\n", max_rom_decode.fwh);
  488. return 0;
  489. }
  490. static int enable_flash_ich_fwh(struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl)
  491. {
  492. int err;
  493. /* Configure FWH IDSEL decoder maps. */
  494. if ((err = enable_flash_ich_fwh_decode(dev, ich_generation)) != 0)
  495. return err;
  496. internal_buses_supported = BUS_FWH;
  497. return enable_flash_ich_bios_cntl_config_space(dev, ich_generation, bios_cntl);
  498. }
  499. static int enable_flash_ich0(struct pci_dev *dev, const char *name)
  500. {
  501. return enable_flash_ich_fwh(dev, CHIPSET_ICH, 0x4e);
  502. }
  503. static int enable_flash_ich2345(struct pci_dev *dev, const char *name)
  504. {
  505. return enable_flash_ich_fwh(dev, CHIPSET_ICH2345, 0x4e);
  506. }
  507. static int enable_flash_ich6(struct pci_dev *dev, const char *name)
  508. {
  509. return enable_flash_ich_fwh(dev, CHIPSET_ICH6, 0xdc);
  510. }
  511. static int enable_flash_poulsbo(struct pci_dev *dev, const char *name)
  512. {
  513. return enable_flash_ich_fwh(dev, CHIPSET_POULSBO, 0xd8);
  514. }
  515. static void enable_flash_ich_handle_gcs(struct pci_dev *dev, enum ich_chipset ich_generation, uint32_t gcs, bool top_swap)
  516. {
  517. msg_pdbg("GCS = 0x%x: ", gcs);
  518. msg_pdbg("BIOS Interface Lock-Down: %sabled, ", (gcs & 0x1) ? "en" : "dis");
  519. static const char *const straps_names_EP80579[] = { "SPI", "reserved", "reserved", "LPC" };
  520. static const char *const straps_names_ich7_nm10[] = { "reserved", "SPI", "PCI", "LPC" };
  521. static const char *const straps_names_tunnel_creek[] = { "SPI", "LPC" };
  522. static const char *const straps_names_ich8910[] = { "SPI", "SPI", "PCI", "LPC" };
  523. static const char *const straps_names_pch567[] = { "LPC", "reserved", "PCI", "SPI" };
  524. static const char *const straps_names_pch89_baytrail[] = { "LPC", "reserved", "reserved", "SPI" };
  525. static const char *const straps_names_pch8_lp[] = { "SPI", "LPC" };
  526. static const char *const straps_names_unknown[] = { "unknown", "unknown", "unknown", "unknown" };
  527. const char *const *straps_names;
  528. switch (ich_generation) {
  529. case CHIPSET_ICH7:
  530. /* EP80579 may need further changes, but this is the least
  531. * intrusive way to get correct BOOT Strap printing without
  532. * changing the rest of its code path). */
  533. if (dev->device_id == 0x5031)
  534. straps_names = straps_names_EP80579;
  535. else
  536. straps_names = straps_names_ich7_nm10;
  537. break;
  538. case CHIPSET_ICH8:
  539. case CHIPSET_ICH9:
  540. case CHIPSET_ICH10:
  541. straps_names = straps_names_ich8910;
  542. break;
  543. case CHIPSET_TUNNEL_CREEK:
  544. straps_names = straps_names_tunnel_creek;
  545. break;
  546. case CHIPSET_5_SERIES_IBEX_PEAK:
  547. case CHIPSET_6_SERIES_COUGAR_POINT:
  548. case CHIPSET_7_SERIES_PANTHER_POINT:
  549. straps_names = straps_names_pch567;
  550. break;
  551. case CHIPSET_8_SERIES_LYNX_POINT:
  552. case CHIPSET_9_SERIES_WILDCAT_POINT:
  553. case CHIPSET_BAYTRAIL:
  554. straps_names = straps_names_pch89_baytrail;
  555. break;
  556. case CHIPSET_8_SERIES_LYNX_POINT_LP:
  557. straps_names = straps_names_pch8_lp;
  558. break;
  559. case CHIPSET_8_SERIES_WELLSBURG: // FIXME: check datasheet
  560. case CHIPSET_CENTERTON: // FIXME: Datasheet does not mention GCS at all
  561. straps_names = straps_names_unknown;
  562. break;
  563. default:
  564. msg_gerr("%s: unknown ICH generation. Please report!\n", __func__);
  565. straps_names = straps_names_unknown;
  566. break;
  567. }
  568. uint8_t bbs;
  569. switch (ich_generation) {
  570. case CHIPSET_TUNNEL_CREEK:
  571. bbs = (gcs >> 1) & 0x1;
  572. break;
  573. case CHIPSET_8_SERIES_LYNX_POINT_LP:
  574. /* Lynx Point LP uses a single bit for BBS */
  575. bbs = (gcs >> 10) & 0x1;
  576. break;
  577. default:
  578. /* Other chipsets use two bits for BBS */
  579. bbs = (gcs >> 10) & 0x3;
  580. break;
  581. }
  582. msg_pdbg("Boot BIOS Straps: 0x%x (%s)\n", bbs, straps_names[bbs]);
  583. /* Centerton has its TS bit in [GPE0BLK] + 0x30 while the exact location for Tunnel Creek is unknown. */
  584. if (ich_generation != CHIPSET_TUNNEL_CREEK && ich_generation != CHIPSET_CENTERTON)
  585. msg_pdbg("Top Swap: %s\n", (top_swap) ? "enabled (A16(+) inverted)" : "not enabled");
  586. }
  587. static int enable_flash_ich_spi(struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl)
  588. {
  589. /* Get physical address of Root Complex Register Block */
  590. uint32_t rcra = pci_read_long(dev, 0xf0) & 0xffffc000;
  591. msg_pdbg("Root Complex Register Block address = 0x%x\n", rcra);
  592. /* Map RCBA to virtual memory */
  593. void *rcrb = rphysmap("ICH RCRB", rcra, 0x4000);
  594. if (rcrb == ERROR_PTR)
  595. return ERROR_FATAL;
  596. enable_flash_ich_handle_gcs(dev, ich_generation, mmio_readl(rcrb + 0x3410), mmio_readb(rcrb + 0x3414));
  597. /* Handle FWH-related parameters and initialization */
  598. int ret_fwh = enable_flash_ich_fwh(dev, ich_generation, bios_cntl);
  599. if (ret_fwh == ERROR_FATAL)
  600. return ret_fwh;
  601. /* SPIBAR is at RCRB+0x3020 for ICH[78], Tunnel Creek and Centerton, and RCRB+0x3800 for ICH9. */
  602. uint16_t spibar_offset;
  603. switch (ich_generation) {
  604. case CHIPSET_BAYTRAIL:
  605. case CHIPSET_ICH_UNKNOWN:
  606. return ERROR_FATAL;
  607. case CHIPSET_ICH7:
  608. case CHIPSET_ICH8:
  609. case CHIPSET_TUNNEL_CREEK:
  610. case CHIPSET_CENTERTON:
  611. spibar_offset = 0x3020;
  612. break;
  613. case CHIPSET_ICH9:
  614. default: /* Future version might behave the same */
  615. spibar_offset = 0x3800;
  616. break;
  617. }
  618. msg_pdbg("SPIBAR = 0x%0*" PRIxPTR " + 0x%04x\n", PRIxPTR_WIDTH, (uintptr_t)rcrb, spibar_offset);
  619. void *spibar = rcrb + spibar_offset;
  620. /* This adds BUS_SPI */
  621. int ret_spi = ich_init_spi(dev, spibar, ich_generation);
  622. if (ret_spi == ERROR_FATAL)
  623. return ret_spi;
  624. if (ret_fwh || ret_spi)
  625. return ERROR_NONFATAL;
  626. return 0;
  627. }
  628. static int enable_flash_tunnelcreek(struct pci_dev *dev, const char *name)
  629. {
  630. return enable_flash_ich_spi(dev, CHIPSET_TUNNEL_CREEK, 0xd8);
  631. }
  632. static int enable_flash_s12x0(struct pci_dev *dev, const char *name)
  633. {
  634. return enable_flash_ich_spi(dev, CHIPSET_CENTERTON, 0xd8);
  635. }
  636. static int enable_flash_ich7(struct pci_dev *dev, const char *name)
  637. {
  638. return enable_flash_ich_spi(dev, CHIPSET_ICH7, 0xdc);
  639. }
  640. static int enable_flash_ich8(struct pci_dev *dev, const char *name)
  641. {
  642. return enable_flash_ich_spi(dev, CHIPSET_ICH8, 0xdc);
  643. }
  644. static int enable_flash_ich9(struct pci_dev *dev, const char *name)
  645. {
  646. return enable_flash_ich_spi(dev, CHIPSET_ICH9, 0xdc);
  647. }
  648. static int enable_flash_ich10(struct pci_dev *dev, const char *name)
  649. {
  650. return enable_flash_ich_spi(dev, CHIPSET_ICH10, 0xdc);
  651. }
  652. /* Ibex Peak aka. 5 series & 3400 series */
  653. static int enable_flash_pch5(struct pci_dev *dev, const char *name)
  654. {
  655. return enable_flash_ich_spi(dev, CHIPSET_5_SERIES_IBEX_PEAK, 0xdc);
  656. }
  657. /* Cougar Point aka. 6 series & c200 series */
  658. static int enable_flash_pch6(struct pci_dev *dev, const char *name)
  659. {
  660. return enable_flash_ich_spi(dev, CHIPSET_6_SERIES_COUGAR_POINT, 0xdc);
  661. }
  662. /* Panther Point aka. 7 series */
  663. static int enable_flash_pch7(struct pci_dev *dev, const char *name)
  664. {
  665. return enable_flash_ich_spi(dev, CHIPSET_7_SERIES_PANTHER_POINT, 0xdc);
  666. }
  667. /* Lynx Point aka. 8 series */
  668. static int enable_flash_pch8(struct pci_dev *dev, const char *name)
  669. {
  670. return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_LYNX_POINT, 0xdc);
  671. }
  672. /* Lynx Point LP aka. 8 series low-power */
  673. static int enable_flash_pch8_lp(struct pci_dev *dev, const char *name)
  674. {
  675. return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_LYNX_POINT_LP, 0xdc);
  676. }
  677. /* Wellsburg (for Haswell-EP Xeons) */
  678. static int enable_flash_pch8_wb(struct pci_dev *dev, const char *name)
  679. {
  680. return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_WELLSBURG, 0xdc);
  681. }
  682. /* Wildcat Point */
  683. static int enable_flash_pch9(struct pci_dev *dev, const char *name)
  684. {
  685. return enable_flash_ich_spi(dev, CHIPSET_9_SERIES_WILDCAT_POINT, 0xdc);
  686. }
  687. /* Silvermont architecture: Bay Trail(-T/-I), Avoton/Rangeley.
  688. * These have a distinctly different behavior compared to other Intel chipsets and hence are handled separately.
  689. *
  690. * Differences include:
  691. * - RCBA at LPC config 0xF0 too but mapped range is only 4 B long instead of 16 kB.
  692. * - GCS at [RCRB] + 0 (instead of [RCRB] + 0x3410).
  693. * - TS (Top Swap) in GCS (instead of [RCRB] + 0x3414).
  694. * - SPIBAR (coined SBASE) at LPC config 0x54 (instead of [RCRB] + 0x3800).
  695. * - BIOS_CNTL (coined BCR) at [SPIBAR] + 0xFC (instead of LPC config 0xDC).
  696. */
  697. static int enable_flash_silvermont(struct pci_dev *dev, const char *name)
  698. {
  699. enum ich_chipset ich_generation = CHIPSET_BAYTRAIL;
  700. /* Get physical address of Root Complex Register Block */
  701. uint32_t rcba = pci_read_long(dev, 0xf0) & 0xfffffc00;
  702. msg_pdbg("Root Complex Register Block address = 0x%x\n", rcba);
  703. /* Handle GCS (in RCRB) */
  704. void *rcrb = physmap("BYT RCRB", rcba, 4);
  705. uint32_t gcs = mmio_readl(rcrb + 0);
  706. enable_flash_ich_handle_gcs(dev, ich_generation, gcs, gcs & 0x2);
  707. physunmap(rcrb, 4);
  708. /* Handle fwh_idsel parameter */
  709. int ret_fwh = enable_flash_ich_fwh_decode(dev, ich_generation);
  710. if (ret_fwh == ERROR_FATAL)
  711. return ret_fwh;
  712. internal_buses_supported = BUS_FWH;
  713. /* Get physical address of SPI Base Address and map it */
  714. uint32_t sbase = pci_read_long(dev, 0x54) & 0xfffffe00;
  715. msg_pdbg("SPI_BASE_ADDRESS = 0x%x\n", sbase);
  716. void *spibar = rphysmap("BYT SBASE", sbase, 512); /* Last defined address on Bay Trail is 0x100 */
  717. /* Enable Flash Writes.
  718. * Silvermont-based: BCR at SBASE + 0xFC (some bits of BCR are also accessible via BC at IBASE + 0x1C).
  719. */
  720. enable_flash_ich_bios_cntl_memmapped(ich_generation, spibar + 0xFC);
  721. int ret_spi = ich_init_spi(dev, spibar, ich_generation);
  722. if (ret_spi == ERROR_FATAL)
  723. return ret_spi;
  724. if (ret_fwh || ret_spi)
  725. return ERROR_NONFATAL;
  726. return 0;
  727. }
  728. static int via_no_byte_merge(struct pci_dev *dev, const char *name)
  729. {
  730. uint8_t val;
  731. val = pci_read_byte(dev, 0x71);
  732. if (val & 0x40) {
  733. msg_pdbg("Disabling byte merging\n");
  734. val &= ~0x40;
  735. rpci_write_byte(dev, 0x71, val);
  736. }
  737. return NOT_DONE_YET; /* need to find south bridge, too */
  738. }
  739. static int enable_flash_vt823x(struct pci_dev *dev, const char *name)
  740. {
  741. uint8_t val;
  742. /* Enable ROM decode range (1MB) FFC00000 - FFFFFFFF. */
  743. rpci_write_byte(dev, 0x41, 0x7f);
  744. /* ROM write enable */
  745. val = pci_read_byte(dev, 0x40);
  746. val |= 0x10;
  747. rpci_write_byte(dev, 0x40, val);
  748. if (pci_read_byte(dev, 0x40) != val) {
  749. msg_pwarn("\nWarning: Failed to enable flash write on \"%s\"\n", name);
  750. return -1;
  751. }
  752. if (dev->device_id == 0x3227) { /* VT8237/VT8237R */
  753. /* All memory cycles, not just ROM ones, go to LPC. */
  754. val = pci_read_byte(dev, 0x59);
  755. val &= ~0x80;
  756. rpci_write_byte(dev, 0x59, val);
  757. }
  758. return 0;
  759. }
  760. static int enable_flash_vt_vx(struct pci_dev *dev, const char *name)
  761. {
  762. struct pci_dev *south_north = pci_dev_find(0x1106, 0xa353);
  763. if (south_north == NULL) {
  764. msg_perr("Could not find South-North Module Interface Control device!\n");
  765. return ERROR_FATAL;
  766. }
  767. msg_pdbg("Strapped to ");
  768. if ((pci_read_byte(south_north, 0x56) & 0x01) == 0) {
  769. msg_pdbg("LPC.\n");
  770. return enable_flash_vt823x(dev, name);
  771. }
  772. msg_pdbg("SPI.\n");
  773. uint32_t mmio_base;
  774. void *mmio_base_physmapped;
  775. uint32_t spi_cntl;
  776. #define SPI_CNTL_LEN 0x08
  777. uint32_t spi0_mm_base = 0;
  778. switch(dev->device_id) {
  779. case 0x8353: /* VX800/VX820 */
  780. spi0_mm_base = pci_read_long(dev, 0xbc) << 8;
  781. break;
  782. case 0x8409: /* VX855/VX875 */
  783. case 0x8410: /* VX900 */
  784. mmio_base = pci_read_long(dev, 0xbc) << 8;
  785. mmio_base_physmapped = physmap("VIA VX MMIO register", mmio_base, SPI_CNTL_LEN);
  786. if (mmio_base_physmapped == ERROR_PTR)
  787. return ERROR_FATAL;
  788. /* Offset 0 - Bit 0 holds SPI Bus0 Enable Bit. */
  789. spi_cntl = mmio_readl(mmio_base_physmapped) + 0x00;
  790. if ((spi_cntl & 0x01) == 0) {
  791. msg_pdbg ("SPI Bus0 disabled!\n");
  792. physunmap(mmio_base_physmapped, SPI_CNTL_LEN);
  793. return ERROR_FATAL;
  794. }
  795. /* Offset 1-3 has SPI Bus Memory Map Base Address: */
  796. spi0_mm_base = spi_cntl & 0xFFFFFF00;
  797. /* Offset 4 - Bit 0 holds SPI Bus1 Enable Bit. */
  798. spi_cntl = mmio_readl(mmio_base_physmapped) + 0x04;
  799. if ((spi_cntl & 0x01) == 1)
  800. msg_pdbg2("SPI Bus1 is enabled too.\n");
  801. physunmap(mmio_base_physmapped, SPI_CNTL_LEN);
  802. break;
  803. default:
  804. msg_perr("%s: Unsupported chipset %x:%x!\n", __func__, dev->vendor_id, dev->device_id);
  805. return ERROR_FATAL;
  806. }
  807. return via_init_spi(dev, spi0_mm_base);
  808. }
  809. static int enable_flash_vt8237s_spi(struct pci_dev *dev, const char *name)
  810. {
  811. return via_init_spi(dev, pci_read_long(dev, 0xbc) << 8);
  812. }
  813. static int enable_flash_cs5530(struct pci_dev *dev, const char *name)
  814. {
  815. uint8_t reg8;
  816. #define DECODE_CONTROL_REG2 0x5b /* F0 index 0x5b */
  817. #define ROM_AT_LOGIC_CONTROL_REG 0x52 /* F0 index 0x52 */
  818. #define CS5530_RESET_CONTROL_REG 0x44 /* F0 index 0x44 */
  819. #define CS5530_USB_SHADOW_REG 0x43 /* F0 index 0x43 */
  820. #define LOWER_ROM_ADDRESS_RANGE (1 << 0)
  821. #define ROM_WRITE_ENABLE (1 << 1)
  822. #define UPPER_ROM_ADDRESS_RANGE (1 << 2)
  823. #define BIOS_ROM_POSITIVE_DECODE (1 << 5)
  824. #define CS5530_ISA_MASTER (1 << 7)
  825. #define CS5530_ENABLE_SA2320 (1 << 2)
  826. #define CS5530_ENABLE_SA20 (1 << 6)
  827. internal_buses_supported = BUS_PARALLEL;
  828. /* Decode 0x000E0000-0x000FFFFF (128 kB), not just 64 kB, and
  829. * decode 0xFF000000-0xFFFFFFFF (16 MB), not just 256 kB.
  830. * FIXME: Should we really touch the low mapping below 1 MB? Flashrom
  831. * ignores that region completely.
  832. * Make the configured ROM areas writable.
  833. */
  834. reg8 = pci_read_byte(dev, ROM_AT_LOGIC_CONTROL_REG);
  835. reg8 |= LOWER_ROM_ADDRESS_RANGE;
  836. reg8 |= UPPER_ROM_ADDRESS_RANGE;
  837. reg8 |= ROM_WRITE_ENABLE;
  838. rpci_write_byte(dev, ROM_AT_LOGIC_CONTROL_REG, reg8);
  839. /* Set positive decode on ROM. */
  840. reg8 = pci_read_byte(dev, DECODE_CONTROL_REG2);
  841. reg8 |= BIOS_ROM_POSITIVE_DECODE;
  842. rpci_write_byte(dev, DECODE_CONTROL_REG2, reg8);
  843. reg8 = pci_read_byte(dev, CS5530_RESET_CONTROL_REG);
  844. if (reg8 & CS5530_ISA_MASTER) {
  845. /* We have A0-A23 available. */
  846. max_rom_decode.parallel = 16 * 1024 * 1024;
  847. } else {
  848. reg8 = pci_read_byte(dev, CS5530_USB_SHADOW_REG);
  849. if (reg8 & CS5530_ENABLE_SA2320) {
  850. /* We have A0-19, A20-A23 available. */
  851. max_rom_decode.parallel = 16 * 1024 * 1024;
  852. } else if (reg8 & CS5530_ENABLE_SA20) {
  853. /* We have A0-19, A20 available. */
  854. max_rom_decode.parallel = 2 * 1024 * 1024;
  855. } else {
  856. /* A20 and above are not active. */
  857. max_rom_decode.parallel = 1024 * 1024;
  858. }
  859. }
  860. return 0;
  861. }
  862. /*
  863. * Geode systems write protect the BIOS via RCONFs (cache settings similar
  864. * to MTRRs). To unlock, change MSR 0x1808 top byte to 0x22.
  865. *
  866. * Geode systems also write protect the NOR flash chip itself via MSR_NORF_CTL.
  867. * To enable write to NOR Boot flash for the benefit of systems that have such
  868. * a setup, raise MSR 0x51400018 WE_CS3 (write enable Boot Flash Chip Select).
  869. */
  870. static int enable_flash_cs5536(struct pci_dev *dev, const char *name)
  871. {
  872. #define MSR_RCONF_DEFAULT 0x1808
  873. #define MSR_NORF_CTL 0x51400018
  874. msr_t msr;
  875. /* Geode only has a single core */
  876. if (setup_cpu_msr(0))
  877. return -1;
  878. msr = rdmsr(MSR_RCONF_DEFAULT);
  879. if ((msr.hi >> 24) != 0x22) {
  880. msr.hi &= 0xfbffffff;
  881. wrmsr(MSR_RCONF_DEFAULT, msr);
  882. }
  883. msr = rdmsr(MSR_NORF_CTL);
  884. /* Raise WE_CS3 bit. */
  885. msr.lo |= 0x08;
  886. wrmsr(MSR_NORF_CTL, msr);
  887. cleanup_cpu_msr();
  888. #undef MSR_RCONF_DEFAULT
  889. #undef MSR_NORF_CTL
  890. return 0;
  891. }
  892. static int enable_flash_sc1100(struct pci_dev *dev, const char *name)
  893. {
  894. #define SC_REG 0x52
  895. uint8_t new;
  896. rpci_write_byte(dev, SC_REG, 0xee);
  897. new = pci_read_byte(dev, SC_REG);
  898. if (new != 0xee) { /* FIXME: share this with other code? */
  899. msg_pinfo("Setting register 0x%x to 0x%02x on %s failed (WARNING ONLY).\n", SC_REG, new, name);
  900. return -1;
  901. }
  902. return 0;
  903. }
  904. /* Works for AMD-768, AMD-8111, VIA VT82C586A/B, VIA VT82C596, VIA VT82C686A/B.
  905. *
  906. * ROM decode control register matrix
  907. * AMD-768 AMD-8111 VT82C586A/B VT82C596 VT82C686A/B
  908. * 7 FFC0_0000h–FFFF_FFFFh <- FFFE0000h-FFFEFFFFh <- <-
  909. * 6 FFB0_0000h–FFBF_FFFFh <- FFF80000h-FFFDFFFFh <- <-
  910. * 5 00E8... <- <- FFF00000h-FFF7FFFFh <-
  911. */
  912. static int enable_flash_amd_via(struct pci_dev *dev, const char *name, uint8_t decode_val)
  913. {
  914. #define AMD_MAPREG 0x43
  915. #define AMD_ENREG 0x40
  916. uint8_t old, new;
  917. old = pci_read_byte(dev, AMD_MAPREG);
  918. new = old | decode_val;
  919. if (new != old) {
  920. rpci_write_byte(dev, AMD_MAPREG, new);
  921. if (pci_read_byte(dev, AMD_MAPREG) != new) {
  922. msg_pwarn("Setting register 0x%x to 0x%02x on %s failed (WARNING ONLY).\n",
  923. AMD_MAPREG, new, name);
  924. } else
  925. msg_pdbg("Changed ROM decode range to 0x%02x successfully.\n", new);
  926. }
  927. /* Enable 'ROM write' bit. */
  928. old = pci_read_byte(dev, AMD_ENREG);
  929. new = old | 0x01;
  930. if (new == old)
  931. return 0;
  932. rpci_write_byte(dev, AMD_ENREG, new);
  933. if (pci_read_byte(dev, AMD_ENREG) != new) {
  934. msg_pwarn("Setting register 0x%x to 0x%02x on %s failed (WARNING ONLY).\n",
  935. AMD_ENREG, new, name);
  936. return ERROR_NONFATAL;
  937. }
  938. msg_pdbg2("Set ROM enable bit successfully.\n");
  939. return 0;
  940. }
  941. static int enable_flash_amd_768_8111(struct pci_dev *dev, const char *name)
  942. {
  943. /* Enable decoding of 0xFFB00000 to 0xFFFFFFFF (5 MB). */
  944. max_rom_decode.lpc = 5 * 1024 * 1024;
  945. return enable_flash_amd_via(dev, name, 0xC0);
  946. }
  947. static int enable_flash_vt82c586(struct pci_dev *dev, const char *name)
  948. {
  949. /* Enable decoding of 0xFFF80000 to 0xFFFFFFFF. (512 kB) */
  950. max_rom_decode.parallel = 512 * 1024;
  951. return enable_flash_amd_via(dev, name, 0xC0);
  952. }
  953. /* Works for VT82C686A/B too. */
  954. static int enable_flash_vt82c596(struct pci_dev *dev, const char *name)
  955. {
  956. /* Enable decoding of 0xFFF00000 to 0xFFFFFFFF. (1 MB) */
  957. max_rom_decode.parallel = 1024 * 1024;
  958. return enable_flash_amd_via(dev, name, 0xE0);
  959. }
  960. static int enable_flash_sb600(struct pci_dev *dev, const char *name)
  961. {
  962. uint32_t prot;
  963. uint8_t reg;
  964. int ret;
  965. /* Clear ROM protect 0-3. */
  966. for (reg = 0x50; reg < 0x60; reg += 4) {
  967. prot = pci_read_long(dev, reg);
  968. /* No protection flags for this region?*/
  969. if ((prot & 0x3) == 0)
  970. continue;
  971. msg_pdbg("Chipset %s%sprotected flash from 0x%08x to 0x%08x, unlocking...",
  972. (prot & 0x2) ? "read " : "",
  973. (prot & 0x1) ? "write " : "",
  974. (prot & 0xfffff800),
  975. (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff));
  976. prot &= 0xfffffffc;
  977. rpci_write_byte(dev, reg, prot);
  978. prot = pci_read_long(dev, reg);
  979. if ((prot & 0x3) != 0) {
  980. msg_perr("Disabling %s%sprotection of flash addresses from 0x%08x to 0x%08x failed.\n",
  981. (prot & 0x2) ? "read " : "",
  982. (prot & 0x1) ? "write " : "",
  983. (prot & 0xfffff800),
  984. (prot & 0xfffff800) + (((prot & 0x7fc) << 8) | 0x3ff));
  985. continue;
  986. }
  987. msg_pdbg("done.\n");
  988. }
  989. internal_buses_supported = BUS_LPC | BUS_FWH;
  990. ret = sb600_probe_spi(dev);
  991. /* Read ROM strap override register. */
  992. OUTB(0x8f, 0xcd6);
  993. reg = INB(0xcd7);
  994. reg &= 0x0e;
  995. msg_pdbg("ROM strap override is %sactive", (reg & 0x02) ? "" : "not ");
  996. if (reg & 0x02) {
  997. switch ((reg & 0x0c) >> 2) {
  998. case 0x00:
  999. msg_pdbg(": LPC");
  1000. break;
  1001. case 0x01:
  1002. msg_pdbg(": PCI");
  1003. break;
  1004. case 0x02:
  1005. msg_pdbg(": FWH");
  1006. break;
  1007. case 0x03:
  1008. msg_pdbg(": SPI");
  1009. break;
  1010. }
  1011. }
  1012. msg_pdbg("\n");
  1013. /* Force enable SPI ROM in SB600 PM register.
  1014. * If we enable SPI ROM here, we have to disable it after we leave.
  1015. * But how can we know which ROM we are going to handle? So we have
  1016. * to trade off. We only access LPC ROM if we boot via LPC ROM. And
  1017. * only SPI ROM if we boot via SPI ROM. If you want to access SPI on
  1018. * boards with LPC straps, you have to use the code below.
  1019. */
  1020. /*
  1021. OUTB(0x8f, 0xcd6);
  1022. OUTB(0x0e, 0xcd7);
  1023. */
  1024. return ret;
  1025. }
  1026. /* sets bit 0 in 0x6d */
  1027. static int enable_flash_nvidia_common(struct pci_dev *dev, const char *name)
  1028. {
  1029. uint8_t old, new;
  1030. old = pci_read_byte(dev, 0x6d);
  1031. new = old | 0x01;
  1032. if (new == old)
  1033. return 0;
  1034. rpci_write_byte(dev, 0x6d, new);
  1035. if (pci_read_byte(dev, 0x6d) != new) {
  1036. msg_pinfo("Setting register 0x6d to 0x%02x on %s failed.\n", new, name);
  1037. return 1;
  1038. }
  1039. return 0;
  1040. }
  1041. static int enable_flash_nvidia_nforce2(struct pci_dev *dev, const char *name)
  1042. {
  1043. rpci_write_byte(dev, 0x92, 0);
  1044. if (enable_flash_nvidia_common(dev, name))
  1045. return ERROR_NONFATAL;
  1046. else
  1047. return 0;
  1048. }
  1049. static int enable_flash_ck804(struct pci_dev *dev, const char *name)
  1050. {
  1051. uint32_t segctrl;
  1052. uint8_t reg, old, new;
  1053. unsigned int err = 0;
  1054. /* 0x8A is special: it is a single byte and only one nibble is touched. */
  1055. reg = 0x8A;
  1056. segctrl = pci_read_byte(dev, reg);
  1057. if ((segctrl & 0x3) != 0x0) {
  1058. if ((segctrl & 0xC) != 0x0) {
  1059. msg_pinfo("Can not unlock existing protection in register 0x%02x.\n", reg);
  1060. err++;
  1061. } else {
  1062. msg_pdbg("Unlocking protection in register 0x%02x... ", reg);
  1063. rpci_write_byte(dev, reg, segctrl & 0xF0);
  1064. segctrl = pci_read_byte(dev, reg);
  1065. if ((segctrl & 0x3) != 0x0) {
  1066. msg_pinfo("Could not unlock protection in register 0x%02x (new value: 0x%x).\n",
  1067. reg, segctrl);
  1068. err++;
  1069. } else
  1070. msg_pdbg("OK\n");
  1071. }
  1072. }
  1073. for (reg = 0x8C; reg <= 0x94; reg += 4) {
  1074. segctrl = pci_read_long(dev, reg);
  1075. if ((segctrl & 0x33333333) == 0x00000000) {
  1076. /* reads and writes are unlocked */
  1077. continue;
  1078. }
  1079. if ((segctrl & 0xCCCCCCCC) != 0x00000000) {
  1080. msg_pinfo("Can not unlock existing protection in register 0x%02x.\n", reg);
  1081. err++;
  1082. continue;
  1083. }
  1084. msg_pdbg("Unlocking protection in register 0x%02x... ", reg);
  1085. rpci_write_long(dev, reg, 0x00000000);
  1086. segctrl = pci_read_long(dev, reg);
  1087. if ((segctrl & 0x33333333) != 0x00000000) {
  1088. msg_pinfo("Could not unlock protection in register 0x%02x (new value: 0x%08x).\n",
  1089. reg, segctrl);
  1090. err++;
  1091. } else
  1092. msg_pdbg("OK\n");
  1093. }
  1094. if (err > 0) {
  1095. msg_pinfo("%d locks could not be disabled, disabling writes (reads may also fail).\n", err);
  1096. programmer_may_write = 0;
  1097. }
  1098. reg = 0x88;
  1099. old = pci_read_byte(dev, reg);
  1100. new = old | 0xC0;
  1101. if (new != old) {
  1102. rpci_write_byte(dev, reg, new);
  1103. if (pci_read_byte(dev, reg) != new) { /* FIXME: share this with other code? */
  1104. msg_pinfo("Setting register 0x%02x to 0x%02x on %s failed.\n", reg, new, name);
  1105. err++;
  1106. }
  1107. }
  1108. if (enable_flash_nvidia_common(dev, name))
  1109. err++;
  1110. if (err > 0)
  1111. return ERROR_NONFATAL;
  1112. else
  1113. return 0;
  1114. }
  1115. static int enable_flash_osb4(struct pci_dev *dev, const char *name)
  1116. {
  1117. uint8_t tmp;
  1118. internal_buses_supported = BUS_PARALLEL;
  1119. tmp = INB(0xc06);
  1120. tmp |= 0x1;
  1121. OUTB(tmp, 0xc06);
  1122. tmp = INB(0xc6f);
  1123. tmp |= 0x40;
  1124. OUTB(tmp, 0xc6f);
  1125. return 0;
  1126. }
  1127. /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
  1128. static int enable_flash_sb400(struct pci_dev *dev, const char *name)
  1129. {
  1130. uint8_t tmp;
  1131. struct pci_dev *smbusdev;
  1132. /* Look for the SMBus device. */
  1133. smbusdev = pci_dev_find(0x1002, 0x4372);
  1134. if (!smbusdev) {
  1135. msg_perr("ERROR: SMBus device not found. Aborting.\n");
  1136. return ERROR_FATAL;
  1137. }
  1138. /* Enable some SMBus stuff. */
  1139. tmp = pci_read_byte(smbusdev, 0x79);
  1140. tmp |= 0x01;
  1141. rpci_write_byte(smbusdev, 0x79, tmp);
  1142. /* Change southbridge. */
  1143. tmp = pci_read_byte(dev, 0x48);
  1144. tmp |= 0x21;
  1145. rpci_write_byte(dev, 0x48, tmp);
  1146. /* Now become a bit silly. */
  1147. tmp = INB(0xc6f);
  1148. OUTB(tmp, 0xeb);
  1149. OUTB(tmp, 0xeb);
  1150. tmp |= 0x40;
  1151. OUTB(tmp, 0xc6f);
  1152. OUTB(tmp, 0xeb);
  1153. OUTB(tmp, 0xeb);
  1154. return 0;
  1155. }
  1156. static int enable_flash_mcp55(struct pci_dev *dev, const char *name)
  1157. {
  1158. uint8_t val;
  1159. uint16_t wordval;
  1160. /* Set the 0-16 MB enable bits. */
  1161. val = pci_read_byte(dev, 0x88);
  1162. val |= 0xff; /* 256K */
  1163. rpci_write_byte(dev, 0x88, val);
  1164. val = pci_read_byte(dev, 0x8c);
  1165. val |= 0xff; /* 1M */
  1166. rpci_write_byte(dev, 0x8c, val);
  1167. wordval = pci_read_word(dev, 0x90);
  1168. wordval |= 0x7fff; /* 16M */
  1169. rpci_write_word(dev, 0x90, wordval);
  1170. if (enable_flash_nvidia_common(dev, name))
  1171. return ERROR_NONFATAL;
  1172. else
  1173. return 0;
  1174. }
  1175. /*
  1176. * The MCP6x/MCP7x code is based on cleanroom reverse engineering.
  1177. * It is assumed that LPC chips need the MCP55 code and SPI chips need the
  1178. * code provided in enable_flash_mcp6x_7x_common.
  1179. */
  1180. static int enable_flash_mcp6x_7x(struct pci_dev *dev, const char *name)
  1181. {
  1182. int ret = 0, want_spi = 0;
  1183. uint8_t val;
  1184. /* dev is the ISA bridge. No idea what the stuff below does. */
  1185. val = pci_read_byte(dev, 0x8a);
  1186. msg_pdbg("ISA/LPC bridge reg 0x8a contents: 0x%02x, bit 6 is %i, bit 5 "
  1187. "is %i\n", val, (val >> 6) & 0x1, (val >> 5) & 0x1);
  1188. switch ((val >> 5) & 0x3) {
  1189. case 0x0:
  1190. ret = enable_flash_mcp55(dev, name);
  1191. internal_buses_supported = BUS_LPC;
  1192. msg_pdbg("Flash bus type is LPC\n");
  1193. break;
  1194. case 0x2:
  1195. want_spi = 1;
  1196. /* SPI is added in mcp6x_spi_init if it works.
  1197. * Do we really want to disable LPC in this case?
  1198. */
  1199. internal_buses_supported = BUS_NONE;
  1200. msg_pdbg("Flash bus type is SPI\n");
  1201. break;
  1202. default:
  1203. /* Should not happen. */
  1204. internal_buses_supported = BUS_NONE;
  1205. msg_pwarn("Flash bus type is unknown (none)\n");
  1206. msg_pinfo("Please send the log files created by \"flashrom -p internal -o logfile\" to \n"
  1207. "flashrom@flashrom.org with \"your board name: flashrom -V\" as the subject to\n"
  1208. "help us finish support for your chipset. Thanks.\n");
  1209. return ERROR_NONFATAL;
  1210. }
  1211. /* Force enable SPI and disable LPC? Not a good idea. */
  1212. #if 0
  1213. val |= (1 << 6);
  1214. val &= ~(1 << 5);
  1215. rpci_write_byte(dev, 0x8a, val);
  1216. #endif
  1217. if (mcp6x_spi_init(want_spi))
  1218. ret = 1;
  1219. return ret;
  1220. }
  1221. static int enable_flash_ht1000(struct pci_dev *dev, const char *name)
  1222. {
  1223. uint8_t val;
  1224. /* Set the 4MB enable bit. */
  1225. val = pci_read_byte(dev, 0x41);
  1226. val |= 0x0e;
  1227. rpci_write_byte(dev, 0x41, val);
  1228. val = pci_read_byte(dev, 0x43);
  1229. val |= (1 << 4);
  1230. rpci_write_byte(dev, 0x43, val);
  1231. return 0;
  1232. }
  1233. /*
  1234. * Usually on the x86 architectures (and on other PC-like platforms like some
  1235. * Alphas or Itanium) the system flash is mapped right below 4G. On the AMD
  1236. * Elan SC520 only a small piece of the system flash is mapped there, but the
  1237. * complete flash is mapped somewhere below 1G. The position can be determined
  1238. * by the BOOTCS PAR register.
  1239. */
  1240. static int get_flashbase_sc520(struct pci_dev *dev, const char *name)
  1241. {
  1242. int i, bootcs_found = 0;
  1243. uint32_t parx = 0;
  1244. void *mmcr;
  1245. /* 1. Map MMCR */
  1246. mmcr = physmap("Elan SC520 MMCR", 0xfffef000, getpagesize());
  1247. if (mmcr == ERROR_PTR)
  1248. return ERROR_FATAL;
  1249. /* 2. Scan PAR0 (0x88) - PAR15 (0xc4) for
  1250. * BOOTCS region (PARx[31:29] = 100b)e
  1251. */
  1252. for (i = 0x88; i <= 0xc4; i += 4) {
  1253. parx = mmio_readl(mmcr + i);
  1254. if ((parx >> 29) == 4) {
  1255. bootcs_found = 1;
  1256. break; /* BOOTCS found */
  1257. }
  1258. }
  1259. /* 3. PARx[25] = 1b --> flashbase[29:16] = PARx[13:0]
  1260. * PARx[25] = 0b --> flashbase[29:12] = PARx[17:0]
  1261. */
  1262. if (bootcs_found) {
  1263. if (parx & (1 << 25)) {
  1264. parx &= (1 << 14) - 1; /* Mask [13:0] */
  1265. flashbase = parx << 16;
  1266. } else {
  1267. parx &= (1 << 18) - 1; /* Mask [17:0] */
  1268. flashbase = parx << 12;
  1269. }
  1270. } else {
  1271. msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. "
  1272. "Assuming flash at 4G.\n");
  1273. }
  1274. /* 4. Clean up */
  1275. physunmap(mmcr, getpagesize());
  1276. return 0;
  1277. }
  1278. #endif
  1279. /* Please keep this list numerically sorted by vendor/device ID. */
  1280. const struct penable chipset_enables[] = {
  1281. #if defined(__i386__) || defined(__x86_64__)
  1282. {0x1002, 0x4377, OK, "ATI", "SB400", enable_flash_sb400},
  1283. {0x1002, 0x438d, OK, "AMD", "SB600", enable_flash_sb600},
  1284. {0x1002, 0x439d, OK, "AMD", "SB7x0/SB8x0/SB9x0", enable_flash_sb600},
  1285. {0x100b, 0x0510, NT, "AMD", "SC1100", enable_flash_sc1100},
  1286. {0x1022, 0x2080, OK, "AMD", "CS5536", enable_flash_cs5536},
  1287. {0x1022, 0x2090, OK, "AMD", "CS5536", enable_flash_cs5536},
  1288. {0x1022, 0x3000, OK, "AMD", "Elan SC520", get_flashbase_sc520},
  1289. {0x1022, 0x7440, OK, "AMD", "AMD-768", enable_flash_amd_768_8111},
  1290. {0x1022, 0x7468, OK, "AMD", "AMD-8111", enable_flash_amd_768_8111},
  1291. {0x1022, 0x780e, OK, "AMD", "FCH", enable_flash_sb600},
  1292. {0x1039, 0x0406, NT, "SiS", "501/5101/5501", enable_flash_sis501},
  1293. {0x1039, 0x0496, NT, "SiS", "85C496+497", enable_flash_sis85c496},
  1294. {0x1039, 0x0530, OK, "SiS", "530", enable_flash_sis530},
  1295. {0x1039, 0x0540, NT, "SiS", "540", enable_flash_sis540},
  1296. {0x1039, 0x0620, NT, "SiS", "620", enable_flash_sis530},
  1297. {0x1039, 0x0630, NT, "SiS", "630", enable_flash_sis540},
  1298. {0x1039, 0x0635, NT, "SiS", "635", enable_flash_sis540},
  1299. {0x1039, 0x0640, NT, "SiS", "640", enable_flash_sis540},
  1300. {0x1039, 0x0645, NT, "SiS", "645", enable_flash_sis540},
  1301. {0x1039, 0x0646, OK, "SiS", "645DX", enable_flash_sis540},
  1302. {0x1039, 0x0648, OK, "SiS", "648", enable_flash_sis540},
  1303. {0x1039, 0x0650, OK, "SiS", "650", enable_flash_sis540},
  1304. {0x1039, 0x0651, OK, "SiS", "651", enable_flash_sis540},
  1305. {0x1039, 0x0655, NT, "SiS", "655", enable_flash_sis540},
  1306. {0x1039, 0x0661, OK, "SiS", "661", enable_flash_sis540},
  1307. {0x1039, 0x0730, OK, "SiS", "730", enable_flash_sis540},
  1308. {0x1039, 0x0733, NT, "SiS", "733", enable_flash_sis540},
  1309. {0x1039, 0x0735, OK, "SiS", "735", enable_flash_sis540},
  1310. {0x1039, 0x0740, NT, "SiS", "740", enable_flash_sis540},
  1311. {0x1039, 0x0741, OK, "SiS", "741", enable_flash_sis540},
  1312. {0x1039, 0x0745, OK, "SiS", "745", enable_flash_sis540},
  1313. {0x1039, 0x0746, NT, "SiS", "746", enable_flash_sis540},
  1314. {0x1039, 0x0748, NT, "SiS", "748", enable_flash_sis540},
  1315. {0x1039, 0x0755, OK, "SiS", "755", enable_flash_sis540},
  1316. {0x1039, 0x5511, NT, "SiS", "5511", enable_flash_sis5511},
  1317. {0x1039, 0x5571, NT, "SiS", "5571", enable_flash_sis530},
  1318. {0x1039, 0x5591, NT, "SiS", "5591/5592", enable_flash_sis530},
  1319. {0x1039, 0x5596, NT, "SiS", "5596", enable_flash_sis5511},
  1320. {0x1039, 0x5597, NT, "SiS", "5597/5598/5581/5120", enable_flash_sis530},
  1321. {0x1039, 0x5600, NT, "SiS", "600", enable_flash_sis530},
  1322. {0x1078, 0x0100, OK, "AMD", "CS5530(A)", enable_flash_cs5530},
  1323. {0x10b9, 0x1533, OK, "ALi", "M1533", enable_flash_ali_m1533},
  1324. {0x10de, 0x0030, OK, "NVIDIA", "nForce4/MCP4", enable_flash_nvidia_nforce2},
  1325. {0x10de, 0x0050, OK, "NVIDIA", "CK804", enable_flash_ck804}, /* LPC */
  1326. {0x10de, 0x0051, OK, "NVIDIA", "CK804", enable_flash_ck804}, /* Pro */
  1327. {0x10de, 0x0060, OK, "NVIDIA", "NForce2", enable_flash_nvidia_nforce2},
  1328. {0x10de, 0x00e0, OK, "NVIDIA", "NForce3", enable_flash_nvidia_nforce2},
  1329. /* Slave, should not be here, to fix known bug for A01. */
  1330. {0x10de, 0x00d3, OK, "NVIDIA", "CK804", enable_flash_ck804},
  1331. {0x10de, 0x0260, OK, "NVIDIA", "MCP51", enable_flash_ck804},
  1332. {0x10de, 0x0261, OK, "NVIDIA", "MCP51", enable_flash_ck804},
  1333. {0x10de, 0x0262, NT, "NVIDIA", "MCP51", enable_flash_ck804},
  1334. {0x10de, 0x0263, NT, "NVIDIA", "MCP51", enable_flash_ck804},
  1335. {0x10de, 0x0360, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* M57SLI*/
  1336. /* 10de:0361 is present in Tyan S2915 OEM systems, but not connected to
  1337. * the flash chip. Instead, 10de:0364 is connected to the flash chip.
  1338. * Until we have PCI device class matching or some fallback mechanism,
  1339. * this is needed to get flashrom working on Tyan S2915 and maybe other
  1340. * dual-MCP55 boards.
  1341. */
  1342. #if 0
  1343. {0x10de, 0x0361, NT, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1344. #endif
  1345. {0x10de, 0x0362, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1346. {0x10de, 0x0363, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1347. {0x10de, 0x0364, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1348. {0x10de, 0x0365, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1349. {0x10de, 0x0366, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* LPC */
  1350. {0x10de, 0x0367, OK, "NVIDIA", "MCP55", enable_flash_mcp55}, /* Pro */
  1351. {0x10de, 0x03e0, OK, "NVIDIA", "MCP61", enable_flash_mcp6x_7x},
  1352. {0x10de, 0x03e1, OK, "NVIDIA", "MCP61", enable_flash_mcp6x_7x},
  1353. {0x10de, 0x03e3, NT, "NVIDIA", "MCP61", enable_flash_mcp6x_7x},
  1354. {0x10de, 0x0440, NT, "NVIDIA", "MCP65", enable_flash_mcp6x_7x},
  1355. {0x10de, 0x0441, NT, "NVIDIA", "MCP65", enable_flash_mcp6x_7x},
  1356. {0x10de, 0x0442, NT, "NVIDIA", "MCP65", enable_flash_mcp6x_7x},
  1357. {0x10de, 0x0443, NT, "NVIDIA", "MCP65", enable_flash_mcp6x_7x},
  1358. {0x10de, 0x0548, OK, "NVIDIA", "MCP67", enable_flash_mcp6x_7x},
  1359. {0x10de, 0x075c, OK, "NVIDIA", "MCP78S", enable_flash_mcp6x_7x},
  1360. {0x10de, 0x075d, OK, "NVIDIA", "MCP78S", enable_flash_mcp6x_7x},
  1361. {0x10de, 0x07d7, OK, "NVIDIA", "MCP73", enable_flash_mcp6x_7x},
  1362. {0x10de, 0x0aac, OK, "NVIDIA", "MCP79", enable_flash_mcp6x_7x},
  1363. {0x10de, 0x0aad, NT, "NVIDIA", "MCP79", enable_flash_mcp6x_7x},
  1364. {0x10de, 0x0aae, NT, "NVIDIA", "MCP79", enable_flash_mcp6x_7x},
  1365. {0x10de, 0x0aaf, NT, "NVIDIA", "MCP79", enable_flash_mcp6x_7x},
  1366. {0x10de, 0x0d80, NT, "NVIDIA", "MCP89", enable_flash_mcp6x_7x},
  1367. /* VIA northbridges */
  1368. {0x1106, 0x0585, NT, "VIA", "VT82C585VPX", via_no_byte_merge},
  1369. {0x1106, 0x0595, NT, "VIA", "VT82C595", via_no_byte_merge},
  1370. {0x1106, 0x0597, NT, "VIA", "VT82C597", via_no_byte_merge},
  1371. {0x1106, 0x0601, NT, "VIA", "VT8601/VT8601A", via_no_byte_merge},
  1372. {0x1106, 0x0691, OK, "VIA", "VT82C69x", via_no_byte_merge},
  1373. {0x1106, 0x8601, NT, "VIA", "VT8601T", via_no_byte_merge},
  1374. /* VIA southbridges */
  1375. {0x1106, 0x0586, OK, "VIA", "VT82C586A/B", enable_flash_vt82c586},
  1376. {0x1106, 0x0596, OK, "VIA", "VT82C596", enable_flash_vt82c596},
  1377. {0x1106, 0x0686, OK, "VIA", "VT82C686A/B", enable_flash_vt82c596},
  1378. {0x1106, 0x3074, OK, "VIA", "VT8233", enable_flash_vt823x},
  1379. {0x1106, 0x3147, OK, "VIA", "VT8233A", enable_flash_vt823x},
  1380. {0x1106, 0x3177, OK, "VIA", "VT8235", enable_flash_vt823x},
  1381. {0x1106, 0x3227, OK, "VIA", "VT8237(R)", enable_flash_vt823x},
  1382. {0x1106, 0x3287, OK, "VIA", "VT8251", enable_flash_vt823x},
  1383. {0x1106, 0x3337, OK, "VIA", "VT8237A", enable_flash_vt823x},
  1384. {0x1106, 0x3372, OK, "VIA", "VT8237S", enable_flash_vt8237s_spi},
  1385. {0x1106, 0x8231, NT, "VIA", "VT8231", enable_flash_vt823x},
  1386. {0x1106, 0x8324, OK, "VIA", "CX700", enable_flash_vt823x},
  1387. {0x1106, 0x8353, NT, "VIA", "VX800/VX820", enable_flash_vt_vx},
  1388. {0x1106, 0x8409, NT, "VIA", "VX855/VX875", enable_flash_vt_vx},
  1389. {0x1106, 0x8410, NT, "VIA", "VX900", enable_flash_vt_vx},
  1390. {0x1166, 0x0200, OK, "Broadcom", "OSB4", enable_flash_osb4},
  1391. {0x1166, 0x0205, OK, "Broadcom", "HT-1000", enable_flash_ht1000},
  1392. {0x17f3, 0x6030, OK, "RDC", "R8610/R3210", enable_flash_rdc_r8610},
  1393. {0x8086, 0x0c60, NT, "Intel", "S12x0", enable_flash_s12x0},
  1394. {0x8086, 0x0f1c, OK, "Intel", "Bay Trail", enable_flash_silvermont},
  1395. {0x8086, 0x0f1d, NT, "Intel", "Bay Trail", enable_flash_silvermont},
  1396. {0x8086, 0x0f1e, NT, "Intel", "Bay Trail", enable_flash_silvermont},
  1397. {0x8086, 0x0f1f, NT, "Intel", "Bay Trail", enable_flash_silvermont},
  1398. {0x8086, 0x122e, OK, "Intel", "PIIX", enable_flash_piix4},
  1399. {0x8086, 0x1234, NT, "Intel", "MPIIX", enable_flash_piix4},
  1400. {0x8086, 0x1c44, DEP, "Intel", "Z68", enable_flash_pch6},
  1401. {0x8086, 0x1c46, DEP, "Intel", "P67", enable_flash_pch6},
  1402. {0x8086, 0x1c47, NT, "Intel", "UM67", enable_flash_pch6},
  1403. {0x8086, 0x1c49, NT, "Intel", "HM65", enable_flash_pch6},
  1404. {0x8086, 0x1c4a, DEP, "Intel", "H67", enable_flash_pch6},
  1405. {0x8086, 0x1c4b, NT, "Intel", "HM67", enable_flash_pch6},
  1406. {0x8086, 0x1c4c, NT, "Intel", "Q65", enable_flash_pch6},
  1407. {0x8086, 0x1c4d, NT, "Intel", "QS67", enable_flash_pch6},
  1408. {0x8086, 0x1c4e, NT, "Intel", "Q67", enable_flash_pch6},
  1409. {0x8086, 0x1c4f, DEP, "Intel", "QM67", enable_flash_pch6},
  1410. {0x8086, 0x1c50, NT, "Intel", "B65", enable_flash_pch6},
  1411. {0x8086, 0x1c52, NT, "Intel", "C202", enable_flash_pch6},
  1412. {0x8086, 0x1c54, DEP, "Intel", "C204", enable_flash_pch6},
  1413. {0x8086, 0x1c56, NT, "Intel", "C206", enable_flash_pch6},
  1414. {0x8086, 0x1c5c, DEP, "Intel", "H61", enable_flash_pch6},
  1415. {0x8086, 0x1d40, DEP, "Intel", "C60x/X79", enable_flash_pch6},
  1416. {0x8086, 0x1d41, DEP, "Intel", "C60x/X79", enable_flash_pch6},
  1417. {0x8086, 0x1e44, DEP, "Intel", "Z77", enable_flash_pch7},
  1418. {0x8086, 0x1e46, NT, "Intel", "Z75", enable_flash_pch7},
  1419. {0x8086, 0x1e47, NT, "Intel", "Q77", enable_flash_pch7},
  1420. {0x8086, 0x1e48, NT, "Intel", "Q75", enable_flash_pch7},
  1421. {0x8086, 0x1e49, DEP, "Intel", "B75", enable_flash_pch7},
  1422. {0x8086, 0x1e4a, DEP, "Intel", "H77", enable_flash_pch7},
  1423. {0x8086, 0x1e53, NT, "Intel", "C216", enable_flash_pch7},
  1424. {0x8086, 0x1e55, DEP, "Intel", "QM77", enable_flash_pch7},
  1425. {0x8086, 0x1e56, NT, "Intel", "QS77", enable_flash_pch7},
  1426. {0x8086, 0x1e57, DEP, "Intel", "HM77", enable_flash_pch7},
  1427. {0x8086, 0x1e58, NT, "Intel", "UM77", enable_flash_pch7},
  1428. {0x8086, 0x1e59, NT, "Intel", "HM76", enable_flash_pch7},
  1429. {0x8086, 0x1e5d, NT, "Intel", "HM75", enable_flash_pch7},
  1430. {0x8086, 0x1e5e, NT, "Intel", "HM70", enable_flash_pch7},
  1431. {0x8086, 0x1e5f, DEP, "Intel", "NM70", enable_flash_pch7},
  1432. {0x8086, 0x1f38, DEP, "Intel", "Avoton/Rangeley", enable_flash_silvermont},
  1433. {0x8086, 0x1f39, NT, "Intel", "Avoton/Rangeley", enable_flash_silvermont},
  1434. {0x8086, 0x1f3a, NT, "Intel", "Avoton/Rangeley", enable_flash_silvermont},
  1435. {0x8086, 0x1f3b, NT, "Intel", "Avoton/Rangeley", enable_flash_silvermont},
  1436. {0x8086, 0x229c, NT, "Intel", "Braswell", enable_flash_silvermont},
  1437. {0x8086, 0x2310, NT, "Intel", "DH89xxCC (Cave Creek)", enable_flash_pch7},
  1438. {0x8086, 0x2390, NT, "Intel", "Coleto Creek", enable_flash_pch7},
  1439. {0x8086, 0x2410, OK, "Intel", "ICH", enable_flash_ich0},
  1440. {0x8086, 0x2420, OK, "Intel", "ICH0", enable_flash_ich0},
  1441. {0x8086, 0x2440, OK, "Intel", "ICH2", enable_flash_ich2345},
  1442. {0x8086, 0x244c, OK, "Intel", "ICH2-M", enable_flash_ich2345},
  1443. {0x8086, 0x2450, NT, "Intel", "C-ICH", enable_flash_ich2345},
  1444. {0x8086, 0x2480, OK, "Intel", "ICH3-S", enable_flash_ich2345},
  1445. {0x8086, 0x248c, OK, "Intel", "ICH3-M", enable_flash_ich2345},
  1446. {0x8086, 0x24c0, OK, "Intel", "ICH4/ICH4-L", enable_flash_ich2345},
  1447. {0x8086, 0x24cc, OK, "Intel", "ICH4-M", enable_flash_ich2345},
  1448. {0x8086, 0x24d0, OK, "Intel", "ICH5/ICH5R", enable_flash_ich2345},
  1449. {0x8086, 0x25a1, OK, "Intel", "6300ESB", enable_flash_ich2345},
  1450. {0x8086, 0x2640, OK, "Intel", "ICH6/ICH6R", enable_flash_ich6},
  1451. {0x8086, 0x2641, OK, "Intel", "ICH6-M", enable_flash_ich6},
  1452. {0x8086, 0x2642, NT, "Intel", "ICH6W/ICH6RW", enable_flash_ich6},
  1453. {0x8086, 0x2670, OK, "Intel", "631xESB/632xESB/3100", enable_flash_ich6},
  1454. {0x8086, 0x27b0, OK, "Intel", "ICH7DH", enable_flash_ich7},
  1455. {0x8086, 0x27b8, OK, "Intel", "ICH7/ICH7R", enable_flash_ich7},
  1456. {0x8086, 0x27b9, OK, "Intel", "ICH7M", enable_flash_ich7},
  1457. {0x8086, 0x27bc, OK, "Intel", "NM10", enable_flash_ich7},
  1458. {0x8086, 0x27bd, OK, "Intel", "ICH7MDH", enable_flash_ich7},
  1459. {0x8086, 0x2810, DEP, "Intel", "ICH8/ICH8R", enable_flash_ich8},
  1460. {0x8086, 0x2811, DEP, "Intel", "ICH8M-E", enable_flash_ich8},
  1461. {0x8086, 0x2812, DEP, "Intel", "ICH8DH", enable_flash_ich8},
  1462. {0x8086, 0x2814, DEP, "Intel", "ICH8DO", enable_flash_ich8},
  1463. {0x8086, 0x2815, DEP, "Intel", "ICH8M", enable_flash_ich8},
  1464. {0x8086, 0x2910, DEP, "Intel", "ICH9 Eng. Sample", enable_flash_ich9},
  1465. {0x8086, 0x2912, DEP, "Intel", "ICH9DH", enable_flash_ich9},
  1466. {0x8086, 0x2914, DEP, "Intel", "ICH9DO", enable_flash_ich9},
  1467. {0x8086, 0x2916, DEP, "Intel", "ICH9R", enable_flash_ich9},
  1468. {0x8086, 0x2917, DEP, "Intel", "ICH9M-E", enable_flash_ich9},
  1469. {0x8086, 0x2918, DEP, "Intel", "ICH9", enable_flash_ich9},
  1470. {0x8086, 0x2919, DEP, "Intel", "ICH9M", enable_flash_ich9},
  1471. {0x8086, 0x3a10, NT, "Intel", "ICH10R Eng. Sample", enable_flash_ich10},
  1472. {0x8086, 0x3a14, DEP, "Intel", "ICH10DO", enable_flash_ich10},
  1473. {0x8086, 0x3a16, DEP, "Intel", "ICH10R", enable_flash_ich10},
  1474. {0x8086, 0x3a18, DEP, "Intel", "ICH10", enable_flash_ich10},
  1475. {0x8086, 0x3a1a, DEP, "Intel", "ICH10D", enable_flash_ich10},
  1476. {0x8086, 0x3a1e, NT, "Intel", "ICH10 Eng. Sample", enable_flash_ich10},
  1477. {0x8086, 0x3b00, NT, "Intel", "3400 Desktop", enable_flash_pch5},
  1478. {0x8086, 0x3b01, NT, "Intel", "3400 Mobile", enable_flash_pch5},
  1479. {0x8086, 0x3b02, NT, "Intel", "P55", enable_flash_pch5},
  1480. {0x8086, 0x3b03, NT, "Intel", "PM55", enable_flash_pch5},
  1481. {0x8086, 0x3b06, DEP, "Intel", "H55", enable_flash_pch5},
  1482. {0x8086, 0x3b07, DEP, "Intel", "QM57", enable_flash_pch5},
  1483. {0x8086, 0x3b08, NT, "Intel", "H57", enable_flash_pch5},
  1484. {0x8086, 0x3b09, NT, "Intel", "HM55", enable_flash_pch5},
  1485. {0x8086, 0x3b0a, NT, "Intel", "Q57", enable_flash_pch5},
  1486. {0x8086, 0x3b0b, NT, "Intel", "HM57", enable_flash_pch5},
  1487. {0x8086, 0x3b0d, NT, "Intel", "3400 Mobile SFF", enable_flash_pch5},
  1488. {0x8086, 0x3b0e, NT, "Intel", "B55", enable_flash_pch5},
  1489. {0x8086, 0x3b0f, DEP, "Intel", "QS57", enable_flash_pch5},
  1490. {0x8086, 0x3b12, NT, "Intel", "3400", enable_flash_pch5},
  1491. {0x8086, 0x3b14, DEP, "Intel", "3420", enable_flash_pch5},
  1492. {0x8086, 0x3b16, NT, "Intel", "3450", enable_flash_pch5},
  1493. {0x8086, 0x3b1e, NT, "Intel", "B55", enable_flash_pch5},
  1494. {0x8086, 0x5031, OK, "Intel", "EP80579", enable_flash_ich7},
  1495. {0x8086, 0x7000, OK, "Intel", "PIIX3", enable_flash_piix4},
  1496. {0x8086, 0x7110, OK, "Intel", "PIIX4/4E/4M", enable_flash_piix4},
  1497. {0x8086, 0x7198, OK, "Intel", "440MX", enable_flash_piix4},
  1498. {0x8086, 0x8119, OK, "Intel", "SCH Poulsbo", enable_flash_poulsbo},
  1499. {0x8086, 0x8186, OK, "Intel", "Atom E6xx(T) (Tunnel Creek)", enable_flash_tunnelcreek},
  1500. {0x8086, 0x8c40, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1501. {0x8086, 0x8c41, NT, "Intel", "Lynx Point Mobile Eng. Sample", enable_flash_pch8},
  1502. {0x8086, 0x8c42, NT, "Intel", "Lynx Point Desktop Eng. Sample",enable_flash_pch8},
  1503. {0x8086, 0x8c43, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1504. {0x8086, 0x8c44, DEP, "Intel", "Z87", enable_flash_pch8},
  1505. {0x8086, 0x8c45, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1506. {0x8086, 0x8c46, NT, "Intel", "Z85", enable_flash_pch8},
  1507. {0x8086, 0x8c47, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1508. {0x8086, 0x8c48, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1509. {0x8086, 0x8c49, NT, "Intel", "HM86", enable_flash_pch8},
  1510. {0x8086, 0x8c4a, DEP, "Intel", "H87", enable_flash_pch8},
  1511. {0x8086, 0x8c4b, DEP, "Intel", "HM87", enable_flash_pch8},
  1512. {0x8086, 0x8c4c, NT, "Intel", "Q85", enable_flash_pch8},
  1513. {0x8086, 0x8c4d, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1514. {0x8086, 0x8c4e, NT, "Intel", "Q87", enable_flash_pch8},
  1515. {0x8086, 0x8c4f, NT, "Intel", "QM87", enable_flash_pch8},
  1516. {0x8086, 0x8c50, DEP, "Intel", "B85", enable_flash_pch8},
  1517. {0x8086, 0x8c51, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1518. {0x8086, 0x8c52, NT, "Intel", "C222", enable_flash_pch8},
  1519. {0x8086, 0x8c53, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1520. {0x8086, 0x8c54, NT, "Intel", "C224", enable_flash_pch8},
  1521. {0x8086, 0x8c55, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1522. {0x8086, 0x8c56, NT, "Intel", "C226", enable_flash_pch8},
  1523. {0x8086, 0x8c57, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1524. {0x8086, 0x8c58, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1525. {0x8086, 0x8c59, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1526. {0x8086, 0x8c5a, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1527. {0x8086, 0x8c5b, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1528. {0x8086, 0x8c5c, NT, "Intel", "H81", enable_flash_pch8},
  1529. {0x8086, 0x8c5d, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1530. {0x8086, 0x8c5e, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1531. {0x8086, 0x8c5f, NT, "Intel", "Lynx Point", enable_flash_pch8},
  1532. {0x8086, 0x8cc1, NT, "Intel", "9 Series", enable_flash_pch9},
  1533. {0x8086, 0x8cc2, NT, "Intel", "9 Series Engineering Sample", enable_flash_pch9},
  1534. {0x8086, 0x8cc3, NT, "Intel", "9 Series", enable_flash_pch9},
  1535. {0x8086, 0x8cc4, NT, "Intel", "Z97", enable_flash_pch9},
  1536. {0x8086, 0x8cc6, NT, "Intel", "H97", enable_flash_pch9},
  1537. {0x8086, 0x8d40, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1538. {0x8086, 0x8d41, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1539. {0x8086, 0x8d42, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1540. {0x8086, 0x8d43, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1541. {0x8086, 0x8d44, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1542. {0x8086, 0x8d45, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1543. {0x8086, 0x8d46, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1544. {0x8086, 0x8d47, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1545. {0x8086, 0x8d48, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1546. {0x8086, 0x8d49, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1547. {0x8086, 0x8d4a, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1548. {0x8086, 0x8d4b, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1549. {0x8086, 0x8d4c, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1550. {0x8086, 0x8d4d, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1551. {0x8086, 0x8d4e, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1552. {0x8086, 0x8d4f, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1553. {0x8086, 0x8d50, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1554. {0x8086, 0x8d51, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1555. {0x8086, 0x8d52, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1556. {0x8086, 0x8d53, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1557. {0x8086, 0x8d54, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1558. {0x8086, 0x8d55, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1559. {0x8086, 0x8d56, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1560. {0x8086, 0x8d57, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1561. {0x8086, 0x8d58, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1562. {0x8086, 0x8d59, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1563. {0x8086, 0x8d5a, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1564. {0x8086, 0x8d5b, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1565. {0x8086, 0x8d5c, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1566. {0x8086, 0x8d5d, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1567. {0x8086, 0x8d5e, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1568. {0x8086, 0x8d5f, NT, "Intel", "C610/X99 (Wellsburg)", enable_flash_pch8_wb},
  1569. {0x8086, 0x9c41, NT, "Intel", "Lynx Point LP Eng. Sample", enable_flash_pch8_lp},
  1570. {0x8086, 0x9c43, NT, "Intel", "Lynx Point LP Premium", enable_flash_pch8_lp},
  1571. {0x8086, 0x9c45, NT, "Intel", "Lynx Point LP Mainstream", enable_flash_pch8_lp},
  1572. {0x8086, 0x9c47, NT, "Intel", "Lynx Point LP Value", enable_flash_pch8_lp},
  1573. {0x8086, 0x9cc1, NT, "Intel", "Haswell U Sample", enable_flash_pch9},
  1574. {0x8086, 0x9cc2, NT, "Intel", "Broadwell U Sample", enable_flash_pch9},
  1575. {0x8086, 0x9cc3, NT, "Intel", "Broadwell U Premium", enable_flash_pch9},
  1576. {0x8086, 0x9cc5, NT, "Intel", "Broadwell U Base", enable_flash_pch9},
  1577. {0x8086, 0x9cc6, NT, "Intel", "Broadwell Y Sample", enable_flash_pch9},
  1578. {0x8086, 0x9cc7, NT, "Intel", "Broadwell Y Premium", enable_flash_pch9},
  1579. {0x8086, 0x9cc9, NT, "Intel", "Broadwell Y Base", enable_flash_pch9},
  1580. {0x8086, 0x9ccb, NT, "Intel", "Broadwell H", enable_flash_pch9},
  1581. {0x8086, 0x9d41, BAD, "Intel", "Sunrise Point (Skylake LP Sample)", NULL},
  1582. {0x8086, 0x9d43, BAD, "Intel", "Sunrise Point (Skylake-U Base)", NULL},
  1583. {0x8086, 0x9d48, BAD, "Intel", "Sunrise Point (Skylake-U Premium)", NULL},
  1584. {0x8086, 0x9d46, BAD, "Intel", "Sunrise Point (Skylake-Y Premium)", NULL},
  1585. #endif
  1586. {0},
  1587. };
  1588. int chipset_flash_enable(void)
  1589. {
  1590. struct pci_dev *dev = NULL;
  1591. int ret = -2; /* Nothing! */
  1592. int i;
  1593. /* Now let's try to find the chipset we have... */
  1594. for (i = 0; chipset_enables[i].vendor_name != NULL; i++) {
  1595. dev = pci_dev_find(chipset_enables[i].vendor_id,
  1596. chipset_enables[i].device_id);
  1597. if (!dev)
  1598. continue;
  1599. if (ret != -2) {
  1600. msg_pwarn("Warning: unexpected second chipset match: "
  1601. "\"%s %s\"\n"
  1602. "ignoring, please report lspci and board URL "
  1603. "to flashrom@flashrom.org\n"
  1604. "with \'CHIPSET: your board name\' in the "
  1605. "subject line.\n",
  1606. chipset_enables[i].vendor_name,
  1607. chipset_enables[i].device_name);
  1608. continue;
  1609. }
  1610. msg_pinfo("Found chipset \"%s %s\"",
  1611. chipset_enables[i].vendor_name,
  1612. chipset_enables[i].device_name);
  1613. msg_pdbg(" with PCI ID %04x:%04x",
  1614. chipset_enables[i].vendor_id,
  1615. chipset_enables[i].device_id);
  1616. msg_pinfo(".\n");
  1617. if (chipset_enables[i].status == BAD) {
  1618. msg_perr("ERROR: This chipset is not supported yet.\n");
  1619. return ERROR_FATAL;
  1620. }
  1621. if (chipset_enables[i].status == NT) {
  1622. msg_pinfo("This chipset is marked as untested. If "
  1623. "you are using an up-to-date version\nof "
  1624. "flashrom *and* were (not) able to "
  1625. "successfully update your firmware with it,\n"
  1626. "then please email a report to "
  1627. "flashrom@flashrom.org including a verbose "
  1628. "(-V) log.\nThank you!\n");
  1629. }
  1630. msg_pinfo("Enabling flash write... ");
  1631. ret = chipset_enables[i].doit(dev, chipset_enables[i].device_name);
  1632. if (ret == NOT_DONE_YET) {
  1633. ret = -2;
  1634. msg_pinfo("OK - searching further chips.\n");
  1635. } else if (ret < 0)
  1636. msg_pinfo("FAILED!\n");
  1637. else if (ret == 0)
  1638. msg_pinfo("OK.\n");
  1639. else if (ret == ERROR_NONFATAL)
  1640. msg_pinfo("PROBLEMS, continuing anyway\n");
  1641. if (ret == ERROR_FATAL) {
  1642. msg_perr("FATAL ERROR!\n");
  1643. return ret;
  1644. }
  1645. }
  1646. return ret;
  1647. }