blob: 8add4d9de02f1137809e19a56e36c4581e16ab46 [file] [log] [blame]
Ollie Lho184a4042005-11-26 21:55:36 +00001/*
2 * flash rom utility: enable flash writes
3 *
Luc Verhaegen8e3a6002007-04-04 22:45:58 +00004 * Copyright (C) 2000 Silicon Integrated System Corporation
5 * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de>
Stefan Reinauereb366472006-09-06 15:48:48 +00006 * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
Ollie Lho184a4042005-11-26 21:55:36 +00007 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2
11 *
12 */
13
Ollie Lhocbbf1252004-03-17 22:22:08 +000014#include <stdio.h>
15#include <pci/pci.h>
16#include <stdlib.h>
17
Luc Verhaegen8e3a6002007-04-04 22:45:58 +000018#include "flash.h"
19#include "debug.h"
Stefan Reinauer86de2832006-03-31 11:26:55 +000020
Ollie Lho761bf1b2004-03-20 16:46:10 +000021static int enable_flash_sis630(struct pci_dev *dev, char *name)
Ollie Lhocbbf1252004-03-17 22:22:08 +000022{
23 char b;
24
Ollie Lhocbbf1252004-03-17 22:22:08 +000025 /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */
26 outl(0x80000840, 0x0cf8);
27 b = inb(0x0cfc) | 0x0b;
28 outb(b, 0xcfc);
29 /* Flash write enable on SiS 540/630 */
30 outl(0x80000845, 0x0cf8);
31 b = inb(0x0cfd) | 0x40;
32 outb(b, 0xcfd);
33
34 /* The same thing on SiS 950 SuperIO side */
35 outb(0x87, 0x2e);
36 outb(0x01, 0x2e);
37 outb(0x55, 0x2e);
38 outb(0x55, 0x2e);
39
40 if (inb(0x2f) != 0x87) {
41 outb(0x87, 0x4e);
42 outb(0x01, 0x4e);
43 outb(0x55, 0x4e);
44 outb(0xaa, 0x4e);
45 if (inb(0x4f) != 0x87) {
46 printf("Can not access SiS 950\n");
47 return -1;
48 }
49 outb(0x24, 0x4e);
50 b = inb(0x4f) | 0xfc;
51 outb(0x24, 0x4e);
52 outb(b, 0x4f);
53 outb(0x02, 0x4e);
Ollie Lho761bf1b2004-03-20 16:46:10 +000054 outb(0x02, 0x4f);
Ollie Lhocbbf1252004-03-17 22:22:08 +000055 }
56
57 outb(0x24, 0x2e);
58 printf("2f is %#x\n", inb(0x2f));
59 b = inb(0x2f) | 0xfc;
60 outb(0x24, 0x2e);
61 outb(b, 0x2f);
62
63 outb(0x02, 0x2e);
64 outb(0x02, 0x2f);
65
66 return 0;
67}
68
Uwe Hermann987942d2006-11-07 11:16:21 +000069/* Datasheet:
70 * - Name: 82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4)
71 * - URL: http://www.intel.com/design/intarch/datashts/290562.htm
72 * - PDF: http://www.intel.com/design/intarch/datashts/29056201.pdf
73 * - Order Number: 290562-001
74 */
Uwe Hermannea2c66d2006-11-05 18:26:08 +000075static int enable_flash_piix4(struct pci_dev *dev, char *name)
76{
77 uint16_t old, new;
78 uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */
79
80 old = pci_read_word(dev, xbcs);
81
82 /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to
83 FFF00000-FFF7FFFF are forwarded to ISA).
84 Set bit 7: Extended BIOS Enable (PCI master accesses to
85 FFF80000-FFFDFFFF are forwarded to ISA).
86 Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to
Uwe Hermann987942d2006-11-07 11:16:21 +000087 the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top
Uwe Hermannea2c66d2006-11-05 18:26:08 +000088 of 1 Mbyte, or the aliases at the top of 4 Gbyte
Uwe Hermann987942d2006-11-07 11:16:21 +000089 (FFFE0000-FFFEFFFF) result in the generation of BIOSCS#.
90 Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA.
91 Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable). */
Uwe Hermannea2c66d2006-11-05 18:26:08 +000092 new = old | 0x2c4;
93
94 if (new == old)
95 return 0;
96
97 pci_write_word(dev, xbcs, new);
98
99 if (pci_read_word(dev, xbcs) != new) {
100 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", xbcs, new, name);
101 return -1;
102 }
103 return 0;
104}
105
Stefan Reinauer86de2832006-03-31 11:26:55 +0000106static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl)
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000107{
108 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000109 uint8_t old, new;
Stefan Reinauereb366472006-09-06 15:48:48 +0000110
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000111 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000112 * that it is hard to argue that we should quit at this point.
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000113 */
114
Stefan Reinauereb366472006-09-06 15:48:48 +0000115 /* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000116 * just treating it as 8 bit wide seems to work fine in practice.
Stefan Reinauereb366472006-09-06 15:48:48 +0000117 */
118
119 /* see ie. page 375 of "Intel ICH7 External Design Specification"
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000120 * http://download.intel.com/design/chipsets/datashts/30701302.pdf
Stefan Reinauereb366472006-09-06 15:48:48 +0000121 */
122
Stefan Reinauer86de2832006-03-31 11:26:55 +0000123 old = pci_read_byte(dev, bios_cntl);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000124
125 new = old | 1;
126
127 if (new == old)
128 return 0;
129
Stefan Reinauer86de2832006-03-31 11:26:55 +0000130 pci_write_byte(dev, bios_cntl, new);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000131
Stefan Reinauer86de2832006-03-31 11:26:55 +0000132 if (pci_read_byte(dev, bios_cntl) != new) {
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000133 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
Stefan Reinauer86de2832006-03-31 11:26:55 +0000134 bios_cntl, new, name);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000135 return -1;
136 }
137 return 0;
138}
139
Stefan Reinauereb366472006-09-06 15:48:48 +0000140static int enable_flash_ich_4e(struct pci_dev *dev, char *name)
Stefan Reinauer86de2832006-03-31 11:26:55 +0000141{
Stefan Reinauereb366472006-09-06 15:48:48 +0000142 return enable_flash_ich(dev, name, 0x4e);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000143}
144
Stefan Reinauereb366472006-09-06 15:48:48 +0000145static int enable_flash_ich_dc(struct pci_dev *dev, char *name)
Stefan Reinauer86de2832006-03-31 11:26:55 +0000146{
Stefan Reinauereb366472006-09-06 15:48:48 +0000147 return enable_flash_ich(dev, name, 0xdc);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000148}
149
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000150/*
151 *
152 */
153static int
154enable_flash_vt823x(struct pci_dev *dev, char *name)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000155{
Ollie Lho184a4042005-11-26 21:55:36 +0000156 uint8_t val;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000157
Luc Verhaegen6382b442007-03-02 22:16:38 +0000158 /* ROM Write enable */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000159 val = pci_read_byte(dev, 0x40);
160 val |= 0x10;
161 pci_write_byte(dev, 0x40, val);
162
163 if (pci_read_byte(dev, 0x40) != val) {
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000164 printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n",
165 name);
166 return -1;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000167 }
Luc Verhaegen6382b442007-03-02 22:16:38 +0000168
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000169 return 0;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000170}
171
172static int enable_flash_cs5530(struct pci_dev *dev, char *name)
173{
Ollie Lho184a4042005-11-26 21:55:36 +0000174 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000175
Ollie Lhocbbf1252004-03-17 22:22:08 +0000176 pci_write_byte(dev, 0x52, 0xee);
177
178 new = pci_read_byte(dev, 0x52);
179
180 if (new != 0xee) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000181 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
182 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000183 return -1;
184 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000185
Ollie Lho184a4042005-11-26 21:55:36 +0000186 new = pci_read_byte(dev, 0x5b) | 0x20;
187 pci_write_byte(dev, 0x5b, new);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000188
Ollie Lhocbbf1252004-03-17 22:22:08 +0000189 return 0;
190}
191
Ollie Lho184a4042005-11-26 21:55:36 +0000192
Ollie Lhocbbf1252004-03-17 22:22:08 +0000193static int enable_flash_sc1100(struct pci_dev *dev, char *name)
194{
Ollie Lho184a4042005-11-26 21:55:36 +0000195 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000196
Ollie Lhocbbf1252004-03-17 22:22:08 +0000197 pci_write_byte(dev, 0x52, 0xee);
198
199 new = pci_read_byte(dev, 0x52);
200
201 if (new != 0xee) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000202 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
203 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000204 return -1;
205 }
206 return 0;
207}
208
209static int enable_flash_sis5595(struct pci_dev *dev, char *name)
210{
Ollie Lho184a4042005-11-26 21:55:36 +0000211 uint8_t new, newer;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000212
Ollie Lhocbbf1252004-03-17 22:22:08 +0000213 new = pci_read_byte(dev, 0x45);
214
215 /* clear bit 5 */
Ollie Lho761bf1b2004-03-20 16:46:10 +0000216 new &= (~0x20);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000217 /* set bit 2 */
218 new |= 0x4;
219
220 pci_write_byte(dev, 0x45, new);
221
222 newer = pci_read_byte(dev, 0x45);
223 if (newer != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000224 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
225 0x45, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000226 printf("Stuck at 0x%x\n", newer);
227 return -1;
228 }
229 return 0;
230}
231
Ollie Lho761bf1b2004-03-20 16:46:10 +0000232static int enable_flash_amd8111(struct pci_dev *dev, char *name)
233{
Ollie Lhocbbf1252004-03-17 22:22:08 +0000234 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000235 uint8_t old, new;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000236 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000237 * that it is hard to argue that we should quit at this point.
Ollie Lhocbbf1252004-03-17 22:22:08 +0000238 */
239
Ollie Lhod11f3612004-12-07 17:19:04 +0000240 /* enable decoding at 0xffb00000 to 0xffffffff */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000241 old = pci_read_byte(dev, 0x43);
Ollie Lhod11f3612004-12-07 17:19:04 +0000242 new = old | 0xC0;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000243 if (new != old) {
244 pci_write_byte(dev, 0x43, new);
245 if (pci_read_byte(dev, 0x43) != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000246 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
247 0x43, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000248 }
249 }
250
Ollie Lho761bf1b2004-03-20 16:46:10 +0000251 old = pci_read_byte(dev, 0x40);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000252 new = old | 0x01;
253 if (new == old)
254 return 0;
255 pci_write_byte(dev, 0x40, new);
256
257 if (pci_read_byte(dev, 0x40) != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000258 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
259 0x40, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000260 return -1;
261 }
262 return 0;
263}
264
Yinghai Lu952dfce2005-07-06 17:13:46 +0000265static int enable_flash_ck804(struct pci_dev *dev, char *name)
266{
267 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000268 uint8_t old, new;
Yinghai Lu952dfce2005-07-06 17:13:46 +0000269 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000270 * that it is hard to argue that we should quit at this point.
Yinghai Lu952dfce2005-07-06 17:13:46 +0000271 */
272
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000273 /* dump_pci_device(dev); */
274
Yinghai Lu952dfce2005-07-06 17:13:46 +0000275 old = pci_read_byte(dev, 0x88);
276 new = old | 0xc0;
277 if (new != old) {
278 pci_write_byte(dev, 0x88, new);
279 if (pci_read_byte(dev, 0x88) != new) {
280 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
281 0x88, new, name);
282 }
283 }
284
285 old = pci_read_byte(dev, 0x6d);
286 new = old | 0x01;
287 if (new == old)
288 return 0;
289 pci_write_byte(dev, 0x6d, new);
290
291 if (pci_read_byte(dev, 0x6d) != new) {
292 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
293 0x6d, new, name);
294 return -1;
295 }
296 return 0;
297}
298
Stefan Reinauer86de2832006-03-31 11:26:55 +0000299static int enable_flash_sb400(struct pci_dev *dev, char *name)
300{
301 uint8_t tmp;
302
303 struct pci_filter f;
304 struct pci_dev *smbusdev;
305
Stefan Reinauer86de2832006-03-31 11:26:55 +0000306 /* then look for the smbus device */
307 pci_filter_init((struct pci_access *) 0, &f);
308 f.vendor = 0x1002;
309 f.device = 0x4372;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000310
Stefan Reinauer86de2832006-03-31 11:26:55 +0000311 for (smbusdev = pacc->devices; smbusdev; smbusdev = smbusdev->next) {
312 if (pci_filter_match(&f, smbusdev)) {
313 break;
314 }
315 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000316
Stefan Reinauer86de2832006-03-31 11:26:55 +0000317 if(!smbusdev) {
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000318 fprintf(stderr, "ERROR: SMBus device not found. aborting\n");
Stefan Reinauer86de2832006-03-31 11:26:55 +0000319 exit(1);
320 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000321
322 /* enable some smbus stuff */
Stefan Reinauer86de2832006-03-31 11:26:55 +0000323 tmp=pci_read_byte(smbusdev, 0x79);
324 tmp|=0x01;
325 pci_write_byte(smbusdev, 0x79, tmp);
326
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000327 /* change southbridge */
Stefan Reinauer86de2832006-03-31 11:26:55 +0000328 tmp=pci_read_byte(dev, 0x48);
329 tmp|=0x21;
330 pci_write_byte(dev, 0x48, tmp);
331
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000332 /* now become a bit silly. */
Stefan Reinauer86de2832006-03-31 11:26:55 +0000333 tmp=inb(0xc6f);
334 outb(tmp,0xeb);
335 outb(tmp, 0xeb);
336 tmp|=0x40;
337 outb(tmp, 0xc6f);
338 outb(tmp, 0xeb);
339 outb(tmp, 0xeb);
340
341 return 0;
342}
343
Yinghai Luca782972007-01-22 20:21:17 +0000344static int enable_flash_mcp55(struct pci_dev *dev, char *name)
345{
346 /* register 4e.b gets or'ed with one */
347 unsigned char old, new, byte;
348 unsigned short word;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000349
Yinghai Luca782972007-01-22 20:21:17 +0000350 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000351 * that it is hard to argue that we should quit at this point.
Yinghai Luca782972007-01-22 20:21:17 +0000352 */
353
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000354 /* dump_pci_device(dev); */
Yinghai Luca782972007-01-22 20:21:17 +0000355
356 /* Set the 4MB enable bit bit */
357 byte = pci_read_byte(dev, 0x88);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000358 byte |= 0xff; /* 256K */
Yinghai Luca782972007-01-22 20:21:17 +0000359 pci_write_byte(dev, 0x88, byte);
360 byte = pci_read_byte(dev, 0x8c);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000361 byte |= 0xff; /* 1M */
Yinghai Luca782972007-01-22 20:21:17 +0000362 pci_write_byte(dev, 0x8c, byte);
363 word = pci_read_word(dev, 0x90);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000364 word |= 0x7fff; /* 15M */
Yinghai Luca782972007-01-22 20:21:17 +0000365 pci_write_word(dev, 0x90, word);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000366
Yinghai Luca782972007-01-22 20:21:17 +0000367 old = pci_read_byte(dev, 0x6d);
368 new = old | 0x01;
369 if (new == old)
370 return 0;
371 pci_write_byte(dev, 0x6d, new);
372
373 if (pci_read_byte(dev, 0x6d) != new) {
374 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
375 0x6d, new, name);
376 return -1;
377 }
378
379 return 0;
380
381}
382
Ollie Lhocbbf1252004-03-17 22:22:08 +0000383typedef struct penable {
Ollie Lho761bf1b2004-03-20 16:46:10 +0000384 unsigned short vendor, device;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000385 char *name;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000386 int (*doit) (struct pci_dev * dev, char *name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000387} FLASH_ENABLE;
388
389static FLASH_ENABLE enables[] = {
Stefan Reinauereb366472006-09-06 15:48:48 +0000390 {0x1039, 0x0630, "SIS630", enable_flash_sis630},
Uwe Hermannea2c66d2006-11-05 18:26:08 +0000391 {0x8086, 0x7110, "PIIX4/PIIX4E/PIIX4M", enable_flash_piix4},
Stefan Reinauereb366472006-09-06 15:48:48 +0000392 {0x8086, 0x2410, "ICH", enable_flash_ich_4e},
393 {0x8086, 0x2420, "ICH0", enable_flash_ich_4e},
394 {0x8086, 0x2440, "ICH2", enable_flash_ich_4e},
395 {0x8086, 0x244c, "ICH2-M", enable_flash_ich_4e},
396 {0x8086, 0x2480, "ICH3-S", enable_flash_ich_4e},
397 {0x8086, 0x248c, "ICH3-M", enable_flash_ich_4e},
398 {0x8086, 0x24c0, "ICH4/ICH4-L", enable_flash_ich_4e},
399 {0x8086, 0x24cc, "ICH4-M", enable_flash_ich_4e},
400 {0x8086, 0x24d0, "ICH5/ICH5R", enable_flash_ich_4e},
401 {0x8086, 0x2640, "ICH6/ICH6R", enable_flash_ich_dc},
402 {0x8086, 0x2641, "ICH6-M", enable_flash_ich_dc},
Uwe Hermann3ad25182007-03-31 19:48:38 +0000403 {0x8086, 0x27b0, "ICH7DH", enable_flash_ich_dc},
Stefan Reinauereb366472006-09-06 15:48:48 +0000404 {0x8086, 0x27b8, "ICH7/ICH7R", enable_flash_ich_dc},
405 {0x8086, 0x27b9, "ICH7M", enable_flash_ich_dc},
406 {0x8086, 0x27bd, "ICH7MDH", enable_flash_ich_dc},
407 {0x8086, 0x2810, "ICH8/ICH8R", enable_flash_ich_dc},
408 {0x8086, 0x2812, "ICH8DH", enable_flash_ich_dc},
409 {0x8086, 0x2814, "ICH8DO", enable_flash_ich_dc},
Luc Verhaegen6382b442007-03-02 22:16:38 +0000410 {0x1106, 0x8231, "VT8231", enable_flash_vt823x},
411 {0x1106, 0x3177, "VT8235", enable_flash_vt823x},
412 {0x1106, 0x3227, "VT8237", enable_flash_vt823x},
Stefan Reinauerc6b5f492006-11-07 10:22:20 +0000413 {0x1106, 0x0686, "VT82C686", enable_flash_amd8111},
Ollie Lho761bf1b2004-03-20 16:46:10 +0000414 {0x1078, 0x0100, "CS5530", enable_flash_cs5530},
415 {0x100b, 0x0510, "SC1100", enable_flash_sc1100},
Ollie Lhocbbf1252004-03-17 22:22:08 +0000416 {0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
417 {0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000418 /* this fallthrough looks broken. */
419 {0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */
420 {0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */
421 {0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, /* Slave, should not be here, to fix known bug for A01. */
Stefan Reinauer219b61e2006-10-14 21:04:49 +0000422
423 {0x10de, 0x0260, "NVidia MCP51", enable_flash_ck804},
424 {0x10de, 0x0261, "NVidia MCP51", enable_flash_ck804},
425 {0x10de, 0x0262, "NVidia MCP51", enable_flash_ck804},
426 {0x10de, 0x0263, "NVidia MCP51", enable_flash_ck804},
427
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000428 {0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* Gigabyte m57sli-s4 */
429 {0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
430 {0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
431 {0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
432 {0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
433 {0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
434 {0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
435 {0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */
Yinghai Luca782972007-01-22 20:21:17 +0000436
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000437 {0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000438};
Ollie Lho761bf1b2004-03-20 16:46:10 +0000439
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000440/*
441 *
Stefan Reinauer86de2832006-03-31 11:26:55 +0000442 */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000443int
444chipset_flash_enable(void)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000445{
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000446 struct pci_dev *dev = 0;
447 int ret = -2; /* nothing! */
448 int i;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000449
Ollie Lhocbbf1252004-03-17 22:22:08 +0000450 /* now let's try to find the chipset we have ... */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000451 for (i = 0; i < sizeof(enables) / sizeof(enables[0]); i++) {
452 dev = pci_dev_find(enables[i].vendor, enables[i].device);
453 if (dev)
454 break;
455 }
456
457 if (dev) {
458 printf("Found chipset \"%s\": Enabling flash write... ",
459 enables[i].name);
460
461 ret = enables[i].doit(dev, enables[i].name);
462 if (ret)
463 printf("Failed!\n");
464 else
465 printf("OK.\n");
Ollie Lhocbbf1252004-03-17 22:22:08 +0000466 }
467
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000468 return ret;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000469}