blob: 907774d9d4340e6f599bc511c3853e1d4d694169 [file] [log] [blame]
Luc Verhaegen8e3a6002007-04-04 22:45:58 +00001/*
Uwe Hermannd1107642007-08-29 17:52:32 +00002 * This file is part of the flashrom project.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +00003 *
Uwe Hermannd1107642007-08-29 17:52:32 +00004 * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de>
5 * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
Luc Verhaegen97866082008-02-09 02:03:06 +00006 * Copyright (C) 2007-2008 Luc Verhaegen <libv@skynet.be>
Carl-Daniel Hailfinger92242622007-09-27 14:29:57 +00007 * Copyright (C) 2007 Carl-Daniel Hailfinger
Luc Verhaegen8e3a6002007-04-04 22:45:58 +00008 *
Uwe Hermannd1107642007-08-29 17:52:32 +00009 * 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.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000012 *
Uwe Hermannd1107642007-08-29 17:52:32 +000013 * 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
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000021 */
22
23/*
24 * Contains the board specific flash enables.
25 */
26
27#include <stdio.h>
28#include <pci/pci.h>
29#include <stdint.h>
30#include <string.h>
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000031#include "flash.h"
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000032
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000033/*
Uwe Hermannffec5f32007-08-23 16:08:21 +000034 * Helper functions for many Winbond Super I/Os of the W836xx range.
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000035 */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000036/* Enter extended functions */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000037static void w836xx_ext_enter(uint16_t port)
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000038{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000039 outb(0x87, port);
40 outb(0x87, port);
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000041}
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000042
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000043/* Leave extended functions */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000044static void w836xx_ext_leave(uint16_t port)
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000045{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000046 outb(0xAA, port);
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000047}
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000048
Uwe Hermannffec5f32007-08-23 16:08:21 +000049/* General functions for reading/writing Winbond Super I/Os. */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000050static unsigned char wbsio_read(uint16_t index, uint8_t reg)
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000051{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000052 outb(reg, index);
Uwe Hermann372eeb52007-12-04 21:49:06 +000053 return inb(index + 1);
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000054}
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000055
Ronald G. Minnichfa496922007-10-12 21:22:40 +000056static void wbsio_write(uint16_t index, uint8_t reg, uint8_t data)
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000057{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000058 outb(reg, index);
Uwe Hermann372eeb52007-12-04 21:49:06 +000059 outb(data, index + 1);
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000060}
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000061
Ronald G. Minnichfa496922007-10-12 21:22:40 +000062static void wbsio_mask(uint16_t index, uint8_t reg, uint8_t data, uint8_t mask)
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000063{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000064 uint8_t tmp;
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000065
Ronald G. Minnichfa496922007-10-12 21:22:40 +000066 outb(reg, index);
Uwe Hermann372eeb52007-12-04 21:49:06 +000067 tmp = inb(index + 1) & ~mask;
68 outb(tmp | (data & mask), index + 1);
Mondrian Nuessleaef1c7c2007-05-03 10:09:23 +000069}
70
Uwe Hermannffec5f32007-08-23 16:08:21 +000071/**
72 * Winbond W83627HF: Raise GPIO24.
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000073 *
74 * Suited for:
Uwe Hermannffec5f32007-08-23 16:08:21 +000075 * - Agami Aruma
76 * - IWILL DK8-HTX
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000077 */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000078static int w83627hf_gpio24_raise(uint16_t index, const char *name)
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000079{
Ronald G. Minnichfa496922007-10-12 21:22:40 +000080 w836xx_ext_enter(index);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000081
Uwe Hermann372eeb52007-12-04 21:49:06 +000082 /* Is this the W83627HF? */
83 if (wbsio_read(index, 0x20) != 0x52) { /* Super I/O device ID reg. */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000084 fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n",
Ronald G. Minnichfa496922007-10-12 21:22:40 +000085 name, wbsio_read(index, 0x20));
86 w836xx_ext_leave(index);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000087 return -1;
88 }
89
Luc Verhaegen7977f4e2007-05-04 04:47:04 +000090 /* PIN89S: WDTO/GP24 multiplex -> GPIO24 */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000091 wbsio_mask(index, 0x2B, 0x10, 0x10);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000092
Uwe Hermann372eeb52007-12-04 21:49:06 +000093 /* Select logical device 8: GPIO port 2 */
94 wbsio_write(index, 0x07, 0x08);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000095
Ronald G. Minnichfa496922007-10-12 21:22:40 +000096 wbsio_mask(index, 0x30, 0x01, 0x01); /* Activate logical device. */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000097 wbsio_mask(index, 0xF0, 0x00, 0x10); /* GPIO24 -> output */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000098 wbsio_mask(index, 0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */
Ronald G. Minnichfa496922007-10-12 21:22:40 +000099 wbsio_mask(index, 0xF1, 0x10, 0x10); /* Raise GPIO24 */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +0000100
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000101 w836xx_ext_leave(index);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000102
103 return 0;
104}
105
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000106static int w83627hf_gpio24_raise_2e(const char *name)
107{
Uwe Hermann372eeb52007-12-04 21:49:06 +0000108 /* TODO: Typo? Shouldn't this be 0x2e? */
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000109 return w83627hf_gpio24_raise(0x2d, name);
110}
111
112/**
113 * Winbond W83627THF: GPIO 4, bit 4
114 *
115 * Suited for:
116 * - MSI K8N-NEO3
117 */
118static int w83627thf_gpio4_4_raise(uint16_t index, const char *name)
119{
120 w836xx_ext_enter(index);
Uwe Hermann372eeb52007-12-04 21:49:06 +0000121
122 /* Is this the W83627THF? */
123 if (wbsio_read(index, 0x20) != 0x82) { /* Super I/O device ID reg. */
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000124 fprintf(stderr, "\nERROR: %s: W83627THF: Wrong ID: 0x%02X.\n",
125 name, wbsio_read(index, 0x20));
126 w836xx_ext_leave(index);
127 return -1;
128 }
129
130 /* PINxxxxS: GPIO4/bit 4 multiplex -> GPIOXXX */
131
Uwe Hermann372eeb52007-12-04 21:49:06 +0000132 wbsio_write(index, 0x07, 0x09); /* Select LDN 9: GPIO port 4 */
133 wbsio_mask(index, 0x30, 0x02, 0x02); /* Activate logical device. */
134 wbsio_mask(index, 0xF4, 0x00, 0x10); /* GPIO4 bit 4 -> output */
135 wbsio_mask(index, 0xF6, 0x00, 0x10); /* Clear GPIO4 bit 4 inversion */
136 wbsio_mask(index, 0xF5, 0x10, 0x10); /* Raise GPIO4 bit 4 */
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000137
138 w836xx_ext_leave(index);
139
140 return 0;
141}
142
143static int w83627thf_gpio4_4_raise_4e(const char *name)
144{
Uwe Hermann372eeb52007-12-04 21:49:06 +0000145 return w83627thf_gpio4_4_raise(0x4e, name);
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000146}
Uwe Hermann372eeb52007-12-04 21:49:06 +0000147
Uwe Hermannffec5f32007-08-23 16:08:21 +0000148/**
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000149 * Suited for VIAs EPIA M and MII, and maybe other CLE266 based EPIAs.
150 *
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000151 * We don't need to do this when using coreboot, GPIO15 is never lowered there.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000152 */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +0000153static int board_via_epia_m(const char *name)
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000154{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000155 struct pci_dev *dev;
Uwe Hermann372eeb52007-12-04 21:49:06 +0000156 uint16_t base;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000157 uint8_t val;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000158
Uwe Hermanna7e05482007-05-09 10:17:44 +0000159 dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
160 if (!dev) {
Uwe Hermanna502dce2007-10-17 23:55:15 +0000161 fprintf(stderr, "\nERROR: VT8235 ISA bridge not found.\n");
Uwe Hermanna7e05482007-05-09 10:17:44 +0000162 return -1;
163 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000164
Uwe Hermanna7e05482007-05-09 10:17:44 +0000165 /* GPIO12-15 -> output */
166 val = pci_read_byte(dev, 0xE4);
167 val |= 0x10;
168 pci_write_byte(dev, 0xE4, val);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000169
Uwe Hermanna7e05482007-05-09 10:17:44 +0000170 /* Get Power Management IO address. */
171 base = pci_read_word(dev, 0x88) & 0xFF80;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000172
Uwe Hermann372eeb52007-12-04 21:49:06 +0000173 /* Enable GPIO15 which is connected to write protect. */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000174 val = inb(base + 0x4D);
175 val |= 0x80;
176 outb(val, base + 0x4D);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000177
Uwe Hermanna7e05482007-05-09 10:17:44 +0000178 return 0;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000179}
180
Uwe Hermannffec5f32007-08-23 16:08:21 +0000181/**
Luc Verhaegen32707542007-07-04 17:51:49 +0000182 * Suited for:
Uwe Hermannffec5f32007-08-23 16:08:21 +0000183 * - ASUS A7V8X-MX SE and A7V400-MX: AMD K7 + VIA KM400A + VT8235
184 * - Tyan Tomcat K7M: AMD Geode NX + VIA KM400 + VT8237.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000185 */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +0000186static int board_asus_a7v8x_mx(const char *name)
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000187{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000188 struct pci_dev *dev;
189 uint8_t val;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000190
Uwe Hermanna7e05482007-05-09 10:17:44 +0000191 dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
Luc Verhaegen32707542007-07-04 17:51:49 +0000192 if (!dev)
193 dev = pci_dev_find(0x1106, 0x3227); /* VT8237 ISA bridge */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000194 if (!dev) {
Luc Verhaegen32707542007-07-04 17:51:49 +0000195 fprintf(stderr, "\nERROR: VT823x ISA bridge not found.\n");
Uwe Hermanna7e05482007-05-09 10:17:44 +0000196 return -1;
197 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000198
Uwe Hermann372eeb52007-12-04 21:49:06 +0000199 /* This bit is marked reserved actually. */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000200 val = pci_read_byte(dev, 0x59);
201 val &= 0x7F;
202 pci_write_byte(dev, 0x59, val);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000203
Uwe Hermann372eeb52007-12-04 21:49:06 +0000204 /* Raise ROM MEMW# line on Winbond W83697 Super I/O. */
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000205 w836xx_ext_enter(0x2E);
Luc Verhaegen7977f4e2007-05-04 04:47:04 +0000206
Uwe Hermann372eeb52007-12-04 21:49:06 +0000207 if (!(wbsio_read(0x2E, 0x24) & 0x02)) /* Flash ROM enabled? */
208 wbsio_mask(0x2E, 0x24, 0x08, 0x08); /* Enable MEMW#. */
Luc Verhaegen7977f4e2007-05-04 04:47:04 +0000209
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000210 w836xx_ext_leave(0x2E);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000211
Uwe Hermanna7e05482007-05-09 10:17:44 +0000212 return 0;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000213}
214
Uwe Hermannffec5f32007-08-23 16:08:21 +0000215/**
Luc Verhaegen97866082008-02-09 02:03:06 +0000216 * Suited for VIAs EPIA SP.
217 */
218static int board_via_epia_sp(const char *name)
219{
220 struct pci_dev *dev;
221 uint8_t val;
222
223 dev = pci_dev_find(0x1106, 0x3227); /* VT8237R ISA bridge */
224 if (!dev) {
225 fprintf(stderr, "\nERROR: VT8237R ISA bridge not found.\n");
226 return -1;
227 }
228
229 /* All memory cycles, not just ROM ones, go to LPC */
230 val = pci_read_byte(dev, 0x59);
231 val &= ~0x80;
232 pci_write_byte(dev, 0x59, val);
233
234 return 0;
235}
236
237/**
Luc Verhaegen6b141752007-05-20 16:16:13 +0000238 * Suited for ASUS P5A.
239 *
240 * This is rather nasty code, but there's no way to do this cleanly.
241 * We're basically talking to some unknown device on SMBus, my guess
242 * is that it is the Winbond W83781D that lives near the DIP BIOS.
243 */
Luc Verhaegen6b141752007-05-20 16:16:13 +0000244static int board_asus_p5a(const char *name)
245{
246 uint8_t tmp;
247 int i;
248
249#define ASUSP5A_LOOP 5000
250
251 outb(0x00, 0xE807);
252 outb(0xEF, 0xE803);
253
254 outb(0xFF, 0xE800);
255
256 for (i = 0; i < ASUSP5A_LOOP; i++) {
257 outb(0xE1, 0xFF);
258 if (inb(0xE800) & 0x04)
259 break;
260 }
261
262 if (i == ASUSP5A_LOOP) {
263 printf("%s: Unable to contact device.\n", name);
264 return -1;
265 }
266
267 outb(0x20, 0xE801);
268 outb(0x20, 0xE1);
269
270 outb(0xFF, 0xE802);
271
272 for (i = 0; i < ASUSP5A_LOOP; i++) {
273 tmp = inb(0xE800);
274 if (tmp & 0x70)
275 break;
276 }
277
278 if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) {
279 printf("%s: failed to read device.\n", name);
280 return -1;
281 }
282
283 tmp = inb(0xE804);
284 tmp &= ~0x02;
285
286 outb(0x00, 0xE807);
287 outb(0xEE, 0xE803);
288
289 outb(tmp, 0xE804);
290
291 outb(0xFF, 0xE800);
292 outb(0xE1, 0xFF);
293
294 outb(0x20, 0xE801);
295 outb(0x20, 0xE1);
296
297 outb(0xFF, 0xE802);
298
299 for (i = 0; i < ASUSP5A_LOOP; i++) {
300 tmp = inb(0xE800);
301 if (tmp & 0x70)
302 break;
303 }
304
305 if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) {
306 printf("%s: failed to write to device.\n", name);
307 return -1;
308 }
309
310 return 0;
311}
312
Stefan Reinauer1c283f42007-06-05 12:51:52 +0000313static int board_ibm_x3455(const char *name)
314{
315 uint8_t byte;
316
Uwe Hermanne823ee02007-06-05 15:02:18 +0000317 /* Set GPIO lines in the Broadcom HT-1000 southbridge. */
Stefan Reinauer1c283f42007-06-05 12:51:52 +0000318 outb(0x45, 0xcd6);
319 byte = inb(0xcd7);
Uwe Hermanne823ee02007-06-05 15:02:18 +0000320 outb(byte | 0x20, 0xcd7);
Stefan Reinauer1c283f42007-06-05 12:51:52 +0000321
322 return 0;
323}
324
Luc Verhaegenfdd0c582007-08-11 16:59:11 +0000325/**
326 * Suited for EPoX EP-BX3, and maybe some other Intel 440BX based boards.
327 */
328static int board_epox_ep_bx3(const char *name)
329{
330 uint8_t tmp;
331
332 /* Raise GPIO22. */
333 tmp = inb(0x4036);
334 outb(tmp, 0xEB);
335
336 tmp |= 0x40;
337
338 outb(tmp, 0x4036);
339 outb(tmp, 0xEB);
340
341 return 0;
342}
343
Uwe Hermannffec5f32007-08-23 16:08:21 +0000344/**
Uwe Hermann372eeb52007-12-04 21:49:06 +0000345 * Suited for Acorp 6A815EPD.
Jonathan A. Kollaschc7785562007-12-02 19:03:23 +0000346 */
347static int board_acorp_6a815epd(const char *name)
348{
349 struct pci_dev *dev;
350 uint16_t port;
351 uint8_t val;
352
353 dev = pci_dev_find(0x8086, 0x2440); /* Intel ICH2 LPC */
354 if (!dev) {
355 fprintf(stderr, "\nERROR: ICH2 LPC bridge not found.\n");
356 return -1;
357 }
358
359 /* Use GPIOBASE register to find where the GPIO is mapped. */
Uwe Hermann372eeb52007-12-04 21:49:06 +0000360 port = (pci_read_word(dev, 0x58) & 0xFFC0) + 0xE;
Jonathan A. Kollaschc7785562007-12-02 19:03:23 +0000361
362 val = inb(port);
363 val |= 0x80; /* Top Block Lock -- pin 8 of PLCC32 */
364 val |= 0x40; /* Lower Blocks Lock -- pin 7 of PLCC32 */
365 outb(val, port);
366
367 return 0;
368}
369
370/**
Uwe Hermannffec5f32007-08-23 16:08:21 +0000371 * We use 2 sets of IDs here, you're free to choose which is which. This
372 * is to provide a very high degree of certainty when matching a board on
373 * the basis of subsystem/card IDs. As not every vendor handles
374 * subsystem/card IDs in a sane manner.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000375 *
Uwe Hermannffec5f32007-08-23 16:08:21 +0000376 * Keep the second set NULLed if it should be ignored.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000377 */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000378struct board_pciid_enable {
Uwe Hermann372eeb52007-12-04 21:49:06 +0000379 /* Any device, but make it sensible, like the ISA bridge. */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000380 uint16_t first_vendor;
381 uint16_t first_device;
382 uint16_t first_card_vendor;
383 uint16_t first_card_device;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000384
Uwe Hermanna7e05482007-05-09 10:17:44 +0000385 /* Any device, but make it sensible, like
Uwe Hermann372eeb52007-12-04 21:49:06 +0000386 * the host bridge. May be NULL.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000387 */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000388 uint16_t second_vendor;
389 uint16_t second_device;
390 uint16_t second_card_vendor;
391 uint16_t second_card_device;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000392
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000393 /* The vendor / part name from the coreboot table. */
Uwe Hermann372eeb52007-12-04 21:49:06 +0000394 const char *lb_vendor;
395 const char *lb_part;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000396
Uwe Hermann372eeb52007-12-04 21:49:06 +0000397 const char *name;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000398 int (*enable) (const char *name);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000399};
400
401struct board_pciid_enable board_pciid_enables[] = {
Carl-Daniel Hailfinger92242622007-09-27 14:29:57 +0000402 {0x10de, 0x0360, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Uwe Hermanna502dce2007-10-17 23:55:15 +0000403 "gigabyte", "m57sli", "GIGABYTE GA-M57SLI-S4", it87xx_probe_spi_flash},
Michael van der Kolff3385cb82007-10-16 21:18:43 +0000404 {0x10de, 0x03e0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Uwe Hermanna502dce2007-10-17 23:55:15 +0000405 "gigabyte", "m61p", "GIGABYTE GA-M61P-S3", it87xx_probe_spi_flash},
Ronald G. Minnich8484d5a2008-01-04 17:22:44 +0000406 {0x1039, 0x0761, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
407 "gigabyte", "2761gxdk", "GIGABYTE GA-2761GXDK", it87xx_probe_spi_flash},
Uwe Hermanna7e05482007-05-09 10:17:44 +0000408 {0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000409 "iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise_2e},
410 {0x10de, 0x005e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
411 "msi", "k8n-neo3", "MSI K8N Neo3", w83627thf_gpio4_4_raise_4e},
Uwe Hermanna7e05482007-05-09 10:17:44 +0000412 {0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000,
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000413 "AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise_2e},
Uwe Hermanna7e05482007-05-09 10:17:44 +0000414 {0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01,
415 NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m},
416 {0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118,
417 NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx},
Luc Verhaegen97866082008-02-09 02:03:06 +0000418 {0x1106, 0x3227, 0x1106, 0xAA01, 0x1106, 0x0259, 0x1106, 0xAA01,
419 NULL, NULL, "VIA EPIA SP", board_via_epia_sp},
Luc Verhaegen32707542007-07-04 17:51:49 +0000420 {0x8086, 0x1076, 0x8086, 0x1176, 0x1106, 0x3059, 0x10f1, 0x2498,
421 NULL, NULL, "Tyan Tomcat K7M", board_asus_a7v8x_mx},
Luc Verhaegen6b141752007-05-20 16:16:13 +0000422 {0x10B9, 0x1541, 0x0000, 0x0000, 0x10B9, 0x1533, 0x0000, 0x0000,
423 "asus", "p5a", "ASUS P5A", board_asus_p5a},
Stefan Reinauer1c283f42007-06-05 12:51:52 +0000424 {0x1166, 0x0205, 0x1014, 0x0347, 0x0000, 0x0000, 0x0000, 0x0000,
425 "ibm", "x3455", "IBM x3455", board_ibm_x3455},
Luc Verhaegenfdd0c582007-08-11 16:59:11 +0000426 {0x8086, 0x7110, 0x0000, 0x0000, 0x8086, 0x7190, 0x0000, 0x0000,
427 "epox", "ep-bx3", "EPoX EP-BX3", board_epox_ep_bx3},
Jonathan A. Kollaschc7785562007-12-02 19:03:23 +0000428 {0x8086, 0x1130, 0x0000, 0x0000, 0x105a, 0x0d30, 0x105a, 0x4d33,
429 "acorp", "6a815epd", "Acorp 6A815EPD", board_acorp_6a815epd},
Uwe Hermanna7e05482007-05-09 10:17:44 +0000430 {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} /* Keep this */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000431};
432
Uwe Hermannffec5f32007-08-23 16:08:21 +0000433/**
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000434 * Match boards on coreboot table gathered vendor and part name.
Uwe Hermannffec5f32007-08-23 16:08:21 +0000435 * Require main PCI IDs to match too as extra safety.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000436 */
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000437static struct board_pciid_enable *board_match_coreboot_name(const char *vendor, const char *part)
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000438{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000439 struct board_pciid_enable *board = board_pciid_enables;
Peter Stuge6b53fed2008-01-27 16:21:21 +0000440 struct board_pciid_enable *partmatch = NULL;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000441
Uwe Hermanna7e05482007-05-09 10:17:44 +0000442 for (; board->name; board++) {
Peter Stuge6b53fed2008-01-27 16:21:21 +0000443 if (vendor && (!board->lb_vendor || strcmp(board->lb_vendor, vendor)))
Uwe Hermanna7e05482007-05-09 10:17:44 +0000444 continue;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000445
Uwe Hermanna7e05482007-05-09 10:17:44 +0000446 if (!board->lb_part || strcmp(board->lb_part, part))
447 continue;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000448
Uwe Hermanna7e05482007-05-09 10:17:44 +0000449 if (!pci_dev_find(board->first_vendor, board->first_device))
450 continue;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000451
Uwe Hermanna7e05482007-05-09 10:17:44 +0000452 if (board->second_vendor &&
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000453 !pci_dev_find(board->second_vendor, board->second_device))
Uwe Hermanna7e05482007-05-09 10:17:44 +0000454 continue;
Peter Stuge6b53fed2008-01-27 16:21:21 +0000455
456 if (vendor)
457 return board;
458
459 if (partmatch) {
460 /* a second entry has a matching part name */
461 printf("AMBIGUOUS BOARD NAME: %s\n", part);
462 printf("At least vendors '%s' and '%s' match.\n",
463 partmatch->lb_vendor, board->lb_vendor);
464 printf("Please use the full -m vendor:part syntax.\n");
465 return NULL;
466 }
467 partmatch = board;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000468 }
Uwe Hermann372eeb52007-12-04 21:49:06 +0000469
Peter Stuge6b53fed2008-01-27 16:21:21 +0000470 if (partmatch)
471 return partmatch;
472
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000473 printf("NOT FOUND %s:%s\n", vendor, part);
Uwe Hermann372eeb52007-12-04 21:49:06 +0000474
Uwe Hermanna7e05482007-05-09 10:17:44 +0000475 return NULL;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000476}
477
Uwe Hermannffec5f32007-08-23 16:08:21 +0000478/**
479 * Match boards on PCI IDs and subsystem IDs.
480 * Second set of IDs can be main only or missing completely.
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000481 */
482static struct board_pciid_enable *board_match_pci_card_ids(void)
483{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000484 struct board_pciid_enable *board = board_pciid_enables;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000485
Uwe Hermanna7e05482007-05-09 10:17:44 +0000486 for (; board->name; board++) {
487 if (!board->first_card_vendor || !board->first_card_device)
488 continue;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000489
Uwe Hermanna7e05482007-05-09 10:17:44 +0000490 if (!pci_card_find(board->first_vendor, board->first_device,
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000491 board->first_card_vendor,
492 board->first_card_device))
Uwe Hermanna7e05482007-05-09 10:17:44 +0000493 continue;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000494
Uwe Hermanna7e05482007-05-09 10:17:44 +0000495 if (board->second_vendor) {
496 if (board->second_card_vendor) {
497 if (!pci_card_find(board->second_vendor,
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000498 board->second_device,
499 board->second_card_vendor,
500 board->second_card_device))
Uwe Hermanna7e05482007-05-09 10:17:44 +0000501 continue;
502 } else {
503 if (!pci_dev_find(board->second_vendor,
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000504 board->second_device))
Uwe Hermanna7e05482007-05-09 10:17:44 +0000505 continue;
506 }
507 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000508
Uwe Hermanna7e05482007-05-09 10:17:44 +0000509 return board;
510 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000511
Uwe Hermanna7e05482007-05-09 10:17:44 +0000512 return NULL;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000513}
514
Uwe Hermann372eeb52007-12-04 21:49:06 +0000515int board_flash_enable(const char *vendor, const char *part)
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000516{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000517 struct board_pciid_enable *board = NULL;
518 int ret = 0;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000519
Peter Stuge6b53fed2008-01-27 16:21:21 +0000520 if (part)
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000521 board = board_match_coreboot_name(vendor, part);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000522
Uwe Hermanna7e05482007-05-09 10:17:44 +0000523 if (!board)
524 board = board_match_pci_card_ids();
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000525
Uwe Hermanna7e05482007-05-09 10:17:44 +0000526 if (board) {
Uwe Hermanna502dce2007-10-17 23:55:15 +0000527 printf("Found board \"%s\": enabling flash write... ",
Ronald G. Minnichfa496922007-10-12 21:22:40 +0000528 board->name);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000529
Uwe Hermanna7e05482007-05-09 10:17:44 +0000530 ret = board->enable(board->name);
531 if (ret)
Uwe Hermanna502dce2007-10-17 23:55:15 +0000532 printf("FAILED!\n");
Uwe Hermanna7e05482007-05-09 10:17:44 +0000533 else
534 printf("OK.\n");
535 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000536
Uwe Hermanna7e05482007-05-09 10:17:44 +0000537 return ret;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000538}