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> |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 7 | * Copyright (C) 2007 Carl-Daniel Hailfinger |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 8 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; version 2 of the License. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 12 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Contains the board specific flash enables. |
| 25 | */ |
| 26 | |
| 27 | #include <stdio.h> |
| 28 | #include <pci/pci.h> |
| 29 | #include <stdint.h> |
| 30 | #include <string.h> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 31 | #include "flash.h" |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 32 | |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 33 | #define ITE_SUPERIO_PORT1 0x2e |
| 34 | #define ITE_SUPERIO_PORT2 0x4e |
| 35 | |
| 36 | #define JEDEC_RDID {0x9f} |
| 37 | #define JEDEC_RDID_OUTSIZE 0x01 |
| 38 | #define JEDEC_RDID_INSIZE 0x03 |
| 39 | |
| 40 | static uint16_t it8716f_flashport = 0; |
| 41 | |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 42 | /* Generic Super I/O helper functions */ |
| 43 | uint8_t regval(uint16_t port, uint8_t reg) |
| 44 | { |
| 45 | outb(reg, port); |
| 46 | return inb(port + 1); |
| 47 | } |
| 48 | |
| 49 | void regwrite(uint16_t port, uint8_t reg, uint8_t val) |
| 50 | { |
| 51 | outb(reg, port); |
| 52 | outb(val, port + 1); |
| 53 | } |
| 54 | |
| 55 | /* Helper functions for most recent ITE IT87xx Super I/O chips */ |
| 56 | #define CHIP_ID_BYTE1_REG 0x20 |
| 57 | #define CHIP_ID_BYTE2_REG 0x21 |
| 58 | static void enter_conf_mode_ite(uint16_t port) |
| 59 | { |
| 60 | outb(0x87, port); |
| 61 | outb(0x01, port); |
| 62 | outb(0x55, port); |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 63 | if (port == ITE_SUPERIO_PORT1) |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 64 | outb(0x55, port); |
| 65 | else |
| 66 | outb(0xaa, port); |
| 67 | } |
| 68 | |
| 69 | static void exit_conf_mode_ite(uint16_t port) |
| 70 | { |
| 71 | regwrite(port, 0x02, 0x02); |
| 72 | } |
| 73 | |
| 74 | static uint16_t find_ite_serial_flash_port(uint16_t port) |
| 75 | { |
| 76 | uint8_t tmp = 0; |
| 77 | uint16_t id, flashport = 0; |
| 78 | |
| 79 | enter_conf_mode_ite(port); |
| 80 | |
| 81 | id = regval(port, CHIP_ID_BYTE1_REG) << 8; |
| 82 | id |= regval(port, CHIP_ID_BYTE2_REG); |
| 83 | |
| 84 | /* TODO: Handle more IT87xx if they support flash translation */ |
| 85 | if (id == 0x8716) { |
| 86 | /* NOLDN, reg 0x24, mask out lowest bit (suspend) */ |
| 87 | tmp = regval(port, 0x24) & 0xFE; |
| 88 | printf("Serial flash segment 0x%08x-0x%08x %sabled\n", |
| 89 | 0xFFFE0000, 0xFFFFFFFF, (tmp & 1 << 1) ? "en" : "dis"); |
| 90 | printf("Serial flash segment 0x%08x-0x%08x %sabled\n", |
| 91 | 0x000E0000, 0x000FFFFF, (tmp & 1 << 1) ? "en" : "dis"); |
| 92 | printf("Serial flash segment 0x%08x-0x%08x %sabled\n", |
| 93 | 0xFFEE0000, 0xFFEFFFFF, (tmp & 1 << 2) ? "en" : "dis"); |
| 94 | printf("Serial flash segment 0x%08x-0x%08x %sabled\n", |
| 95 | 0xFFF80000, 0xFFFEFFFF, (tmp & 1 << 3) ? "en" : "dis"); |
| 96 | printf("LPC write to serial flash %sabled\n", |
| 97 | (tmp & 1 << 4) ? "en" : "dis"); |
| 98 | printf("serial flash pin %i\n", (tmp & 1 << 5) ? 87 : 29); |
| 99 | /* LDN 0x7, reg 0x64/0x65 */ |
| 100 | regwrite(port, 0x07, 0x7); |
| 101 | flashport = regval(port, 0x64) << 8; |
| 102 | flashport |= regval(port, 0x65); |
| 103 | } |
| 104 | exit_conf_mode_ite(port); |
| 105 | return flashport; |
| 106 | } |
| 107 | |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 108 | /* The IT8716F only supports commands with length 1,2,4,5 bytes including |
| 109 | command byte and can not read more than 3 bytes from the device. |
| 110 | This function expects writearr[0] to be the first byte sent to the device, |
| 111 | whereas the IT8716F splits commands internally into address and non-address |
| 112 | commands with the address in inverse wire order. That's why the register |
| 113 | ordering in case 4 and 5 may seem strange. */ |
| 114 | static int it8716f_spi_command(uint16_t port, unsigned char writecnt, unsigned char readcnt, const unsigned char *writearr, unsigned char *readarr) |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 115 | { |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 116 | uint8_t busy, writeenc; |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 117 | do { |
| 118 | busy = inb(port) & 0x80; |
| 119 | } while (busy); |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 120 | if (readcnt > 3) { |
| 121 | printf("%s called with unsupported readcnt %i\n", |
| 122 | __FUNCTION__, readcnt); |
| 123 | return 1; |
| 124 | } |
| 125 | switch (writecnt) { |
| 126 | case 1: |
| 127 | outb(writearr[0], port + 1); |
| 128 | writeenc = 0x0; |
| 129 | break; |
| 130 | case 2: |
| 131 | outb(writearr[0], port + 1); |
| 132 | outb(writearr[1], port + 7); |
| 133 | writeenc = 0x1; |
| 134 | break; |
| 135 | case 4: |
| 136 | outb(writearr[0], port + 1); |
| 137 | outb(writearr[1], port + 4); |
| 138 | outb(writearr[2], port + 3); |
| 139 | outb(writearr[3], port + 2); |
| 140 | writeenc = 0x2; |
| 141 | break; |
| 142 | case 5: |
| 143 | outb(writearr[0], port + 1); |
| 144 | outb(writearr[1], port + 4); |
| 145 | outb(writearr[2], port + 3); |
| 146 | outb(writearr[3], port + 2); |
| 147 | outb(writearr[4], port + 7); |
| 148 | writeenc = 0x3; |
| 149 | break; |
| 150 | default: |
| 151 | printf("%s called with unsupported writecnt %i\n", |
| 152 | __FUNCTION__, writecnt); |
| 153 | return 1; |
| 154 | } |
| 155 | /* Start IO, 33MHz, readcnt input bytes, writecnt output bytes. Note: |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 156 | * We can't use writecnt directly, but have to use a strange encoding |
| 157 | */ |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 158 | outb((0x5 << 4) | ((readcnt & 0x3) << 2) | (writeenc), port); |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 159 | do { |
| 160 | busy = inb(port) & 0x80; |
| 161 | } while (busy); |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 162 | readarr[0] = inb(port + 5); |
| 163 | readarr[1] = inb(port + 6); |
| 164 | readarr[2] = inb(port + 7); |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static int it8716f_serial_rdid(uint16_t port, unsigned char *readarr) |
| 169 | { |
| 170 | const unsigned char cmd[] = JEDEC_RDID; |
| 171 | |
| 172 | if (it8716f_spi_command(port, JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr)) |
| 173 | return 1; |
| 174 | printf("RDID returned %02x %02x %02x\n", readarr[0], readarr[1], readarr[2]); |
| 175 | return 0; |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static int it87xx_probe_serial_flash(const char *name) |
| 179 | { |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 180 | it8716f_flashport = find_ite_serial_flash_port(ITE_SUPERIO_PORT1); |
| 181 | if (!it8716f_flashport) |
| 182 | it8716f_flashport = find_ite_serial_flash_port(ITE_SUPERIO_PORT2); |
| 183 | return (!it8716f_flashport); |
| 184 | } |
| 185 | |
| 186 | int probe_spi(struct flashchip *flash) |
| 187 | { |
| 188 | unsigned char readarr[3]; |
| 189 | uint8_t manuf_id; |
| 190 | uint16_t model_id; |
| 191 | if (it8716f_flashport) { |
| 192 | it8716f_serial_rdid(it8716f_flashport, readarr); |
| 193 | manuf_id = readarr[0]; |
| 194 | model_id = (readarr[1] << 8) | readarr[2]; |
| 195 | printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id); |
| 196 | if (manuf_id == flash->manufacture_id && model_id == flash->model_id) |
| 197 | return 1; |
| 198 | } |
| 199 | |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 203 | /* |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 204 | * Helper functions for many Winbond Super I/Os of the W836xx range. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 205 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 206 | /* Enter extended functions */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 207 | static void w836xx_ext_enter(uint16_t port) |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 208 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 209 | outb(0x87, port); |
| 210 | outb(0x87, port); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 211 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 212 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 213 | /* Leave extended functions */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 214 | static void w836xx_ext_leave(uint16_t port) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 215 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 216 | outb(0xAA, port); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 217 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 218 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 219 | /* General functions for reading/writing Winbond Super I/Os. */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 220 | static unsigned char wbsio_read(uint16_t index, uint8_t reg) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 221 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 222 | outb(reg, index); |
| 223 | return inb(index+1); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 224 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 225 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 226 | static void wbsio_write(uint16_t index, uint8_t reg, uint8_t data) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 227 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 228 | outb(reg, index); |
| 229 | outb(data, index+1); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 230 | } |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 231 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 232 | static void wbsio_mask(uint16_t index, uint8_t reg, uint8_t data, uint8_t mask) |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 233 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 234 | uint8_t tmp; |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 235 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 236 | outb(reg, index); |
| 237 | tmp = inb(index+1) & ~mask; |
| 238 | outb(tmp | (data & mask), index+1); |
Mondrian Nuessle | aef1c7c | 2007-05-03 10:09:23 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 241 | /** |
| 242 | * Winbond W83627HF: Raise GPIO24. |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 243 | * |
| 244 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 245 | * - Agami Aruma |
| 246 | * - IWILL DK8-HTX |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 247 | */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 248 | static int w83627hf_gpio24_raise(uint16_t index, const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 249 | { |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 250 | w836xx_ext_enter(index); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 251 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 252 | /* Is this the w83627hf? */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 253 | if (wbsio_read(index, 0x20) != 0x52) { /* Super I/O device ID register */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 254 | fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n", |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 255 | name, wbsio_read(index, 0x20)); |
| 256 | w836xx_ext_leave(index); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 257 | return -1; |
| 258 | } |
| 259 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 260 | /* PIN89S: WDTO/GP24 multiplex -> GPIO24 */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 261 | wbsio_mask(index, 0x2B, 0x10, 0x10); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 262 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 263 | wbsio_write(index, 0x07, 0x08); /* Select logical device 8: GPIO port 2 */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 264 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 265 | wbsio_mask(index, 0x30, 0x01, 0x01); /* Activate logical device. */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 266 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 267 | wbsio_mask(index, 0xF0, 0x00, 0x10); /* GPIO24 -> output */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 268 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 269 | wbsio_mask(index, 0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 270 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 271 | wbsio_mask(index, 0xF1, 0x10, 0x10); /* Raise GPIO24 */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 272 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 273 | w836xx_ext_leave(index); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 274 | |
| 275 | return 0; |
| 276 | } |
| 277 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 278 | static int w83627hf_gpio24_raise_2e(const char *name) |
| 279 | { |
| 280 | return w83627hf_gpio24_raise(0x2d, name); |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Winbond W83627THF: GPIO 4, bit 4 |
| 285 | * |
| 286 | * Suited for: |
| 287 | * - MSI K8N-NEO3 |
| 288 | */ |
| 289 | static int w83627thf_gpio4_4_raise(uint16_t index, const char *name) |
| 290 | { |
| 291 | w836xx_ext_enter(index); |
| 292 | /* Is this the w83627thf? */ |
| 293 | if (wbsio_read(index, 0x20) != 0x82) { /* Super I/O device ID register */ |
| 294 | fprintf(stderr, "\nERROR: %s: W83627THF: Wrong ID: 0x%02X.\n", |
| 295 | name, wbsio_read(index, 0x20)); |
| 296 | w836xx_ext_leave(index); |
| 297 | return -1; |
| 298 | } |
| 299 | |
| 300 | /* PINxxxxS: GPIO4/bit 4 multiplex -> GPIOXXX */ |
| 301 | |
| 302 | wbsio_write(index, 0x07, 0x09); /* Select logical device 9: GPIO port 4 */ |
| 303 | |
| 304 | wbsio_mask(index, 0x30, 0x02, 0x02); /* Activate logical device. */ |
| 305 | |
| 306 | wbsio_mask(index, 0xF4, 0x00, 0x10); /* GPIO4 bit 4 -> output */ |
| 307 | |
| 308 | wbsio_mask(index, 0xF6, 0x00, 0x10); /* Clear GPIO4 bit 4 inversion */ |
| 309 | |
| 310 | wbsio_mask(index, 0xF5, 0x10, 0x10); /* Raise GPIO4 bit 4 */ |
| 311 | |
| 312 | w836xx_ext_leave(index); |
| 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | static int w83627thf_gpio4_4_raise_4e(const char *name) |
| 318 | { |
| 319 | return w83627thf_gpio4_4_raise(0x4E, name); |
| 320 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 321 | /** |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 322 | * Suited for VIAs EPIA M and MII, and maybe other CLE266 based EPIAs. |
| 323 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 324 | * 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] | 325 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 326 | static int board_via_epia_m(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 327 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 328 | struct pci_dev *dev; |
| 329 | unsigned int base; |
| 330 | uint8_t val; |
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 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
| 333 | if (!dev) { |
| 334 | fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n"); |
| 335 | return -1; |
| 336 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 337 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 338 | /* GPIO12-15 -> output */ |
| 339 | val = pci_read_byte(dev, 0xE4); |
| 340 | val |= 0x10; |
| 341 | pci_write_byte(dev, 0xE4, val); |
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 | /* Get Power Management IO address. */ |
| 344 | base = pci_read_word(dev, 0x88) & 0xFF80; |
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 | /* enable GPIO15 which is connected to write protect. */ |
| 347 | val = inb(base + 0x4D); |
| 348 | val |= 0x80; |
| 349 | outb(val, base + 0x4D); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 350 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 351 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 354 | /** |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 355 | * Suited for: |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 356 | * - ASUS A7V8X-MX SE and A7V400-MX: AMD K7 + VIA KM400A + VT8235 |
| 357 | * - Tyan Tomcat K7M: AMD Geode NX + VIA KM400 + VT8237. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 358 | */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 359 | static int board_asus_a7v8x_mx(const char *name) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 360 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 361 | struct pci_dev *dev; |
| 362 | uint8_t val; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 363 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 364 | dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */ |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 365 | if (!dev) |
| 366 | dev = pci_dev_find(0x1106, 0x3227); /* VT8237 ISA bridge */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 367 | if (!dev) { |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 368 | fprintf(stderr, "\nERROR: VT823x ISA bridge not found.\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 369 | return -1; |
| 370 | } |
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 | /* This bit is marked reserved actually */ |
| 373 | val = pci_read_byte(dev, 0x59); |
| 374 | val &= 0x7F; |
| 375 | pci_write_byte(dev, 0x59, val); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 376 | |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 377 | /* Raise ROM MEMW# line on Winbond w83697 SuperIO */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 378 | w836xx_ext_enter(0x2E); |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 379 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 380 | if (!(wbsio_read(0x2E, 0x24) & 0x02)) /* flash rom enabled? */ |
| 381 | wbsio_mask(0x2E, 0x24, 0x08, 0x08); /* enable MEMW# */ |
Luc Verhaegen | 7977f4e | 2007-05-04 04:47:04 +0000 | [diff] [blame] | 382 | |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 383 | w836xx_ext_leave(0x2E); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 384 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 385 | return 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 386 | } |
| 387 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 388 | /** |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 389 | * Suited for ASUS P5A. |
| 390 | * |
| 391 | * This is rather nasty code, but there's no way to do this cleanly. |
| 392 | * We're basically talking to some unknown device on SMBus, my guess |
| 393 | * is that it is the Winbond W83781D that lives near the DIP BIOS. |
| 394 | */ |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 395 | static int board_asus_p5a(const char *name) |
| 396 | { |
| 397 | uint8_t tmp; |
| 398 | int i; |
| 399 | |
| 400 | #define ASUSP5A_LOOP 5000 |
| 401 | |
| 402 | outb(0x00, 0xE807); |
| 403 | outb(0xEF, 0xE803); |
| 404 | |
| 405 | outb(0xFF, 0xE800); |
| 406 | |
| 407 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 408 | outb(0xE1, 0xFF); |
| 409 | if (inb(0xE800) & 0x04) |
| 410 | break; |
| 411 | } |
| 412 | |
| 413 | if (i == ASUSP5A_LOOP) { |
| 414 | printf("%s: Unable to contact device.\n", name); |
| 415 | return -1; |
| 416 | } |
| 417 | |
| 418 | outb(0x20, 0xE801); |
| 419 | outb(0x20, 0xE1); |
| 420 | |
| 421 | outb(0xFF, 0xE802); |
| 422 | |
| 423 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 424 | tmp = inb(0xE800); |
| 425 | if (tmp & 0x70) |
| 426 | break; |
| 427 | } |
| 428 | |
| 429 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 430 | printf("%s: failed to read device.\n", name); |
| 431 | return -1; |
| 432 | } |
| 433 | |
| 434 | tmp = inb(0xE804); |
| 435 | tmp &= ~0x02; |
| 436 | |
| 437 | outb(0x00, 0xE807); |
| 438 | outb(0xEE, 0xE803); |
| 439 | |
| 440 | outb(tmp, 0xE804); |
| 441 | |
| 442 | outb(0xFF, 0xE800); |
| 443 | outb(0xE1, 0xFF); |
| 444 | |
| 445 | outb(0x20, 0xE801); |
| 446 | outb(0x20, 0xE1); |
| 447 | |
| 448 | outb(0xFF, 0xE802); |
| 449 | |
| 450 | for (i = 0; i < ASUSP5A_LOOP; i++) { |
| 451 | tmp = inb(0xE800); |
| 452 | if (tmp & 0x70) |
| 453 | break; |
| 454 | } |
| 455 | |
| 456 | if ((i == ASUSP5A_LOOP) || !(tmp & 0x10)) { |
| 457 | printf("%s: failed to write to device.\n", name); |
| 458 | return -1; |
| 459 | } |
| 460 | |
| 461 | return 0; |
| 462 | } |
| 463 | |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 464 | static int board_ibm_x3455(const char *name) |
| 465 | { |
| 466 | uint8_t byte; |
| 467 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 468 | /* Set GPIO lines in the Broadcom HT-1000 southbridge. */ |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 469 | outb(0x45, 0xcd6); |
| 470 | byte = inb(0xcd7); |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 471 | outb(byte | 0x20, 0xcd7); |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
Luc Verhaegen | fdd0c58 | 2007-08-11 16:59:11 +0000 | [diff] [blame] | 476 | /** |
| 477 | * Suited for EPoX EP-BX3, and maybe some other Intel 440BX based boards. |
| 478 | */ |
| 479 | static int board_epox_ep_bx3(const char *name) |
| 480 | { |
| 481 | uint8_t tmp; |
| 482 | |
| 483 | /* Raise GPIO22. */ |
| 484 | tmp = inb(0x4036); |
| 485 | outb(tmp, 0xEB); |
| 486 | |
| 487 | tmp |= 0x40; |
| 488 | |
| 489 | outb(tmp, 0x4036); |
| 490 | outb(tmp, 0xEB); |
| 491 | |
| 492 | return 0; |
| 493 | } |
| 494 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 495 | /** |
| 496 | * We use 2 sets of IDs here, you're free to choose which is which. This |
| 497 | * is to provide a very high degree of certainty when matching a board on |
| 498 | * the basis of subsystem/card IDs. As not every vendor handles |
| 499 | * subsystem/card IDs in a sane manner. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 500 | * |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 501 | * Keep the second set NULLed if it should be ignored. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 502 | */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 503 | struct board_pciid_enable { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 504 | /* Any device, but make it sensible, like the isa bridge. */ |
| 505 | uint16_t first_vendor; |
| 506 | uint16_t first_device; |
| 507 | uint16_t first_card_vendor; |
| 508 | uint16_t first_card_device; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 509 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 510 | /* Any device, but make it sensible, like |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 511 | * the host bridge. May be NULL |
| 512 | */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 513 | uint16_t second_vendor; |
| 514 | uint16_t second_device; |
| 515 | uint16_t second_card_vendor; |
| 516 | uint16_t second_card_device; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 517 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 518 | /* From linuxbios table */ |
| 519 | char *lb_vendor; |
| 520 | char *lb_part; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 521 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 522 | char *name; |
| 523 | int (*enable) (const char *name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | struct board_pciid_enable board_pciid_enables[] = { |
Carl-Daniel Hailfinger | 9224262 | 2007-09-27 14:29:57 +0000 | [diff] [blame] | 527 | {0x10de, 0x0360, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
| 528 | "gigabyte", "m57sli", "GIGABYTE GA-M57SLI", it87xx_probe_serial_flash}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 529 | {0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 530 | "iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise_2e}, |
| 531 | {0x10de, 0x005e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
| 532 | "msi", "k8n-neo3", "MSI K8N Neo3", w83627thf_gpio4_4_raise_4e}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 533 | {0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000, |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 534 | "AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise_2e}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 535 | {0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01, |
| 536 | NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m}, |
| 537 | {0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118, |
| 538 | NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx}, |
Luc Verhaegen | 3270754 | 2007-07-04 17:51:49 +0000 | [diff] [blame] | 539 | {0x8086, 0x1076, 0x8086, 0x1176, 0x1106, 0x3059, 0x10f1, 0x2498, |
| 540 | NULL, NULL, "Tyan Tomcat K7M", board_asus_a7v8x_mx}, |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 541 | {0x10B9, 0x1541, 0x0000, 0x0000, 0x10B9, 0x1533, 0x0000, 0x0000, |
| 542 | "asus", "p5a", "ASUS P5A", board_asus_p5a}, |
Stefan Reinauer | 1c283f4 | 2007-06-05 12:51:52 +0000 | [diff] [blame] | 543 | {0x1166, 0x0205, 0x1014, 0x0347, 0x0000, 0x0000, 0x0000, 0x0000, |
| 544 | "ibm", "x3455", "IBM x3455", board_ibm_x3455}, |
Luc Verhaegen | fdd0c58 | 2007-08-11 16:59:11 +0000 | [diff] [blame] | 545 | {0x8086, 0x7110, 0x0000, 0x0000, 0x8086, 0x7190, 0x0000, 0x0000, |
| 546 | "epox", "ep-bx3", "EPoX EP-BX3", board_epox_ep_bx3}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 547 | {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} /* Keep this */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 548 | }; |
| 549 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 550 | /** |
| 551 | * Match boards on LinuxBIOS table gathered vendor and part name. |
| 552 | * Require main PCI IDs to match too as extra safety. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 553 | */ |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 554 | static struct board_pciid_enable *board_match_linuxbios_name(char *vendor, |
| 555 | char *part) |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 556 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 557 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 558 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 559 | for (; board->name; board++) { |
| 560 | if (!board->lb_vendor || strcmp(board->lb_vendor, vendor)) |
| 561 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 562 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 563 | if (!board->lb_part || strcmp(board->lb_part, part)) |
| 564 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 565 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 566 | if (!pci_dev_find(board->first_vendor, board->first_device)) |
| 567 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 568 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 569 | if (board->second_vendor && |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 570 | !pci_dev_find(board->second_vendor, board->second_device)) |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 571 | continue; |
| 572 | return board; |
| 573 | } |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 574 | printf("NOT FOUND %s:%s\n", vendor, part); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 575 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 576 | } |
| 577 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 578 | /** |
| 579 | * Match boards on PCI IDs and subsystem IDs. |
| 580 | * Second set of IDs can be main only or missing completely. |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 581 | */ |
| 582 | static struct board_pciid_enable *board_match_pci_card_ids(void) |
| 583 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 584 | struct board_pciid_enable *board = board_pciid_enables; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 585 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 586 | for (; board->name; board++) { |
| 587 | if (!board->first_card_vendor || !board->first_card_device) |
| 588 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 589 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 590 | if (!pci_card_find(board->first_vendor, board->first_device, |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 591 | board->first_card_vendor, |
| 592 | board->first_card_device)) |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 593 | continue; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 594 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 595 | if (board->second_vendor) { |
| 596 | if (board->second_card_vendor) { |
| 597 | if (!pci_card_find(board->second_vendor, |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 598 | board->second_device, |
| 599 | board->second_card_vendor, |
| 600 | board->second_card_device)) |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 601 | continue; |
| 602 | } else { |
| 603 | if (!pci_dev_find(board->second_vendor, |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 604 | board->second_device)) |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 605 | continue; |
| 606 | } |
| 607 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 608 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 609 | return board; |
| 610 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 611 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 612 | return NULL; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 613 | } |
| 614 | |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 615 | int board_flash_enable(char *vendor, char *part) |
| 616 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 617 | struct board_pciid_enable *board = NULL; |
| 618 | int ret = 0; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 619 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 620 | if (vendor && part) |
| 621 | board = board_match_linuxbios_name(vendor, part); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 622 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 623 | if (!board) |
| 624 | board = board_match_pci_card_ids(); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 625 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 626 | if (board) { |
| 627 | printf("Found board \"%s\": Enabling flash write... ", |
Ronald G. Minnich | fa49692 | 2007-10-12 21:22:40 +0000 | [diff] [blame^] | 628 | board->name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 629 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 630 | ret = board->enable(board->name); |
| 631 | if (ret) |
| 632 | printf("Failed!\n"); |
| 633 | else |
| 634 | printf("OK.\n"); |
| 635 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 636 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 637 | return ret; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 638 | } |