Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 2 | * This file is part of the flashrom project. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 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> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 7 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 11 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * Contains the board specific flash enables. |
| 24 | */ |
| 25 | |
| 26 | #include <stdio.h> |
| 27 | #include <pci/pci.h> |
| 28 | #include <stdint.h> |
| 29 | #include <string.h> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 30 | #include "flash.h" |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 31 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 32 | /* |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 33 | * Helper functions for many Winbond Super I/Os of the W836xx range. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 34 | */ |
| 35 | #define W836_INDEX 0x2E |
| 36 | #define W836_DATA 0x2F |
| 37 | |
| 38 | /* Enter extended functions */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 39 | static void w836xx_ext_enter(void) |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 40 | { |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 41 | outb(0x87, W836_INDEX); |
| 42 | outb(0x87, 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 | /* Leave extended functions */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 46 | static void w836xx_ext_leave(void) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 47 | { |
| 48 | outb(0xAA, W836_INDEX); |
| 49 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 50 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 51 | /* General functions for reading/writing Winbond Super I/Os. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 52 | static unsigned char wbsio_read(unsigned char index) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 53 | { |
| 54 | outb(index, W836_INDEX); |
| 55 | return inb(W836_DATA); |
| 56 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 57 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 58 | static void wbsio_write(unsigned char index, unsigned char data) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 59 | { |
| 60 | outb(index, W836_INDEX); |
| 61 | outb(data, W836_DATA); |
| 62 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 63 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 64 | static void wbsio_mask(unsigned char index, unsigned char data, |
| 65 | unsigned char mask) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 66 | { |
| 67 | unsigned char tmp; |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 68 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 69 | outb(index, W836_INDEX); |
| 70 | tmp = inb(W836_DATA) & ~mask; |
| 71 | outb(tmp | (data & mask), W836_DATA); |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 74 | /** |
| 75 | * Winbond W83627HF: Raise GPIO24. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 76 | * |
| 77 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 78 | * - Agami Aruma |
| 79 | * - IWILL DK8-HTX |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 80 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 81 | static int w83627hf_gpio24_raise(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 82 | { |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 83 | w836xx_ext_enter(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 84 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 85 | /* Is this the w83627hf? */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 86 | if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 87 | fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n", |
| 88 | name, wbsio_read(0x20)); |
| 89 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 90 | return -1; |
| 91 | } |
| 92 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 93 | /* PIN89S: WDTO/GP24 multiplex -> GPIO24 */ |
| 94 | wbsio_mask(0x2B, 0x10, 0x10); |
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_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 97 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 98 | wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 99 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 100 | wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 101 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 102 | wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 103 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 104 | wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 105 | |
| 106 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 111 | /** |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 112 | * Suited for VIAs EPIA M and MII, and maybe other CLE266 based EPIAs. |
| 113 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 114 | * 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] | 115 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 116 | static int board_via_epia_m(const char *name) |
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 | struct pci_dev *dev; |
| 119 | unsigned int base; |
| 120 | uint8_t val; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 121 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 122 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
| 123 | if (!dev) { |
| 124 | fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n"); |
| 125 | return -1; |
| 126 | } |
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 | /* GPIO12-15 -> output */ |
| 129 | val = pci_read_byte(dev, 0xE4); |
| 130 | val |= 0x10; |
| 131 | pci_write_byte(dev, 0xE4, val); |
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 | /* Get Power Management IO address. */ |
| 134 | base = pci_read_word(dev, 0x88) & 0xFF80; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 135 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 136 | /* enable GPIO15 which is connected to write protect. */ |
| 137 | val = inb(base + 0x4D); |
| 138 | val |= 0x80; |
| 139 | outb(val, base + 0x4D); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 140 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 141 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 144 | /** |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 145 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 146 | * - ASUS A7V8X-MX SE and A7V400-MX: AMD K7 + VIA KM400A + VT8235 |
| 147 | * - Tyan Tomcat K7M: AMD Geode NX + VIA KM400 + VT8237. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 148 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 149 | static int board_asus_a7v8x_mx(const char *name) |
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 | struct pci_dev *dev; |
| 152 | uint8_t val; |
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 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 155 | if (!dev) |
| 156 | dev = pci_dev_find(0x1106, 0x3227); /* VT8237 ISA bridge */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 157 | if (!dev) { |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 158 | fprintf(stderr, "\nERROR: VT823x ISA bridge not found.\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 159 | return -1; |
| 160 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 161 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 162 | /* This bit is marked reserved actually */ |
| 163 | val = pci_read_byte(dev, 0x59); |
| 164 | val &= 0x7F; |
| 165 | pci_write_byte(dev, 0x59, val); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 166 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 167 | /* Raise ROM MEMW# line on Winbond w83697 SuperIO */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 168 | w836xx_ext_enter(); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 169 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 170 | if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */ |
| 171 | wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 172 | |
| 173 | w836xx_ext_leave(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 174 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 175 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 178 | /** |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 179 | * Suited for ASUS P5A. |
| 180 | * |
| 181 | * This is rather nasty code, but there's no way to do this cleanly. |
| 182 | * We're basically talking to some unknown device on SMBus, my guess |
| 183 | * is that it is the Winbond W83781D that lives near the DIP BIOS. |
| 184 | */ |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 185 | static int board_asus_p5a(const char *name) |
| 186 | { |
| 187 | uint8_t tmp; |
| 188 | int i; |
| 189 | |
| 190 | #define ASUSP5A_LOOP 5000 |
| 191 | |
| 192 | outb(0x00, 0xE807); |
| 193 | outb(0xEF, 0xE803); |
| 194 | |
| 195 | outb(0xFF, 0xE800); |
| 196 | |
| 197 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 198 | outb(0xE1, 0xFF); |
| 199 | if (inb(0xE800) & 0x04) |
| 200 | break; |
| 201 | } |
| 202 | |
| 203 | if (i == ASUSP5A_LOOP) { |
| 204 | printf("%s: Unable to contact device.\n", name); |
| 205 | return -1; |
| 206 | } |
| 207 | |
| 208 | outb(0x20, 0xE801); |
| 209 | outb(0x20, 0xE1); |
| 210 | |
| 211 | outb(0xFF, 0xE802); |
| 212 | |
| 213 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 214 | tmp = inb(0xE800); |
| 215 | if (tmp & 0x70) |
| 216 | break; |
| 217 | } |
| 218 | |
| 219 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 220 | printf("%s: failed to read device.\n", name); |
| 221 | return -1; |
| 222 | } |
| 223 | |
| 224 | tmp = inb(0xE804); |
| 225 | tmp &= ~0x02; |
| 226 | |
| 227 | outb(0x00, 0xE807); |
| 228 | outb(0xEE, 0xE803); |
| 229 | |
| 230 | outb(tmp, 0xE804); |
| 231 | |
| 232 | outb(0xFF, 0xE800); |
| 233 | outb(0xE1, 0xFF); |
| 234 | |
| 235 | outb(0x20, 0xE801); |
| 236 | outb(0x20, 0xE1); |
| 237 | |
| 238 | outb(0xFF, 0xE802); |
| 239 | |
| 240 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 241 | tmp = inb(0xE800); |
| 242 | if (tmp & 0x70) |
| 243 | break; |
| 244 | } |
| 245 | |
| 246 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 247 | printf("%s: failed to write to device.\n", name); |
| 248 | return -1; |
| 249 | } |
| 250 | |
| 251 | return 0; |
| 252 | } |
| 253 | |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 254 | static int board_ibm_x3455(const char *name) |
| 255 | { |
| 256 | uint8_t byte; |
| 257 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 258 | /* Set GPIO lines in the Broadcom HT-1000 southbridge. */ |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 259 | outb(0x45, 0xcd6); |
| 260 | byte = inb(0xcd7); |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 261 | outb(byte | 0x20, 0xcd7); |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
Luc Verhaegen | fdd0c58 | 2007-08-11 16:59:11 +0000 | [diff] [blame] | 266 | /** |
| 267 | * Suited for EPoX EP-BX3, and maybe some other Intel 440BX based boards. |
| 268 | */ |
| 269 | static int board_epox_ep_bx3(const char *name) |
| 270 | { |
| 271 | uint8_t tmp; |
| 272 | |
| 273 | /* Raise GPIO22. */ |
| 274 | tmp = inb(0x4036); |
| 275 | outb(tmp, 0xEB); |
| 276 | |
| 277 | tmp |= 0x40; |
| 278 | |
| 279 | outb(tmp, 0x4036); |
| 280 | outb(tmp, 0xEB); |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 285 | /** |
| 286 | * We use 2 sets of IDs here, you're free to choose which is which. This |
| 287 | * is to provide a very high degree of certainty when matching a board on |
| 288 | * the basis of subsystem/card IDs. As not every vendor handles |
| 289 | * subsystem/card IDs in a sane manner. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 290 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 291 | * Keep the second set NULLed if it should be ignored. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 292 | */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 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 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 336 | /** |
| 337 | * Match boards on LinuxBIOS table gathered vendor and part name. |
| 338 | * Require main PCI IDs to match too as extra safety. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 339 | */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 340 | static struct board_pciid_enable *board_match_linuxbios_name(char *vendor, |
| 341 | char *part) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 342 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 343 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 344 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 345 | for (; board->name; board++) { |
| 346 | if (!board->lb_vendor || strcmp(board->lb_vendor, vendor)) |
| 347 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 348 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 349 | if (!board->lb_part || strcmp(board->lb_part, part)) |
| 350 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 351 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 352 | if (!pci_dev_find(board->first_vendor, board->first_device)) |
| 353 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 354 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 355 | if (board->second_vendor && |
| 356 | !pci_dev_find(board->second_vendor, board->second_device)) |
| 357 | continue; |
| 358 | return board; |
| 359 | } |
| 360 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 363 | /** |
| 364 | * Match boards on PCI IDs and subsystem IDs. |
| 365 | * Second set of IDs can be main only or missing completely. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 366 | */ |
| 367 | static struct board_pciid_enable *board_match_pci_card_ids(void) |
| 368 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 369 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 370 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 371 | for (; board->name; board++) { |
| 372 | if (!board->first_card_vendor || !board->first_card_device) |
| 373 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 374 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 375 | if (!pci_card_find(board->first_vendor, board->first_device, |
| 376 | board->first_card_vendor, |
| 377 | board->first_card_device)) |
| 378 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 379 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 380 | if (board->second_vendor) { |
| 381 | if (board->second_card_vendor) { |
| 382 | if (!pci_card_find(board->second_vendor, |
| 383 | board->second_device, |
| 384 | board->second_card_vendor, |
| 385 | board->second_card_device)) |
| 386 | continue; |
| 387 | } else { |
| 388 | if (!pci_dev_find(board->second_vendor, |
| 389 | board->second_device)) |
| 390 | continue; |
| 391 | } |
| 392 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 393 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 394 | return board; |
| 395 | } |
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 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 398 | } |
| 399 | |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 400 | int board_flash_enable(char *vendor, char *part) |
| 401 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 402 | struct board_pciid_enable *board = NULL; |
| 403 | int ret = 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 404 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 405 | if (vendor && part) |
| 406 | board = board_match_linuxbios_name(vendor, part); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 407 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 408 | if (!board) |
| 409 | board = board_match_pci_card_ids(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 410 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 411 | if (board) { |
| 412 | printf("Found board \"%s\": Enabling flash write... ", |
| 413 | board->name); |
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 | ret = board->enable(board->name); |
| 416 | if (ret) |
| 417 | printf("Failed!\n"); |
| 418 | else |
| 419 | printf("OK.\n"); |
| 420 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 421 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 422 | return ret; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 423 | } |