blob: 75c9b2616ee8cf65ed56b6c85b1995216349a6cb [file] [log] [blame]
Ollie Lho184a4042005-11-26 21:55:36 +00001/*
2 * flash rom utility: enable flash writes
3 *
4 * Copyright (C) 2000-2004 ???
5 * Copyright (C) 2005 coresystems GmbH <stepan@openbios.org>
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 <sys/io.h>
15#include <stdio.h>
16#include <pci/pci.h>
17#include <stdlib.h>
Ollie Lho184a4042005-11-26 21:55:36 +000018#include <stdint.h>
19#include <string.h>
20#include "lbtable.h"
21#include "debug.h"
Ollie Lhocbbf1252004-03-17 22:22:08 +000022
Stefan Reinauer86de2832006-03-31 11:26:55 +000023// We keep this for the others.
24static struct pci_access *pacc;
25
Ollie Lho761bf1b2004-03-20 16:46:10 +000026static int enable_flash_sis630(struct pci_dev *dev, char *name)
Ollie Lhocbbf1252004-03-17 22:22:08 +000027{
28 char b;
29
30 /* get io privilege access PCI configuration space */
31 if (iopl(3) != 0) {
32 perror("Can not set io priviliage");
33 exit(1);
34 }
35
36 /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */
37 outl(0x80000840, 0x0cf8);
38 b = inb(0x0cfc) | 0x0b;
39 outb(b, 0xcfc);
40 /* Flash write enable on SiS 540/630 */
41 outl(0x80000845, 0x0cf8);
42 b = inb(0x0cfd) | 0x40;
43 outb(b, 0xcfd);
44
45 /* The same thing on SiS 950 SuperIO side */
46 outb(0x87, 0x2e);
47 outb(0x01, 0x2e);
48 outb(0x55, 0x2e);
49 outb(0x55, 0x2e);
50
51 if (inb(0x2f) != 0x87) {
52 outb(0x87, 0x4e);
53 outb(0x01, 0x4e);
54 outb(0x55, 0x4e);
55 outb(0xaa, 0x4e);
56 if (inb(0x4f) != 0x87) {
57 printf("Can not access SiS 950\n");
58 return -1;
59 }
60 outb(0x24, 0x4e);
61 b = inb(0x4f) | 0xfc;
62 outb(0x24, 0x4e);
63 outb(b, 0x4f);
64 outb(0x02, 0x4e);
Ollie Lho761bf1b2004-03-20 16:46:10 +000065 outb(0x02, 0x4f);
Ollie Lhocbbf1252004-03-17 22:22:08 +000066 }
67
68 outb(0x24, 0x2e);
69 printf("2f is %#x\n", inb(0x2f));
70 b = inb(0x2f) | 0xfc;
71 outb(0x24, 0x2e);
72 outb(b, 0x2f);
73
74 outb(0x02, 0x2e);
75 outb(0x02, 0x2f);
76
77 return 0;
78}
79
Stefan Reinauer86de2832006-03-31 11:26:55 +000080static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl)
Ronald G. Minnich6a967412004-09-28 20:09:06 +000081{
82 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +000083 uint8_t old, new;
Stefan Reinauereb366472006-09-06 15:48:48 +000084
Ronald G. Minnich6a967412004-09-28 20:09:06 +000085 /* if it fails, it fails. There are so many variations of broken mobos
86 * that it is hard to argue that we should quit at this point.
87 */
88
Stefan Reinauereb366472006-09-06 15:48:48 +000089 /* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but
90 * just treating it as 8 bit wide seems to work fine in practice.
91 */
92
93 /* see ie. page 375 of "Intel ICH7 External Design Specification"
94 * http://download.intel.com/design/chipsets/datashts/30701302.pdf
95 */
96
Stefan Reinauer86de2832006-03-31 11:26:55 +000097 old = pci_read_byte(dev, bios_cntl);
Ronald G. Minnich6a967412004-09-28 20:09:06 +000098
99 new = old | 1;
100
101 if (new == old)
102 return 0;
103
Stefan Reinauer86de2832006-03-31 11:26:55 +0000104 pci_write_byte(dev, bios_cntl, new);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000105
Stefan Reinauer86de2832006-03-31 11:26:55 +0000106 if (pci_read_byte(dev, bios_cntl) != new) {
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000107 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
Stefan Reinauer86de2832006-03-31 11:26:55 +0000108 bios_cntl, new, name);
Ronald G. Minnich6a967412004-09-28 20:09:06 +0000109 return -1;
110 }
111 return 0;
112}
113
Stefan Reinauereb366472006-09-06 15:48:48 +0000114static int enable_flash_ich_4e(struct pci_dev *dev, char *name)
Stefan Reinauer86de2832006-03-31 11:26:55 +0000115{
Stefan Reinauereb366472006-09-06 15:48:48 +0000116 return enable_flash_ich(dev, name, 0x4e);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000117}
118
Stefan Reinauereb366472006-09-06 15:48:48 +0000119static int enable_flash_ich_dc(struct pci_dev *dev, char *name)
Stefan Reinauer86de2832006-03-31 11:26:55 +0000120{
Stefan Reinauereb366472006-09-06 15:48:48 +0000121 return enable_flash_ich(dev, name, 0xdc);
Stefan Reinauer86de2832006-03-31 11:26:55 +0000122}
123
Ollie Lhocbbf1252004-03-17 22:22:08 +0000124static int enable_flash_vt8235(struct pci_dev *dev, char *name)
125{
Ollie Lho184a4042005-11-26 21:55:36 +0000126 uint8_t old, new, val;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000127 unsigned int base;
128 int ok;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000129
Ollie Lhocbbf1252004-03-17 22:22:08 +0000130 /* get io privilege access PCI configuration space */
131 if (iopl(3) != 0) {
132 perror("Can not set io priviliage");
133 exit(1);
134 }
135
136 old = pci_read_byte(dev, 0x40);
137
138 new = old | 0x10;
139
140 if (new == old)
141 return 0;
142
143 ok = pci_write_byte(dev, 0x40, new);
144 if (ok != 0) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000145 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
146 old, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000147 }
148
149 /* enable GPIO15 which is connected to write protect. */
Ollie Lho8b8897a2004-03-27 00:18:15 +0000150 base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000151 val = inb(base + 0x4d);
152 val |= 0x80;
153 outb(val, base + 0x4d);
154
155 if (ok != 0) {
156 return -1;
157 } else {
158 return 0;
159 }
160}
161
162static int enable_flash_vt8231(struct pci_dev *dev, char *name)
163{
Ollie Lho184a4042005-11-26 21:55:36 +0000164 uint8_t val;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000165
Ollie Lhocbbf1252004-03-17 22:22:08 +0000166 val = pci_read_byte(dev, 0x40);
167 val |= 0x10;
168 pci_write_byte(dev, 0x40, val);
169
170 if (pci_read_byte(dev, 0x40) != val) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000171 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
172 0x40, val, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000173 return -1;
174 }
175 return 0;
176}
177
178static int enable_flash_cs5530(struct pci_dev *dev, char *name)
179{
Ollie Lho184a4042005-11-26 21:55:36 +0000180 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000181
Ollie Lhocbbf1252004-03-17 22:22:08 +0000182 pci_write_byte(dev, 0x52, 0xee);
183
184 new = pci_read_byte(dev, 0x52);
185
186 if (new != 0xee) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000187 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
188 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000189 return -1;
190 }
Ollie Lho184a4042005-11-26 21:55:36 +0000191
192 new = pci_read_byte(dev, 0x5b) | 0x20;
193 pci_write_byte(dev, 0x5b, new);
194
Ollie Lhocbbf1252004-03-17 22:22:08 +0000195 return 0;
196}
197
Ollie Lho184a4042005-11-26 21:55:36 +0000198
Ollie Lhocbbf1252004-03-17 22:22:08 +0000199static int enable_flash_sc1100(struct pci_dev *dev, char *name)
200{
Ollie Lho184a4042005-11-26 21:55:36 +0000201 uint8_t new;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000202
Ollie Lhocbbf1252004-03-17 22:22:08 +0000203 pci_write_byte(dev, 0x52, 0xee);
204
205 new = pci_read_byte(dev, 0x52);
206
207 if (new != 0xee) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000208 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
209 0x52, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000210 return -1;
211 }
212 return 0;
213}
214
215static int enable_flash_sis5595(struct pci_dev *dev, char *name)
216{
Ollie Lho184a4042005-11-26 21:55:36 +0000217 uint8_t new, newer;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000218
Ollie Lhocbbf1252004-03-17 22:22:08 +0000219 new = pci_read_byte(dev, 0x45);
220
221 /* clear bit 5 */
Ollie Lho761bf1b2004-03-20 16:46:10 +0000222 new &= (~0x20);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000223 /* set bit 2 */
224 new |= 0x4;
225
226 pci_write_byte(dev, 0x45, new);
227
228 newer = pci_read_byte(dev, 0x45);
229 if (newer != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000230 printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
231 0x45, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000232 printf("Stuck at 0x%x\n", newer);
233 return -1;
234 }
235 return 0;
236}
237
Ollie Lho761bf1b2004-03-20 16:46:10 +0000238static int enable_flash_amd8111(struct pci_dev *dev, char *name)
239{
Ollie Lhocbbf1252004-03-17 22:22:08 +0000240 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000241 uint8_t old, new;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000242 /* if it fails, it fails. There are so many variations of broken mobos
243 * that it is hard to argue that we should quit at this point.
244 */
245
Ollie Lhod11f3612004-12-07 17:19:04 +0000246 /* enable decoding at 0xffb00000 to 0xffffffff */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000247 old = pci_read_byte(dev, 0x43);
Ollie Lhod11f3612004-12-07 17:19:04 +0000248 new = old | 0xC0;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000249 if (new != old) {
250 pci_write_byte(dev, 0x43, new);
251 if (pci_read_byte(dev, 0x43) != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000252 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
253 0x43, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000254 }
255 }
256
Ollie Lho761bf1b2004-03-20 16:46:10 +0000257 old = pci_read_byte(dev, 0x40);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000258 new = old | 0x01;
259 if (new == old)
260 return 0;
261 pci_write_byte(dev, 0x40, new);
262
263 if (pci_read_byte(dev, 0x40) != new) {
Ollie Lho8b8897a2004-03-27 00:18:15 +0000264 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
265 0x40, new, name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000266 return -1;
267 }
268 return 0;
269}
270
Yinghai Lu952dfce2005-07-06 17:13:46 +0000271//By yhlu
272static int enable_flash_ck804(struct pci_dev *dev, char *name)
273{
274 /* register 4e.b gets or'ed with one */
Ollie Lho184a4042005-11-26 21:55:36 +0000275 uint8_t old, new;
Yinghai Lu952dfce2005-07-06 17:13:46 +0000276 /* if it fails, it fails. There are so many variations of broken mobos
277 * that it is hard to argue that we should quit at this point.
278 */
279
280 //dump_pci_device(dev);
281
282 old = pci_read_byte(dev, 0x88);
283 new = old | 0xc0;
284 if (new != old) {
285 pci_write_byte(dev, 0x88, new);
286 if (pci_read_byte(dev, 0x88) != new) {
287 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
288 0x88, new, name);
289 }
290 }
291
292 old = pci_read_byte(dev, 0x6d);
293 new = old | 0x01;
294 if (new == old)
295 return 0;
296 pci_write_byte(dev, 0x6d, new);
297
298 if (pci_read_byte(dev, 0x6d) != new) {
299 printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
300 0x6d, new, name);
301 return -1;
302 }
303 return 0;
304}
305
Stefan Reinauer86de2832006-03-31 11:26:55 +0000306static int enable_flash_sb400(struct pci_dev *dev, char *name)
307{
308 uint8_t tmp;
309
310 struct pci_filter f;
311 struct pci_dev *smbusdev;
312
313 /* get io privilege access */
314 if (iopl(3) != 0) {
315 perror("Can not set io priviliage");
316 exit(1);
317 }
318
319 /* then look for the smbus device */
320 pci_filter_init((struct pci_access *) 0, &f);
321 f.vendor = 0x1002;
322 f.device = 0x4372;
323
324 for (smbusdev = pacc->devices; smbusdev; smbusdev = smbusdev->next) {
325 if (pci_filter_match(&f, smbusdev)) {
326 break;
327 }
328 }
329
330 if(!smbusdev) {
331 perror("smbus device not found. aborting\n");
332 exit(1);
333 }
334
335 // enable some smbus stuff
336 tmp=pci_read_byte(smbusdev, 0x79);
337 tmp|=0x01;
338 pci_write_byte(smbusdev, 0x79, tmp);
339
340 // change southbridge
341 tmp=pci_read_byte(dev, 0x48);
342 tmp|=0x21;
343 pci_write_byte(dev, 0x48, tmp);
344
345 // now become a bit silly.
346 tmp=inb(0xc6f);
347 outb(tmp,0xeb);
348 outb(tmp, 0xeb);
349 tmp|=0x40;
350 outb(tmp, 0xc6f);
351 outb(tmp, 0xeb);
352 outb(tmp, 0xeb);
353
354 return 0;
355}
356
Ollie Lhocbbf1252004-03-17 22:22:08 +0000357typedef struct penable {
Ollie Lho761bf1b2004-03-20 16:46:10 +0000358 unsigned short vendor, device;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000359 char *name;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000360 int (*doit) (struct pci_dev * dev, char *name);
Ollie Lhocbbf1252004-03-17 22:22:08 +0000361} FLASH_ENABLE;
362
363static FLASH_ENABLE enables[] = {
Stefan Reinauereb366472006-09-06 15:48:48 +0000364 {0x1039, 0x0630, "SIS630", enable_flash_sis630},
365 {0x8086, 0x2410, "ICH", enable_flash_ich_4e},
366 {0x8086, 0x2420, "ICH0", enable_flash_ich_4e},
367 {0x8086, 0x2440, "ICH2", enable_flash_ich_4e},
368 {0x8086, 0x244c, "ICH2-M", enable_flash_ich_4e},
369 {0x8086, 0x2480, "ICH3-S", enable_flash_ich_4e},
370 {0x8086, 0x248c, "ICH3-M", enable_flash_ich_4e},
371 {0x8086, 0x24c0, "ICH4/ICH4-L", enable_flash_ich_4e},
372 {0x8086, 0x24cc, "ICH4-M", enable_flash_ich_4e},
373 {0x8086, 0x24d0, "ICH5/ICH5R", enable_flash_ich_4e},
374 {0x8086, 0x2640, "ICH6/ICH6R", enable_flash_ich_dc},
375 {0x8086, 0x2641, "ICH6-M", enable_flash_ich_dc},
376 {0x8086, 0x27b8, "ICH7/ICH7R", enable_flash_ich_dc},
377 {0x8086, 0x27b9, "ICH7M", enable_flash_ich_dc},
378 {0x8086, 0x27bd, "ICH7MDH", enable_flash_ich_dc},
379 {0x8086, 0x2810, "ICH8/ICH8R", enable_flash_ich_dc},
380 {0x8086, 0x2812, "ICH8DH", enable_flash_ich_dc},
381 {0x8086, 0x2814, "ICH8DO", enable_flash_ich_dc},
Ollie Lho761bf1b2004-03-20 16:46:10 +0000382 {0x1106, 0x8231, "VT8231", enable_flash_vt8231},
383 {0x1106, 0x3177, "VT8235", enable_flash_vt8235},
384 {0x1078, 0x0100, "CS5530", enable_flash_cs5530},
385 {0x100b, 0x0510, "SC1100", enable_flash_sc1100},
Ollie Lhocbbf1252004-03-17 22:22:08 +0000386 {0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
387 {0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
Stefan Reinauer86de2832006-03-31 11:26:55 +0000388 // this fallthrough looks broken.
Yinghai Lu952dfce2005-07-06 17:13:46 +0000389 {0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, // LPC
390 {0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, // Pro
391 {0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, // Slave, should not be here, to fix known bug for A01.
Stefan Reinauere807d822006-07-31 23:37:17 +0000392 {0x10de, 0x0261, "NVIDIA C51", enable_flash_ck804},
Stefan Reinauer86de2832006-03-31 11:26:55 +0000393 {0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, // ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000394};
Ollie Lho761bf1b2004-03-20 16:46:10 +0000395
Ollie Lho184a4042005-11-26 21:55:36 +0000396static int mbenable_island_aruma(void)
397{
Stefan Reinauer86de2832006-03-31 11:26:55 +0000398#define EFIR 0x2e /* Extended function index register, either 0x2e or 0x4e */
399#define EFDR EFIR + 1 /* Extended function data register, one plus the index reg. */
Ollie Lho184a4042005-11-26 21:55:36 +0000400 char b;
Stefan Reinauer86de2832006-03-31 11:26:55 +0000401
402/* Disable the flash write protect. The flash write protect is
403 * connected to the WinBond w83627hf GPIO 24.
404 */
Ollie Lho184a4042005-11-26 21:55:36 +0000405
406 /* get io privilege access winbond config space */
407 if (iopl(3) != 0) {
408 perror("Can not set io priviliage");
409 exit(1);
410 }
411
412 printf("Disabling mainboard flash write protection.\n");
413
414 outb(0x87, EFIR); // sequence to unlock extended functions
415 outb(0x87, EFIR);
416
417 outb(0x20, EFIR); // SIO device ID register
418 b = inb(EFDR);
419 printf_debug("W83627HF device ID = 0x%x\n",b);
420
421 if (b != 0x52) {
422 perror("Incorrect device ID, aborting write protect disable\n");
423 exit(1);
424 }
425
426 outb(0x2b, EFIR); // GPIO multiplexed pin reg.
427 b = inb(EFDR) | 0x10;
428 outb(0x2b, EFIR);
429 outb(b, EFDR); // select GPIO 24 instead of WDTO
430
431 outb(0x7, EFIR); // logical device select
432 outb(0x8, EFDR); // point to device 8, GPIO port 2
433
434 outb(0x30, EFIR); // logic device activation control
435 outb(0x1, EFDR); // activate
436
437 outb(0xf0, EFIR); // GPIO 20-27 I/O selection register
438 b = inb(EFDR) & ~0x10;
439 outb(0xf0, EFIR);
440 outb(b, EFDR); // set GPIO 24 as an output
441
442 outb(0xf1, EFIR); // GPIO 20-27 data register
443 b = inb(EFDR) | 0x10;
444 outb(0xf1, EFIR);
445 outb(b, EFDR); // set GPIO 24
446
447 outb(0xaa, EFIR); // command to exit extended functions
448
449 return 0;
450}
451
452typedef struct mbenable {
453 char *vendor, *part;
454 int (*doit)(void);
455} MAINBOARD_ENABLE;
456
457static MAINBOARD_ENABLE mbenables[] = {
458 { "ISLAND", "ARUMA", mbenable_island_aruma },
459};
460
Ollie Lhocbbf1252004-03-17 22:22:08 +0000461int enable_flash_write()
462{
463 int i;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000464 struct pci_dev *dev = 0;
465 FLASH_ENABLE *enable = 0;
466
Ollie Lho761bf1b2004-03-20 16:46:10 +0000467 pacc = pci_alloc(); /* Get the pci_access structure */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000468 /* Set all options you want -- here we stick with the defaults */
Ollie Lho761bf1b2004-03-20 16:46:10 +0000469 pci_init(pacc); /* Initialize the PCI library */
470 pci_scan_bus(pacc); /* We want to get the list of devices */
Ollie Lhocbbf1252004-03-17 22:22:08 +0000471
Ollie Lho184a4042005-11-26 21:55:36 +0000472
473 /* First look whether we have to do something for this
474 * motherboard.
475 */
476 for (i = 0; i < sizeof(mbenables) / sizeof(mbenables[0]); i++) {
477 if(lb_vendor && !strcmp(mbenables[i].vendor, lb_vendor) &&
478 lb_part && !strcmp(mbenables[i].part, lb_part)) {
479 mbenables[i].doit();
480 break;
481 }
482 }
483
Ollie Lhocbbf1252004-03-17 22:22:08 +0000484 /* now let's try to find the chipset we have ... */
Ollie Lho761bf1b2004-03-20 16:46:10 +0000485 for (i = 0; i < sizeof(enables) / sizeof(enables[0]) && (!dev);
486 i++) {
Ollie Lhocbbf1252004-03-17 22:22:08 +0000487 struct pci_filter f;
488 struct pci_dev *z;
489 /* the first param is unused. */
490 pci_filter_init((struct pci_access *) 0, &f);
491 f.vendor = enables[i].vendor;
492 f.device = enables[i].device;
Ollie Lho761bf1b2004-03-20 16:46:10 +0000493 for (z = pacc->devices; z; z = z->next)
Ollie Lhocbbf1252004-03-17 22:22:08 +0000494 if (pci_filter_match(&f, z)) {
495 enable = &enables[i];
496 dev = z;
497 }
498 }
499
Stefan Reinauercbc55d02006-08-25 19:21:42 +0000500 if (!enable) {
501 printf("Warning: Unknown system. Flash detection "
502 "will most likely fail.\n");
503 return 1;
Ollie Lhocbbf1252004-03-17 22:22:08 +0000504 }
Stefan Reinauercbc55d02006-08-25 19:21:42 +0000505
506 /* now do the deed. */
507 printf("Enabling flash write on %s...", enable->name);
508 if (enable->doit(dev, enable->name) == 0)
509 printf("OK\n");
Ollie Lhocbbf1252004-03-17 22:22:08 +0000510 return 0;
511}