Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * flash rom utility: enable flash writes (board specific) |
| 3 | * |
| 4 | * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de> |
| 5 | * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> |
| 6 | * Copyright (C) 2007 Luc Verhaegen <libv@skynet.be> |
| 7 | * |
| 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 | |
| 14 | /* |
| 15 | * Contains the board specific flash enables. |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <pci/pci.h> |
| 20 | #include <stdint.h> |
| 21 | #include <string.h> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 22 | #include "flash.h" |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 23 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 24 | /* |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 25 | * Helper functions for many Winbond Super I/Os of the W836xx range. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 26 | */ |
| 27 | #define W836_INDEX 0x2E |
| 28 | #define W836_DATA 0x2F |
| 29 | |
| 30 | /* Enter extended functions */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 31 | static void w836xx_ext_enter(void) |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 32 | { |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 33 | outb(0x87, W836_INDEX); |
| 34 | outb(0x87, W836_INDEX); |
| 35 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 36 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 37 | /* Leave extended functions */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 38 | static void w836xx_ext_leave(void) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 39 | { |
| 40 | outb(0xAA, W836_INDEX); |
| 41 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 42 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 43 | /* General functions for reading/writing Winbond Super I/Os. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 44 | static unsigned char wbsio_read(unsigned char index) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 45 | { |
| 46 | outb(index, W836_INDEX); |
| 47 | return inb(W836_DATA); |
| 48 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 49 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 50 | static void wbsio_write(unsigned char index, unsigned char data) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 51 | { |
| 52 | outb(index, W836_INDEX); |
| 53 | outb(data, W836_DATA); |
| 54 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 55 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 56 | static void wbsio_mask(unsigned char index, unsigned char data, |
| 57 | unsigned char mask) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 58 | { |
| 59 | unsigned char tmp; |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 60 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 61 | outb(index, W836_INDEX); |
| 62 | tmp = inb(W836_DATA) & ~mask; |
| 63 | outb(tmp | (data & mask), W836_DATA); |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 66 | /** |
| 67 | * Winbond W83627HF: Raise GPIO24. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 68 | * |
| 69 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 70 | * - Agami Aruma |
| 71 | * - IWILL DK8-HTX |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 72 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 73 | static int w83627hf_gpio24_raise(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 74 | { |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 75 | w836xx_ext_enter(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 76 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 77 | /* Is this the w83627hf? */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 78 | if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 79 | fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n", |
| 80 | name, wbsio_read(0x20)); |
| 81 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 82 | return -1; |
| 83 | } |
| 84 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 85 | /* PIN89S: WDTO/GP24 multiplex -> GPIO24 */ |
| 86 | wbsio_mask(0x2B, 0x10, 0x10); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 87 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 88 | wbsio_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 89 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 90 | wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 91 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 92 | wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 93 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 94 | wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 95 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 96 | wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 97 | |
| 98 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 103 | /** |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 104 | * Suited for VIAs EPIA M and MII, and maybe other CLE266 based EPIAs. |
| 105 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 106 | * We don't need to do this when using LinuxBIOS, GPIO15 is never lowered there. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 107 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 108 | static int board_via_epia_m(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 109 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 110 | struct pci_dev *dev; |
| 111 | unsigned int base; |
| 112 | uint8_t val; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 113 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 114 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
| 115 | if (!dev) { |
| 116 | fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n"); |
| 117 | return -1; |
| 118 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 119 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 120 | /* GPIO12-15 -> output */ |
| 121 | val = pci_read_byte(dev, 0xE4); |
| 122 | val |= 0x10; |
| 123 | pci_write_byte(dev, 0xE4, val); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 124 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 125 | /* Get Power Management IO address. */ |
| 126 | base = pci_read_word(dev, 0x88) & 0xFF80; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 127 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 128 | /* enable GPIO15 which is connected to write protect. */ |
| 129 | val = inb(base + 0x4D); |
| 130 | val |= 0x80; |
| 131 | outb(val, base + 0x4D); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 132 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 133 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 136 | /** |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 137 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 138 | * - ASUS A7V8X-MX SE and A7V400-MX: AMD K7 + VIA KM400A + VT8235 |
| 139 | * - Tyan Tomcat K7M: AMD Geode NX + VIA KM400 + VT8237. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 140 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 141 | static int board_asus_a7v8x_mx(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 142 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 143 | struct pci_dev *dev; |
| 144 | uint8_t val; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 145 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 146 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 147 | if (!dev) |
| 148 | dev = pci_dev_find(0x1106, 0x3227); /* VT8237 ISA bridge */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 149 | if (!dev) { |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 150 | fprintf(stderr, "\nERROR: VT823x ISA bridge not found.\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 151 | return -1; |
| 152 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 153 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 154 | /* This bit is marked reserved actually */ |
| 155 | val = pci_read_byte(dev, 0x59); |
| 156 | val &= 0x7F; |
| 157 | pci_write_byte(dev, 0x59, val); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 158 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 159 | /* Raise ROM MEMW# line on Winbond w83697 SuperIO */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 160 | w836xx_ext_enter(); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 161 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 162 | if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */ |
| 163 | wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 164 | |
| 165 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 166 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 167 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 170 | /** |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 171 | * Suited for ASUS P5A. |
| 172 | * |
| 173 | * This is rather nasty code, but there's no way to do this cleanly. |
| 174 | * We're basically talking to some unknown device on SMBus, my guess |
| 175 | * is that it is the Winbond W83781D that lives near the DIP BIOS. |
| 176 | */ |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 177 | static int board_asus_p5a(const char *name) |
| 178 | { |
| 179 | uint8_t tmp; |
| 180 | int i; |
| 181 | |
| 182 | #define ASUSP5A_LOOP 5000 |
| 183 | |
| 184 | outb(0x00, 0xE807); |
| 185 | outb(0xEF, 0xE803); |
| 186 | |
| 187 | outb(0xFF, 0xE800); |
| 188 | |
| 189 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 190 | outb(0xE1, 0xFF); |
| 191 | if (inb(0xE800) & 0x04) |
| 192 | break; |
| 193 | } |
| 194 | |
| 195 | if (i == ASUSP5A_LOOP) { |
| 196 | printf("%s: Unable to contact device.\n", name); |
| 197 | return -1; |
| 198 | } |
| 199 | |
| 200 | outb(0x20, 0xE801); |
| 201 | outb(0x20, 0xE1); |
| 202 | |
| 203 | outb(0xFF, 0xE802); |
| 204 | |
| 205 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 206 | tmp = inb(0xE800); |
| 207 | if (tmp & 0x70) |
| 208 | break; |
| 209 | } |
| 210 | |
| 211 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 212 | printf("%s: failed to read device.\n", name); |
| 213 | return -1; |
| 214 | } |
| 215 | |
| 216 | tmp = inb(0xE804); |
| 217 | tmp &= ~0x02; |
| 218 | |
| 219 | outb(0x00, 0xE807); |
| 220 | outb(0xEE, 0xE803); |
| 221 | |
| 222 | outb(tmp, 0xE804); |
| 223 | |
| 224 | outb(0xFF, 0xE800); |
| 225 | outb(0xE1, 0xFF); |
| 226 | |
| 227 | outb(0x20, 0xE801); |
| 228 | outb(0x20, 0xE1); |
| 229 | |
| 230 | outb(0xFF, 0xE802); |
| 231 | |
| 232 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 233 | tmp = inb(0xE800); |
| 234 | if (tmp & 0x70) |
| 235 | break; |
| 236 | } |
| 237 | |
| 238 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 239 | printf("%s: failed to write to device.\n", name); |
| 240 | return -1; |
| 241 | } |
| 242 | |
| 243 | return 0; |
| 244 | } |
| 245 | |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 246 | static int board_ibm_x3455(const char *name) |
| 247 | { |
| 248 | uint8_t byte; |
| 249 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 250 | /* Set GPIO lines in the Broadcom HT-1000 southbridge. */ |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 251 | outb(0x45, 0xcd6); |
| 252 | byte = inb(0xcd7); |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 253 | outb(byte | 0x20, 0xcd7); |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
Luc Verhaegen | fdd0c58 | 2007-08-11 16:59:11 +0000 | [diff] [blame] | 258 | /** |
| 259 | * Suited for EPoX EP-BX3, and maybe some other Intel 440BX based boards. |
| 260 | */ |
| 261 | static int board_epox_ep_bx3(const char *name) |
| 262 | { |
| 263 | uint8_t tmp; |
| 264 | |
| 265 | /* Raise GPIO22. */ |
| 266 | tmp = inb(0x4036); |
| 267 | outb(tmp, 0xEB); |
| 268 | |
| 269 | tmp |= 0x40; |
| 270 | |
| 271 | outb(tmp, 0x4036); |
| 272 | outb(tmp, 0xEB); |
| 273 | |
| 274 | return 0; |
| 275 | } |
| 276 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 277 | /** |
| 278 | * We use 2 sets of IDs here, you're free to choose which is which. This |
| 279 | * is to provide a very high degree of certainty when matching a board on |
| 280 | * the basis of subsystem/card IDs. As not every vendor handles |
| 281 | * subsystem/card IDs in a sane manner. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 282 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 283 | * Keep the second set NULLed if it should be ignored. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 284 | */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 285 | struct board_pciid_enable { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 286 | /* Any device, but make it sensible, like the isa bridge. */ |
| 287 | uint16_t first_vendor; |
| 288 | uint16_t first_device; |
| 289 | uint16_t first_card_vendor; |
| 290 | uint16_t first_card_device; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 291 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 292 | /* Any device, but make it sensible, like |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 293 | * the host bridge. May be NULL |
| 294 | */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 295 | uint16_t second_vendor; |
| 296 | uint16_t second_device; |
| 297 | uint16_t second_card_vendor; |
| 298 | uint16_t second_card_device; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 299 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 300 | /* From linuxbios table */ |
| 301 | char *lb_vendor; |
| 302 | char *lb_part; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 303 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 304 | char *name; |
| 305 | int (*enable) (const char *name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | struct board_pciid_enable board_pciid_enables[] = { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 309 | {0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
| 310 | "iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise}, |
| 311 | {0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000, |
| 312 | "AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise}, |
| 313 | {0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01, |
| 314 | NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m}, |
| 315 | {0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118, |
| 316 | NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx}, |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 317 | {0x8086, 0x1076, 0x8086, 0x1176, 0x1106, 0x3059, 0x10f1, 0x2498, |
| 318 | NULL, NULL, "Tyan Tomcat K7M", board_asus_a7v8x_mx}, |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 319 | {0x10B9, 0x1541, 0x0000, 0x0000, 0x10B9, 0x1533, 0x0000, 0x0000, |
| 320 | "asus", "p5a", "ASUS P5A", board_asus_p5a}, |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 321 | {0x1166, 0x0205, 0x1014, 0x0347, 0x0000, 0x0000, 0x0000, 0x0000, |
| 322 | "ibm", "x3455", "IBM x3455", board_ibm_x3455}, |
Luc Verhaegen | fdd0c58 | 2007-08-11 16:59:11 +0000 | [diff] [blame] | 323 | {0x8086, 0x7110, 0x0000, 0x0000, 0x8086, 0x7190, 0x0000, 0x0000, |
| 324 | "epox", "ep-bx3", "EPoX EP-BX3", board_epox_ep_bx3}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 325 | {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} /* Keep this */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 328 | /** |
| 329 | * Match boards on LinuxBIOS table gathered vendor and part name. |
| 330 | * Require main PCI IDs to match too as extra safety. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 331 | */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 332 | static struct board_pciid_enable *board_match_linuxbios_name(char *vendor, |
| 333 | char *part) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 334 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 335 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 336 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 337 | for (; board->name; board++) { |
| 338 | if (!board->lb_vendor || strcmp(board->lb_vendor, vendor)) |
| 339 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 340 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 341 | if (!board->lb_part || strcmp(board->lb_part, part)) |
| 342 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 343 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 344 | if (!pci_dev_find(board->first_vendor, board->first_device)) |
| 345 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 346 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 347 | if (board->second_vendor && |
| 348 | !pci_dev_find(board->second_vendor, board->second_device)) |
| 349 | continue; |
| 350 | return board; |
| 351 | } |
| 352 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame^] | 355 | /** |
| 356 | * Match boards on PCI IDs and subsystem IDs. |
| 357 | * Second set of IDs can be main only or missing completely. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 358 | */ |
| 359 | static struct board_pciid_enable *board_match_pci_card_ids(void) |
| 360 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 361 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 362 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 363 | for (; board->name; board++) { |
| 364 | if (!board->first_card_vendor || !board->first_card_device) |
| 365 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 366 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 367 | if (!pci_card_find(board->first_vendor, board->first_device, |
| 368 | board->first_card_vendor, |
| 369 | board->first_card_device)) |
| 370 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 371 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 372 | if (board->second_vendor) { |
| 373 | if (board->second_card_vendor) { |
| 374 | if (!pci_card_find(board->second_vendor, |
| 375 | board->second_device, |
| 376 | board->second_card_vendor, |
| 377 | board->second_card_device)) |
| 378 | continue; |
| 379 | } else { |
| 380 | if (!pci_dev_find(board->second_vendor, |
| 381 | board->second_device)) |
| 382 | continue; |
| 383 | } |
| 384 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 385 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 386 | return board; |
| 387 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 388 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 389 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 392 | int board_flash_enable(char *vendor, char *part) |
| 393 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 394 | struct board_pciid_enable *board = NULL; |
| 395 | int ret = 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 396 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 397 | if (vendor && part) |
| 398 | board = board_match_linuxbios_name(vendor, part); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 399 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 400 | if (!board) |
| 401 | board = board_match_pci_card_ids(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 402 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 403 | if (board) { |
| 404 | printf("Found board \"%s\": Enabling flash write... ", |
| 405 | board->name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 406 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 407 | ret = board->enable(board->name); |
| 408 | if (ret) |
| 409 | printf("Failed!\n"); |
| 410 | else |
| 411 | printf("OK.\n"); |
| 412 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 413 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 414 | return ret; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 415 | } |