summaryrefslogtreecommitdiff
path: root/util/flashrom/board_enable.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/flashrom/board_enable.c')
-rw-r--r--util/flashrom/board_enable.c277
1 files changed, 136 insertions, 141 deletions
diff --git a/util/flashrom/board_enable.c b/util/flashrom/board_enable.c
index 89d66ad1b5..10608adca0 100644
--- a/util/flashrom/board_enable.c
+++ b/util/flashrom/board_enable.c
@@ -30,38 +30,33 @@
#define W836_DATA 0x2F
/* Enter extended functions */
-static void
-w836xx_ext_enter(void)
+static void w836xx_ext_enter(void)
{
outb(0x87, W836_INDEX);
outb(0x87, W836_INDEX);
}
/* Leave extended functions */
-static void
-w836xx_ext_leave(void)
+static void w836xx_ext_leave(void)
{
outb(0xAA, W836_INDEX);
}
/* General functions for read/writing WB SuperIOs */
-static unsigned char
-wbsio_read(unsigned char index)
+static unsigned char wbsio_read(unsigned char index)
{
outb(index, W836_INDEX);
return inb(W836_DATA);
}
-static void
-wbsio_write(unsigned char index, unsigned char data)
+static void wbsio_write(unsigned char index, unsigned char data)
{
outb(index, W836_INDEX);
outb(data, W836_DATA);
}
static void
-wbsio_mask(unsigned char index, unsigned char data,
- unsigned char mask)
+wbsio_mask(unsigned char index, unsigned char data, unsigned char mask)
{
unsigned char tmp;
@@ -83,7 +78,7 @@ static int w83627hf_gpio24_raise(const char *name)
w836xx_ext_enter();
/* Is this the w83627hf? */
- if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */
+ if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */
fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n",
name, wbsio_read(0x20));
w836xx_ext_leave();
@@ -93,15 +88,15 @@ static int w83627hf_gpio24_raise(const char *name)
/* PIN89S: WDTO/GP24 multiplex -> GPIO24 */
wbsio_mask(0x2B, 0x10, 0x10);
- wbsio_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */
+ wbsio_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */
- wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */
+ wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */
- wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */
+ wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */
- wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */
+ wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */
- wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */
+ wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */
w836xx_ext_leave();
@@ -116,30 +111,30 @@ static int w83627hf_gpio24_raise(const char *name)
static int board_via_epia_m(const char *name)
{
- struct pci_dev *dev;
- unsigned int base;
- uint8_t val;
-
- dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
- if (!dev) {
- fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
- return -1;
- }
-
- /* GPIO12-15 -> output */
- val = pci_read_byte(dev, 0xE4);
- val |= 0x10;
- pci_write_byte(dev, 0xE4, val);
-
- /* Get Power Management IO address. */
- base = pci_read_word(dev, 0x88) & 0xFF80;
-
- /* enable GPIO15 which is connected to write protect. */
- val = inb(base + 0x4D);
- val |= 0x80;
- outb(val, base + 0x4D);
-
- return 0;
+ struct pci_dev *dev;
+ unsigned int base;
+ uint8_t val;
+
+ dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
+ if (!dev) {
+ fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
+ return -1;
+ }
+
+ /* GPIO12-15 -> output */
+ val = pci_read_byte(dev, 0xE4);
+ val |= 0x10;
+ pci_write_byte(dev, 0xE4, val);
+
+ /* Get Power Management IO address. */
+ base = pci_read_word(dev, 0x88) & 0xFF80;
+
+ /* enable GPIO15 which is connected to write protect. */
+ val = inb(base + 0x4D);
+ val |= 0x80;
+ outb(val, base + 0x4D);
+
+ return 0;
}
/*
@@ -149,29 +144,29 @@ static int board_via_epia_m(const char *name)
static int board_asus_a7v8x_mx(const char *name)
{
- struct pci_dev *dev;
- uint8_t val;
+ struct pci_dev *dev;
+ uint8_t val;
- dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
- if (!dev) {
- fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
- return -1;
- }
+ dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
+ if (!dev) {
+ fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
+ return -1;
+ }
- /* This bit is marked reserved actually */
- val = pci_read_byte(dev, 0x59);
- val &= 0x7F;
- pci_write_byte(dev, 0x59, val);
+ /* This bit is marked reserved actually */
+ val = pci_read_byte(dev, 0x59);
+ val &= 0x7F;
+ pci_write_byte(dev, 0x59, val);
/* Raise ROM MEMW# line on Winbond w83697 SuperIO */
- w836xx_ext_enter();
+ w836xx_ext_enter();
- if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */
- wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */
+ if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */
+ wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */
w836xx_ext_leave();
- return 0;
+ return 0;
}
/*
@@ -185,39 +180,39 @@ static int board_asus_a7v8x_mx(const char *name)
*/
struct board_pciid_enable {
- /* Any device, but make it sensible, like the isa bridge. */
- uint16_t first_vendor;
- uint16_t first_device;
- uint16_t first_card_vendor;
- uint16_t first_card_device;
+ /* Any device, but make it sensible, like the isa bridge. */
+ uint16_t first_vendor;
+ uint16_t first_device;
+ uint16_t first_card_vendor;
+ uint16_t first_card_device;
- /* Any device, but make it sensible, like
+ /* Any device, but make it sensible, like
* the host bridge. May be NULL
*/
- uint16_t second_vendor;
- uint16_t second_device;
- uint16_t second_card_vendor;
- uint16_t second_card_device;
+ uint16_t second_vendor;
+ uint16_t second_device;
+ uint16_t second_card_vendor;
+ uint16_t second_card_device;
- /* From linuxbios table */
- char *lb_vendor;
- char *lb_part;
+ /* From linuxbios table */
+ char *lb_vendor;
+ char *lb_part;
- char *name;
- int (*enable)(const char *name);
+ char *name;
+ int (*enable) (const char *name);
};
struct board_pciid_enable board_pciid_enables[] = {
- { 0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- "iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise },
- { 0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000,
- "AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise },
- { 0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01,
- NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m },
- { 0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118,
- NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx },
-
- { 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL } /* Keep this */
+ {0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ "iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise},
+ {0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000,
+ "AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise},
+ {0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01,
+ NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m},
+ {0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118,
+ NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx},
+
+ {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} /* Keep this */
};
/*
@@ -225,27 +220,27 @@ struct board_pciid_enable board_pciid_enables[] = {
* Require main pci-ids to match too as extra safety.
*
*/
-static struct board_pciid_enable *
-board_match_linuxbios_name(char *vendor, char *part)
+static struct board_pciid_enable *board_match_linuxbios_name(char *vendor,
+ char *part)
{
- struct board_pciid_enable *board = board_pciid_enables;
+ struct board_pciid_enable *board = board_pciid_enables;
- for (; board->name; board++) {
- if (!board->lb_vendor || strcmp(board->lb_vendor, vendor))
- continue;
+ for (; board->name; board++) {
+ if (!board->lb_vendor || strcmp(board->lb_vendor, vendor))
+ continue;
- if (!board->lb_part || strcmp(board->lb_part, part))
- continue;
+ if (!board->lb_part || strcmp(board->lb_part, part))
+ continue;
- if (!pci_dev_find(board->first_vendor, board->first_device))
- continue;
+ if (!pci_dev_find(board->first_vendor, board->first_device))
+ continue;
- if (board->second_vendor &&
- !pci_dev_find(board->second_vendor, board->second_device))
- continue;
- return board;
- }
- return NULL;
+ if (board->second_vendor &&
+ !pci_dev_find(board->second_vendor, board->second_device))
+ continue;
+ return board;
+ }
+ return NULL;
}
/*
@@ -254,35 +249,35 @@ board_match_linuxbios_name(char *vendor, char *part)
*/
static struct board_pciid_enable *board_match_pci_card_ids(void)
{
- struct board_pciid_enable *board = board_pciid_enables;
-
- for (; board->name; board++) {
- if (!board->first_card_vendor || !board->first_card_device)
- continue;
-
- if (!pci_card_find(board->first_vendor, board->first_device,
- board->first_card_vendor,
- board->first_card_device))
- continue;
-
- if (board->second_vendor) {
- if (board->second_card_vendor) {
- if (!pci_card_find(board->second_vendor,
- board->second_device,
- board->second_card_vendor,
- board->second_card_device))
- continue;
- } else {
- if (!pci_dev_find(board->second_vendor,
- board->second_device))
- continue;
- }
- }
-
- return board;
- }
-
- return NULL;
+ struct board_pciid_enable *board = board_pciid_enables;
+
+ for (; board->name; board++) {
+ if (!board->first_card_vendor || !board->first_card_device)
+ continue;
+
+ if (!pci_card_find(board->first_vendor, board->first_device,
+ board->first_card_vendor,
+ board->first_card_device))
+ continue;
+
+ if (board->second_vendor) {
+ if (board->second_card_vendor) {
+ if (!pci_card_find(board->second_vendor,
+ board->second_device,
+ board->second_card_vendor,
+ board->second_card_device))
+ continue;
+ } else {
+ if (!pci_dev_find(board->second_vendor,
+ board->second_device))
+ continue;
+ }
+ }
+
+ return board;
+ }
+
+ return NULL;
}
/*
@@ -290,25 +285,25 @@ static struct board_pciid_enable *board_match_pci_card_ids(void)
*/
int board_flash_enable(char *vendor, char *part)
{
- struct board_pciid_enable *board = NULL;
- int ret = 0;
+ struct board_pciid_enable *board = NULL;
+ int ret = 0;
- if (vendor && part)
- board = board_match_linuxbios_name(vendor, part);
+ if (vendor && part)
+ board = board_match_linuxbios_name(vendor, part);
- if (!board)
- board = board_match_pci_card_ids();
+ if (!board)
+ board = board_match_pci_card_ids();
- if (board) {
- printf("Found board \"%s\": Enabling flash write... ",
- board->name);
+ if (board) {
+ printf("Found board \"%s\": Enabling flash write... ",
+ board->name);
- ret = board->enable(board->name);
- if (ret)
- printf("Failed!\n");
- else
- printf("OK.\n");
- }
+ ret = board->enable(board->name);
+ if (ret)
+ printf("Failed!\n");
+ else
+ printf("OK.\n");
+ }
- return ret;
+ return ret;
}