blob: d903f2187425dca1b212c4a5e356ee17a4ced476 [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;
Uwe Hermanna7e05482007-05-09 10:17:44 +000078 uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */
Uwe Hermannea2c66d2006-11-05 18:26:08 +000079
80 old = pci_read_word(dev, xbcs);
81
82 /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to
Uwe Hermanna7e05482007-05-09 10:17:44 +000083 * 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
87 * the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top
88 * of 1 Mbyte, or the aliases at the top of 4 Gbyte
89 * (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).
92 */
Uwe Hermannea2c66d2006-11-05 18:26:08 +000093 new = old | 0x2c4;
94
95 if (new == old)
96 return 0;
97
98 pci_write_word(dev, xbcs, new);
99
100 if (pci_read_word(dev, xbcs) != new) {
101 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", xbcs, new, name);
102 return -1;
103 }
104 return 0;
105}
106
Stefan Reinauer86de2832006-03-31 11:26:55 +0000107static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl)
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000108{
109 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000110 uint8_t old, new;
Stefan Reinauereb366472006-09-06 15:48:48 +0000111
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000112 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000113 * that it is hard to argue that we should quit at this point.
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000114 */
115
Stefan Reinauereb366472006-09-06 15:48:48 +0000116 /* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but
Uwe Hermanna7e05482007-05-09 10:17:44 +0000117 * just treating it as 8 bit wide seems to work fine in practice.
Stefan Reinauereb366472006-09-06 15:48:48 +0000118 */
119
120 /* see ie. page 375 of "Intel ICH7 External Design Specification"
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000121 * http://download.intel.com/design/chipsets/datashts/30701302.pdf
Stefan Reinauereb366472006-09-06 15:48:48 +0000122 */
123
Stefan Reinauer86de2832006-03-31 11:26:55 +0000124 old = pci_read_byte(dev, bios_cntl);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000125
126 new = old | 1;
127
128 if (new == old)
129 return 0;
130
Stefan Reinauer86de2832006-03-31 11:26:55 +0000131 pci_write_byte(dev, bios_cntl, new);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000132
Stefan Reinauer86de2832006-03-31 11:26:55 +0000133 if (pci_read_byte(dev, bios_cntl) != new) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000134 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 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 */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000153static int enable_flash_vt823x(struct pci_dev *dev, char *name)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000154{
Ollie Lho184a4042005-11-26 21:55:36 +0000155 uint8_t val;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000156
Uwe Hermanna7e05482007-05-09 10:17:44 +0000157 /* ROM Write enable */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000158 val = pci_read_byte(dev, 0x40);
159 val |= 0x10;
160 pci_write_byte(dev, 0x40, val);
161
162 if (pci_read_byte(dev, 0x40) != val) {
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000163 printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n",
Uwe Hermanna7e05482007-05-09 10:17:44 +0000164 name);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000165 return -1;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000166 }
Luc Verhaegen6382b442007-03-02 22:16:38 +0000167
Uwe Hermanna7e05482007-05-09 10:17:44 +0000168 return 0;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000169}
170
171static int enable_flash_cs5530(struct pci_dev *dev, char *name)
172{
Ollie Lho184a4042005-11-26 21:55:36 +0000173 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000174
Ollie Lhocbbf1252004-03-17 22:22:08 +0000175 pci_write_byte(dev, 0x52, 0xee);
176
177 new = pci_read_byte(dev, 0x52);
178
179 if (new != 0xee) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000180 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000181 return -1;
182 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000183
Ollie Lho184a4042005-11-26 21:55:36 +0000184 new = pci_read_byte(dev, 0x5b) | 0x20;
185 pci_write_byte(dev, 0x5b, new);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000186
Ollie Lhocbbf1252004-03-17 22:22:08 +0000187 return 0;
188}
189
190static int enable_flash_sc1100(struct pci_dev *dev, char *name)
191{
Ollie Lho184a4042005-11-26 21:55:36 +0000192 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000193
Ollie Lhocbbf1252004-03-17 22:22:08 +0000194 pci_write_byte(dev, 0x52, 0xee);
195
196 new = pci_read_byte(dev, 0x52);
197
198 if (new != 0xee) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000199 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000200 return -1;
201 }
202 return 0;
203}
204
205static int enable_flash_sis5595(struct pci_dev *dev, char *name)
206{
Ollie Lho184a4042005-11-26 21:55:36 +0000207 uint8_t new, newer;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000208
Ollie Lhocbbf1252004-03-17 22:22:08 +0000209 new = pci_read_byte(dev, 0x45);
210
211 /* clear bit 5 */
Ollie Lho761bf1b2004-03-20 16:46:10 +0000212 new &= (~0x20);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000213 /* set bit 2 */
214 new |= 0x4;
215
216 pci_write_byte(dev, 0x45, new);
217
218 newer = pci_read_byte(dev, 0x45);
219 if (newer != new) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000220 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x45, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000221 printf("Stuck at 0x%x\n", newer);
222 return -1;
223 }
224 return 0;
225}
226
Ollie Lho761bf1b2004-03-20 16:46:10 +0000227static int enable_flash_amd8111(struct pci_dev *dev, char *name)
228{
Ollie Lhocbbf1252004-03-17 22:22:08 +0000229 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000230 uint8_t old, new;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000231
Ollie Lhocbbf1252004-03-17 22:22:08 +0000232 /* if it fails, it fails. There are so many variations of broken mobos
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000233 * that it is hard to argue that we should quit at this point.
Ollie Lhocbbf1252004-03-17 22:22:08 +0000234 */
235
Ollie Lhod11f3612004-12-07 17:19:04 +0000236 /* enable decoding at 0xffb00000 to 0xffffffff */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000237 old = pci_read_byte(dev, 0x43);
Ollie Lhod11f3612004-12-07 17:19:04 +0000238 new = old | 0xC0;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000239 if (new != old) {
240 pci_write_byte(dev, 0x43, new);
241 if (pci_read_byte(dev, 0x43) != new) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000242 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x43, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000243 }
244 }
245
Ollie Lho761bf1b2004-03-20 16:46:10 +0000246 old = pci_read_byte(dev, 0x40);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000247 new = old | 0x01;
248 if (new == old)
249 return 0;
250 pci_write_byte(dev, 0x40, new);
251
252 if (pci_read_byte(dev, 0x40) != new) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000253 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000254 return -1;
255 }
256 return 0;
257}
258
Yinghai Lu952dfce2005-07-06 17:13:46 +0000259static int enable_flash_ck804(struct pci_dev *dev, char *name)
260{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000261 /* register 4e.b gets or'ed with one */
262 uint8_t old, new;
Yinghai Lu952dfce2005-07-06 17:13:46 +0000263
Uwe Hermanna7e05482007-05-09 10:17:44 +0000264 /* if it fails, it fails. There are so many variations of broken mobos
265 * that it is hard to argue that we should quit at this point.
266 */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000267
Uwe Hermanna7e05482007-05-09 10:17:44 +0000268 /* dump_pci_device(dev); */
Yinghai Lu952dfce2005-07-06 17:13:46 +0000269
Uwe Hermanna7e05482007-05-09 10:17:44 +0000270 old = pci_read_byte(dev, 0x88);
271 new = old | 0xc0;
272 if (new != old) {
273 pci_write_byte(dev, 0x88, new);
274 if (pci_read_byte(dev, 0x88) != new) {
275 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name);
276 }
277 }
Yinghai Lu952dfce2005-07-06 17:13:46 +0000278
Uwe Hermanna7e05482007-05-09 10:17:44 +0000279 old = pci_read_byte(dev, 0x6d);
280 new = old | 0x01;
281 if (new == old)
282 return 0;
283 pci_write_byte(dev, 0x6d, new);
284
285 if (pci_read_byte(dev, 0x6d) != new) {
286 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name);
287 return -1;
288 }
289 return 0;
Yinghai Lu952dfce2005-07-06 17:13:46 +0000290}
291
Stefan Reinauer86de2832006-03-31 11:26:55 +0000292static int enable_flash_sb400(struct pci_dev *dev, char *name)
293{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000294 uint8_t tmp;
Stefan Reinauer86de2832006-03-31 11:26:55 +0000295
296 struct pci_filter f;
297 struct pci_dev *smbusdev;
298
Stefan Reinauer86de2832006-03-31 11:26:55 +0000299 /* then look for the smbus device */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000300 pci_filter_init((struct pci_access *)0, &f);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000301 f.vendor = 0x1002;
302 f.device = 0x4372;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000303
Stefan Reinauer86de2832006-03-31 11:26:55 +0000304 for (smbusdev = pacc->devices; smbusdev; smbusdev = smbusdev->next) {
305 if (pci_filter_match(&f, smbusdev)) {
306 break;
307 }
308 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000309
Uwe Hermanna7e05482007-05-09 10:17:44 +0000310 if (!smbusdev) {
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000311 fprintf(stderr, "ERROR: SMBus device not found. aborting\n");
Stefan Reinauer86de2832006-03-31 11:26:55 +0000312 exit(1);
313 }
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000314
315 /* enable some smbus stuff */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000316 tmp = pci_read_byte(smbusdev, 0x79);
317 tmp |= 0x01;
Stefan Reinauer86de2832006-03-31 11:26:55 +0000318 pci_write_byte(smbusdev, 0x79, tmp);
319
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000320 /* change southbridge */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000321 tmp = pci_read_byte(dev, 0x48);
322 tmp |= 0x21;
Stefan Reinauer86de2832006-03-31 11:26:55 +0000323 pci_write_byte(dev, 0x48, tmp);
324
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000325 /* now become a bit silly. */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000326 tmp = inb(0xc6f);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000327 outb(tmp, 0xeb);
Uwe Hermanna7e05482007-05-09 10:17:44 +0000328 outb(tmp, 0xeb);
329 tmp |= 0x40;
Stefan Reinauer86de2832006-03-31 11:26:55 +0000330 outb(tmp, 0xc6f);
331 outb(tmp, 0xeb);
332 outb(tmp, 0xeb);
333
334 return 0;
335}
336
Yinghai Luca782972007-01-22 20:21:17 +0000337static int enable_flash_mcp55(struct pci_dev *dev, char *name)
338{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000339 /* register 4e.b gets or'ed with one */
340 unsigned char old, new, byte;
341 unsigned short word;
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000342
Uwe Hermanna7e05482007-05-09 10:17:44 +0000343 /* if it fails, it fails. There are so many variations of broken mobos
344 * that it is hard to argue that we should quit at this point.
345 */
Yinghai Luca782972007-01-22 20:21:17 +0000346
Uwe Hermanna7e05482007-05-09 10:17:44 +0000347 /* dump_pci_device(dev); */
Yinghai Luca782972007-01-22 20:21:17 +0000348
Uwe Hermanna7e05482007-05-09 10:17:44 +0000349 /* Set the 4MB enable bit bit */
350 byte = pci_read_byte(dev, 0x88);
351 byte |= 0xff; /* 256K */
352 pci_write_byte(dev, 0x88, byte);
353 byte = pci_read_byte(dev, 0x8c);
354 byte |= 0xff; /* 1M */
355 pci_write_byte(dev, 0x8c, byte);
356 word = pci_read_word(dev, 0x90);
357 word |= 0x7fff; /* 15M */
358 pci_write_word(dev, 0x90, word);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000359
Uwe Hermanna7e05482007-05-09 10:17:44 +0000360 old = pci_read_byte(dev, 0x6d);
361 new = old | 0x01;
362 if (new == old)
363 return 0;
364 pci_write_byte(dev, 0x6d, new);
Yinghai Luca782972007-01-22 20:21:17 +0000365
Uwe Hermanna7e05482007-05-09 10:17:44 +0000366 if (pci_read_byte(dev, 0x6d) != new) {
367 printf
368 ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
369 0x6d, new, name);
370 return -1;
371 }
Yinghai Luca782972007-01-22 20:21:17 +0000372
373 return 0;
374
375}
376
Ollie Lhocbbf1252004-03-17 22:22:08 +0000377typedef struct penable {
Ollie Lho761bf1b2004-03-20 16:46:10 +0000378 unsigned short vendor, device;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000379 char *name;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000380 int (*doit) (struct pci_dev * dev, char *name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000381} FLASH_ENABLE;
382
383static FLASH_ENABLE enables[] = {
Stefan Reinauereb366472006-09-06 15:48:48 +0000384 {0x1039, 0x0630, "SIS630", enable_flash_sis630},
Uwe Hermannea2c66d2006-11-05 18:26:08 +0000385 {0x8086, 0x7110, "PIIX4/PIIX4E/PIIX4M", enable_flash_piix4},
Stefan Reinauereb366472006-09-06 15:48:48 +0000386 {0x8086, 0x2410, "ICH", enable_flash_ich_4e},
387 {0x8086, 0x2420, "ICH0", enable_flash_ich_4e},
388 {0x8086, 0x2440, "ICH2", enable_flash_ich_4e},
389 {0x8086, 0x244c, "ICH2-M", enable_flash_ich_4e},
390 {0x8086, 0x2480, "ICH3-S", enable_flash_ich_4e},
391 {0x8086, 0x248c, "ICH3-M", enable_flash_ich_4e},
392 {0x8086, 0x24c0, "ICH4/ICH4-L", enable_flash_ich_4e},
393 {0x8086, 0x24cc, "ICH4-M", enable_flash_ich_4e},
394 {0x8086, 0x24d0, "ICH5/ICH5R", enable_flash_ich_4e},
395 {0x8086, 0x2640, "ICH6/ICH6R", enable_flash_ich_dc},
396 {0x8086, 0x2641, "ICH6-M", enable_flash_ich_dc},
Uwe Hermann3ad25182007-03-31 19:48:38 +0000397 {0x8086, 0x27b0, "ICH7DH", enable_flash_ich_dc},
Stefan Reinauereb366472006-09-06 15:48:48 +0000398 {0x8086, 0x27b8, "ICH7/ICH7R", enable_flash_ich_dc},
399 {0x8086, 0x27b9, "ICH7M", enable_flash_ich_dc},
400 {0x8086, 0x27bd, "ICH7MDH", enable_flash_ich_dc},
401 {0x8086, 0x2810, "ICH8/ICH8R", enable_flash_ich_dc},
402 {0x8086, 0x2812, "ICH8DH", enable_flash_ich_dc},
403 {0x8086, 0x2814, "ICH8DO", enable_flash_ich_dc},
Luc Verhaegen6382b442007-03-02 22:16:38 +0000404 {0x1106, 0x8231, "VT8231", enable_flash_vt823x},
405 {0x1106, 0x3177, "VT8235", enable_flash_vt823x},
406 {0x1106, 0x3227, "VT8237", enable_flash_vt823x},
Uwe Hermanna7e05482007-05-09 10:17:44 +0000407 {0x1106, 0x8324, "CX700", enable_flash_vt823x},
Stefan Reinauerc6b5f492006-11-07 10:22:20 +0000408 {0x1106, 0x0686, "VT82C686", enable_flash_amd8111},
Ollie Lho761bf1b2004-03-20 16:46:10 +0000409 {0x1078, 0x0100, "CS5530", enable_flash_cs5530},
410 {0x100b, 0x0510, "SC1100", enable_flash_sc1100},
Ollie Lhocbbf1252004-03-17 22:22:08 +0000411 {0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
412 {0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000413 /* this fallthrough looks broken. */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000414 {0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */
415 {0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */
416 {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 +0000417
Uwe Hermanna7e05482007-05-09 10:17:44 +0000418 {0x10de, 0x0260, "NVidia MCP51", enable_flash_ck804},
419 {0x10de, 0x0261, "NVidia MCP51", enable_flash_ck804},
420 {0x10de, 0x0262, "NVidia MCP51", enable_flash_ck804},
421 {0x10de, 0x0263, "NVidia MCP51", enable_flash_ck804},
Stefan Reinauer219b61e2006-10-14 21:04:49 +0000422
Uwe Hermanna7e05482007-05-09 10:17:44 +0000423 {0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* Gigabyte m57sli-s4 */
424 {0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
425 {0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
426 {0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
427 {0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
428 {0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
429 {0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
430 {0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */
Yinghai Luca782972007-01-22 20:21:17 +0000431
Uwe Hermanna7e05482007-05-09 10:17:44 +0000432 {0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000433};
Ollie Lho761bf1b2004-03-20 16:46:10 +0000434
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000435/*
436 *
Stefan Reinauer86de2832006-03-31 11:26:55 +0000437 */
Uwe Hermanna7e05482007-05-09 10:17:44 +0000438int chipset_flash_enable(void)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000439{
Uwe Hermanna7e05482007-05-09 10:17:44 +0000440 struct pci_dev *dev = 0;
441 int ret = -2; /* nothing! */
442 int i;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000443
Ollie Lhocbbf1252004-03-17 22:22:08 +0000444 /* now let's try to find the chipset we have ... */
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000445 for (i = 0; i < sizeof(enables) / sizeof(enables[0]); i++) {
Uwe Hermanna7e05482007-05-09 10:17:44 +0000446 dev = pci_dev_find(enables[i].vendor, enables[i].device);
447 if (dev)
448 break;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000449 }
450
Uwe Hermanna7e05482007-05-09 10:17:44 +0000451 if (dev) {
452 printf("Found chipset \"%s\": Enabling flash write... ",
453 enables[i].name);
454
455 ret = enables[i].doit(dev, enables[i].name);
456 if (ret)
457 printf("Failed!\n");
458 else
459 printf("OK.\n");
460 }
461
462 return ret;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000463}