board_enable.c 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438
  1. /*
  2. * This file is part of the flashrom project.
  3. *
  4. * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de>
  5. * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
  6. * Copyright (C) 2007-2009 Luc Verhaegen <libv@skynet.be>
  7. * Copyright (C) 2007 Carl-Daniel Hailfinger
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /*
  23. * Contains the board specific flash enables.
  24. */
  25. #include <string.h>
  26. #include "flash.h"
  27. #include "programmer.h"
  28. #if defined(__i386__) || defined(__x86_64__)
  29. /*
  30. * Helper functions for many Winbond Super I/Os of the W836xx range.
  31. */
  32. /* Enter extended functions */
  33. void w836xx_ext_enter(uint16_t port)
  34. {
  35. OUTB(0x87, port);
  36. OUTB(0x87, port);
  37. }
  38. /* Leave extended functions */
  39. void w836xx_ext_leave(uint16_t port)
  40. {
  41. OUTB(0xAA, port);
  42. }
  43. /* Generic Super I/O helper functions */
  44. uint8_t sio_read(uint16_t port, uint8_t reg)
  45. {
  46. OUTB(reg, port);
  47. return INB(port + 1);
  48. }
  49. void sio_write(uint16_t port, uint8_t reg, uint8_t data)
  50. {
  51. OUTB(reg, port);
  52. OUTB(data, port + 1);
  53. }
  54. void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask)
  55. {
  56. uint8_t tmp;
  57. OUTB(reg, port);
  58. tmp = INB(port + 1) & ~mask;
  59. OUTB(tmp | (data & mask), port + 1);
  60. }
  61. /* Not used yet. */
  62. #if 0
  63. static int enable_flash_decode_superio(void)
  64. {
  65. int ret;
  66. uint8_t tmp;
  67. switch (superio.vendor) {
  68. case SUPERIO_VENDOR_NONE:
  69. ret = -1;
  70. break;
  71. case SUPERIO_VENDOR_ITE:
  72. enter_conf_mode_ite(superio.port);
  73. /* Enable flash mapping. Works for most old ITE style Super I/O. */
  74. tmp = sio_read(superio.port, 0x24);
  75. tmp |= 0xfc;
  76. sio_write(superio.port, 0x24, tmp);
  77. exit_conf_mode_ite(superio.port);
  78. ret = 0;
  79. break;
  80. default:
  81. msg_pdbg("Unhandled Super I/O type!\n");
  82. ret = -1;
  83. break;
  84. }
  85. return ret;
  86. }
  87. #endif
  88. /*
  89. * SMSC FDC37B787: Raise GPIO50
  90. */
  91. static int fdc37b787_gpio50_raise(uint16_t port)
  92. {
  93. uint8_t id, val;
  94. OUTB(0x55, port); /* enter conf mode */
  95. id = sio_read(port, 0x20);
  96. if (id != 0x44) {
  97. msg_perr("\nERROR: FDC37B787: Wrong ID 0x%02X.\n", id);
  98. OUTB(0xAA, port); /* leave conf mode */
  99. return -1;
  100. }
  101. sio_write(port, 0x07, 0x08); /* Select Aux I/O subdevice */
  102. val = sio_read(port, 0xC8); /* GP50 */
  103. if ((val & 0x1B) != 0x10) /* output, no invert, GPIO */
  104. {
  105. msg_perr("\nERROR: GPIO50 mode 0x%02X unexpected.\n", val);
  106. OUTB(0xAA, port);
  107. return -1;
  108. }
  109. sio_mask(port, 0xF9, 0x01, 0x01);
  110. OUTB(0xAA, port); /* Leave conf mode */
  111. return 0;
  112. }
  113. /*
  114. * Suited for:
  115. * - Nokia IP530: Intel 440BX + PIIX4 + FDC37B787
  116. */
  117. static int fdc37b787_gpio50_raise_3f0(void)
  118. {
  119. return fdc37b787_gpio50_raise(0x3f0);
  120. }
  121. struct winbond_mux {
  122. uint8_t reg; /* 0 if the corresponding pin is not muxed */
  123. uint8_t data; /* reg/data/mask may be directly ... */
  124. uint8_t mask; /* ... passed to sio_mask */
  125. };
  126. struct winbond_port {
  127. const struct winbond_mux *mux; /* NULL or pointer to mux info for the 8 bits */
  128. uint8_t ldn; /* LDN this GPIO register is located in */
  129. uint8_t enable_bit; /* bit in 0x30 of that LDN to enable
  130. the GPIO port */
  131. uint8_t base; /* base register in that LDN for the port */
  132. };
  133. struct winbond_chip {
  134. uint8_t device_id; /* reg 0x20 of the expected w83626x */
  135. uint8_t gpio_port_count;
  136. const struct winbond_port *port;
  137. };
  138. #define UNIMPLEMENTED_PORT {NULL, 0, 0, 0}
  139. enum winbond_id {
  140. WINBOND_W83627HF_ID = 0x52,
  141. WINBOND_W83627EHF_ID = 0x88,
  142. WINBOND_W83627THF_ID = 0x82,
  143. };
  144. static const struct winbond_mux w83627hf_port2_mux[8] = {
  145. {0x2A, 0x01, 0x01}, /* or MIDI */
  146. {0x2B, 0x80, 0x80}, /* or SPI */
  147. {0x2B, 0x40, 0x40}, /* or SPI */
  148. {0x2B, 0x20, 0x20}, /* or power LED */
  149. {0x2B, 0x10, 0x10}, /* or watchdog */
  150. {0x2B, 0x08, 0x08}, /* or infra red */
  151. {0x2B, 0x04, 0x04}, /* or infra red */
  152. {0x2B, 0x03, 0x03} /* or IRQ1 input */
  153. };
  154. static const struct winbond_port w83627hf[3] = {
  155. UNIMPLEMENTED_PORT,
  156. {w83627hf_port2_mux, 0x08, 0, 0xF0},
  157. UNIMPLEMENTED_PORT,
  158. };
  159. static const struct winbond_mux w83627ehf_port2_mux[8] = {
  160. {0x29, 0x06, 0x02}, /* or MIDI */
  161. {0x29, 0x06, 0x02},
  162. {0x24, 0x02, 0x00}, /* or SPI ROM interface */
  163. {0x24, 0x02, 0x00},
  164. {0x2A, 0x01, 0x01}, /* or keyboard/mouse interface */
  165. {0x2A, 0x01, 0x01},
  166. {0x2A, 0x01, 0x01},
  167. {0x2A, 0x01, 0x01},
  168. };
  169. static const struct winbond_port w83627ehf[6] = {
  170. UNIMPLEMENTED_PORT,
  171. {w83627ehf_port2_mux, 0x09, 0, 0xE3},
  172. UNIMPLEMENTED_PORT,
  173. UNIMPLEMENTED_PORT,
  174. UNIMPLEMENTED_PORT,
  175. UNIMPLEMENTED_PORT,
  176. };
  177. static const struct winbond_mux w83627thf_port4_mux[8] = {
  178. {0x2D, 0x01, 0x01}, /* or watchdog or VID level strap */
  179. {0x2D, 0x02, 0x02}, /* or resume reset */
  180. {0x2D, 0x04, 0x04}, /* or S3 input */
  181. {0x2D, 0x08, 0x08}, /* or PSON# */
  182. {0x2D, 0x10, 0x10}, /* or PWROK */
  183. {0x2D, 0x20, 0x20}, /* or suspend LED */
  184. {0x2D, 0x40, 0x40}, /* or panel switch input */
  185. {0x2D, 0x80, 0x80}, /* or panel switch output */
  186. };
  187. static const struct winbond_port w83627thf[5] = {
  188. UNIMPLEMENTED_PORT, /* GPIO1 */
  189. UNIMPLEMENTED_PORT, /* GPIO2 */
  190. UNIMPLEMENTED_PORT, /* GPIO3 */
  191. {w83627thf_port4_mux, 0x09, 1, 0xF4},
  192. UNIMPLEMENTED_PORT, /* GPIO5 */
  193. };
  194. static const struct winbond_chip winbond_chips[] = {
  195. {WINBOND_W83627HF_ID, ARRAY_SIZE(w83627hf), w83627hf },
  196. {WINBOND_W83627EHF_ID, ARRAY_SIZE(w83627ehf), w83627ehf},
  197. {WINBOND_W83627THF_ID, ARRAY_SIZE(w83627thf), w83627thf},
  198. };
  199. /*
  200. * Detects which Winbond Super I/O is responding at the given base address,
  201. * but takes no effort to make sure the chip is really a Winbond Super I/O.
  202. */
  203. static const struct winbond_chip *winbond_superio_detect(uint16_t base)
  204. {
  205. uint8_t chipid;
  206. const struct winbond_chip *chip = NULL;
  207. int i;
  208. w836xx_ext_enter(base);
  209. chipid = sio_read(base, 0x20);
  210. for (i = 0; i < ARRAY_SIZE(winbond_chips); i++) {
  211. if (winbond_chips[i].device_id == chipid) {
  212. chip = &winbond_chips[i];
  213. break;
  214. }
  215. }
  216. w836xx_ext_leave(base);
  217. return chip;
  218. }
  219. /*
  220. * The chipid parameter goes away as soon as we have Super I/O matching in the
  221. * board enable table. The call to winbond_superio_detect() goes away as
  222. * soon as we have generic Super I/O detection code.
  223. */
  224. static int winbond_gpio_set(uint16_t base, enum winbond_id chipid,
  225. int pin, int raise)
  226. {
  227. const struct winbond_chip *chip = NULL;
  228. const struct winbond_port *gpio;
  229. int port = pin / 10;
  230. int bit = pin % 10;
  231. chip = winbond_superio_detect(base);
  232. if (!chip) {
  233. msg_perr("\nERROR: No supported Winbond Super I/O found\n");
  234. return -1;
  235. }
  236. if (chip->device_id != chipid) {
  237. msg_perr("\nERROR: Found Winbond chip with ID 0x%x, "
  238. "expected %x\n", chip->device_id, chipid);
  239. return -1;
  240. }
  241. if (bit >= 8 || port == 0 || port > chip->gpio_port_count) {
  242. msg_perr("\nERROR: winbond_gpio_set: Invalid GPIO number %d\n",
  243. pin);
  244. return -1;
  245. }
  246. gpio = &chip->port[port - 1];
  247. if (gpio->ldn == 0) {
  248. msg_perr("\nERROR: GPIO%d is not supported yet on this"
  249. " winbond chip\n", port);
  250. return -1;
  251. }
  252. w836xx_ext_enter(base);
  253. /* Select logical device. */
  254. sio_write(base, 0x07, gpio->ldn);
  255. /* Activate logical device. */
  256. sio_mask(base, 0x30, 1 << gpio->enable_bit, 1 << gpio->enable_bit);
  257. /* Select GPIO function of that pin. */
  258. if (gpio->mux && gpio->mux[bit].reg)
  259. sio_mask(base, gpio->mux[bit].reg,
  260. gpio->mux[bit].data, gpio->mux[bit].mask);
  261. sio_mask(base, gpio->base + 0, 0, 1 << bit); /* Make pin output */
  262. sio_mask(base, gpio->base + 2, 0, 1 << bit); /* Clear inversion */
  263. sio_mask(base, gpio->base + 1, raise << bit, 1 << bit);
  264. w836xx_ext_leave(base);
  265. return 0;
  266. }
  267. /*
  268. * Winbond W83627HF: Raise GPIO24.
  269. *
  270. * Suited for:
  271. * - Agami Aruma
  272. * - IWILL DK8-HTX
  273. */
  274. static int w83627hf_gpio24_raise_2e(void)
  275. {
  276. return winbond_gpio_set(0x2e, WINBOND_W83627HF_ID, 24, 1);
  277. }
  278. /*
  279. * Winbond W83627HF: Raise GPIO25.
  280. *
  281. * Suited for:
  282. * - MSI MS-6577
  283. */
  284. static int w83627hf_gpio25_raise_2e(void)
  285. {
  286. return winbond_gpio_set(0x2e, WINBOND_W83627HF_ID, 25, 1);
  287. }
  288. /*
  289. * Winbond W83627EHF: Raise GPIO22.
  290. *
  291. * Suited for:
  292. * - ASUS A8N-VM CSM: AMD Socket 939 + GeForce 6150 (C51) + MCP51
  293. */
  294. static int w83627ehf_gpio22_raise_2e(void)
  295. {
  296. return winbond_gpio_set(0x2e, WINBOND_W83627EHF_ID, 22, 1);
  297. }
  298. /*
  299. * Winbond W83627THF: Raise GPIO 44.
  300. *
  301. * Suited for:
  302. * - MSI K8T Neo2-F
  303. */
  304. static int w83627thf_gpio44_raise_2e(void)
  305. {
  306. return winbond_gpio_set(0x2e, WINBOND_W83627THF_ID, 44, 1);
  307. }
  308. /*
  309. * Winbond W83627THF: Raise GPIO 44.
  310. *
  311. * Suited for:
  312. * - MSI K8N Neo3
  313. */
  314. static int w83627thf_gpio44_raise_4e(void)
  315. {
  316. return winbond_gpio_set(0x4e, WINBOND_W83627THF_ID, 44, 1);
  317. }
  318. /*
  319. * Enable MEMW# and set ROM size to max.
  320. * Supported chips: W83L517D, W83697HF/F/HG, W83697SF/UF/UG
  321. */
  322. static void w836xx_memw_enable(uint16_t port)
  323. {
  324. w836xx_ext_enter(port);
  325. if (!(sio_read(port, 0x24) & 0x02)) { /* Flash ROM enabled? */
  326. /* Enable MEMW# and set ROM size select to max. (4M). */
  327. sio_mask(port, 0x24, 0x28, 0x28);
  328. }
  329. w836xx_ext_leave(port);
  330. }
  331. /*
  332. * Suited for:
  333. * - EPoX EP-8K5A2: VIA KT333 + VT8235
  334. * - Albatron PM266A Pro: VIA P4M266A + VT8235
  335. * - Shuttle AK31 (all versions): VIA KT266 + VT8233
  336. * - ASUS A7V8X-MX SE and A7V400-MX: AMD K7 + VIA KM400A + VT8235
  337. * - Tyan S2498 (Tomcat K7M): AMD Geode NX + VIA KM400 + VT8237
  338. * - MSI KM4M-V and KM4AM-V: VIA KM400/KM400A + VT8237
  339. * - MSI MS-6561 (745 Ultra): SiS 745 + W83697HF
  340. * - MSI MS-6787 (P4MAM-V/P4MAM-L): VIA P4M266 + VT8235
  341. * - ASRock K7S41: SiS 741 + SiS 963 + W83697HF
  342. * - ASRock K7S41GX: SiS 741GX + SiS 963L + W83697HF
  343. */
  344. static int w836xx_memw_enable_2e(void)
  345. {
  346. w836xx_memw_enable(0x2E);
  347. return 0;
  348. }
  349. /*
  350. * Suited for:
  351. * - Termtek TK-3370 (rev. 2.5b)
  352. */
  353. static int w836xx_memw_enable_4e(void)
  354. {
  355. w836xx_memw_enable(0x4E);
  356. return 0;
  357. }
  358. /*
  359. * Suited for all boards with ITE IT8705F.
  360. * The SIS950 Super I/O probably requires a similar flash write enable.
  361. */
  362. int it8705f_write_enable(uint8_t port)
  363. {
  364. uint8_t tmp;
  365. int ret = 0;
  366. enter_conf_mode_ite(port);
  367. tmp = sio_read(port, 0x24);
  368. /* Check if at least one flash segment is enabled. */
  369. if (tmp & 0xf0) {
  370. /* The IT8705F will respond to LPC cycles and translate them. */
  371. internal_buses_supported = BUS_PARALLEL;
  372. /* Flash ROM I/F Writes Enable */
  373. tmp |= 0x04;
  374. msg_pdbg("Enabling IT8705F flash ROM interface write.\n");
  375. if (tmp & 0x02) {
  376. /* The data sheet contradicts itself about max size. */
  377. max_rom_decode.parallel = 1024 * 1024;
  378. msg_pinfo("IT8705F with very unusual settings. Please "
  379. "send the output of \"flashrom -V\" to \n"
  380. "flashrom@flashrom.org with "
  381. "IT8705: your board name: flashrom -V\n"
  382. "as the subject to help us finish "
  383. "support for your Super I/O. Thanks.\n");
  384. ret = 1;
  385. } else if (tmp & 0x08) {
  386. max_rom_decode.parallel = 512 * 1024;
  387. } else {
  388. max_rom_decode.parallel = 256 * 1024;
  389. }
  390. /* Safety checks. The data sheet is unclear here: Segments 1+3
  391. * overlap, no segment seems to cover top - 1MB to top - 512kB.
  392. * We assume that certain combinations make no sense.
  393. */
  394. if (((tmp & 0x02) && !(tmp & 0x08)) || /* 1 MB en, 512 kB dis */
  395. (!(tmp & 0x10)) || /* 128 kB dis */
  396. (!(tmp & 0x40))) { /* 256/512 kB dis */
  397. msg_perr("Inconsistent IT8705F decode size!\n");
  398. ret = 1;
  399. }
  400. if (sio_read(port, 0x25) != 0) {
  401. msg_perr("IT8705F flash data pins disabled!\n");
  402. ret = 1;
  403. }
  404. if (sio_read(port, 0x26) != 0) {
  405. msg_perr("IT8705F flash address pins 0-7 disabled!\n");
  406. ret = 1;
  407. }
  408. if (sio_read(port, 0x27) != 0) {
  409. msg_perr("IT8705F flash address pins 8-15 disabled!\n");
  410. ret = 1;
  411. }
  412. if ((sio_read(port, 0x29) & 0x10) != 0) {
  413. msg_perr("IT8705F flash write enable pin disabled!\n");
  414. ret = 1;
  415. }
  416. if ((sio_read(port, 0x29) & 0x08) != 0) {
  417. msg_perr("IT8705F flash chip select pin disabled!\n");
  418. ret = 1;
  419. }
  420. if ((sio_read(port, 0x29) & 0x04) != 0) {
  421. msg_perr("IT8705F flash read strobe pin disabled!\n");
  422. ret = 1;
  423. }
  424. if ((sio_read(port, 0x29) & 0x03) != 0) {
  425. msg_perr("IT8705F flash address pins 16-17 disabled!\n");
  426. /* Not really an error if you use flash chips smaller
  427. * than 256 kByte, but such a configuration is unlikely.
  428. */
  429. ret = 1;
  430. }
  431. msg_pdbg("Maximum IT8705F parallel flash decode size is %u.\n",
  432. max_rom_decode.parallel);
  433. if (ret) {
  434. msg_pinfo("Not enabling IT8705F flash write.\n");
  435. } else {
  436. sio_write(port, 0x24, tmp);
  437. }
  438. } else {
  439. msg_pdbg("No IT8705F flash segment enabled.\n");
  440. ret = 1;
  441. }
  442. exit_conf_mode_ite(port);
  443. return ret;
  444. }
  445. /*
  446. * The ITE IT8707F is a custom chip made by ITE exclusively for ASUS.
  447. * It uses the Winbond command sequence to enter extended configuration
  448. * mode and the ITE sequence to exit.
  449. *
  450. * Registers seems similar to the ones on ITE IT8710F.
  451. */
  452. static int it8707f_write_enable(uint8_t port)
  453. {
  454. uint8_t tmp;
  455. w836xx_ext_enter(port);
  456. /* Set bit 3 (GLB_REG_WE) of reg 0x23: Makes reg 0x24-0x2A rw */
  457. tmp = sio_read(port, 0x23);
  458. tmp |= (1 << 3);
  459. sio_write(port, 0x23, tmp);
  460. /* Set bit 2 (FLASH_WE) and bit 3 (FLASH_IF_EN) of reg 0x24 */
  461. tmp = sio_read(port, 0x24);
  462. tmp |= (1 << 2) | (1 << 3);
  463. sio_write(port, 0x24, tmp);
  464. /* Clear bit 3 (GLB_REG_WE) of reg 0x23: Makes reg 0x24-0x2A ro */
  465. tmp = sio_read(port, 0x23);
  466. tmp &= ~(1 << 3);
  467. sio_write(port, 0x23, tmp);
  468. exit_conf_mode_ite(port);
  469. return 0;
  470. }
  471. /*
  472. * Suited for:
  473. * - ASUS P4SC-E: SiS 651 + 962 + ITE IT8707F
  474. */
  475. static int it8707f_write_enable_2e(void)
  476. {
  477. return it8707f_write_enable(0x2e);
  478. }
  479. #define PC87360_ID 0xE1
  480. #define PC87364_ID 0xE4
  481. static int pc8736x_gpio_set(uint8_t chipid, uint8_t gpio, int raise)
  482. {
  483. static const int bankbase[] = {0, 4, 8, 10, 12};
  484. int gpio_bank = gpio / 8;
  485. int gpio_pin = gpio % 8;
  486. uint16_t baseport;
  487. uint8_t id, val;
  488. if (gpio_bank > 4) {
  489. msg_perr("PC8736x: Invalid GPIO %d\n", gpio);
  490. return -1;
  491. }
  492. id = sio_read(0x2E, 0x20);
  493. if (id != chipid) {
  494. msg_perr("PC8736x: unexpected ID %02x (expected %02x)\n",
  495. id, chipid);
  496. return -1;
  497. }
  498. sio_write(0x2E, 0x07, 0x07); /* Select GPIO device. */
  499. baseport = (sio_read(0x2E, 0x60) << 8) | sio_read(0x2E, 0x61);
  500. if ((baseport & 0xFFF0) == 0xFFF0 || baseport == 0) {
  501. msg_perr("PC87360: invalid GPIO base address %04x\n",
  502. baseport);
  503. return -1;
  504. }
  505. sio_mask (0x2E, 0x30, 0x01, 0x01); /* Enable logical device. */
  506. sio_write(0x2E, 0xF0, gpio_bank * 16 + gpio_pin);
  507. sio_mask (0x2E, 0xF1, 0x01, 0x01); /* Make pin output. */
  508. val = INB(baseport + bankbase[gpio_bank]);
  509. if (raise)
  510. val |= 1 << gpio_pin;
  511. else
  512. val &= ~(1 << gpio_pin);
  513. OUTB(val, baseport + bankbase[gpio_bank]);
  514. return 0;
  515. }
  516. /*
  517. * VIA VT823x: Set one of the GPIO pins.
  518. */
  519. static int via_vt823x_gpio_set(uint8_t gpio, int raise)
  520. {
  521. struct pci_dev *dev;
  522. uint16_t base;
  523. uint8_t val, bit, offset;
  524. dev = pci_dev_find_vendorclass(0x1106, 0x0601);
  525. switch (dev->device_id) {
  526. case 0x3177: /* VT8235 */
  527. case 0x3227: /* VT8237R */
  528. case 0x3337: /* VT8237A */
  529. break;
  530. default:
  531. msg_perr("\nERROR: VT823x ISA bridge not found.\n");
  532. return -1;
  533. }
  534. if ((gpio >= 12) && (gpio <= 15)) {
  535. /* GPIO12-15 -> output */
  536. val = pci_read_byte(dev, 0xE4);
  537. val |= 0x10;
  538. pci_write_byte(dev, 0xE4, val);
  539. } else if (gpio == 9) {
  540. /* GPIO9 -> Output */
  541. val = pci_read_byte(dev, 0xE4);
  542. val |= 0x20;
  543. pci_write_byte(dev, 0xE4, val);
  544. } else if (gpio == 5) {
  545. val = pci_read_byte(dev, 0xE4);
  546. val |= 0x01;
  547. pci_write_byte(dev, 0xE4, val);
  548. } else {
  549. msg_perr("\nERROR: "
  550. "VT823x GPIO%02d is not implemented.\n", gpio);
  551. return -1;
  552. }
  553. /* We need the I/O Base Address for this board's flash enable. */
  554. base = pci_read_word(dev, 0x88) & 0xff80;
  555. offset = 0x4C + gpio / 8;
  556. bit = 0x01 << (gpio % 8);
  557. val = INB(base + offset);
  558. if (raise)
  559. val |= bit;
  560. else
  561. val &= ~bit;
  562. OUTB(val, base + offset);
  563. return 0;
  564. }
  565. /*
  566. * Suited for:
  567. * - ASUS M2V-MX: VIA K8M890 + VT8237A + IT8716F
  568. */
  569. static int via_vt823x_gpio5_raise(void)
  570. {
  571. /* On M2V-MX: GPO5 is connected to WP# and TBL#. */
  572. return via_vt823x_gpio_set(5, 1);
  573. }
  574. /*
  575. * Suited for:
  576. * - VIA EPIA EK & N & NL
  577. */
  578. static int via_vt823x_gpio9_raise(void)
  579. {
  580. return via_vt823x_gpio_set(9, 1);
  581. }
  582. /*
  583. * Suited for:
  584. * - VIA EPIA M and MII (and maybe other CLE266 based EPIAs)
  585. *
  586. * We don't need to do this for EPIA M when using coreboot, GPIO15 is never
  587. * lowered there.
  588. */
  589. static int via_vt823x_gpio15_raise(void)
  590. {
  591. return via_vt823x_gpio_set(15, 1);
  592. }
  593. /*
  594. * Winbond W83697HF Super I/O + VIA VT8235 southbridge
  595. *
  596. * Suited for:
  597. * - MSI KT4V and KT4V-L: AMD K7 + VIA KT400 + VT8235
  598. * - MSI KT4 Ultra: AMD K7 + VIA KT400 + VT8235
  599. */
  600. static int board_msi_kt4v(void)
  601. {
  602. int ret;
  603. ret = via_vt823x_gpio_set(12, 1);
  604. w836xx_memw_enable(0x2E);
  605. return ret;
  606. }
  607. /*
  608. * Suited for:
  609. * - ASUS P5A
  610. *
  611. * This is rather nasty code, but there's no way to do this cleanly.
  612. * We're basically talking to some unknown device on SMBus, my guess
  613. * is that it is the Winbond W83781D that lives near the DIP BIOS.
  614. */
  615. static int board_asus_p5a(void)
  616. {
  617. uint8_t tmp;
  618. int i;
  619. #define ASUSP5A_LOOP 5000
  620. OUTB(0x00, 0xE807);
  621. OUTB(0xEF, 0xE803);
  622. OUTB(0xFF, 0xE800);
  623. for (i = 0; i < ASUSP5A_LOOP; i++) {
  624. OUTB(0xE1, 0xFF);
  625. if (INB(0xE800) & 0x04)
  626. break;
  627. }
  628. if (i == ASUSP5A_LOOP) {
  629. msg_perr("Unable to contact device.\n");
  630. return -1;
  631. }
  632. OUTB(0x20, 0xE801);
  633. OUTB(0x20, 0xE1);
  634. OUTB(0xFF, 0xE802);
  635. for (i = 0; i < ASUSP5A_LOOP; i++) {
  636. tmp = INB(0xE800);
  637. if (tmp & 0x70)
  638. break;
  639. }
  640. if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) {
  641. msg_perr("Failed to read device.\n");
  642. return -1;
  643. }
  644. tmp = INB(0xE804);
  645. tmp &= ~0x02;
  646. OUTB(0x00, 0xE807);
  647. OUTB(0xEE, 0xE803);
  648. OUTB(tmp, 0xE804);
  649. OUTB(0xFF, 0xE800);
  650. OUTB(0xE1, 0xFF);
  651. OUTB(0x20, 0xE801);
  652. OUTB(0x20, 0xE1);
  653. OUTB(0xFF, 0xE802);
  654. for (i = 0; i < ASUSP5A_LOOP; i++) {
  655. tmp = INB(0xE800);
  656. if (tmp & 0x70)
  657. break;
  658. }
  659. if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) {
  660. msg_perr("Failed to write to device.\n");
  661. return -1;
  662. }
  663. return 0;
  664. }
  665. /*
  666. * Set GPIO lines in the Broadcom HT-1000 southbridge.
  667. *
  668. * It's not a Super I/O but it uses the same index/data port method.
  669. */
  670. static int board_hp_dl145_g3_enable(void)
  671. {
  672. /* GPIO 0 reg from PM regs */
  673. /* Set GPIO 2 and 5 high, connected to flash WP# and TBL# pins. */
  674. sio_mask(0xcd6, 0x44, 0x24, 0x24);
  675. return 0;
  676. }
  677. /*
  678. * Set GPIO lines in the Broadcom HT-1000 southbridge.
  679. *
  680. * It's not a Super I/O but it uses the same index/data port method.
  681. */
  682. static int board_hp_dl165_g6_enable(void)
  683. {
  684. /* Variant of DL145, with slightly different pin placement. */
  685. sio_mask(0xcd6, 0x44, 0x80, 0x80); /* TBL# */
  686. sio_mask(0xcd6, 0x46, 0x04, 0x04); /* WP# */
  687. return 0;
  688. }
  689. static int board_ibm_x3455(void)
  690. {
  691. /* Raise GPIO13. */
  692. sio_mask(0xcd6, 0x45, 0x20, 0x20);
  693. return 0;
  694. }
  695. /*
  696. * Suited for:
  697. * - Shuttle FN25 (SN25P): AMD S939 + NVIDIA CK804 (nForce4)
  698. */
  699. static int board_shuttle_fn25(void)
  700. {
  701. struct pci_dev *dev;
  702. dev = pci_dev_find(0x10DE, 0x0050); /* NVIDIA CK804 ISA bridge. */
  703. if (!dev) {
  704. msg_perr("\nERROR: NVIDIA nForce4 ISA bridge not found.\n");
  705. return -1;
  706. }
  707. /* One of those bits seems to be connected to TBL#, but -ENOINFO. */
  708. pci_write_byte(dev, 0x92, 0);
  709. return 0;
  710. }
  711. /*
  712. * Suited for:
  713. * - Elitegroup GeForce6100SM-M: NVIDIA MCP61 + ITE IT8726F
  714. */
  715. static int board_ecs_geforce6100sm_m(void)
  716. {
  717. struct pci_dev *dev;
  718. uint32_t tmp;
  719. dev = pci_dev_find(0x10DE, 0x03EB); /* NVIDIA MCP61 SMBus. */
  720. if (!dev) {
  721. msg_perr("\nERROR: NVIDIA MCP61 SMBus not found.\n");
  722. return -1;
  723. }
  724. tmp = pci_read_byte(dev, 0xE0);
  725. tmp &= ~(1 << 3);
  726. pci_write_byte(dev, 0xE0, tmp);
  727. return 0;
  728. }
  729. /*
  730. * Very similar to AMD 8111 IO Hub.
  731. */
  732. static int nvidia_mcp_gpio_set(int gpio, int raise)
  733. {
  734. struct pci_dev *dev;
  735. uint16_t base, devclass;
  736. uint8_t tmp;
  737. if ((gpio < 0) || (gpio >= 0x40)) {
  738. msg_perr("\nERROR: unsupported GPIO: %d.\n", gpio);
  739. return -1;
  740. }
  741. /* Check for the ISA bridge first. */
  742. dev = pci_dev_find_vendorclass(0x10DE, 0x0601);
  743. switch (dev->device_id) {
  744. case 0x0030: /* CK804 */
  745. case 0x0050: /* MCP04 */
  746. case 0x0060: /* MCP2 */
  747. case 0x00E0: /* CK8 */
  748. break;
  749. case 0x0260: /* MCP51 */
  750. case 0x0261: /* MCP51 */
  751. case 0x0364: /* MCP55 */
  752. /* find SMBus controller on *this* southbridge */
  753. /* The infamous Tyan S2915-E has two south bridges; they are
  754. easily told apart from each other by the class of the
  755. LPC bridge, but have the same SMBus bridge IDs */
  756. if (dev->func != 0) {
  757. msg_perr("MCP LPC bridge at unexpected function"
  758. " number %d\n", dev->func);
  759. return -1;
  760. }
  761. #if PCI_LIB_VERSION >= 0x020200
  762. dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
  763. #else
  764. /* pciutils/libpci before version 2.2 is too old to support
  765. * PCI domains. Such old machines usually don't have domains
  766. * besides domain 0, so this is not a problem.
  767. */
  768. dev = pci_get_dev(pacc, dev->bus, dev->dev, 1);
  769. #endif
  770. if (!dev) {
  771. msg_perr("MCP SMBus controller could not be found\n");
  772. return -1;
  773. }
  774. devclass = pci_read_word(dev, PCI_CLASS_DEVICE);
  775. if (devclass != 0x0C05) {
  776. msg_perr("Unexpected device class %04x for SMBus"
  777. " controller\n", devclass);
  778. return -1;
  779. }
  780. break;
  781. default:
  782. msg_perr("\nERROR: no NVIDIA LPC/SMBus controller found.\n");
  783. return -1;
  784. }
  785. base = pci_read_long(dev, 0x64) & 0x0000FF00; /* System control area */
  786. base += 0xC0;
  787. tmp = INB(base + gpio);
  788. tmp &= ~0x0F; /* null lower nibble */
  789. tmp |= 0x04; /* gpio -> output. */
  790. if (raise)
  791. tmp |= 0x01;
  792. OUTB(tmp, base + gpio);
  793. return 0;
  794. }
  795. /*
  796. * Suited for:
  797. * - ASUS A8M2N-LA (HP OEM "NodusM3-GL8E"): NVIDIA MCP51
  798. * - ASUS A8N-LA (HP OEM "Nagami-GL8E"): NVIDIA MCP51
  799. * - ASUS M2NBP-VM CSM: NVIDIA MCP51
  800. */
  801. static int nvidia_mcp_gpio0_raise(void)
  802. {
  803. return nvidia_mcp_gpio_set(0x00, 1);
  804. }
  805. /*
  806. * Suited for:
  807. * - abit KN8 Ultra: NVIDIA CK804
  808. */
  809. static int nvidia_mcp_gpio2_lower(void)
  810. {
  811. return nvidia_mcp_gpio_set(0x02, 0);
  812. }
  813. /*
  814. * Suited for:
  815. * - Foxconn 6150K8MD-8EKRSH: Socket 939 + NVIDIA MCP51
  816. * - MSI K8N Neo4: NVIDIA CK804. TODO: Should probably be K8N Neo4 Platinum, see http://www.coreboot.org/pipermail/flashrom/2010-August/004362.html.
  817. * - MSI K8NGM2-L: NVIDIA MCP51
  818. */
  819. static int nvidia_mcp_gpio2_raise(void)
  820. {
  821. return nvidia_mcp_gpio_set(0x02, 1);
  822. }
  823. /*
  824. * Suited for:
  825. * - EPoX EP-8NPA7I: Socket 754 + NVIDIA nForce4 4X
  826. */
  827. static int nvidia_mcp_gpio4_raise(void)
  828. {
  829. return nvidia_mcp_gpio_set(0x04, 1);
  830. }
  831. /*
  832. * Suited for:
  833. * - HP xw9400 (Tyan S2915-E OEM): Dual(!) NVIDIA MCP55
  834. *
  835. * Notes: a) There are two MCP55 chips, so also two SMBus bridges on that
  836. * board. We can't tell the SMBus logical devices apart, but we
  837. * can tell the LPC bridge functions apart.
  838. * We need to choose the SMBus bridge next to the LPC bridge with
  839. * ID 0x364 and the "LPC bridge" class.
  840. * b) #TBL is hardwired on that board to a pull-down. It can be
  841. * overridden by connecting the two solder points next to F2.
  842. */
  843. static int nvidia_mcp_gpio5_raise(void)
  844. {
  845. return nvidia_mcp_gpio_set(0x05, 1);
  846. }
  847. /*
  848. * Suited for:
  849. * - abit NF7-S: NVIDIA CK804
  850. */
  851. static int nvidia_mcp_gpio8_raise(void)
  852. {
  853. return nvidia_mcp_gpio_set(0x08, 1);
  854. }
  855. /*
  856. * Suited for:
  857. * - GIGABYTE GA-K8NS Pro-939: Socket 939 + NVIDIA nForce3 + CK8
  858. */
  859. static int nvidia_mcp_gpio0a_raise(void)
  860. {
  861. return nvidia_mcp_gpio_set(0x0a, 1);
  862. }
  863. /*
  864. * Suited for:
  865. * - MSI K8N Neo2 Platinum: Socket 939 + nForce3 Ultra + CK8
  866. */
  867. static int nvidia_mcp_gpio0c_raise(void)
  868. {
  869. return nvidia_mcp_gpio_set(0x0c, 1);
  870. }
  871. /*
  872. * Suited for:
  873. * - abit NF-M2 nView: Socket AM2 + NVIDIA MCP51
  874. */
  875. static int nvidia_mcp_gpio4_lower(void)
  876. {
  877. return nvidia_mcp_gpio_set(0x04, 0);
  878. }
  879. /*
  880. * Suited for:
  881. * - ASUS P5ND2-SLI Deluxe: LGA775 + nForce4 SLI + MCP04
  882. */
  883. static int nvidia_mcp_gpio10_raise(void)
  884. {
  885. return nvidia_mcp_gpio_set(0x10, 1);
  886. }
  887. /*
  888. * Suited for:
  889. * - GIGABYTE GA-K8N-SLI: AMD socket 939 + NVIDIA CK804 + ITE IT8712F
  890. */
  891. static int nvidia_mcp_gpio21_raise(void)
  892. {
  893. return nvidia_mcp_gpio_set(0x21, 0x01);
  894. }
  895. /*
  896. * Suited for:
  897. * - EPoX EP-8RDA3+: Socket A + nForce2 Ultra 400 + MCP2
  898. */
  899. static int nvidia_mcp_gpio31_raise(void)
  900. {
  901. return nvidia_mcp_gpio_set(0x31, 0x01);
  902. }
  903. /*
  904. * Suited for:
  905. * - GIGABYTE GA-K8N51GMF: Socket 754 + Geforce 6100 + MCP51
  906. * - GIGABYTE GA-K8N51GMF-9: Socket 939 + Geforce 6100 + MCP51
  907. */
  908. static int nvidia_mcp_gpio3b_raise(void)
  909. {
  910. return nvidia_mcp_gpio_set(0x3b, 1);
  911. }
  912. /*
  913. * Suited for:
  914. * - Sun Ultra 40 M2: Dual Socket F (1207) + MCP55
  915. */
  916. static int board_sun_ultra_40_m2(void)
  917. {
  918. int ret;
  919. uint8_t reg;
  920. uint16_t base;
  921. struct pci_dev *dev;
  922. ret = nvidia_mcp_gpio4_lower();
  923. if (ret)
  924. return ret;
  925. dev = pci_dev_find(0x10de, 0x0364); /* NVIDIA MCP55 LPC bridge */
  926. if (!dev) {
  927. msg_perr("\nERROR: NVIDIA MCP55 LPC bridge not found.\n");
  928. return -1;
  929. }
  930. base = pci_read_word(dev, 0xb4); /* some IO BAR? */
  931. if (!base)
  932. return -1;
  933. reg = INB(base + 0x4b);
  934. reg |= 0x10;
  935. OUTB(reg, base + 0x4b);
  936. return 0;
  937. }
  938. /*
  939. * Suited for:
  940. * - Artec Group DBE61 and DBE62
  941. */
  942. static int board_artecgroup_dbe6x(void)
  943. {
  944. #define DBE6x_MSR_DIVIL_BALL_OPTS 0x51400015
  945. #define DBE6x_PRI_BOOT_LOC_SHIFT 2
  946. #define DBE6x_BOOT_OP_LATCHED_SHIFT 8
  947. #define DBE6x_SEC_BOOT_LOC_SHIFT 10
  948. #define DBE6x_PRI_BOOT_LOC (3 << DBE6x_PRI_BOOT_LOC_SHIFT)
  949. #define DBE6x_BOOT_OP_LATCHED (3 << DBE6x_BOOT_OP_LATCHED_SHIFT)
  950. #define DBE6x_SEC_BOOT_LOC (3 << DBE6x_SEC_BOOT_LOC_SHIFT)
  951. #define DBE6x_BOOT_LOC_FLASH 2
  952. #define DBE6x_BOOT_LOC_FWHUB 3
  953. msr_t msr;
  954. unsigned long boot_loc;
  955. /* Geode only has a single core */
  956. if (setup_cpu_msr(0))
  957. return -1;
  958. msr = rdmsr(DBE6x_MSR_DIVIL_BALL_OPTS);
  959. if ((msr.lo & (DBE6x_BOOT_OP_LATCHED)) ==
  960. (DBE6x_BOOT_LOC_FWHUB << DBE6x_BOOT_OP_LATCHED_SHIFT))
  961. boot_loc = DBE6x_BOOT_LOC_FWHUB;
  962. else
  963. boot_loc = DBE6x_BOOT_LOC_FLASH;
  964. msr.lo &= ~(DBE6x_PRI_BOOT_LOC | DBE6x_SEC_BOOT_LOC);
  965. msr.lo |= ((boot_loc << DBE6x_PRI_BOOT_LOC_SHIFT) |
  966. (boot_loc << DBE6x_SEC_BOOT_LOC_SHIFT));
  967. wrmsr(DBE6x_MSR_DIVIL_BALL_OPTS, msr);
  968. cleanup_cpu_msr();
  969. return 0;
  970. }
  971. /*
  972. * Suited for:
  973. * - ASUS A8AE-LE (Codename AmberineM; used in Compaq Presario 061)
  974. * Datasheet(s) used:
  975. * - AMD document 43009 "AMD SB700/710/750 Register Reference Guide" rev. 1.00
  976. */
  977. static int amd_sbxxx_gpio9_raise(void)
  978. {
  979. struct pci_dev *dev;
  980. uint32_t reg;
  981. dev = pci_dev_find(0x1002, 0x4372); /* AMD SMBus controller */
  982. if (!dev) {
  983. msg_perr("\nERROR: AMD SMBus Controller (0x4372) not found.\n");
  984. return -1;
  985. }
  986. reg = pci_read_long(dev, 0xA8); /* GPIO_12_to_4_Cntrl CI_Reg: A8h-ABh */
  987. /* enable output (0: enable, 1: tristate):
  988. GPIO9 output enable is at bit 5 in 0xA9 */
  989. reg &= ~((uint32_t)1<<(8+5));
  990. /* raise:
  991. GPIO9 output register is at bit 5 in 0xA8 */
  992. reg |= (1<<5);
  993. pci_write_long(dev, 0xA8, reg);
  994. return 0;
  995. }
  996. /*
  997. * Helper function to raise/drop a given gpo line on Intel PIIX4{,E,M}.
  998. */
  999. static int intel_piix4_gpo_set(unsigned int gpo, int raise)
  1000. {
  1001. unsigned int gpo_byte, gpo_bit;
  1002. struct pci_dev *dev;
  1003. uint32_t tmp, base;
  1004. /* GPO{0,8,27,28,30} are always available. */
  1005. static const uint32_t nonmuxed_gpos = 0x58000101;
  1006. static const struct {unsigned int reg, mask, value; } piix4_gpo[] = {
  1007. {0},
  1008. {0xB0, 0x0001, 0x0000}, /* GPO1... */
  1009. {0xB0, 0x0001, 0x0000},
  1010. {0xB0, 0x0001, 0x0000},
  1011. {0xB0, 0x0001, 0x0000},
  1012. {0xB0, 0x0001, 0x0000},
  1013. {0xB0, 0x0001, 0x0000},
  1014. {0xB0, 0x0001, 0x0000}, /* ...GPO7: GENCFG bit 0 */
  1015. {0},
  1016. {0xB0, 0x0100, 0x0000}, /* GPO9: GENCFG bit 8 */
  1017. {0xB0, 0x0200, 0x0000}, /* GPO10: GENCFG bit 9 */
  1018. {0xB0, 0x0400, 0x0000}, /* GPO11: GENCFG bit 10 */
  1019. {0x4E, 0x0100, 0x0000}, /* GPO12... */
  1020. {0x4E, 0x0100, 0x0000},
  1021. {0x4E, 0x0100, 0x0000}, /* ...GPO14: XBCS bit 8 */
  1022. {0xB2, 0x0002, 0x0002}, /* GPO15... */
  1023. {0xB2, 0x0002, 0x0002}, /* ...GPO16: GENCFG bit 17 */
  1024. {0xB2, 0x0004, 0x0004}, /* GPO17: GENCFG bit 18 */
  1025. {0xB2, 0x0008, 0x0008}, /* GPO18: GENCFG bit 19 */
  1026. {0xB2, 0x0010, 0x0010}, /* GPO19: GENCFG bit 20 */
  1027. {0xB2, 0x0020, 0x0020}, /* GPO20: GENCFG bit 21 */
  1028. {0xB2, 0x0040, 0x0040}, /* GPO21: GENCFG bit 22 */
  1029. {0xB2, 0x1000, 0x1000}, /* GPO22... */
  1030. {0xB2, 0x1000, 0x1000}, /* ...GPO23: GENCFG bit 28 */
  1031. {0xB2, 0x2000, 0x2000}, /* GPO24: GENCFG bit 29 */
  1032. {0xB2, 0x4000, 0x4000}, /* GPO25: GENCFG bit 30 */
  1033. {0xB2, 0x8000, 0x8000}, /* GPO26: GENCFG bit 31 */
  1034. {0},
  1035. {0},
  1036. {0x4E, 0x0100, 0x0000}, /* ...GPO29: XBCS bit 8 */
  1037. {0}
  1038. };
  1039. dev = pci_dev_find(0x8086, 0x7110); /* Intel PIIX4 ISA bridge */
  1040. if (!dev) {
  1041. msg_perr("\nERROR: Intel PIIX4 ISA bridge not found.\n");
  1042. return -1;
  1043. }
  1044. /* Sanity check. */
  1045. if (gpo > 30) {
  1046. msg_perr("\nERROR: Intel PIIX4 has no GPO%d.\n", gpo);
  1047. return -1;
  1048. }
  1049. if ((((1 << gpo) & nonmuxed_gpos) == 0) &&
  1050. ((pci_read_word(dev, piix4_gpo[gpo].reg) & piix4_gpo[gpo].mask) !=
  1051. piix4_gpo[gpo].value)) {
  1052. msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n", gpo);
  1053. return -1;
  1054. }
  1055. dev = pci_dev_find(0x8086, 0x7113); /* Intel PIIX4 PM */
  1056. if (!dev) {
  1057. msg_perr("\nERROR: Intel PIIX4 PM not found.\n");
  1058. return -1;
  1059. }
  1060. /* PM IO base */
  1061. base = pci_read_long(dev, 0x40) & 0x0000FFC0;
  1062. gpo_byte = gpo >> 3;
  1063. gpo_bit = gpo & 7;
  1064. tmp = INB(base + 0x34 + gpo_byte); /* GPO register */
  1065. if (raise)
  1066. tmp |= 0x01 << gpo_bit;
  1067. else
  1068. tmp &= ~(0x01 << gpo_bit);
  1069. OUTB(tmp, base + 0x34 + gpo_byte);
  1070. return 0;
  1071. }
  1072. /*
  1073. * Suited for:
  1074. * - ASUS P2B-N
  1075. */
  1076. static int intel_piix4_gpo18_lower(void)
  1077. {
  1078. return intel_piix4_gpo_set(18, 0);
  1079. }
  1080. /*
  1081. * Suited for:
  1082. * - MSI MS-6163 v2 (MS-6163 Pro): Intel 440BX + PIIX4E + Winbond W83977EF
  1083. */
  1084. static int intel_piix4_gpo14_raise(void)
  1085. {
  1086. return intel_piix4_gpo_set(14, 1);
  1087. }
  1088. /*
  1089. * Suited for:
  1090. * - EPoX EP-BX3
  1091. */
  1092. static int intel_piix4_gpo22_raise(void)
  1093. {
  1094. return intel_piix4_gpo_set(22, 1);
  1095. }
  1096. /*
  1097. * Suited for:
  1098. * - abit BM6
  1099. */
  1100. static int intel_piix4_gpo26_lower(void)
  1101. {
  1102. return intel_piix4_gpo_set(26, 0);
  1103. }
  1104. /*
  1105. * Suited for:
  1106. * - Intel SE440BX-2
  1107. */
  1108. static int intel_piix4_gpo27_lower(void)
  1109. {
  1110. return intel_piix4_gpo_set(27, 0);
  1111. }
  1112. /*
  1113. * Suited for:
  1114. * - Dell OptiPlex GX1
  1115. */
  1116. static int intel_piix4_gpo30_lower(void)
  1117. {
  1118. return intel_piix4_gpo_set(30, 0);
  1119. }
  1120. /*
  1121. * Set a GPIO line on a given Intel ICH LPC controller.
  1122. */
  1123. static int intel_ich_gpio_set(int gpio, int raise)
  1124. {
  1125. /* Table mapping the different Intel ICH LPC chipsets. */
  1126. static struct {
  1127. uint16_t id;
  1128. uint8_t base_reg;
  1129. uint32_t bank0;
  1130. uint32_t bank1;
  1131. uint32_t bank2;
  1132. } intel_ich_gpio_table[] = {
  1133. {0x2410, 0x58, 0x0FE30000, 0, 0}, /* 82801AA (ICH) */
  1134. {0x2420, 0x58, 0x0FE30000, 0, 0}, /* 82801AB (ICH0) */
  1135. {0x2440, 0x58, 0x1BFF391B, 0, 0}, /* 82801BA (ICH2) */
  1136. {0x244C, 0x58, 0x1A23399B, 0, 0}, /* 82801BAM (ICH2M) */
  1137. {0x2450, 0x58, 0x1BFF0000, 0, 0}, /* 82801E (C-ICH) */
  1138. {0x2480, 0x58, 0x1BFF0000, 0x00000FFF, 0}, /* 82801CA (ICH3-S) */
  1139. {0x248C, 0x58, 0x1A230000, 0x00000FFF, 0}, /* 82801CAM (ICH3-M) */
  1140. {0x24C0, 0x58, 0x1BFF0000, 0x00000FFF, 0}, /* 82801DB/DBL (ICH4/ICH4-L) */
  1141. {0x24CC, 0x58, 0x1A030000, 0x00000FFF, 0}, /* 82801DBM (ICH4-M) */
  1142. {0x24D0, 0x58, 0x1BFF0000, 0x00030305, 0}, /* 82801EB/ER (ICH5/ICH5R) */
  1143. {0x2640, 0x48, 0x1BFF0000, 0x00030307, 0}, /* 82801FB/FR (ICH6/ICH6R) */
  1144. {0x2641, 0x48, 0x1BFF0000, 0x00030307, 0}, /* 82801FBM (ICH6M) */
  1145. {0x27B8, 0x48, 0xFFFFFFFF, 0x000300FF, 0}, /* 82801GB/GR (ICH7 Family) */
  1146. {0x27B9, 0x48, 0xFFEBFFFE, 0x000300FE, 0}, /* 82801GBM (ICH7-M) */
  1147. {0x27BD, 0x48, 0xFFEBFFFE, 0x000300FE, 0}, /* 82801GHM (ICH7-M DH) */
  1148. {0x2810, 0x48, 0xFFFFFFFF, 0x00FF0FFF, 0}, /* 82801HB/HR (ICH8/R) */
  1149. {0x2811, 0x48, 0xFFFFFFFF, 0x00FF0FFF, 0}, /* 82801HBM (ICH8M-E) */
  1150. {0x2812, 0x48, 0xFFFFFFFF, 0x00FF0FFF, 0}, /* 82801HH (ICH8DH) */
  1151. {0x2814, 0x48, 0xFFFFFFFF, 0x00FF0FFF, 0}, /* 82801HO (ICH8DO) */
  1152. {0x2815, 0x48, 0xFFFFFFFF, 0x00FF0FFF, 0}, /* 82801HEM (ICH8M) */
  1153. {0x2912, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IH (ICH9DH) */
  1154. {0x2914, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IO (ICH9DO) */
  1155. {0x2916, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IR (ICH9R) */
  1156. {0x2917, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IEM (ICH9M-E) */
  1157. {0x2918, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IB (ICH9) */
  1158. {0x2919, 0x48, 0xFFFFFFFF, 0x00FFFFFF, 0}, /* 82801IBM (ICH9M) */
  1159. {0x3A14, 0x48, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000100}, /* 82801JDO (ICH10DO) */
  1160. {0x3A16, 0x48, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000100}, /* 82801JIR (ICH10R) */
  1161. {0x3A18, 0x48, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000100}, /* 82801JIB (ICH10) */
  1162. {0x3A1A, 0x48, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000100}, /* 82801JD (ICH10D) */
  1163. {0, 0, 0, 0, 0} /* end marker */
  1164. };
  1165. struct pci_dev *dev;
  1166. uint16_t base;
  1167. uint32_t tmp;
  1168. int i, allowed;
  1169. /* First, look for a known LPC bridge */
  1170. for (dev = pacc->devices; dev; dev = dev->next) {
  1171. uint16_t device_class;
  1172. /* libpci before version 2.2.4 does not store class info. */
  1173. device_class = pci_read_word(dev, PCI_CLASS_DEVICE);
  1174. if ((dev->vendor_id == 0x8086) &&
  1175. (device_class == 0x0601)) { /* ISA bridge */
  1176. /* Is this device in our list? */
  1177. for (i = 0; intel_ich_gpio_table[i].id; i++)
  1178. if (dev->device_id == intel_ich_gpio_table[i].id)
  1179. break;
  1180. if (intel_ich_gpio_table[i].id)
  1181. break;
  1182. }
  1183. }
  1184. if (!dev) {
  1185. msg_perr("\nERROR: No known Intel LPC bridge found.\n");
  1186. return -1;
  1187. }
  1188. /*
  1189. * According to the datasheets, all Intel ICHs have the GPIO bar 5:1
  1190. * strapped to zero. From some mobile ICH9 version on, this becomes
  1191. * 6:1. The mask below catches all.
  1192. */
  1193. base = pci_read_word(dev, intel_ich_gpio_table[i].base_reg) & 0xFFC0;
  1194. /* Check whether the line is allowed. */
  1195. if (gpio < 32)
  1196. allowed = (intel_ich_gpio_table[i].bank0 >> gpio) & 0x01;
  1197. else if (gpio < 64)
  1198. allowed = (intel_ich_gpio_table[i].bank1 >> (gpio - 32)) & 0x01;
  1199. else
  1200. allowed = (intel_ich_gpio_table[i].bank2 >> (gpio - 64)) & 0x01;
  1201. if (!allowed) {
  1202. msg_perr("\nERROR: This Intel LPC bridge does not allow"
  1203. " setting GPIO%02d\n", gpio);
  1204. return -1;
  1205. }
  1206. msg_pdbg("\nIntel ICH LPC bridge: %sing GPIO%02d.\n",
  1207. raise ? "Rais" : "Dropp", gpio);
  1208. if (gpio < 32) {
  1209. /* Set line to GPIO. */
  1210. tmp = INL(base);
  1211. /* ICH/ICH0 multiplexes 27/28 on the line set. */
  1212. if ((gpio == 28) &&
  1213. ((dev->device_id == 0x2410) || (dev->device_id == 0x2420)))
  1214. tmp |= 1 << 27;
  1215. else
  1216. tmp |= 1 << gpio;
  1217. OUTL(tmp, base);
  1218. /* As soon as we are talking to ICH8 and above, this register
  1219. decides whether we can set the gpio or not. */
  1220. if (dev->device_id > 0x2800) {
  1221. tmp = INL(base);
  1222. if (!(tmp & (1 << gpio))) {
  1223. msg_perr("\nERROR: This Intel LPC bridge"
  1224. " does not allow setting GPIO%02d\n",
  1225. gpio);
  1226. return -1;
  1227. }
  1228. }
  1229. /* Set GPIO to OUTPUT. */
  1230. tmp = INL(base + 0x04);
  1231. tmp &= ~(1 << gpio);
  1232. OUTL(tmp, base + 0x04);
  1233. /* Raise GPIO line. */
  1234. tmp = INL(base + 0x0C);
  1235. if (raise)
  1236. tmp |= 1 << gpio;
  1237. else
  1238. tmp &= ~(1 << gpio);
  1239. OUTL(tmp, base + 0x0C);
  1240. } else if (gpio < 64) {
  1241. gpio -= 32;
  1242. /* Set line to GPIO. */
  1243. tmp = INL(base + 0x30);
  1244. tmp |= 1 << gpio;
  1245. OUTL(tmp, base + 0x30);
  1246. /* As soon as we are talking to ICH8 and above, this register
  1247. decides whether we can set the gpio or not. */
  1248. if (dev->device_id > 0x2800) {
  1249. tmp = INL(base + 30);
  1250. if (!(tmp & (1 << gpio))) {
  1251. msg_perr("\nERROR: This Intel LPC bridge"
  1252. " does not allow setting GPIO%02d\n",
  1253. gpio + 32);
  1254. return -1;
  1255. }
  1256. }
  1257. /* Set GPIO to OUTPUT. */
  1258. tmp = INL(base + 0x34);
  1259. tmp &= ~(1 << gpio);
  1260. OUTL(tmp, base + 0x34);
  1261. /* Raise GPIO line. */
  1262. tmp = INL(base + 0x38);
  1263. if (raise)
  1264. tmp |= 1 << gpio;
  1265. else
  1266. tmp &= ~(1 << gpio);
  1267. OUTL(tmp, base + 0x38);
  1268. } else {
  1269. gpio -= 64;
  1270. /* Set line to GPIO. */
  1271. tmp = INL(base + 0x40);
  1272. tmp |= 1 << gpio;
  1273. OUTL(tmp, base + 0x40);
  1274. tmp = INL(base + 40);
  1275. if (!(tmp & (1 << gpio))) {
  1276. msg_perr("\nERROR: This Intel LPC bridge does "
  1277. "not allow setting GPIO%02d\n", gpio + 64);
  1278. return -1;
  1279. }
  1280. /* Set GPIO to OUTPUT. */
  1281. tmp = INL(base + 0x44);
  1282. tmp &= ~(1 << gpio);
  1283. OUTL(tmp, base + 0x44);
  1284. /* Raise GPIO line. */
  1285. tmp = INL(base + 0x48);
  1286. if (raise)
  1287. tmp |= 1 << gpio;
  1288. else
  1289. tmp &= ~(1 << gpio);
  1290. OUTL(tmp, base + 0x48);
  1291. }
  1292. return 0;
  1293. }
  1294. /*
  1295. * Suited for:
  1296. * - abit IP35: Intel P35 + ICH9R
  1297. * - abit IP35 Pro: Intel P35 + ICH9R
  1298. * - ASUS P5LD2
  1299. */
  1300. static int intel_ich_gpio16_raise(void)
  1301. {
  1302. return intel_ich_gpio_set(16, 1);
  1303. }
  1304. /*
  1305. * Suited for:
  1306. * - HP Puffer2-UL8E (ASUS PTGD-LA OEM): LGA775 + 915 + ICH6
  1307. */
  1308. static int intel_ich_gpio18_raise(void)
  1309. {
  1310. return intel_ich_gpio_set(18, 1);
  1311. }
  1312. /*
  1313. * Suited for:
  1314. * - MSI MS-7046: LGA775 + 915P + ICH6
  1315. */
  1316. static int intel_ich_gpio19_raise(void)
  1317. {
  1318. return intel_ich_gpio_set(19, 1);
  1319. }
  1320. /*
  1321. * Suited for:
  1322. * - ASUS P4B266LM (Sony Vaio PCV-RX650): socket478 + 845D + ICH2
  1323. * - ASUS P4C800-E Deluxe: socket478 + 875P + ICH5
  1324. * - ASUS P4P800: Intel socket478 + 865PE + ICH5R
  1325. * - ASUS P4P800-E Deluxe: Intel socket478 + 865PE + ICH5R
  1326. * - ASUS P4P800-VM: Intel socket478 + 865PE + ICH5R
  1327. * - ASUS P5GD1 Pro: Intel LGA 775 + 915P + ICH6R
  1328. * - ASUS P5GD2 Premium: Intel LGA775 + 915G + ICH6R
  1329. * - ASUS P5GDC Deluxe: Intel socket775 + 915P + ICH6R
  1330. * - ASUS P5PE-VM: Intel LGA775 + 865G + ICH5
  1331. * - Samsung Polaris 32: socket478 + 865P + ICH5
  1332. */
  1333. static int intel_ich_gpio21_raise(void)
  1334. {
  1335. return intel_ich_gpio_set(21, 1);
  1336. }
  1337. /*
  1338. * Suited for:
  1339. * - ASUS P4B266: socket478 + Intel 845D + ICH2
  1340. * - ASUS P4B533-E: socket478 + 845E + ICH4
  1341. * - ASUS P4B-MX variant in HP Vectra VL420 SFF: socket478 + 845D + ICH2
  1342. * - TriGem Anaheim-3: socket370 + Intel 810 + ICH
  1343. */
  1344. static int intel_ich_gpio22_raise(void)
  1345. {
  1346. return intel_ich_gpio_set(22, 1);
  1347. }
  1348. /*
  1349. * Suited for:
  1350. * - ASUS A8Jm (laptop): Intel 945 + ICH7
  1351. * - ASUS P5LP-LE used in ...
  1352. * - HP Media Center m7270.fr Desktop PC as "Lithium-UL8E"
  1353. * - Epson Endeavor MT7700
  1354. */
  1355. static int intel_ich_gpio34_raise(void)
  1356. {
  1357. return intel_ich_gpio_set(34, 1);
  1358. }
  1359. /*
  1360. * Suited for:
  1361. * - AOpen i945GMx-VFX: Intel 945GM + ICH7-M used in ...
  1362. * - FSC ESPRIMO Q5010 (SMBIOS: D2544-B1)
  1363. */
  1364. static int intel_ich_gpio38_raise(void)
  1365. {
  1366. return intel_ich_gpio_set(38, 1);
  1367. }
  1368. /*
  1369. * Suited for:
  1370. * - ASUS M6Ne (laptop): socket 479M (guessed) + Intel 855PM + ICH4-M
  1371. */
  1372. static int intel_ich_gpio43_raise(void)
  1373. {
  1374. return intel_ich_gpio_set(43, 1);
  1375. }
  1376. /*
  1377. * Suited for:
  1378. * - HP Vectra VL400: 815 + ICH + PC87360
  1379. */
  1380. static int board_hp_vl400(void)
  1381. {
  1382. int ret;
  1383. ret = intel_ich_gpio_set(25, 1); /* Master write enable ? */
  1384. if (!ret)
  1385. ret = pc8736x_gpio_set(PC87360_ID, 0x09, 1); /* #WP ? */
  1386. if (!ret)
  1387. ret = pc8736x_gpio_set(PC87360_ID, 0x27, 1); /* #TBL */
  1388. return ret;
  1389. }
  1390. /*
  1391. * Suited for:
  1392. * - HP e-Vectra P2706T: 810E + ICH + PC87364
  1393. */
  1394. static int board_hp_p2706t(void)
  1395. {
  1396. int ret;
  1397. ret = pc8736x_gpio_set(PC87364_ID, 0x25, 1);
  1398. if (!ret)
  1399. ret = pc8736x_gpio_set(PC87364_ID, 0x26, 1);
  1400. return ret;
  1401. }
  1402. /*
  1403. * Suited for:
  1404. * - Dell PowerEdge 1850: Intel PPGA604 + E7520 + ICH5R
  1405. * - ASRock P4i65GV: Intel Socket478 + 865GV + ICH5R
  1406. * - ASRock 775i65G: Intel LGA 775 + 865G + ICH5
  1407. * - MSI MS-6391 (845 Pro4): Intel Socket478 + 845 + ICH2
  1408. */
  1409. static int intel_ich_gpio23_raise(void)
  1410. {
  1411. return intel_ich_gpio_set(23, 1);
  1412. }
  1413. /*
  1414. * Suited for:
  1415. * - GIGABYTE GA-6IEM: Intel Socket370 + i815 + ICH2
  1416. * - GIGABYTE GA-8IRML: Intel Socket478 + i845 + ICH2
  1417. */
  1418. static int intel_ich_gpio25_raise(void)
  1419. {
  1420. return intel_ich_gpio_set(25, 1);
  1421. }
  1422. /*
  1423. * Suited for:
  1424. * - IBASE MB899: i945GM + ICH7
  1425. */
  1426. static int intel_ich_gpio26_raise(void)
  1427. {
  1428. return intel_ich_gpio_set(26, 1);
  1429. }
  1430. /*
  1431. * Suited for:
  1432. * - P4SD-LA (HP OEM): i865 + ICH5
  1433. * - GIGABYTE GA-8IP775: 865P + ICH5
  1434. * - GIGABYTE GA-8PE667 Ultra 2: socket 478 + i845PE + ICH4
  1435. * - MSI MS-6788-40 (aka 848P Neo-V)
  1436. */
  1437. static int intel_ich_gpio32_raise(void)
  1438. {
  1439. return intel_ich_gpio_set(32, 1);
  1440. }
  1441. /*
  1442. * Suited for:
  1443. * - AOpen i975Xa-YDG: i975X + ICH7 + W83627EHF
  1444. */
  1445. static int board_aopen_i975xa_ydg(void)
  1446. {
  1447. int ret;
  1448. /* Vendor BIOS ends up in LDN6... maybe the board enable is wrong,
  1449. * or perhaps it's not needed at all?
  1450. * The regs it tries to touch are 0xF0, 0xF1, 0xF2 which means if it
  1451. * were in the right LDN, it would have to be GPIO1 or GPIO3.
  1452. */
  1453. /*
  1454. ret = winbond_gpio_set(0x2e, WINBOND_W83627EHF_ID, x, 0)
  1455. if (!ret)
  1456. */
  1457. ret = intel_ich_gpio_set(33, 1);
  1458. return ret;
  1459. }
  1460. /*
  1461. * Suited for:
  1462. * - Acorp 6A815EPD: socket 370 + intel 815 + ICH2
  1463. */
  1464. static int board_acorp_6a815epd(void)
  1465. {
  1466. int ret;
  1467. /* Lower Blocks Lock -- pin 7 of PLCC32 */
  1468. ret = intel_ich_gpio_set(22, 1);
  1469. if (!ret) /* Top Block Lock -- pin 8 of PLCC32 */
  1470. ret = intel_ich_gpio_set(23, 1);
  1471. return ret;
  1472. }
  1473. /*
  1474. * Suited for:
  1475. * - Kontron 986LCD-M: Socket478 + 915GM + ICH7R
  1476. */
  1477. static int board_kontron_986lcd_m(void)
  1478. {
  1479. int ret;
  1480. ret = intel_ich_gpio_set(34, 1); /* #TBL */
  1481. if (!ret)
  1482. ret = intel_ich_gpio_set(35, 1); /* #WP */
  1483. return ret;
  1484. }
  1485. /*
  1486. * Suited for:
  1487. * - Soyo SY-7VCA: Pro133A + VT82C686
  1488. */
  1489. static int via_apollo_gpo_set(int gpio, int raise)
  1490. {
  1491. struct pci_dev *dev;
  1492. uint32_t base, tmp;
  1493. /* VT82C686 power management */
  1494. dev = pci_dev_find(0x1106, 0x3057);
  1495. if (!dev) {
  1496. msg_perr("\nERROR: VT82C686 PM device not found.\n");
  1497. return -1;
  1498. }
  1499. msg_pdbg("\nVIA Apollo ACPI: %sing GPIO%02d.\n",
  1500. raise ? "Rais" : "Dropp", gpio);
  1501. /* Select GPO function on multiplexed pins. */
  1502. tmp = pci_read_byte(dev, 0x54);
  1503. switch (gpio) {
  1504. case 0:
  1505. tmp &= ~0x03;
  1506. break;
  1507. case 1:
  1508. tmp |= 0x04;
  1509. break;
  1510. case 2:
  1511. tmp |= 0x08;
  1512. break;
  1513. case 3:
  1514. tmp |= 0x10;
  1515. break;
  1516. }
  1517. pci_write_byte(dev, 0x54, tmp);
  1518. /* PM IO base */
  1519. base = pci_read_long(dev, 0x48) & 0x0000FF00;
  1520. /* Drop GPO0 */
  1521. tmp = INL(base + 0x4C);
  1522. if (raise)
  1523. tmp |= 1U << gpio;
  1524. else
  1525. tmp &= ~(1U << gpio);
  1526. OUTL(tmp, base + 0x4C);
  1527. return 0;
  1528. }
  1529. /*
  1530. * Suited for:
  1531. * - abit VT6X4: Pro133x + VT82C686A
  1532. * - abit VA6: Pro133x + VT82C686A
  1533. */
  1534. static int via_apollo_gpo4_lower(void)
  1535. {
  1536. return via_apollo_gpo_set(4, 0);
  1537. }
  1538. /*
  1539. * Suited for:
  1540. * - Soyo SY-7VCA: Pro133A + VT82C686
  1541. */
  1542. static int via_apollo_gpo0_lower(void)
  1543. {
  1544. return via_apollo_gpo_set(0, 0);
  1545. }
  1546. /*
  1547. * Enable some GPIO pin on SiS southbridge and enables SIO flash writes.
  1548. *
  1549. * Suited for:
  1550. * - MSI 651M-L: SiS651 / SiS962
  1551. * - GIGABYTE GA-8SIMLH
  1552. */
  1553. static int sis_gpio0_raise_and_w836xx_memw(void)
  1554. {
  1555. struct pci_dev *dev;
  1556. uint16_t base, temp;
  1557. dev = pci_dev_find(0x1039, 0x0962);
  1558. if (!dev) {
  1559. msg_perr("Expected south bridge not found\n");
  1560. return 1;
  1561. }
  1562. base = pci_read_word(dev, 0x74);
  1563. temp = INW(base + 0x68);
  1564. temp &= ~(1 << 0); /* Make pin output? */
  1565. OUTW(temp, base + 0x68);
  1566. temp = INW(base + 0x64);
  1567. temp |= (1 << 0); /* Raise output? */
  1568. OUTW(temp, base + 0x64);
  1569. w836xx_memw_enable(0x2E);
  1570. return 0;
  1571. }
  1572. /*
  1573. * Find the runtime registers of an SMSC Super I/O, after verifying its
  1574. * chip ID.
  1575. *
  1576. * Returns the base port of the runtime register block, or 0 on error.
  1577. */
  1578. static uint16_t smsc_find_runtime(uint16_t sio_port, uint16_t chip_id,
  1579. uint8_t logical_device)
  1580. {
  1581. uint16_t rt_port = 0;
  1582. /* Verify the chip ID. */
  1583. OUTB(0x55, sio_port); /* Enable configuration. */
  1584. if (sio_read(sio_port, 0x20) != chip_id) {
  1585. msg_perr("\nERROR: SMSC Super I/O not found.\n");
  1586. goto out;
  1587. }
  1588. /* If the runtime block is active, get its address. */
  1589. sio_write(sio_port, 0x07, logical_device);
  1590. if (sio_read(sio_port, 0x30) & 1) {
  1591. rt_port = (sio_read(sio_port, 0x60) << 8)
  1592. | sio_read(sio_port, 0x61);
  1593. }
  1594. if (rt_port == 0) {
  1595. msg_perr("\nERROR: "
  1596. "Super I/O runtime interface not available.\n");
  1597. }
  1598. out:
  1599. OUTB(0xaa, sio_port); /* Disable configuration. */
  1600. return rt_port;
  1601. }
  1602. /*
  1603. * Disable write protection on the Mitac 6513WU. WP# on the FWH is
  1604. * connected to GP30 on the Super I/O, and TBL# is always high.
  1605. */
  1606. static int board_mitac_6513wu(void)
  1607. {
  1608. struct pci_dev *dev;
  1609. uint16_t rt_port;
  1610. uint8_t val;
  1611. dev = pci_dev_find(0x8086, 0x2410); /* Intel 82801AA ISA bridge */
  1612. if (!dev) {
  1613. msg_perr("\nERROR: Intel 82801AA ISA bridge not found.\n");
  1614. return -1;
  1615. }
  1616. rt_port = smsc_find_runtime(0x4e, 0x54 /* LPC47U33x */, 0xa);
  1617. if (rt_port == 0)
  1618. return -1;
  1619. /* Configure the GPIO pin. */
  1620. val = INB(rt_port + 0x33); /* GP30 config */
  1621. val &= ~0x87; /* Output, non-inverted, GPIO, push/pull */
  1622. OUTB(val, rt_port + 0x33);
  1623. /* Disable write protection. */
  1624. val = INB(rt_port + 0x4d); /* GP3 values */
  1625. val |= 0x01; /* Set GP30 high. */
  1626. OUTB(val, rt_port + 0x4d);
  1627. return 0;
  1628. }
  1629. /*
  1630. * Suited for:
  1631. * - abit AV8: Socket939 + K8T800Pro + VT8237
  1632. */
  1633. static int board_abit_av8(void)
  1634. {
  1635. uint8_t val;
  1636. /* Raise GPO pins GP22 & GP23 */
  1637. val = INB(0x404E);
  1638. val |= 0xC0;
  1639. OUTB(val, 0x404E);
  1640. return 0;
  1641. }
  1642. /*
  1643. * Suited for:
  1644. * - ASUS A7V333: VIA KT333 + VT8233A + IT8703F
  1645. * - ASUS A7V8X: VIA KT400 + VT8235 + IT8703F
  1646. */
  1647. static int it8703f_gpio51_raise(void)
  1648. {
  1649. uint16_t id, base;
  1650. uint8_t tmp;
  1651. /* Find the IT8703F. */
  1652. w836xx_ext_enter(0x2E);
  1653. id = (sio_read(0x2E, 0x20) << 8) | sio_read(0x2E, 0x21);
  1654. w836xx_ext_leave(0x2E);
  1655. if (id != 0x8701) {
  1656. msg_perr("\nERROR: IT8703F Super I/O not found.\n");
  1657. return -1;
  1658. }
  1659. /* Get the GP567 I/O base. */
  1660. w836xx_ext_enter(0x2E);
  1661. sio_write(0x2E, 0x07, 0x0C);
  1662. base = (sio_read(0x2E, 0x60) << 8) | sio_read(0x2E, 0x61);
  1663. w836xx_ext_leave(0x2E);
  1664. if (!base) {
  1665. msg_perr("\nERROR: Failed to read IT8703F Super I/O GPIO"
  1666. " Base.\n");
  1667. return -1;
  1668. }
  1669. /* Raise GP51. */
  1670. tmp = INB(base);
  1671. tmp |= 0x02;
  1672. OUTB(tmp, base);
  1673. return 0;
  1674. }
  1675. /*
  1676. * General routine for raising/dropping GPIO lines on the ITE IT87xx.
  1677. */
  1678. static int it87_gpio_set(unsigned int gpio, int raise)
  1679. {
  1680. int allowed, sio;
  1681. unsigned int port;
  1682. uint16_t base, sioport;
  1683. uint8_t tmp;
  1684. /* IT87 GPIO configuration table */
  1685. static const struct it87cfg {
  1686. uint16_t id;
  1687. uint8_t base_reg;
  1688. uint32_t bank0;
  1689. uint32_t bank1;
  1690. uint32_t bank2;
  1691. } it87_gpio_table[] = {
  1692. {0x8712, 0x62, 0xCFF3FC00, 0x00FCFF3F, 0},
  1693. {0x8718, 0x62, 0xCFF37C00, 0xF3FCDF3F, 0x0000000F},
  1694. {0, 0, 0, 0, 0} /* end marker */
  1695. };
  1696. const struct it87cfg *cfg = NULL;
  1697. /* Find the Super I/O in the probed list */
  1698. for (sio = 0; sio < superio_count; sio++) {
  1699. int i;
  1700. if (superios[sio].vendor != SUPERIO_VENDOR_ITE)
  1701. continue;
  1702. /* Is this device in our list? */
  1703. for (i = 0; it87_gpio_table[i].id; i++)
  1704. if (superios[sio].model == it87_gpio_table[i].id) {
  1705. cfg = &it87_gpio_table[i];
  1706. goto found;
  1707. }
  1708. }
  1709. if (cfg == NULL) {
  1710. msg_perr("\nERROR: No IT87 Super I/O GPIO configuration "
  1711. "found.\n");
  1712. return -1;
  1713. }
  1714. found:
  1715. /* Check whether the gpio is allowed. */
  1716. if (gpio < 32)
  1717. allowed = (cfg->bank0 >> gpio) & 0x01;
  1718. else if (gpio < 64)
  1719. allowed = (cfg->bank1 >> (gpio - 32)) & 0x01;
  1720. else if (gpio < 96)
  1721. allowed = (cfg->bank2 >> (gpio - 64)) & 0x01;
  1722. else
  1723. allowed = 0;
  1724. if (!allowed) {
  1725. msg_perr("\nERROR: IT%02X does not allow setting GPIO%02u.\n",
  1726. cfg->id, gpio);
  1727. return -1;
  1728. }
  1729. /* Read the Simple I/O Base Address Register */
  1730. sioport = superios[sio].port;
  1731. enter_conf_mode_ite(sioport);
  1732. sio_write(sioport, 0x07, 0x07);
  1733. base = (sio_read(sioport, cfg->base_reg) << 8) |
  1734. sio_read(sioport, cfg->base_reg + 1);
  1735. exit_conf_mode_ite(sioport);
  1736. if (!base) {
  1737. msg_perr("\nERROR: Failed to read IT87 Super I/O GPIO Base.\n");
  1738. return -1;
  1739. }
  1740. msg_pdbg("Using IT87 GPIO base 0x%04x\n", base);
  1741. port = gpio / 10 - 1;
  1742. gpio %= 10;
  1743. /* set GPIO. */
  1744. tmp = INB(base + port);
  1745. if (raise)
  1746. tmp |= 1 << gpio;
  1747. else
  1748. tmp &= ~(1 << gpio);
  1749. OUTB(tmp, base + port);
  1750. return 0;
  1751. }
  1752. /*
  1753. * Suited for:
  1754. * - ASUS A7N8X-VM/400: NVIDIA nForce2 IGP2 + IT8712F
  1755. */
  1756. static int it8712f_gpio12_raise(void)
  1757. {
  1758. return it87_gpio_set(12, 1);
  1759. }
  1760. /*
  1761. * Suited for:
  1762. * - ASUS A7V600-X: VIA KT600 + VT8237 + IT8712F
  1763. * - ASUS A7V8X-X: VIA KT400 + VT8235 + IT8712F
  1764. */
  1765. static int it8712f_gpio31_raise(void)
  1766. {
  1767. return it87_gpio_set(32, 1);
  1768. }
  1769. /*
  1770. * Suited for:
  1771. * - ASUS P5N-D: NVIDIA MCP51 + IT8718F
  1772. * - ASUS P5N-E SLI: NVIDIA MCP51 + IT8718F
  1773. */
  1774. static int it8718f_gpio63_raise(void)
  1775. {
  1776. return it87_gpio_set(63, 1);
  1777. }
  1778. /*
  1779. * Suited for all boards with ambiguous DMI chassis information, which should be
  1780. * whitelisted because they are known to work:
  1781. * - MSC Q7 Tunnel Creek Module (Q7-TCTC)
  1782. */
  1783. static int p2_not_a_laptop(void)
  1784. {
  1785. /* label this board as not a laptop */
  1786. is_laptop = 0;
  1787. msg_pdbg("Laptop detection overridden by P2 board enable.\n");
  1788. return 0;
  1789. }
  1790. #endif
  1791. /*
  1792. * Below is the list of boards which need a special "board enable" code in
  1793. * flashrom before their ROM chip can be accessed/written to.
  1794. *
  1795. * NOTE: Please add boards that _don't_ need such enables or don't work yet
  1796. * to the respective tables in print.c. Thanks!
  1797. *
  1798. * We use 2 sets of IDs here, you're free to choose which is which. This
  1799. * is to provide a very high degree of certainty when matching a board on
  1800. * the basis of subsystem/card IDs. As not every vendor handles
  1801. * subsystem/card IDs in a sane manner.
  1802. *
  1803. * Keep the second set NULLed if it should be ignored. Keep the subsystem IDs
  1804. * NULLed if they don't identify the board fully and if you can't use DMI.
  1805. * But please take care to provide an as complete set of pci ids as possible;
  1806. * autodetection is the preferred behaviour and we would like to make sure that
  1807. * matches are unique.
  1808. *
  1809. * If PCI IDs are not sufficient for board matching, the match can be further
  1810. * constrained by a string that has to be present in the DMI database for
  1811. * the baseboard or the system entry. The pattern is matched by case sensitive
  1812. * substring match, unless it is anchored to the beginning (with a ^ in front)
  1813. * or the end (with a $ at the end). Both anchors may be specified at the
  1814. * same time to match the full field.
  1815. *
  1816. * When a board is matched through DMI, the first and second main PCI IDs
  1817. * and the first subsystem PCI ID have to match as well. If you specify the
  1818. * first subsystem ID as 0x0:0x0, the DMI matching code expects that the
  1819. * subsystem ID of that device is indeed zero.
  1820. *
  1821. * The coreboot ids are used two fold. When running with a coreboot firmware,
  1822. * the ids uniquely matches the coreboot board identification string. When a
  1823. * legacy bios is installed and when autodetection is not possible, these ids
  1824. * can be used to identify the board through the -p internal:mainboard=
  1825. * programmer parameter.
  1826. *
  1827. * When a board is identified through its coreboot ids (in both cases), the
  1828. * main pci ids are still required to match, as a safeguard.
  1829. */
  1830. /* Please keep this list alphabetically ordered by vendor/board name. */
  1831. const struct board_match board_matches[] = {
  1832. /* first pci-id set [4], second pci-id set [4], dmi identifier, coreboot id [2], phase, vendor name, board name max_rom_... OK? flash enable */
  1833. #if defined(__i386__) || defined(__x86_64__)
  1834. {0x10DE, 0x0547, 0x147B, 0x1C2F, 0x10DE, 0x0548, 0x147B, 0x1C2F, NULL, NULL, NULL, P3, "abit", "AN-M2", 0, NT, nvidia_mcp_gpio2_raise},
  1835. {0x1106, 0x0282, 0x147B, 0x1415, 0x1106, 0x3227, 0x147B, 0x1415, "^AV8 ", NULL, NULL, P3, "abit", "AV8", 0, OK, board_abit_av8},
  1836. {0x8086, 0x7190, 0, 0, 0x8086, 0x7110, 0, 0, "^i440BX-W977 (BM6)$", NULL, NULL, P3, "abit", "BM6", 0, OK, intel_piix4_gpo26_lower},
  1837. {0x8086, 0x24d3, 0x147b, 0x1014, 0x8086, 0x2578, 0x147b, 0x1014, NULL, NULL, NULL, P3, "abit", "IC7", 0, NT, intel_ich_gpio23_raise},
  1838. {0x8086, 0x2930, 0x147b, 0x1084, 0x11ab, 0x4364, 0x147b, 0x1084, NULL, NULL, NULL, P3, "abit", "IP35", 0, OK, intel_ich_gpio16_raise},
  1839. {0x8086, 0x2930, 0x147b, 0x1083, 0x10ec, 0x8167, 0x147b, 0x1083, NULL, NULL, NULL, P3, "abit", "IP35 Pro", 0, OK, intel_ich_gpio16_raise},
  1840. {0x10de, 0x0050, 0x147b, 0x1c1a, 0, 0, 0, 0, NULL, NULL, NULL, P3, "abit", "KN8 Ultra", 0, NT, nvidia_mcp_gpio2_lower},
  1841. {0x10de, 0x01e0, 0x147b, 0x1c00, 0x10de, 0x0060, 0x147B, 0x1c00, NULL, NULL, NULL, P3, "abit", "NF7-S", 0, OK, nvidia_mcp_gpio8_raise},
  1842. {0x10de, 0x02f0, 0x147b, 0x1c26, 0x10de, 0x0260, 0x147b, 0x1c26, NULL, NULL, NULL, P3, "abit", "NF-M2 nView", 0, OK, nvidia_mcp_gpio4_lower},
  1843. {0x1106, 0x0691, 0, 0, 0x1106, 0x3057, 0, 0, "(VA6)$", NULL, NULL, P3, "abit", "VA6", 0, OK, via_apollo_gpo4_lower},
  1844. {0x1106, 0x0691, 0, 0, 0x1106, 0x3057, 0, 0, NULL, "abit", "vt6x4", P3, "abit", "VT6X4", 0, OK, via_apollo_gpo4_lower},
  1845. {0x105a, 0x0d30, 0x105a, 0x4d33, 0x8086, 0x1130, 0x8086, 0, NULL, NULL, NULL, P3, "Acorp", "6A815EPD", 0, OK, board_acorp_6a815epd},
  1846. {0x1022, 0x746B, 0, 0, 0, 0, 0, 0, NULL, "AGAMI", "ARUMA", P3, "agami", "Aruma", 0, OK, w83627hf_gpio24_raise_2e},
  1847. {0x1106, 0x3177, 0x17F2, 0x3177, 0x1106, 0x3148, 0x17F2, 0x3148, NULL, NULL, NULL, P3, "Albatron", "PM266A Pro", 0, OK, w836xx_memw_enable_2e},
  1848. {0x1022, 0x2090, 0, 0, 0x1022, 0x2080, 0, 0, NULL, "artecgroup", "dbe61", P3, "Artec Group", "DBE61", 0, OK, board_artecgroup_dbe6x},
  1849. {0x1022, 0x2090, 0, 0, 0x1022, 0x2080, 0, 0, NULL, "artecgroup", "dbe62", P3, "Artec Group", "DBE62", 0, OK, board_artecgroup_dbe6x},
  1850. {0x8086, 0x27b9, 0xa0a0, 0x0632, 0x8086, 0x27da, 0xa0a0, 0x0632, NULL, NULL, NULL, P3, "AOpen", "i945GMx-VFX", 0, OK, intel_ich_gpio38_raise},
  1851. {0x8086, 0x277c, 0xa0a0, 0x060b, 0x8086, 0x27da, 0xa0a0, 0x060b, NULL, NULL, NULL, P3, "AOpen", "i975Xa-YDG", 0, OK, board_aopen_i975xa_ydg},
  1852. {0x8086, 0x27b8, 0x1849, 0x27b8, 0x8086, 0x27da, 0x1849, 0x27da, "^ConRoeXFire-eSATA2", NULL, NULL, P3, "ASRock", "ConRoeXFire-eSATA2", 0, OK, intel_ich_gpio16_raise},
  1853. {0x1039, 0x0741, 0x1849, 0x0741, 0x1039, 0x5513, 0x1849, 0x5513, "^K7S41 $", NULL, NULL, P3, "ASRock", "K7S41", 0, OK, w836xx_memw_enable_2e},
  1854. {0x1039, 0x0741, 0x1849, 0x0741, 0x1039, 0x5513, 0x1849, 0x5513, "^K7S41GX$", NULL, NULL, P3, "ASRock", "K7S41GX", 0, OK, w836xx_memw_enable_2e},
  1855. {0x8086, 0x24D4, 0x1849, 0x24D0, 0x8086, 0x24D5, 0x1849, 0x9739, NULL, NULL, NULL, P3, "ASRock", "P4i65GV", 0, OK, intel_ich_gpio23_raise},
  1856. {0x8086, 0x2570, 0x1849, 0x2570, 0x8086, 0x24d3, 0x1849, 0x24d0, NULL, NULL, NULL, P3, "ASRock", "775i65G", 0, OK, intel_ich_gpio23_raise},
  1857. {0x10DE, 0x0060, 0x1043, 0x80AD, 0x10DE, 0x01E0, 0x1043, 0x80C0, NULL, NULL, NULL, P3, "ASUS", "A7N8X-VM/400", 0, OK, it8712f_gpio12_raise},
  1858. {0x1106, 0x3189, 0x1043, 0x807F, 0x1106, 0x3065, 0x1043, 0x80ED, NULL, NULL, NULL, P3, "ASUS", "A7V600-X", 0, OK, it8712f_gpio31_raise},
  1859. {0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118, NULL, NULL, NULL, P3, "ASUS", "A7V8X-MX SE", 0, OK, w836xx_memw_enable_2e},
  1860. {0x1106, 0x3189, 0x1043, 0x807F, 0x1106, 0x3177, 0x1043, 0x808C, NULL, NULL, NULL, P3, "ASUS", "A7V8X", 0, OK, it8703f_gpio51_raise},
  1861. {0x1106, 0x3099, 0x1043, 0x807F, 0x1106, 0x3147, 0x1043, 0x808C, NULL, NULL, NULL, P3, "ASUS", "A7V333", 0, OK, it8703f_gpio51_raise},
  1862. {0x1106, 0x3189, 0x1043, 0x807F, 0x1106, 0x3177, 0x1043, 0x80A1, NULL, NULL, NULL, P3, "ASUS", "A7V8X-X", 0, OK, it8712f_gpio31_raise},
  1863. {0x1002, 0x4372, 0x103c, 0x2a26, 0x1002, 0x4377, 0x103c, 0x2a26, NULL, NULL, NULL, P3, "ASUS", "A8AE-LE", 0, OK, amd_sbxxx_gpio9_raise},
  1864. {0x8086, 0x27A0, 0x1043, 0x1287, 0x8086, 0x27DF, 0x1043, 0x1287, "^A8J", NULL, NULL, P3, "ASUS", "A8Jm", 0, NT, intel_ich_gpio34_raise},
  1865. {0x10DE, 0x0260, 0x103C, 0x2A34, 0x10DE, 0x0264, 0x103C, 0x2A34, "NODUSM3", NULL, NULL, P3, "ASUS", "A8M2N-LA (NodusM3-GL8E)", 0, OK, nvidia_mcp_gpio0_raise},
  1866. {0x10DE, 0x0260, 0x103c, 0x2a3e, 0x10DE, 0x0264, 0x103c, 0x2a3e, "NAGAMI2L", NULL, NULL, P3, "ASUS", "A8N-LA (Nagami-GL8E)", 0, OK, nvidia_mcp_gpio0_raise},
  1867. {0x10DE, 0x005E, 0x1043, 0x815A, 0x10DE, 0x0054, 0x1043, 0x815A, "^A8N-SLI DELUXE", NULL, NULL, P3, "ASUS", "A8N-SLI Deluxe", 0, NT, board_shuttle_fn25},
  1868. {0x10de, 0x0264, 0x1043, 0x81bc, 0x10de, 0x02f0, 0x1043, 0x81cd, NULL, NULL, NULL, P3, "ASUS", "A8N-VM CSM", 0, OK, w83627ehf_gpio22_raise_2e},
  1869. {0x10DE, 0x0264, 0x1043, 0x81C0, 0x10DE, 0x0260, 0x1043, 0x81C0, NULL, NULL, NULL, P3, "ASUS", "M2NBP-VM CSM", 0, OK, nvidia_mcp_gpio0_raise},
  1870. {0x1106, 0x1336, 0x1043, 0x80ed, 0x1106, 0x3288, 0x1043, 0x8249, NULL, NULL, NULL, P3, "ASUS", "M2V-MX", 0, OK, via_vt823x_gpio5_raise},
  1871. {0x8086, 0x24cc, 0, 0, 0x8086, 0x24c3, 0x1043, 0x1869, "^M6Ne$", NULL, NULL, P3, "ASUS", "M6Ne", 0, NT, intel_ich_gpio43_raise},
  1872. {0x8086, 0x7190, 0, 0, 0x8086, 0x7110, 0, 0, "^P2B-N$", NULL, NULL, P3, "ASUS", "P2B-N", 0, OK, intel_piix4_gpo18_lower},
  1873. {0x8086, 0x1A30, 0x1043, 0x8025, 0x8086, 0x244B, 0x104D, 0x80F0, NULL, NULL, NULL, P3, "ASUS", "P4B266-LM", 0, OK, intel_ich_gpio21_raise},
  1874. {0x8086, 0x1a30, 0x1043, 0x8070, 0x8086, 0x244b, 0x1043, 0x8028, NULL, NULL, NULL, P3, "ASUS", "P4B266", 0, OK, intel_ich_gpio22_raise},
  1875. {0x8086, 0x1A30, 0x1043, 0x8088, 0x8086, 0x24C3, 0x1043, 0x8089, NULL, NULL, NULL, P3, "ASUS", "P4B533-E", 0, NT, intel_ich_gpio22_raise},
  1876. {0x8086, 0x2560, 0x103C, 0x2A00, 0x8086, 0x24C3, 0x103C, 0x2A01, "^Guppy", NULL, NULL, P3, "ASUS", "P4GV-LA (Guppy)", 0, OK, intel_ich_gpio21_raise},
  1877. {0x8086, 0x24D3, 0x1043, 0x80A6, 0x8086, 0x2578, 0x1043, 0x80F6, NULL, NULL, NULL, P3, "ASUS", "P4C800-E Deluxe", 0, OK, intel_ich_gpio21_raise},
  1878. {0x8086, 0x2570, 0x1043, 0x80F2, 0x8086, 0x24D5, 0x1043, 0x80F3, NULL, NULL, NULL, P3, "ASUS", "P4P800", 0, NT, intel_ich_gpio21_raise},
  1879. {0x8086, 0x2570, 0x1043, 0x80F2, 0x8086, 0x24D3, 0x1043, 0x80A6, "^P4P800-E$", NULL, NULL, P3, "ASUS", "P4P800-E Deluxe", 0, OK, intel_ich_gpio21_raise},
  1880. {0x8086, 0x2570, 0x1043, 0x80A5, 0x8086, 0x24d0, 0, 0, NULL, NULL, NULL, P3, "ASUS", "P4P800-VM", 0, OK, intel_ich_gpio21_raise},
  1881. {0x1039, 0x0651, 0x1043, 0x8081, 0x1039, 0x0962, 0, 0, NULL, NULL, NULL, P3, "ASUS", "P4SC-E", 0, OK, it8707f_write_enable_2e},
  1882. {0x8086, 0x2570, 0x1043, 0x80A5, 0x105A, 0x24D3, 0x1043, 0x80A6, NULL, NULL, NULL, P3, "ASUS", "P4SD-LA", 0, NT, intel_ich_gpio32_raise},
  1883. {0x1039, 0x0661, 0x1043, 0x8113, 0x1039, 0x5513, 0x1043, 0x8087, NULL, NULL, NULL, P3, "ASUS", "P4S800-MX", 512, OK, w836xx_memw_enable_2e},
  1884. {0x10B9, 0x1541, 0, 0, 0x10B9, 0x1533, 0, 0, "^P5A$", "asus", "p5a", P3, "ASUS", "P5A", 0, OK, board_asus_p5a},
  1885. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x814e, "^P5GD1 PRO$", NULL, NULL, P3, "ASUS", "P5GD1 Pro", 0, OK, intel_ich_gpio21_raise},
  1886. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x814e, "^P5GD1-VM$", NULL, NULL, P3, "ASUS", "P5GD1-VM/S", 0, OK, intel_ich_gpio21_raise},
  1887. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x814e, NULL, NULL, NULL, P3, "ASUS", "P5GD1(-VM)", 0, NT, intel_ich_gpio21_raise},
  1888. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x813d, "^P5GD2-Premium$", NULL, NULL, P3, "ASUS", "P5GD2 Premium", 0, OK, intel_ich_gpio21_raise},
  1889. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x813d, "^P5GDC-V$", NULL, NULL, P3, "ASUS", "P5GDC-V Deluxe", 0, OK, intel_ich_gpio21_raise},
  1890. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x813d, "^P5GDC$", NULL, NULL, P3, "ASUS", "P5GDC Deluxe", 0, OK, intel_ich_gpio21_raise},
  1891. {0x8086, 0x266a, 0x1043, 0x80a6, 0x8086, 0x2668, 0x1043, 0x813d, NULL, NULL, NULL, P3, "ASUS", "P5GD2/C variants", 0, NT, intel_ich_gpio21_raise},
  1892. {0x8086, 0x27b8, 0x103c, 0x2a22, 0x8086, 0x2770, 0x103c, 0x2a22, "^LITHIUM$", NULL, NULL, P3, "ASUS", "P5LP-LE (Lithium-UL8E)",0, OK, intel_ich_gpio34_raise},
  1893. {0x8086, 0x27b8, 0x1043, 0x2a22, 0x8086, 0x2770, 0x1043, 0x2a22, "^P5LP-LE$", NULL, NULL, P3, "ASUS", "P5LP-LE (Epson OEM)", 0, OK, intel_ich_gpio34_raise},
  1894. {0x8086, 0x27da, 0x1043, 0x8179, 0x8086, 0x27b8, 0x1043, 0x8179, "^P5LD2$", NULL, NULL, P3, "ASUS", "P5LD2", 0, NT, intel_ich_gpio16_raise},
  1895. {0x10DE, 0x0030, 0x1043, 0x818a, 0x8086, 0x100E, 0x1043, 0x80EE, NULL, NULL, NULL, P3, "ASUS", "P5ND2-SLI Deluxe", 0, OK, nvidia_mcp_gpio10_raise},
  1896. {0x10DE, 0x0260, 0x1043, 0x81BC, 0x10DE, 0x026C, 0x1043, 0x829E, "^P5N-D$", NULL, NULL, P3, "ASUS", "P5N-D", 0, OK, it8718f_gpio63_raise},
  1897. {0x10DE, 0x0260, 0x1043, 0x81BC, 0x10DE, 0x026C, 0x1043, 0x8249, "^P5N-E SLI$",NULL, NULL, P3, "ASUS", "P5N-E SLI", 0, NT, it8718f_gpio63_raise},
  1898. {0x8086, 0x24dd, 0x1043, 0x80a6, 0x8086, 0x2570, 0x1043, 0x8157, NULL, NULL, NULL, P3, "ASUS", "P5PE-VM", 0, OK, intel_ich_gpio21_raise},
  1899. {0x10b7, 0x9055, 0x1028, 0x0082, 0x8086, 0x7190, 0, 0, NULL, NULL, NULL, P3, "Dell", "OptiPlex GX1", 0, OK, intel_piix4_gpo30_lower},
  1900. {0x8086, 0x3590, 0x1028, 0x016c, 0x1000, 0x0030, 0x1028, 0x016c, NULL, NULL, NULL, P3, "Dell", "PowerEdge 1850", 0, OK, intel_ich_gpio23_raise},
  1901. {0x10de, 0x03ea, 0x1019, 0x2602, 0x10de, 0x03e0, 0x1019, 0x2602, NULL, NULL, NULL, P3, "Elitegroup", "GeForce6100SM-M", 0, OK, board_ecs_geforce6100sm_m},
  1902. {0x1106, 0x3038, 0x1019, 0x0996, 0x1106, 0x3177, 0x1019, 0x0996, NULL, NULL, NULL, P3, "Elitegroup", "K7VTA3", 256, OK, NULL},
  1903. {0x1106, 0x3177, 0x1106, 0x3177, 0x1106, 0x3059, 0x1695, 0x3005, NULL, NULL, NULL, P3, "EPoX", "EP-8K5A2", 0, OK, w836xx_memw_enable_2e},
  1904. {0x10DE, 0x005E, 0x1695, 0x1010, 0x10DE, 0x0050, 0x1695, 0x1010, "8NPA7I", NULL, NULL, P3, "EPoX", "EP-8NPA7I", 0, OK, nvidia_mcp_gpio4_raise},
  1905. {0x10DE, 0x005E, 0x1695, 0x1010, 0x10DE, 0x0050, 0x1695, 0x1010, "9NPA7I", NULL, NULL, P3, "EPoX", "EP-9NPA7I", 0, OK, nvidia_mcp_gpio4_raise},
  1906. {0x10EC, 0x8139, 0x1695, 0x9001, 0x11C1, 0x5811, 0x1695, 0x9015, NULL, NULL, NULL, P3, "EPoX", "EP-8RDA3+", 0, OK, nvidia_mcp_gpio31_raise},
  1907. {0x8086, 0x7110, 0, 0, 0x8086, 0x7190, 0, 0, NULL, "epox", "ep-bx3", P3, "EPoX", "EP-BX3", 0, NT, intel_piix4_gpo22_raise},
  1908. {0x10de, 0x02f0, 0x105b, 0x0d01, 0x10de, 0x0264, 0x105b, 0x0d01, NULL, NULL, NULL, P3, "Foxconn", "6150K8MD-8EKRSH", 0, NT, nvidia_mcp_gpio2_raise},
  1909. {0x8086, 0x2443, 0x8086, 0x2442, 0x8086, 0x1130, 0x8086, 0x1130, "^6IEM ", NULL, NULL, P3, "GIGABYTE", "GA-6IEM", 0, NT, intel_ich_gpio25_raise},
  1910. {0x1106, 0x0686, 0x1106, 0x0686, 0x1106, 0x3058, 0x1458, 0xa000, NULL, NULL, NULL, P3, "GIGABYTE", "GA-7ZM", 512, OK, NULL},
  1911. {0x8086, 0x2570, 0x1458, 0x2570, 0x8086, 0x24d0, 0, 0, "^8IP775/-G$",NULL, NULL, P3, "GIGABYTE", "GA-8IP775", 0, OK, intel_ich_gpio32_raise},
  1912. {0x8086, 0x244b, 0x8086, 0x2442, 0x8086, 0x2445, 0x1458, 0xa002, NULL, NULL, NULL, P3, "GIGABYTE", "GA-8IRML", 0, OK, intel_ich_gpio25_raise},
  1913. {0x8086, 0x24c3, 0x1458, 0x24c2, 0x8086, 0x24cd, 0x1458, 0x5004, NULL, NULL, NULL, P3, "GIGABYTE", "GA-8PE667 Ultra 2", 0, OK, intel_ich_gpio32_raise},
  1914. {0x1039, 0x0651, 0x1039, 0x0651, 0x1039, 0x7002, 0x1458, 0x5004, "^GA-8SIMLH$",NULL, NULL, P3, "GIGABYTE", "GA-8SIMLH", 0, OK, sis_gpio0_raise_and_w836xx_memw},
  1915. {0x10DE, 0x02F1, 0x1458, 0x5000, 0x10DE, 0x0261, 0x1458, 0x5001, NULL, NULL, NULL, P3, "GIGABYTE", "GA-K8N51GMF", 0, OK, nvidia_mcp_gpio3b_raise},
  1916. {0x10DE, 0x026C, 0x1458, 0xA102, 0x10DE, 0x0260, 0x1458, 0x5001, NULL, NULL, NULL, P3, "GIGABYTE", "GA-K8N51GMF-9", 0, OK, nvidia_mcp_gpio3b_raise},
  1917. {0x10de, 0x00e4, 0x1458, 0x0c11, 0x10de, 0x00e0, 0x1458, 0x0c11, NULL, NULL, NULL, P3, "GIGABYTE", "GA-K8NS Pro-939", 0, NT, nvidia_mcp_gpio0a_raise},
  1918. {0x10DE, 0x0050, 0x1458, 0x0C11, 0x10DE, 0x005e, 0x1458, 0x5000, NULL, NULL, NULL, P3, "GIGABYTE", "GA-K8N-SLI", 0, OK, nvidia_mcp_gpio21_raise},
  1919. {0x8086, 0x2415, 0x103c, 0x1250, 0x10b7, 0x9200, 0x103c, 0x1247, NULL, NULL, NULL, P3, "HP", "e-Vectra P2706T", 0, OK, board_hp_p2706t},
  1920. {0x1166, 0x0223, 0x103c, 0x320d, 0x14e4, 0x1678, 0x103c, 0x703e, NULL, "hp", "dl145_g3", P3, "HP", "ProLiant DL145 G3", 0, OK, board_hp_dl145_g3_enable},
  1921. {0x1166, 0x0223, 0x103c, 0x320d, 0x14e4, 0x1648, 0x103c, 0x310f, NULL, "hp", "dl165_g6", P3, "HP", "ProLiant DL165 G6", 0, OK, board_hp_dl165_g6_enable},
  1922. {0x8086, 0x2580, 0x103c, 0x2a08, 0x8086, 0x2640, 0x103c, 0x2a0a, NULL, NULL, NULL, P3, "HP", "Puffer2-UL8E", 0, OK, intel_ich_gpio18_raise},
  1923. {0x8086, 0x2415, 0x103c, 0x1249, 0x10b7, 0x9200, 0x103c, 0x1246, NULL, NULL, NULL, P3, "HP", "Vectra VL400", 0, OK, board_hp_vl400},
  1924. {0x8086, 0x1a30, 0x103c, 0x1a30, 0x8086, 0x2443, 0x103c, 0x2440, "^VL420$", NULL, NULL, P3, "HP", "Vectra VL420 SFF", 0, OK, intel_ich_gpio22_raise},
  1925. {0x10de, 0x0369, 0x103c, 0x12fe, 0x10de, 0x0364, 0x103c, 0x12fe, NULL, "hp", "xw9400", P3, "HP", "xw9400", 0, OK, nvidia_mcp_gpio5_raise},
  1926. {0x8086, 0x27A0, 0, 0, 0x8086, 0x27B9, 0, 0, NULL, "ibase", "mb899", P3, "IBASE", "MB899", 0, OK, intel_ich_gpio26_raise},
  1927. {0x1166, 0x0205, 0x1014, 0x0347, 0x1002, 0x515E, 0x1014, 0x0325, NULL, NULL, NULL, P3, "IBM", "x3455", 0, OK, board_ibm_x3455},
  1928. {0x1039, 0x5513, 0x8086, 0xd61f, 0x1039, 0x6330, 0x8086, 0xd61f, NULL, NULL, NULL, P3, "Intel", "D201GLY", 0, OK, wbsio_check_for_spi},
  1929. {0x8086, 0x7190, 0, 0, 0x8086, 0x7110, 0, 0, "^SE440BX-2$", NULL, NULL, P3, "Intel", "SE440BX-2", 0, NT, intel_piix4_gpo27_lower},
  1930. {0x1022, 0x7468, 0, 0, 0, 0, 0, 0, NULL, "iwill", "dk8_htx", P3, "IWILL", "DK8-HTX", 0, OK, w83627hf_gpio24_raise_2e},
  1931. {0x8086, 0x27A0, 0x8086, 0x27a0, 0x8086, 0x27b8, 0x8086, 0x27b8, NULL, "kontron", "986lcd-m", P3, "Kontron", "986LCD-M", 0, OK, board_kontron_986lcd_m},
  1932. {0x8086, 0x2411, 0x8086, 0x2411, 0x8086, 0x7125, 0x0e11, 0xb165, NULL, NULL, NULL, P3, "Mitac", "6513WU", 0, OK, board_mitac_6513wu},
  1933. {0x8086, 0x8186, 0x8086, 0x8186, 0x8086, 0x8800, 0x0000, 0x0000, "^MSC Vertriebs GmbH$", NULL, NULL, P2, "MSC", "Q7-TCTC", 0, OK, p2_not_a_laptop},
  1934. {0x10DE, 0x005E, 0x1462, 0x7125, 0x10DE, 0x0052, 0x1462, 0x7125, NULL, NULL, NULL, P3, "MSI", "K8N Neo4-F", 0, OK, nvidia_mcp_gpio2_raise}, /* TODO: Should probably be K8N Neo4 Platinum, see http://www.coreboot.org/pipermail/flashrom/2010-August/004362.html. */
  1935. {0x8086, 0x7190, 0, 0, 0x8086, 0x7110, 0, 0, "^MS-6163 (i440BX)$", NULL, NULL, P3, "MSI", "MS-6163 (MS-6163 Pro)", 0, OK, intel_piix4_gpo14_raise},
  1936. {0x1039, 0x0745, 0, 0, 0x1039, 0x0018, 0, 0, "^MS-6561", NULL, NULL, P3, "MSI", "MS-6561 (745 Ultra)", 0, OK, w836xx_memw_enable_2e},
  1937. {0x8086, 0x2560, 0x1462, 0x5770, 0x8086, 0x2562, 0x1462, 0x5778, NULL, NULL, NULL, P3, "MSI", "MS-6577 (Xenon)", 0, OK, w83627hf_gpio25_raise_2e},
  1938. {0x13f6, 0x0111, 0x1462, 0x5900, 0x1106, 0x3177, 0x1106, 0, NULL, NULL, NULL, P3, "MSI", "MS-6590 (KT4 Ultra)", 0, OK, board_msi_kt4v},
  1939. {0x1106, 0x3149, 0x1462, 0x7094, 0x10ec, 0x8167, 0x1462, 0x094c, NULL, NULL, NULL, P3, "MSI", "MS-6702E (K8T Neo2-F)", 0, OK, w83627thf_gpio44_raise_2e},
  1940. {0x1106, 0x0571, 0x1462, 0x7120, 0x1106, 0x3065, 0x1462, 0x7120, NULL, NULL, NULL, P3, "MSI", "MS-6712 (KT4V)", 0, OK, board_msi_kt4v},
  1941. {0x1106, 0x3148, 0 , 0 , 0x1106, 0x3177, 0 , 0 , NULL, "msi", "ms6787", P3, "MSI", "MS-6787 (P4MAM-V/P4MAM-L)", 0, OK, w836xx_memw_enable_2e},
  1942. {0x8086, 0x24d3, 0x1462, 0x7880, 0x8086, 0x2570, 0, 0, NULL, NULL, NULL, P3, "MSI", "MS-6788-040 (848P NeoV)", 0, OK, intel_ich_gpio32_raise},
  1943. {0x1039, 0x7012, 0x1462, 0x0050, 0x1039, 0x6325, 0x1462, 0x0058, NULL, NULL, NULL, P3, "MSI", "MS-7005 (651M-L)", 0, OK, sis_gpio0_raise_and_w836xx_memw},
  1944. {0x10DE, 0x00E0, 0x1462, 0x0250, 0x10DE, 0x00E1, 0x1462, 0x0250, NULL, NULL, NULL, P3, "MSI", "MS-7025 (K8N Neo2 Platinum)", 0, OK, nvidia_mcp_gpio0c_raise},
  1945. {0x8086, 0x2658, 0x1462, 0x7046, 0x1106, 0x3044, 0x1462, 0x046d, NULL, NULL, NULL, P3, "MSI", "MS-7046", 0, OK, intel_ich_gpio19_raise},
  1946. {0x8086, 0x244b, 0x1462, 0x3910, 0x8086, 0x2442, 0x1462, 0x3910, NULL, NULL, NULL, P3, "MSI", "MS-6391 (845 Pro4)", 0, OK, intel_ich_gpio23_raise},
  1947. {0x1106, 0x3149, 0x1462, 0x7061, 0x1106, 0x3227, 0, 0, NULL, NULL, NULL, P3, "MSI", "MS-7061 (KM4M-V/KM4AM-V)", 0, OK, w836xx_memw_enable_2e},
  1948. {0x10DE, 0x005E, 0x1462, 0x7135, 0x10DE, 0x0050, 0x1462, 0x7135, NULL, "msi", "k8n-neo3", P3, "MSI", "MS-7135 (K8N Neo3)", 0, OK, w83627thf_gpio44_raise_4e},
  1949. {0x10DE, 0x0270, 0x1462, 0x7207, 0x10DE, 0x0264, 0x1462, 0x7207, NULL, NULL, NULL, P3, "MSI", "MS-7207 (K8NGM2-L)", 0, NT, nvidia_mcp_gpio2_raise},
  1950. {0x1011, 0x0019, 0xaa55, 0xaa55, 0x8086, 0x7190, 0, 0, NULL, NULL, NULL, P3, "Nokia", "IP530", 0, OK, fdc37b787_gpio50_raise_3f0},
  1951. {0x8086, 0x24d3, 0x144d, 0xb025, 0x8086, 0x1050, 0x144d, 0xb025, NULL, NULL, NULL, P3, "Samsung", "Polaris 32", 0, OK, intel_ich_gpio21_raise},
  1952. {0x1106, 0x3099, 0, 0, 0x1106, 0x3074, 0, 0, NULL, "shuttle", "ak31", P3, "Shuttle", "AK31", 0, OK, w836xx_memw_enable_2e},
  1953. {0x1106, 0x3104, 0x1297, 0xa238, 0x1106, 0x3059, 0x1297, 0xc063, NULL, NULL, NULL, P3, "Shuttle", "AK38N", 256, OK, NULL},
  1954. {0x10DE, 0x0050, 0x1297, 0x5036, 0x1412, 0x1724, 0x1297, 0x5036, NULL, NULL, NULL, P3, "Shuttle", "FN25", 0, OK, board_shuttle_fn25},
  1955. {0x1106, 0x3038, 0x0925, 0x1234, 0x1106, 0x3058, 0x15DD, 0x7609, NULL, NULL, NULL, P3, "Soyo", "SY-7VCA", 0, OK, via_apollo_gpo0_lower},
  1956. {0x10de, 0x0364, 0x108e, 0x6676, 0x10de, 0x0369, 0x108e, 0x6676, "^Sun Ultra 40 M2", NULL, NULL, P3, "Sun", "Ultra 40 M2", 0, OK, board_sun_ultra_40_m2},
  1957. {0x1106, 0x3038, 0x0925, 0x1234, 0x1106, 0x0596, 0x1106, 0, NULL, NULL, NULL, P3, "Tekram", "P6Pro-A5", 256, OK, NULL},
  1958. {0x1106, 0x3123, 0x1106, 0x3123, 0x1106, 0x3059, 0x1106, 0x4161, NULL, NULL, NULL, P3, "Termtek", "TK-3370 (Rev:2.5B)", 0, OK, w836xx_memw_enable_4e},
  1959. {0x8086, 0x7120, 0x109f, 0x3157, 0x8086, 0x2410, 0, 0, NULL, NULL, NULL, P3, "TriGem", "Anaheim-3", 0, OK, intel_ich_gpio22_raise},
  1960. {0x8086, 0x1076, 0x8086, 0x1176, 0x1106, 0x3059, 0x10f1, 0x2498, NULL, NULL, NULL, P3, "Tyan", "S2498 (Tomcat K7M)", 0, OK, w836xx_memw_enable_2e},
  1961. {0x1106, 0x0259, 0x1106, 0xAA07, 0x1106, 0x3227, 0x1106, 0xAA07, NULL, NULL, NULL, P3, "VIA", "EPIA EK", 0, NT, via_vt823x_gpio9_raise},
  1962. {0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01, NULL, NULL, NULL, P3, "VIA", "EPIA M/MII/...", 0, OK, via_vt823x_gpio15_raise},
  1963. {0x1106, 0x0259, 0x1106, 0x3227, 0x1106, 0x3065, 0x1106, 0x3149, NULL, NULL, NULL, P3, "VIA", "EPIA-N/NL", 0, OK, via_vt823x_gpio9_raise},
  1964. #endif
  1965. { 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, P3, NULL, NULL, 0, NT, NULL}, /* end marker */
  1966. };
  1967. /*
  1968. * Match boards on coreboot table gathered vendor and part name.
  1969. * Require main PCI IDs to match too as extra safety.
  1970. */
  1971. static const struct board_match *board_match_cbname(const char *vendor,
  1972. const char *part)
  1973. {
  1974. const struct board_match *board = board_matches;
  1975. const struct board_match *partmatch = NULL;
  1976. for (; board->vendor_name; board++) {
  1977. if (vendor && (!board->lb_vendor
  1978. || strcasecmp(board->lb_vendor, vendor)))
  1979. continue;
  1980. if (!board->lb_part || strcasecmp(board->lb_part, part))
  1981. continue;
  1982. if (!pci_dev_find(board->first_vendor, board->first_device))
  1983. continue;
  1984. if (board->second_vendor &&
  1985. !pci_dev_find(board->second_vendor, board->second_device))
  1986. continue;
  1987. if (vendor)
  1988. return board;
  1989. if (partmatch) {
  1990. /* a second entry has a matching part name */
  1991. msg_pinfo("AMBIGUOUS BOARD NAME: %s\n", part);
  1992. msg_pinfo("At least vendors '%s' and '%s' match.\n",
  1993. partmatch->lb_vendor, board->lb_vendor);
  1994. msg_perr("Please use the full -p internal:mainboard=vendor:part syntax.\n");
  1995. return NULL;
  1996. }
  1997. partmatch = board;
  1998. }
  1999. if (partmatch)
  2000. return partmatch;
  2001. if (!partvendor_from_cbtable) {
  2002. /* Only warn if the mainboard type was not gathered from the
  2003. * coreboot table. If it was, the coreboot implementor is
  2004. * expected to fix flashrom, too.
  2005. */
  2006. msg_perr("\nUnknown vendor:board from -p internal:mainboard= programmer parameter:\n%s:%s\n\n",
  2007. vendor, part);
  2008. }
  2009. return NULL;
  2010. }
  2011. /*
  2012. * Match boards on PCI IDs and subsystem IDs.
  2013. * Second set of IDs can be either main+subsystem IDs, main IDs or no IDs.
  2014. */
  2015. const static struct board_match *board_match_pci_ids(enum board_match_phase phase)
  2016. {
  2017. const struct board_match *board = board_matches;
  2018. for (; board->vendor_name; board++) {
  2019. if ((!board->first_card_vendor || !board->first_card_device) &&
  2020. !board->dmi_pattern)
  2021. continue;
  2022. if (board->phase != phase)
  2023. continue;
  2024. if (!pci_card_find(board->first_vendor, board->first_device,
  2025. board->first_card_vendor,
  2026. board->first_card_device))
  2027. continue;
  2028. if (board->second_vendor) {
  2029. if (board->second_card_vendor) {
  2030. if (!pci_card_find(board->second_vendor,
  2031. board->second_device,
  2032. board->second_card_vendor,
  2033. board->second_card_device))
  2034. continue;
  2035. } else {
  2036. if (!pci_dev_find(board->second_vendor,
  2037. board->second_device))
  2038. continue;
  2039. }
  2040. }
  2041. if (board->dmi_pattern) {
  2042. if (!has_dmi_support) {
  2043. msg_perr("WARNING: Can't autodetect %s %s,"
  2044. " DMI info unavailable.\n",
  2045. board->vendor_name, board->board_name);
  2046. continue;
  2047. } else {
  2048. if (!dmi_match(board->dmi_pattern))
  2049. continue;
  2050. }
  2051. }
  2052. return board;
  2053. }
  2054. return NULL;
  2055. }
  2056. static int unsafe_board_handler(const struct board_match *board)
  2057. {
  2058. if (!board)
  2059. return 1;
  2060. if (board->status == OK)
  2061. return 0;
  2062. if (!force_boardenable) {
  2063. msg_pinfo("WARNING: Your mainboard is %s %s, but the mainboard-specific\n"
  2064. "code has not been tested, and thus will not be executed by default.\n"
  2065. "Depending on your hardware environment, erasing, writing or even probing\n"
  2066. "can fail without running the board specific code.\n\n"
  2067. "Please see the man page (section PROGRAMMER SPECIFIC INFO, subsection\n"
  2068. "\"internal programmer\") for details.\n",
  2069. board->vendor_name, board->board_name);
  2070. return 1;
  2071. }
  2072. msg_pinfo("NOTE: Running an untested board enable procedure.\n"
  2073. "Please report success/failure to flashrom@flashrom.org\n"
  2074. "with your board name and SUCCESS or FAILURE in the subject.\n");
  2075. return 0;
  2076. }
  2077. /* FIXME: Should this be identical to board_flash_enable? */
  2078. static int board_handle_phase(enum board_match_phase phase)
  2079. {
  2080. const struct board_match *board = NULL;
  2081. board = board_match_pci_ids(phase);
  2082. if (unsafe_board_handler(board))
  2083. board = NULL;
  2084. if (!board)
  2085. return 0;
  2086. if (!board->enable) {
  2087. /* Not sure if there is a valid case for this. */
  2088. msg_perr("Board match found, but nothing to do?\n");
  2089. return 0;
  2090. }
  2091. return board->enable();
  2092. }
  2093. void board_handle_before_superio(void)
  2094. {
  2095. board_handle_phase(P1);
  2096. }
  2097. void board_handle_before_laptop(void)
  2098. {
  2099. board_handle_phase(P2);
  2100. }
  2101. int board_flash_enable(const char *vendor, const char *part)
  2102. {
  2103. const struct board_match *board = NULL;
  2104. int ret = 0;
  2105. if (part)
  2106. board = board_match_cbname(vendor, part);
  2107. if (!board)
  2108. board = board_match_pci_ids(P3);
  2109. if (unsafe_board_handler(board))
  2110. board = NULL;
  2111. if (board) {
  2112. if (board->max_rom_decode_parallel)
  2113. max_rom_decode.parallel =
  2114. board->max_rom_decode_parallel * 1024;
  2115. if (board->enable != NULL) {
  2116. msg_pinfo("Disabling flash write protection for "
  2117. "board \"%s %s\"... ", board->vendor_name,
  2118. board->board_name);
  2119. ret = board->enable();
  2120. if (ret)
  2121. msg_pinfo("FAILED!\n");
  2122. else
  2123. msg_pinfo("OK.\n");
  2124. }
  2125. }
  2126. return ret;
  2127. }