aboutsummaryrefslogtreecommitdiffstats
path: root/flash_enable.c
diff options
context:
space:
mode:
Diffstat (limited to 'flash_enable.c')
-rw-r--r--flash_enable.c96
1 files changed, 54 insertions, 42 deletions
diff --git a/flash_enable.c b/flash_enable.c
index 8a9bf042..02861f15 100644
--- a/flash_enable.c
+++ b/flash_enable.c
@@ -3,7 +3,7 @@
#include <pci/pci.h>
#include <stdlib.h>
-static int enable_flash_sis630 (struct pci_dev *dev, char *name)
+static int enable_flash_sis630(struct pci_dev *dev, char *name)
{
char b;
@@ -42,7 +42,7 @@ static int enable_flash_sis630 (struct pci_dev *dev, char *name)
outb(0x24, 0x4e);
outb(b, 0x4f);
outb(0x02, 0x4e);
- outb(0x02, 0x4f);
+ outb(0x02, 0x4f);
}
outb(0x24, 0x2e);
@@ -64,7 +64,7 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
/* if it fails, it fails. There are so many variations of broken mobos
* that it is hard to argue that we should quit at this point.
*/
-
+
old = pci_read_byte(dev, 0x4e);
new = old | 1;
@@ -75,8 +75,9 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
pci_write_byte(dev, 0x4e, new);
if (pci_read_byte(dev, 0x4e) != new) {
- printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x4e, new, name);
+ printf
+ ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x4e, new, name);
return -1;
}
return 0;
@@ -87,7 +88,7 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
unsigned char old, new, val;
unsigned int base;
int ok;
-
+
/* get io privilege access PCI configuration space */
if (iopl(3) != 0) {
perror("Can not set io priviliage");
@@ -103,12 +104,15 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
ok = pci_write_byte(dev, 0x40, new);
if (ok != 0) {
- printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- old, new, name);
+ printf
+ ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ old, new, name);
}
/* enable GPIO15 which is connected to write protect. */
- base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8);
+ base =
+ ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89)
+ << 8);
val = inb(base + 0x4d);
val |= 0x80;
outb(val, base + 0x4d);
@@ -123,14 +127,15 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
static int enable_flash_vt8231(struct pci_dev *dev, char *name)
{
unsigned char val;
-
+
val = pci_read_byte(dev, 0x40);
val |= 0x10;
pci_write_byte(dev, 0x40, val);
if (pci_read_byte(dev, 0x40) != val) {
- printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x40, val, name);
+ printf
+ ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x40, val, name);
return -1;
}
return 0;
@@ -139,14 +144,15 @@ static int enable_flash_vt8231(struct pci_dev *dev, char *name)
static int enable_flash_cs5530(struct pci_dev *dev, char *name)
{
unsigned char new;
-
+
pci_write_byte(dev, 0x52, 0xee);
new = pci_read_byte(dev, 0x52);
if (new != 0xee) {
- printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x52, new, name);
+ printf
+ ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x52, new, name);
return -1;
}
return 0;
@@ -155,14 +161,15 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
static int enable_flash_sc1100(struct pci_dev *dev, char *name)
{
unsigned char new;
-
+
pci_write_byte(dev, 0x52, 0xee);
new = pci_read_byte(dev, 0x52);
if (new != 0xee) {
- printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x52, new, name);
+ printf
+ ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x52, new, name);
return -1;
}
return 0;
@@ -171,11 +178,11 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name)
static int enable_flash_sis5595(struct pci_dev *dev, char *name)
{
unsigned char new, newer;
-
+
new = pci_read_byte(dev, 0x45);
/* clear bit 5 */
- new &= (~ 0x20);
+ new &= (~0x20);
/* set bit 2 */
new |= 0x4;
@@ -183,15 +190,17 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
newer = pci_read_byte(dev, 0x45);
if (newer != new) {
- printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x45, new, name);
+ printf
+ ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x45, new, name);
printf("Stuck at 0x%x\n", newer);
return -1;
}
return 0;
}
-static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
+static int enable_flash_amd8111(struct pci_dev *dev, char *name)
+{
/* register 4e.b gets or'ed with one */
unsigned char old, new;
/* if it fails, it fails. There are so many variations of broken mobos
@@ -205,42 +214,44 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
if (new != old) {
pci_write_byte(dev, 0x43, new);
if (pci_read_byte(dev, 0x43) != new) {
- printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x43, new, name);
+ printf
+ ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x43, new, name);
}
}
- old = pci_read_byte(dev, 0x40);
+ old = pci_read_byte(dev, 0x40);
new = old | 0x01;
if (new == old)
return 0;
pci_write_byte(dev, 0x40, new);
if (pci_read_byte(dev, 0x40) != new) {
- printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
- 0x40, new, name);
+ printf
+ ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
+ 0x40, new, name);
return -1;
}
return 0;
}
typedef struct penable {
- unsigned short vendor, device;
+ unsigned short vendor, device;
char *name;
- int (*doit)(struct pci_dev *dev, char *name);
+ int (*doit) (struct pci_dev * dev, char *name);
} FLASH_ENABLE;
static FLASH_ENABLE enables[] = {
- {0x1039, 0x0630, "sis630", enable_flash_sis630},
- {0x8086, 0x2480, "E7500", enable_flash_e7500},
- {0x1106, 0x8231, "VT8231", enable_flash_vt8231},
- {0x1106, 0x3177, "VT8235", enable_flash_vt8235},
- {0x1078, 0x0100, "CS5530", enable_flash_cs5530},
- {0x100b, 0x0510, "SC1100", enable_flash_sc1100},
+ {0x1039, 0x0630, "sis630", enable_flash_sis630},
+ {0x8086, 0x2480, "E7500", enable_flash_e7500},
+ {0x1106, 0x8231, "VT8231", enable_flash_vt8231},
+ {0x1106, 0x3177, "VT8235", enable_flash_vt8235},
+ {0x1078, 0x0100, "CS5530", enable_flash_cs5530},
+ {0x100b, 0x0510, "SC1100", enable_flash_sc1100},
{0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
{0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
};
-
+
int enable_flash_write()
{
int i;
@@ -248,20 +259,21 @@ int enable_flash_write()
struct pci_dev *dev = 0;
FLASH_ENABLE *enable = 0;
- pacc = pci_alloc(); /* Get the pci_access structure */
+ pacc = pci_alloc(); /* Get the pci_access structure */
/* Set all options you want -- here we stick with the defaults */
- pci_init(pacc); /* Initialize the PCI library */
- pci_scan_bus(pacc); /* We want to get the list of devices */
+ pci_init(pacc); /* Initialize the PCI library */
+ pci_scan_bus(pacc); /* We want to get the list of devices */
/* now let's try to find the chipset we have ... */
- for (i = 0; i < sizeof(enables)/sizeof(enables[0]) && (! dev); i++) {
+ for (i = 0; i < sizeof(enables) / sizeof(enables[0]) && (!dev);
+ i++) {
struct pci_filter f;
struct pci_dev *z;
/* the first param is unused. */
pci_filter_init((struct pci_access *) 0, &f);
f.vendor = enables[i].vendor;
f.device = enables[i].device;
- for (z=pacc->devices; z; z=z->next)
+ for (z = pacc->devices; z; z = z->next)
if (pci_filter_match(&f, z)) {
enable = &enables[i];
dev = z;