Ollie Lho | 184a404 | 2005-11-26 21:55:36 +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. |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 4 | * Copyright (C) 2000 Silicon Integrated System Corporation |
| 5 | * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de> |
| 6 | * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +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. |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +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 |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * Contains the chipset specific flash enables. |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame^] | 26 | #define _LARGEFILE64_SOURCE |
| 27 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 28 | #include <stdio.h> |
| 29 | #include <pci/pci.h> |
| 30 | #include <stdlib.h> |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame^] | 31 | #include <sys/types.h> |
| 32 | #include <sys/stat.h> |
| 33 | #include <fcntl.h> |
| 34 | #include <unistd.h> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 35 | #include "flash.h" |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 36 | |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 37 | static int enable_flash_ali_m1533(struct pci_dev *dev, char *name) |
| 38 | { |
| 39 | uint8_t tmp; |
| 40 | |
| 41 | /* ROM Write enable, 0xFFFC0000-0xFFFDFFFF and |
| 42 | 0xFFFE0000-0xFFFFFFFF ROM select enable. */ |
| 43 | tmp = pci_read_byte(dev, 0x47); |
| 44 | tmp |= 0x46; |
| 45 | pci_write_byte(dev, 0x47, tmp); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 50 | static int enable_flash_sis630(struct pci_dev *dev, char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 51 | { |
| 52 | char b; |
| 53 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 54 | /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */ |
Alex Beregszaszi | c9fb5d9 | 2007-09-11 15:58:18 +0000 | [diff] [blame] | 55 | b = pci_read_byte(dev, 0x40); |
| 56 | pci_write_byte(dev, 0x40, b | 0xb); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 57 | /* Flash write enable on SiS 540/630 */ |
Alex Beregszaszi | c9fb5d9 | 2007-09-11 15:58:18 +0000 | [diff] [blame] | 58 | b = pci_read_byte(dev, 0x45); |
| 59 | pci_write_byte(dev, 0x45, b | 0x40); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 60 | |
| 61 | /* The same thing on SiS 950 SuperIO side */ |
| 62 | outb(0x87, 0x2e); |
| 63 | outb(0x01, 0x2e); |
| 64 | outb(0x55, 0x2e); |
| 65 | outb(0x55, 0x2e); |
| 66 | |
| 67 | if (inb(0x2f) != 0x87) { |
| 68 | outb(0x87, 0x4e); |
| 69 | outb(0x01, 0x4e); |
| 70 | outb(0x55, 0x4e); |
| 71 | outb(0xaa, 0x4e); |
| 72 | if (inb(0x4f) != 0x87) { |
| 73 | printf("Can not access SiS 950\n"); |
| 74 | return -1; |
| 75 | } |
| 76 | outb(0x24, 0x4e); |
| 77 | b = inb(0x4f) | 0xfc; |
| 78 | outb(0x24, 0x4e); |
| 79 | outb(b, 0x4f); |
| 80 | outb(0x02, 0x4e); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 81 | outb(0x02, 0x4f); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | outb(0x24, 0x2e); |
| 85 | printf("2f is %#x\n", inb(0x2f)); |
| 86 | b = inb(0x2f) | 0xfc; |
| 87 | outb(0x24, 0x2e); |
| 88 | outb(b, 0x2f); |
| 89 | |
| 90 | outb(0x02, 0x2e); |
| 91 | outb(0x02, 0x2f); |
| 92 | |
| 93 | return 0; |
| 94 | } |
| 95 | |
Uwe Hermann | 987942d | 2006-11-07 11:16:21 +0000 | [diff] [blame] | 96 | /* Datasheet: |
| 97 | * - Name: 82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4) |
| 98 | * - URL: http://www.intel.com/design/intarch/datashts/290562.htm |
| 99 | * - PDF: http://www.intel.com/design/intarch/datashts/29056201.pdf |
| 100 | * - Order Number: 290562-001 |
| 101 | */ |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 102 | static int enable_flash_piix4(struct pci_dev *dev, char *name) |
| 103 | { |
| 104 | uint16_t old, new; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 105 | uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */ |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 106 | |
| 107 | old = pci_read_word(dev, xbcs); |
| 108 | |
| 109 | /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 110 | * FFF00000-FFF7FFFF are forwarded to ISA). |
| 111 | * Set bit 7: Extended BIOS Enable (PCI master accesses to |
| 112 | * FFF80000-FFFDFFFF are forwarded to ISA). |
| 113 | * Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to |
| 114 | * the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top |
| 115 | * of 1 Mbyte, or the aliases at the top of 4 Gbyte |
| 116 | * (FFFE0000-FFFEFFFF) result in the generation of BIOSCS#. |
| 117 | * Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA. |
| 118 | * Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable). |
| 119 | */ |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 120 | new = old | 0x2c4; |
| 121 | |
| 122 | if (new == old) |
| 123 | return 0; |
| 124 | |
| 125 | pci_write_word(dev, xbcs, new); |
| 126 | |
| 127 | if (pci_read_word(dev, xbcs) != new) { |
| 128 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", xbcs, new, name); |
| 129 | return -1; |
| 130 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 131 | |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 132 | return 0; |
| 133 | } |
| 134 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 135 | static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl) |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 136 | { |
| 137 | /* register 4e.b gets or'ed with one */ |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 138 | uint8_t old, new; |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 139 | |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 140 | /* if it fails, it fails. There are so many variations of broken mobos |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 141 | * that it is hard to argue that we should quit at this point. |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 142 | */ |
| 143 | |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 144 | /* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 145 | * just treating it as 8 bit wide seems to work fine in practice. |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 146 | */ |
| 147 | |
| 148 | /* see ie. page 375 of "Intel ICH7 External Design Specification" |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 149 | * http://download.intel.com/design/chipsets/datashts/30701302.pdf |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 150 | */ |
| 151 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 152 | old = pci_read_byte(dev, bios_cntl); |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 153 | |
| 154 | new = old | 1; |
| 155 | |
| 156 | if (new == old) |
| 157 | return 0; |
| 158 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 159 | pci_write_byte(dev, bios_cntl, new); |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 160 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 161 | if (pci_read_byte(dev, bios_cntl) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 162 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", bios_cntl, new, name); |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 163 | return -1; |
| 164 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 165 | |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 166 | return 0; |
| 167 | } |
| 168 | |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 169 | static int enable_flash_ich_4e(struct pci_dev *dev, char *name) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 170 | { |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 171 | return enable_flash_ich(dev, name, 0x4e); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 174 | static int enable_flash_ich_dc(struct pci_dev *dev, char *name) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 175 | { |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 176 | return enable_flash_ich(dev, name, 0xdc); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 179 | static int enable_flash_vt823x(struct pci_dev *dev, char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 180 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 181 | uint8_t val; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 182 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 183 | /* ROM write enable */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 184 | val = pci_read_byte(dev, 0x40); |
| 185 | val |= 0x10; |
| 186 | pci_write_byte(dev, 0x40, val); |
| 187 | |
| 188 | if (pci_read_byte(dev, 0x40) != val) { |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 189 | printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 190 | name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 191 | return -1; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 192 | } |
Luc Verhaegen | 6382b44 | 2007-03-02 22:16:38 +0000 | [diff] [blame] | 193 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 194 | return 0; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static int enable_flash_cs5530(struct pci_dev *dev, char *name) |
| 198 | { |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 199 | uint8_t reg8; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 200 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 201 | #define DECODE_CONTROL_REG2 0x5b /* F0 index 0x5b */ |
| 202 | #define ROM_AT_LOGIC_CONTROL_REG 0x52 /* F0 index 0x52 */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 203 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 204 | #define LOWER_ROM_ADDRESS_RANGE (1 << 0) |
| 205 | #define ROM_WRITE_ENABLE (1 << 1) |
| 206 | #define UPPER_ROM_ADDRESS_RANGE (1 << 2) |
| 207 | #define BIOS_ROM_POSITIVE_DECODE (1 << 5) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 208 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 209 | /* Decode 0x000E0000-0x000FFFFF (128 KB), not just 64 KB, and |
| 210 | * decode 0xFF000000-0xFFFFFFFF (16 MB), not just 256 KB. |
| 211 | * Make the configured ROM areas writable. |
| 212 | */ |
| 213 | reg8 = pci_read_byte(dev, ROM_AT_LOGIC_CONTROL_REG); |
| 214 | reg8 |= LOWER_ROM_ADDRESS_RANGE; |
| 215 | reg8 |= UPPER_ROM_ADDRESS_RANGE; |
| 216 | reg8 |= ROM_WRITE_ENABLE; |
| 217 | pci_write_byte(dev, ROM_AT_LOGIC_CONTROL_REG, reg8); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 218 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 219 | /* Set positive decode on ROM. */ |
| 220 | reg8 = pci_read_byte(dev, DECODE_CONTROL_REG2); |
| 221 | reg8 |= BIOS_ROM_POSITIVE_DECODE; |
| 222 | pci_write_byte(dev, DECODE_CONTROL_REG2, reg8); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 223 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame^] | 227 | static int enable_flash_cs5536(struct pci_dev *dev, char *name) |
| 228 | { |
| 229 | int fd_msr; |
| 230 | unsigned char buf[8]; |
| 231 | unsigned int addr = 0x1808; |
| 232 | |
| 233 | /* Geode systems write protect the BIOS via RCONFs (cache |
| 234 | * settings similar to MTRRs). To unlock, change MSR 0x1808 |
| 235 | * top byte to 0x22. Reading and writing to msr, however |
| 236 | * requires instrucitons rdmsr/wrmsr, which are ring0 privileged |
| 237 | * instructions so only the kernel can do the read/write. This |
| 238 | * function, therefore, requires that the msr kernel module be |
| 239 | * loaded to access these instructions from user space using |
| 240 | * device /dev/cpu/0/msr. This hard-coded driver location |
| 241 | * could have potential problems on SMP machines since it |
| 242 | * assumes cpu0, but it is safe on the geode which is not SMP. |
| 243 | * |
| 244 | * This is probably not portable beyond linux. |
| 245 | */ |
| 246 | |
| 247 | fd_msr = open("/dev/cpu/0/msr", O_RDONLY); |
| 248 | if (!fd_msr) { |
| 249 | perror("open msr"); |
| 250 | return -1; |
| 251 | } |
| 252 | lseek64(fd_msr, (off64_t) addr, SEEK_SET); |
| 253 | read(fd_msr, buf, 8); |
| 254 | close(fd_msr); |
| 255 | if (buf[7] != 0x22) { |
| 256 | printf("Enabling Geode MSR to write to flash.\n"); |
| 257 | buf[7] = 0x22; |
| 258 | fd_msr = open("/dev/cpu/0/msr", O_WRONLY); |
| 259 | if (!fd_msr) { |
| 260 | perror("open msr"); |
| 261 | return -1; |
| 262 | } |
| 263 | lseek64(fd_msr, (off64_t) addr, SEEK_SET); |
| 264 | if (write(fd_msr, buf, 8) < 0) { |
| 265 | perror("msr write"); |
| 266 | printf |
| 267 | ("Cannot write to MSR. Make sure msr kernel is loaded: 'modprobe msr'\n"); |
| 268 | return -1; |
| 269 | } |
| 270 | close(fd_msr); |
| 271 | } |
| 272 | return 0; |
| 273 | } |
| 274 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 275 | static int enable_flash_sc1100(struct pci_dev *dev, char *name) |
| 276 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 277 | uint8_t new; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 278 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 279 | pci_write_byte(dev, 0x52, 0xee); |
| 280 | |
| 281 | new = pci_read_byte(dev, 0x52); |
| 282 | |
| 283 | if (new != 0xee) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 284 | printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 285 | return -1; |
| 286 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 287 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | static int enable_flash_sis5595(struct pci_dev *dev, char *name) |
| 292 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 293 | uint8_t new, newer; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 294 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 295 | new = pci_read_byte(dev, 0x45); |
| 296 | |
| 297 | /* clear bit 5 */ |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 298 | new &= (~0x20); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 299 | /* set bit 2 */ |
| 300 | new |= 0x4; |
| 301 | |
| 302 | pci_write_byte(dev, 0x45, new); |
| 303 | |
| 304 | newer = pci_read_byte(dev, 0x45); |
| 305 | if (newer != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 306 | printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x45, new, name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 307 | printf("Stuck at 0x%x\n", newer); |
| 308 | return -1; |
| 309 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 310 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 314 | static int enable_flash_amd8111(struct pci_dev *dev, char *name) |
| 315 | { |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 316 | /* register 4e.b gets or'ed with one */ |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 317 | uint8_t old, new; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 318 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 319 | /* if it fails, it fails. There are so many variations of broken mobos |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 320 | * that it is hard to argue that we should quit at this point. |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 321 | */ |
| 322 | |
Ollie Lho | d11f361 | 2004-12-07 17:19:04 +0000 | [diff] [blame] | 323 | /* enable decoding at 0xffb00000 to 0xffffffff */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 324 | old = pci_read_byte(dev, 0x43); |
Ollie Lho | d11f361 | 2004-12-07 17:19:04 +0000 | [diff] [blame] | 325 | new = old | 0xC0; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 326 | if (new != old) { |
| 327 | pci_write_byte(dev, 0x43, new); |
| 328 | if (pci_read_byte(dev, 0x43) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 329 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x43, new, name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 333 | old = pci_read_byte(dev, 0x40); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 334 | new = old | 0x01; |
| 335 | if (new == old) |
| 336 | return 0; |
| 337 | pci_write_byte(dev, 0x40, new); |
| 338 | |
| 339 | if (pci_read_byte(dev, 0x40) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 340 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 341 | return -1; |
| 342 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 343 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 344 | return 0; |
| 345 | } |
| 346 | |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 347 | static int enable_flash_ck804(struct pci_dev *dev, char *name) |
| 348 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 349 | /* register 4e.b gets or'ed with one */ |
| 350 | uint8_t old, new; |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 351 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 352 | /* if it fails, it fails. There are so many variations of broken mobos |
| 353 | * that it is hard to argue that we should quit at this point. |
| 354 | */ |
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 | /* dump_pci_device(dev); */ |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 357 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 358 | old = pci_read_byte(dev, 0x88); |
| 359 | new = old | 0xc0; |
| 360 | if (new != old) { |
| 361 | pci_write_byte(dev, 0x88, new); |
| 362 | if (pci_read_byte(dev, 0x88) != new) { |
| 363 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name); |
| 364 | } |
| 365 | } |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 366 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 367 | old = pci_read_byte(dev, 0x6d); |
| 368 | new = old | 0x01; |
| 369 | if (new == old) |
| 370 | return 0; |
| 371 | pci_write_byte(dev, 0x6d, new); |
| 372 | |
| 373 | if (pci_read_byte(dev, 0x6d) != new) { |
| 374 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name); |
| 375 | return -1; |
| 376 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 377 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 378 | return 0; |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 381 | static int enable_flash_sb400(struct pci_dev *dev, char *name) |
| 382 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 383 | uint8_t tmp; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 384 | |
| 385 | struct pci_filter f; |
| 386 | struct pci_dev *smbusdev; |
| 387 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 388 | /* then look for the smbus device */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 389 | pci_filter_init((struct pci_access *)0, &f); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 390 | f.vendor = 0x1002; |
| 391 | f.device = 0x4372; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 392 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 393 | for (smbusdev = pacc->devices; smbusdev; smbusdev = smbusdev->next) { |
| 394 | if (pci_filter_match(&f, smbusdev)) { |
| 395 | break; |
| 396 | } |
| 397 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 398 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 399 | if (!smbusdev) { |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 400 | fprintf(stderr, "ERROR: SMBus device not found. aborting\n"); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 401 | exit(1); |
| 402 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 403 | |
| 404 | /* enable some smbus stuff */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 405 | tmp = pci_read_byte(smbusdev, 0x79); |
| 406 | tmp |= 0x01; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 407 | pci_write_byte(smbusdev, 0x79, tmp); |
| 408 | |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 409 | /* change southbridge */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 410 | tmp = pci_read_byte(dev, 0x48); |
| 411 | tmp |= 0x21; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 412 | pci_write_byte(dev, 0x48, tmp); |
| 413 | |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 414 | /* now become a bit silly. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 415 | tmp = inb(0xc6f); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 416 | outb(tmp, 0xeb); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 417 | outb(tmp, 0xeb); |
| 418 | tmp |= 0x40; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 419 | outb(tmp, 0xc6f); |
| 420 | outb(tmp, 0xeb); |
| 421 | outb(tmp, 0xeb); |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 426 | static int enable_flash_mcp55(struct pci_dev *dev, char *name) |
| 427 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 428 | /* register 4e.b gets or'ed with one */ |
| 429 | unsigned char old, new, byte; |
| 430 | unsigned short word; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 431 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 432 | /* if it fails, it fails. There are so many variations of broken mobos |
| 433 | * that it is hard to argue that we should quit at this point. |
| 434 | */ |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 435 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 436 | /* dump_pci_device(dev); */ |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 437 | |
Carl-Daniel Hailfinger | dca0ab1 | 2007-10-17 22:30:07 +0000 | [diff] [blame] | 438 | /* Set the 0-16 MB enable bits */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 439 | byte = pci_read_byte(dev, 0x88); |
| 440 | byte |= 0xff; /* 256K */ |
| 441 | pci_write_byte(dev, 0x88, byte); |
| 442 | byte = pci_read_byte(dev, 0x8c); |
| 443 | byte |= 0xff; /* 1M */ |
| 444 | pci_write_byte(dev, 0x8c, byte); |
| 445 | word = pci_read_word(dev, 0x90); |
Carl-Daniel Hailfinger | dca0ab1 | 2007-10-17 22:30:07 +0000 | [diff] [blame] | 446 | word |= 0x7fff; /* 16M */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 447 | pci_write_word(dev, 0x90, word); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 448 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 449 | old = pci_read_byte(dev, 0x6d); |
| 450 | new = old | 0x01; |
| 451 | if (new == old) |
| 452 | return 0; |
| 453 | pci_write_byte(dev, 0x6d, new); |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 454 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 455 | if (pci_read_byte(dev, 0x6d) != new) { |
| 456 | printf |
| 457 | ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", |
| 458 | 0x6d, new, name); |
| 459 | return -1; |
| 460 | } |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 461 | |
| 462 | return 0; |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 465 | static int enable_flash_ht1000(struct pci_dev *dev, char *name) |
| 466 | { |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 467 | uint8_t byte; |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 468 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 469 | /* Set the 4MB enable bit. */ |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 470 | byte = pci_read_byte(dev, 0x41); |
| 471 | byte |= 0x0e; |
| 472 | pci_write_byte(dev, 0x41, byte); |
| 473 | |
| 474 | byte = pci_read_byte(dev, 0x43); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 475 | byte |= (1 << 4); |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 476 | pci_write_byte(dev, 0x43, byte); |
| 477 | |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 478 | return 0; |
| 479 | } |
| 480 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 481 | typedef struct penable { |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 482 | unsigned short vendor, device; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 483 | char *name; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 484 | int (*doit) (struct pci_dev * dev, char *name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 485 | } FLASH_ENABLE; |
| 486 | |
| 487 | static FLASH_ENABLE enables[] = { |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 488 | {0x1039, 0x0630, "SIS630", enable_flash_sis630}, |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 489 | {0x8086, 0x7110, "PIIX4/PIIX4E/PIIX4M", enable_flash_piix4}, |
Uwe Hermann | 97a6470 | 2007-10-30 00:56:50 +0000 | [diff] [blame] | 490 | {0x8086, 0x7198, "Intel 440MX", enable_flash_piix4}, |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 491 | {0x8086, 0x2410, "ICH", enable_flash_ich_4e}, |
| 492 | {0x8086, 0x2420, "ICH0", enable_flash_ich_4e}, |
| 493 | {0x8086, 0x2440, "ICH2", enable_flash_ich_4e}, |
| 494 | {0x8086, 0x244c, "ICH2-M", enable_flash_ich_4e}, |
| 495 | {0x8086, 0x2480, "ICH3-S", enable_flash_ich_4e}, |
| 496 | {0x8086, 0x248c, "ICH3-M", enable_flash_ich_4e}, |
| 497 | {0x8086, 0x24c0, "ICH4/ICH4-L", enable_flash_ich_4e}, |
| 498 | {0x8086, 0x24cc, "ICH4-M", enable_flash_ich_4e}, |
| 499 | {0x8086, 0x24d0, "ICH5/ICH5R", enable_flash_ich_4e}, |
| 500 | {0x8086, 0x2640, "ICH6/ICH6R", enable_flash_ich_dc}, |
| 501 | {0x8086, 0x2641, "ICH6-M", enable_flash_ich_dc}, |
Uwe Hermann | 3ad2518 | 2007-03-31 19:48:38 +0000 | [diff] [blame] | 502 | {0x8086, 0x27b0, "ICH7DH", enable_flash_ich_dc}, |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 503 | {0x8086, 0x27b8, "ICH7/ICH7R", enable_flash_ich_dc}, |
| 504 | {0x8086, 0x27b9, "ICH7M", enable_flash_ich_dc}, |
| 505 | {0x8086, 0x27bd, "ICH7MDH", enable_flash_ich_dc}, |
| 506 | {0x8086, 0x2810, "ICH8/ICH8R", enable_flash_ich_dc}, |
| 507 | {0x8086, 0x2812, "ICH8DH", enable_flash_ich_dc}, |
| 508 | {0x8086, 0x2814, "ICH8DO", enable_flash_ich_dc}, |
Luc Verhaegen | 6382b44 | 2007-03-02 22:16:38 +0000 | [diff] [blame] | 509 | {0x1106, 0x8231, "VT8231", enable_flash_vt823x}, |
| 510 | {0x1106, 0x3177, "VT8235", enable_flash_vt823x}, |
| 511 | {0x1106, 0x3227, "VT8237", enable_flash_vt823x}, |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 512 | {0x1106, 0x8324, "CX700", enable_flash_vt823x}, |
Stefan Reinauer | c6b5f49 | 2006-11-07 10:22:20 +0000 | [diff] [blame] | 513 | {0x1106, 0x0686, "VT82C686", enable_flash_amd8111}, |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 514 | {0x1078, 0x0100, "CS5530/CS5530A", enable_flash_cs5530}, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 515 | {0x100b, 0x0510, "SC1100", enable_flash_sc1100}, |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 516 | {0x1039, 0x0008, "SIS5595", enable_flash_sis5595}, |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame^] | 517 | {0x1022, 0x2080, "AMD GEODE CS5536", enable_flash_cs5536}, |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 518 | {0x1022, 0x7468, "AMD8111", enable_flash_amd8111}, |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 519 | {0x10B9, 0x1533, "ALi M1533", enable_flash_ali_m1533}, |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 520 | /* this fallthrough looks broken. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 521 | {0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */ |
| 522 | {0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */ |
| 523 | {0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, /* Slave, should not be here, to fix known bug for A01. */ |
Stefan Reinauer | 219b61e | 2006-10-14 21:04:49 +0000 | [diff] [blame] | 524 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 525 | {0x10de, 0x0260, "NVidia MCP51", enable_flash_ck804}, |
| 526 | {0x10de, 0x0261, "NVidia MCP51", enable_flash_ck804}, |
| 527 | {0x10de, 0x0262, "NVidia MCP51", enable_flash_ck804}, |
| 528 | {0x10de, 0x0263, "NVidia MCP51", enable_flash_ck804}, |
Stefan Reinauer | 219b61e | 2006-10-14 21:04:49 +0000 | [diff] [blame] | 529 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 530 | {0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* Gigabyte m57sli-s4 */ |
| 531 | {0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 532 | {0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 533 | {0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 534 | {0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 535 | {0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 536 | {0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 537 | {0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */ |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 538 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 539 | {0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */ |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 540 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 541 | {0x1166, 0x0205, "Broadcom HT-1000", enable_flash_ht1000}, |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 542 | }; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 543 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 544 | int chipset_flash_enable(void) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 545 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 546 | struct pci_dev *dev = 0; |
| 547 | int ret = -2; /* nothing! */ |
| 548 | int i; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 549 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 550 | /* now let's try to find the chipset we have ... */ |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 551 | for (i = 0; i < sizeof(enables) / sizeof(enables[0]); i++) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 552 | dev = pci_dev_find(enables[i].vendor, enables[i].device); |
| 553 | if (dev) |
| 554 | break; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 555 | } |
| 556 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 557 | if (dev) { |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame] | 558 | printf("Found chipset \"%s\", enabling flash write... ", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 559 | enables[i].name); |
| 560 | |
| 561 | ret = enables[i].doit(dev, enables[i].name); |
| 562 | if (ret) |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame] | 563 | printf("FAILED!\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 564 | else |
Uwe Hermann | ac30934 | 2007-10-10 17:42:20 +0000 | [diff] [blame] | 565 | printf("OK.\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | return ret; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 569 | } |