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