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> |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 33 | #include <sys/mman.h> |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 34 | #include <fcntl.h> |
| 35 | #include <unistd.h> |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 36 | #include "flash.h" |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 37 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 38 | /** |
| 39 | * flashrom defaults to LPC flash devices. If a known SPI controller is found |
| 40 | * and the SPI strappings are set, this will be overwritten by the probing code. |
| 41 | * |
| 42 | * Eventually, this will become an array when multiple flash support works. |
| 43 | */ |
| 44 | |
| 45 | flashbus_t flashbus = BUS_TYPE_LPC; |
| 46 | void *spibar = NULL; |
| 47 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 48 | static int enable_flash_ali_m1533(struct pci_dev *dev, const char *name) |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 49 | { |
| 50 | uint8_t tmp; |
| 51 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 52 | /* |
| 53 | * ROM Write enable, 0xFFFC0000-0xFFFDFFFF and |
| 54 | * 0xFFFE0000-0xFFFFFFFF ROM select enable. |
| 55 | */ |
Luc Verhaegen | 6b14175 | 2007-05-20 16:16:13 +0000 | [diff] [blame] | 56 | tmp = pci_read_byte(dev, 0x47); |
| 57 | tmp |= 0x46; |
| 58 | pci_write_byte(dev, 0x47, tmp); |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 63 | static int enable_flash_sis630(struct pci_dev *dev, const char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 64 | { |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 65 | uint8_t b; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 66 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 67 | /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630. */ |
Alex Beregszaszi | c9fb5d9 | 2007-09-11 15:58:18 +0000 | [diff] [blame] | 68 | b = pci_read_byte(dev, 0x40); |
| 69 | pci_write_byte(dev, 0x40, b | 0xb); |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 70 | |
| 71 | /* Flash write enable on SiS 540/630. */ |
Alex Beregszaszi | c9fb5d9 | 2007-09-11 15:58:18 +0000 | [diff] [blame] | 72 | b = pci_read_byte(dev, 0x45); |
| 73 | pci_write_byte(dev, 0x45, b | 0x40); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 74 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 75 | /* The same thing on SiS 950 Super I/O side... */ |
| 76 | |
| 77 | /* First probe for Super I/O on config port 0x2e. */ |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 78 | OUTB(0x87, 0x2e); |
| 79 | OUTB(0x01, 0x2e); |
| 80 | OUTB(0x55, 0x2e); |
| 81 | OUTB(0x55, 0x2e); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 82 | |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 83 | if (INB(0x2f) != 0x87) { |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 84 | /* If that failed, try config port 0x4e. */ |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 85 | OUTB(0x87, 0x4e); |
| 86 | OUTB(0x01, 0x4e); |
| 87 | OUTB(0x55, 0x4e); |
| 88 | OUTB(0xaa, 0x4e); |
| 89 | if (INB(0x4f) != 0x87) { |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 90 | printf("Can not access SiS 950\n"); |
| 91 | return -1; |
| 92 | } |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 93 | OUTB(0x24, 0x4e); |
| 94 | b = INB(0x4f) | 0xfc; |
| 95 | OUTB(0x24, 0x4e); |
| 96 | OUTB(b, 0x4f); |
| 97 | OUTB(0x02, 0x4e); |
| 98 | OUTB(0x02, 0x4f); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 101 | OUTB(0x24, 0x2e); |
| 102 | printf("2f is %#x\n", INB(0x2f)); |
| 103 | b = INB(0x2f) | 0xfc; |
| 104 | OUTB(0x24, 0x2e); |
| 105 | OUTB(b, 0x2f); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 106 | |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 107 | OUTB(0x02, 0x2e); |
| 108 | OUTB(0x02, 0x2f); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
Uwe Hermann | 987942d | 2006-11-07 11:16:21 +0000 | [diff] [blame] | 113 | /* Datasheet: |
| 114 | * - Name: 82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4) |
| 115 | * - URL: http://www.intel.com/design/intarch/datashts/290562.htm |
| 116 | * - PDF: http://www.intel.com/design/intarch/datashts/29056201.pdf |
| 117 | * - Order Number: 290562-001 |
| 118 | */ |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 119 | static int enable_flash_piix4(struct pci_dev *dev, const char *name) |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 120 | { |
| 121 | uint16_t old, new; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 122 | uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */ |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 123 | |
| 124 | old = pci_read_word(dev, xbcs); |
| 125 | |
| 126 | /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 127 | * FFF00000-FFF7FFFF are forwarded to ISA). |
Uwe Hermann | 8720345 | 2008-10-26 18:40:42 +0000 | [diff] [blame^] | 128 | * Note: This bit is reserved on PIIX/PIIX3. |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 129 | * Set bit 7: Extended BIOS Enable (PCI master accesses to |
| 130 | * FFF80000-FFFDFFFF are forwarded to ISA). |
| 131 | * Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to |
| 132 | * the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top |
| 133 | * of 1 Mbyte, or the aliases at the top of 4 Gbyte |
| 134 | * (FFFE0000-FFFEFFFF) result in the generation of BIOSCS#. |
| 135 | * Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA. |
| 136 | * Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable). |
| 137 | */ |
Uwe Hermann | 8720345 | 2008-10-26 18:40:42 +0000 | [diff] [blame^] | 138 | if (dev->device_id == 0x122e || dev->device_id == 0x7000) |
| 139 | new = old | 0x00c4; /* Bit 9 is reserved on PIIX/PIIX3. */ |
| 140 | else |
| 141 | new = old | 0x02c4; |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 142 | |
| 143 | if (new == old) |
| 144 | return 0; |
| 145 | |
| 146 | pci_write_word(dev, xbcs, new); |
| 147 | |
| 148 | if (pci_read_word(dev, xbcs) != new) { |
| 149 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", xbcs, new, name); |
| 150 | return -1; |
| 151 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 152 | |
Uwe Hermann | ea2c66d | 2006-11-05 18:26:08 +0000 | [diff] [blame] | 153 | return 0; |
| 154 | } |
| 155 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 156 | /* |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 157 | * See ie. page 375 of "Intel I/O Controller Hub 7 (ICH7) Family Datasheet" |
| 158 | * http://download.intel.com/design/chipsets/datashts/30701303.pdf |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 159 | */ |
| 160 | static int enable_flash_ich(struct pci_dev *dev, const char *name, |
| 161 | int bios_cntl) |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 162 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 163 | uint8_t old, new; |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 164 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 165 | /* |
| 166 | * 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] | 167 | * 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] | 168 | */ |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 169 | old = pci_read_byte(dev, bios_cntl); |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 170 | |
Uwe Hermann | 793bdcd | 2008-05-22 22:47:04 +0000 | [diff] [blame] | 171 | printf_debug("\nBIOS Lock Enable: %sabled, ", |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 172 | (old & (1 << 1)) ? "en" : "dis"); |
| 173 | printf_debug("BIOS Write Enable: %sabled, ", |
| 174 | (old & (1 << 0)) ? "en" : "dis"); |
| 175 | printf_debug("BIOS_CNTL is 0x%x\n", old); |
| 176 | |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 177 | new = old | 1; |
| 178 | |
| 179 | if (new == old) |
| 180 | return 0; |
| 181 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 182 | pci_write_byte(dev, bios_cntl, new); |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 183 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 184 | if (pci_read_byte(dev, bios_cntl) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 185 | 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] | 186 | return -1; |
| 187 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 188 | |
Ronald G. Minnich | 6a96741 | 2004-09-28 20:09:06 +0000 | [diff] [blame] | 189 | return 0; |
| 190 | } |
| 191 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 192 | static int enable_flash_ich_4e(struct pci_dev *dev, const char *name) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 193 | { |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 194 | return enable_flash_ich(dev, name, 0x4e); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 195 | } |
| 196 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 197 | static int enable_flash_ich_dc(struct pci_dev *dev, const char *name) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 198 | { |
Stefan Reinauer | eb36647 | 2006-09-06 15:48:48 +0000 | [diff] [blame] | 199 | return enable_flash_ich(dev, name, 0xdc); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 202 | #define ICH_STRAP_RSVD 0x00 |
| 203 | #define ICH_STRAP_SPI 0x01 |
| 204 | #define ICH_STRAP_PCI 0x02 |
| 205 | #define ICH_STRAP_LPC 0x03 |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 206 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 207 | static int enable_flash_vt8237s_spi(struct pci_dev *dev, const char *name) |
| 208 | { |
Rudolf Marek | 3fdbccf | 2008-06-30 21:38:30 +0000 | [diff] [blame] | 209 | uint32_t mmio_base; |
| 210 | |
| 211 | mmio_base = (pci_read_long(dev, 0xbc)) << 8; |
| 212 | printf_debug("MMIO base at = 0x%x\n", mmio_base); |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 213 | spibar = mmap(NULL, 0x70, PROT_READ | PROT_WRITE, MAP_SHARED, |
| 214 | fd_mem, mmio_base); |
Rudolf Marek | 3fdbccf | 2008-06-30 21:38:30 +0000 | [diff] [blame] | 215 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 216 | if (spibar == MAP_FAILED) { |
Rudolf Marek | 3fdbccf | 2008-06-30 21:38:30 +0000 | [diff] [blame] | 217 | perror("Can't mmap memory using " MEM_DEV); |
| 218 | exit(1); |
| 219 | } |
| 220 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 221 | printf_debug("0x6c: 0x%04x (CLOCK/DEBUG)\n", |
| 222 | *(uint16_t *) (spibar + 0x6c)); |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 223 | |
| 224 | flashbus = BUS_TYPE_VIA_SPI; |
| 225 | |
Rudolf Marek | 3fdbccf | 2008-06-30 21:38:30 +0000 | [diff] [blame] | 226 | return 0; |
| 227 | } |
| 228 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 229 | static int enable_flash_ich_dc_spi(struct pci_dev *dev, const char *name, |
| 230 | int ich_generation) |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 231 | { |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 232 | int ret, i; |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 233 | uint8_t old, new, bbs, buc; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 234 | uint16_t spibar_offset; |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 235 | uint32_t tmp, gcs; |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 236 | void *rcrb; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 237 | static const char *straps_names[] = { "reserved", "SPI", "PCI", "LPC" }; |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 238 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 239 | /* Enable Flash Writes */ |
| 240 | ret = enable_flash_ich_dc(dev, name); |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 241 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 242 | /* Get physical address of Root Complex Register Block */ |
| 243 | tmp = pci_read_long(dev, 0xf0) & 0xffffc000; |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 244 | printf_debug("\nRoot Complex Register Block address = 0x%x\n", tmp); |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 245 | |
| 246 | /* Map RCBA to virtual memory */ |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 247 | rcrb = mmap(0, 0x4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd_mem, |
| 248 | (off_t) tmp); |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 249 | if (rcrb == MAP_FAILED) { |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 250 | perror("Can't mmap memory using " MEM_DEV); |
| 251 | exit(1); |
| 252 | } |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 253 | |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 254 | gcs = *(volatile uint32_t *)(rcrb + 0x3410); |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 255 | printf_debug("GCS = 0x%x: ", gcs); |
| 256 | printf_debug("BIOS Interface Lock-Down: %sabled, ", |
| 257 | (gcs & 0x1) ? "en" : "dis"); |
| 258 | bbs = (gcs >> 10) & 0x3; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 259 | printf_debug("BOOT BIOS Straps: 0x%x (%s)\n", bbs, straps_names[bbs]); |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 260 | |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 261 | buc = *(volatile uint8_t *)(rcrb + 0x3414); |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 262 | printf_debug("Top Swap : %s\n", |
| 263 | (buc & 1) ? "enabled (A16 inverted)" : "not enabled"); |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 264 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 265 | /* It seems the ICH7 does not support SPI and LPC chips at the same |
| 266 | * time. At least not with our current code. So we prevent searching |
| 267 | * on ICH7 when the southbridge is strapped to LPC |
| 268 | */ |
| 269 | |
| 270 | if (ich_generation == 7 && bbs == ICH_STRAP_LPC) { |
| 271 | /* No further SPI initialization required */ |
| 272 | return ret; |
| 273 | } |
| 274 | |
| 275 | switch (ich_generation) { |
| 276 | case 7: |
| 277 | flashbus = BUS_TYPE_ICH7_SPI; |
| 278 | spibar_offset = 0x3020; |
| 279 | break; |
| 280 | case 8: |
| 281 | flashbus = BUS_TYPE_ICH9_SPI; |
| 282 | spibar_offset = 0x3020; |
| 283 | break; |
| 284 | case 9: |
Carl-Daniel Hailfinger | 28ec74b | 2008-10-10 20:54:41 +0000 | [diff] [blame] | 285 | case 10: |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 286 | default: /* Future version might behave the same */ |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 287 | flashbus = BUS_TYPE_ICH9_SPI; |
| 288 | spibar_offset = 0x3800; |
| 289 | break; |
| 290 | } |
| 291 | |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 292 | /* SPIBAR is at RCRB+0x3020 for ICH[78] and RCRB+0x3800 for ICH9. */ |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 293 | printf_debug("SPIBAR = 0x%x + 0x%04x\n", tmp, spibar_offset); |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 294 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 295 | /* Assign Virtual Address */ |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 296 | spibar = rcrb + spibar_offset; |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 297 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 298 | switch (flashbus) { |
| 299 | case BUS_TYPE_ICH7_SPI: |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 300 | printf_debug("0x00: 0x%04x (SPIS)\n", |
| 301 | *(uint16_t *) (spibar + 0)); |
| 302 | printf_debug("0x02: 0x%04x (SPIC)\n", |
| 303 | *(uint16_t *) (spibar + 2)); |
| 304 | printf_debug("0x04: 0x%08x (SPIA)\n", |
| 305 | *(uint32_t *) (spibar + 4)); |
| 306 | for (i = 0; i < 8; i++) { |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 307 | int offs; |
| 308 | offs = 8 + (i * 8); |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 309 | printf_debug("0x%02x: 0x%08x (SPID%d)\n", offs, |
| 310 | *(uint32_t *) (spibar + offs), i); |
| 311 | printf_debug("0x%02x: 0x%08x (SPID%d+4)\n", offs + 4, |
| 312 | *(uint32_t *) (spibar + offs + 4), i); |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 313 | } |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 314 | printf_debug("0x50: 0x%08x (BBAR)\n", |
| 315 | *(uint32_t *) (spibar + 0x50)); |
| 316 | printf_debug("0x54: 0x%04x (PREOP)\n", |
| 317 | *(uint16_t *) (spibar + 0x54)); |
| 318 | printf_debug("0x56: 0x%04x (OPTYPE)\n", |
| 319 | *(uint16_t *) (spibar + 0x56)); |
| 320 | printf_debug("0x58: 0x%08x (OPMENU)\n", |
| 321 | *(uint32_t *) (spibar + 0x58)); |
| 322 | printf_debug("0x5c: 0x%08x (OPMENU+4)\n", |
| 323 | *(uint32_t *) (spibar + 0x5c)); |
| 324 | for (i = 0; i < 4; i++) { |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 325 | int offs; |
| 326 | offs = 0x60 + (i * 4); |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 327 | printf_debug("0x%02x: 0x%08x (PBR%d)\n", offs, |
| 328 | *(uint32_t *) (spibar + offs), i); |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 329 | } |
| 330 | printf_debug("\n"); |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 331 | if ((*(uint16_t *) spibar) & (1 << 15)) { |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 332 | printf("WARNING: SPI Configuration Lockdown activated.\n"); |
| 333 | } |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 334 | break; |
| 335 | case BUS_TYPE_ICH9_SPI: |
| 336 | /* TODO: Add dumping function for ICH8/ICH9, or drop the |
| 337 | * whole SPIBAR dumping from chipset_enable.c - There's |
| 338 | * inteltool for this task already. |
| 339 | */ |
| 340 | break; |
| 341 | default: |
| 342 | /* Nothing */ |
| 343 | break; |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 346 | old = pci_read_byte(dev, 0xdc); |
| 347 | printf_debug("SPI Read Configuration: "); |
| 348 | new = (old >> 2) & 0x3; |
| 349 | switch (new) { |
| 350 | case 0: |
| 351 | case 1: |
| 352 | case 2: |
| 353 | printf_debug("prefetching %sabled, caching %sabled, ", |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 354 | (new & 0x2) ? "en" : "dis", |
| 355 | (new & 0x1) ? "dis" : "en"); |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 356 | break; |
| 357 | default: |
| 358 | printf_debug("invalid prefetching/caching settings, "); |
| 359 | break; |
| 360 | } |
Carl-Daniel Hailfinger | 67f9ea3 | 2008-03-14 17:20:59 +0000 | [diff] [blame] | 361 | |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 362 | return ret; |
| 363 | } |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 364 | |
Carl-Daniel Hailfinger | 1b18b3c | 2008-05-16 14:39:39 +0000 | [diff] [blame] | 365 | static int enable_flash_ich7(struct pci_dev *dev, const char *name) |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 366 | { |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 367 | return enable_flash_ich_dc_spi(dev, name, 7); |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Carl-Daniel Hailfinger | 1b18b3c | 2008-05-16 14:39:39 +0000 | [diff] [blame] | 370 | static int enable_flash_ich8(struct pci_dev *dev, const char *name) |
| 371 | { |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 372 | return enable_flash_ich_dc_spi(dev, name, 8); |
Carl-Daniel Hailfinger | 1b18b3c | 2008-05-16 14:39:39 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 375 | static int enable_flash_ich9(struct pci_dev *dev, const char *name) |
| 376 | { |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 377 | return enable_flash_ich_dc_spi(dev, name, 9); |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Carl-Daniel Hailfinger | 28ec74b | 2008-10-10 20:54:41 +0000 | [diff] [blame] | 380 | static int enable_flash_ich10(struct pci_dev *dev, const char *name) |
| 381 | { |
| 382 | return enable_flash_ich_dc_spi(dev, name, 10); |
| 383 | } |
| 384 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 385 | static int enable_flash_vt823x(struct pci_dev *dev, const char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 386 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 387 | uint8_t val; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 388 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 389 | /* enable ROM decode range (1MB) FFC00000 - FFFFFFFF */ |
Bari Ari | 9477c4e | 2008-04-29 13:46:38 +0000 | [diff] [blame] | 390 | pci_write_byte(dev, 0x41, 0x7f); |
| 391 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 392 | /* ROM write enable */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 393 | val = pci_read_byte(dev, 0x40); |
| 394 | val |= 0x10; |
| 395 | pci_write_byte(dev, 0x40, val); |
| 396 | |
| 397 | if (pci_read_byte(dev, 0x40) != val) { |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 398 | printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 399 | name); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 400 | return -1; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 401 | } |
Luc Verhaegen | 6382b44 | 2007-03-02 22:16:38 +0000 | [diff] [blame] | 402 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 403 | return 0; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 404 | } |
| 405 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 406 | static int enable_flash_cs5530(struct pci_dev *dev, const char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 407 | { |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 408 | uint8_t reg8; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 409 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 410 | #define DECODE_CONTROL_REG2 0x5b /* F0 index 0x5b */ |
| 411 | #define ROM_AT_LOGIC_CONTROL_REG 0x52 /* F0 index 0x52 */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 412 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 413 | #define LOWER_ROM_ADDRESS_RANGE (1 << 0) |
| 414 | #define ROM_WRITE_ENABLE (1 << 1) |
| 415 | #define UPPER_ROM_ADDRESS_RANGE (1 << 2) |
| 416 | #define BIOS_ROM_POSITIVE_DECODE (1 << 5) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 417 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 418 | /* Decode 0x000E0000-0x000FFFFF (128 KB), not just 64 KB, and |
| 419 | * decode 0xFF000000-0xFFFFFFFF (16 MB), not just 256 KB. |
| 420 | * Make the configured ROM areas writable. |
| 421 | */ |
| 422 | reg8 = pci_read_byte(dev, ROM_AT_LOGIC_CONTROL_REG); |
| 423 | reg8 |= LOWER_ROM_ADDRESS_RANGE; |
| 424 | reg8 |= UPPER_ROM_ADDRESS_RANGE; |
| 425 | reg8 |= ROM_WRITE_ENABLE; |
| 426 | pci_write_byte(dev, ROM_AT_LOGIC_CONTROL_REG, reg8); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 427 | |
Uwe Hermann | f4a673b | 2007-06-06 21:35:45 +0000 | [diff] [blame] | 428 | /* Set positive decode on ROM. */ |
| 429 | reg8 = pci_read_byte(dev, DECODE_CONTROL_REG2); |
| 430 | reg8 |= BIOS_ROM_POSITIVE_DECODE; |
| 431 | pci_write_byte(dev, DECODE_CONTROL_REG2, reg8); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 432 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 433 | return 0; |
| 434 | } |
| 435 | |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 436 | /** |
| 437 | * Geode systems write protect the BIOS via RCONFs (cache settings similar |
| 438 | * to MTRRs). To unlock, change MSR 0x1808 top byte to 0x22. Reading and |
| 439 | * writing to MSRs, however requires instructions rdmsr/wrmsr, which are |
| 440 | * ring0 privileged instructions so only the kernel can do the read/write. |
| 441 | * This function, therefore, requires that the msr kernel module be loaded |
| 442 | * to access these instructions from user space using device /dev/cpu/0/msr. |
| 443 | * |
| 444 | * This hard-coded location could have potential problems on SMP machines |
| 445 | * since it assumes cpu0, but it is safe on the Geode which is not SMP. |
| 446 | * |
| 447 | * Geode systems also write protect the NOR flash chip itself via MSR_NORF_CTL. |
| 448 | * To enable write to NOR Boot flash for the benefit of systems that have such |
| 449 | * a setup, raise MSR 0x51400018 WE_CS3 (write enable Boot Flash Chip Select). |
| 450 | * |
| 451 | * This is probably not portable beyond Linux. |
| 452 | */ |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 453 | static int enable_flash_cs5536(struct pci_dev *dev, const char *name) |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 454 | { |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 455 | #define MSR_RCONF_DEFAULT 0x1808 |
| 456 | #define MSR_NORF_CTL 0x51400018 |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 457 | |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 458 | int fd_msr; |
| 459 | unsigned char buf[8]; |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 460 | |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 461 | fd_msr = open("/dev/cpu/0/msr", O_RDWR); |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 462 | if (!fd_msr) { |
| 463 | perror("open msr"); |
| 464 | return -1; |
| 465 | } |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 466 | |
| 467 | if (lseek64(fd_msr, (off64_t) MSR_RCONF_DEFAULT, SEEK_SET) == -1) { |
| 468 | perror("lseek64"); |
Mart Raudsepp | 3697ac7 | 2008-02-11 14:32:45 +0000 | [diff] [blame] | 469 | printf("Cannot operate on MSR. Did you run 'modprobe msr'?\n"); |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 470 | close(fd_msr); |
| 471 | return -1; |
| 472 | } |
| 473 | |
| 474 | if (read(fd_msr, buf, 8) != 8) { |
Mart Raudsepp | 3697ac7 | 2008-02-11 14:32:45 +0000 | [diff] [blame] | 475 | perror("read msr"); |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 476 | close(fd_msr); |
| 477 | return -1; |
| 478 | } |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 479 | |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 480 | if (buf[7] != 0x22) { |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 481 | buf[7] &= 0xfb; |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 482 | if (lseek64(fd_msr, (off64_t) MSR_RCONF_DEFAULT, |
| 483 | SEEK_SET) == -1) { |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 484 | perror("lseek64"); |
| 485 | close(fd_msr); |
| 486 | return -1; |
| 487 | } |
| 488 | |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 489 | if (write(fd_msr, buf, 8) < 0) { |
| 490 | perror("msr write"); |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 491 | close(fd_msr); |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 492 | return -1; |
| 493 | } |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 494 | } |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 495 | |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 496 | if (lseek64(fd_msr, (off64_t) MSR_NORF_CTL, SEEK_SET) == -1) { |
| 497 | perror("lseek64"); |
| 498 | close(fd_msr); |
| 499 | return -1; |
| 500 | } |
| 501 | |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 502 | if (read(fd_msr, buf, 8) != 8) { |
| 503 | perror("read msr"); |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 504 | close(fd_msr); |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 505 | return -1; |
| 506 | } |
| 507 | |
| 508 | /* Raise WE_CS3 bit. */ |
| 509 | buf[0] |= 0x08; |
| 510 | |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 511 | if (lseek64(fd_msr, (off64_t) MSR_NORF_CTL, SEEK_SET) == -1) { |
| 512 | perror("lseek64"); |
| 513 | close(fd_msr); |
| 514 | return -1; |
| 515 | } |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 516 | if (write(fd_msr, buf, 8) < 0) { |
| 517 | perror("msr write"); |
Mart Raudsepp | e1344da | 2008-02-08 10:10:57 +0000 | [diff] [blame] | 518 | close(fd_msr); |
Mart Raudsepp | 0514a5f | 2008-02-08 09:59:58 +0000 | [diff] [blame] | 519 | return -1; |
| 520 | } |
| 521 | |
| 522 | close(fd_msr); |
| 523 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 524 | #undef MSR_RCONF_DEFAULT |
| 525 | #undef MSR_NORF_CTL |
Lane Brooks | d54958a | 2007-11-13 16:45:22 +0000 | [diff] [blame] | 526 | return 0; |
| 527 | } |
| 528 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 529 | static int enable_flash_sc1100(struct pci_dev *dev, const char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 530 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 531 | uint8_t new; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 532 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 533 | pci_write_byte(dev, 0x52, 0xee); |
| 534 | |
| 535 | new = pci_read_byte(dev, 0x52); |
| 536 | |
| 537 | if (new != 0xee) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 538 | 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] | 539 | return -1; |
| 540 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 541 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 542 | return 0; |
| 543 | } |
| 544 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 545 | static int enable_flash_sis5595(struct pci_dev *dev, const char *name) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 546 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 547 | uint8_t new, newer; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 548 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 549 | new = pci_read_byte(dev, 0x45); |
| 550 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 551 | new &= (~0x20); /* Clear bit 5. */ |
| 552 | new |= 0x4; /* Set bit 2. */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 553 | |
| 554 | pci_write_byte(dev, 0x45, new); |
| 555 | |
| 556 | newer = pci_read_byte(dev, 0x45); |
| 557 | if (newer != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 558 | 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] | 559 | printf("Stuck at 0x%x\n", newer); |
| 560 | return -1; |
| 561 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 562 | |
Urja Rannikko | a88daa7 | 2008-10-18 13:54:30 +0000 | [diff] [blame] | 563 | /* Extended BIOS enable = 1, Lower BIOS Enable = 1 */ |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 564 | new = pci_read_byte(dev, 0x40); |
Urja Rannikko | a88daa7 | 2008-10-18 13:54:30 +0000 | [diff] [blame] | 565 | new &= 0xFB; |
| 566 | new |= 0x3; |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 567 | pci_write_byte(dev, 0x40, new); |
| 568 | newer = pci_read_byte(dev, 0x40); |
Urja Rannikko | a88daa7 | 2008-10-18 13:54:30 +0000 | [diff] [blame] | 569 | if (newer != new) { |
| 570 | printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name); |
| 571 | printf("Stuck at 0x%x\n", newer); |
| 572 | return -1; |
| 573 | } |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 574 | return 0; |
| 575 | } |
| 576 | |
Uwe Hermann | 190f849 | 2008-10-25 18:03:50 +0000 | [diff] [blame] | 577 | /* Works for AMD-8111, VIA VT82C586A/B, VIA VT82C686A/B. */ |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 578 | static int enable_flash_amd8111(struct pci_dev *dev, const char *name) |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 579 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 580 | uint8_t old, new; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 581 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 582 | /* Enable decoding at 0xffb00000 to 0xffffffff. */ |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 583 | old = pci_read_byte(dev, 0x43); |
Ollie Lho | d11f361 | 2004-12-07 17:19:04 +0000 | [diff] [blame] | 584 | new = old | 0xC0; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 585 | if (new != old) { |
| 586 | pci_write_byte(dev, 0x43, new); |
| 587 | if (pci_read_byte(dev, 0x43) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 588 | 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] | 589 | } |
| 590 | } |
| 591 | |
Uwe Hermann | 190f849 | 2008-10-25 18:03:50 +0000 | [diff] [blame] | 592 | /* Enable 'ROM write' bit. */ |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 593 | old = pci_read_byte(dev, 0x40); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 594 | new = old | 0x01; |
| 595 | if (new == old) |
| 596 | return 0; |
| 597 | pci_write_byte(dev, 0x40, new); |
| 598 | |
| 599 | if (pci_read_byte(dev, 0x40) != new) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 600 | 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] | 601 | return -1; |
| 602 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 603 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 604 | return 0; |
| 605 | } |
| 606 | |
Marc Jones | 3af487d | 2008-10-15 17:50:29 +0000 | [diff] [blame] | 607 | static int enable_flash_sb600(struct pci_dev *dev, const char *name) |
| 608 | { |
| 609 | uint32_t old, new; |
| 610 | uint8_t reg; |
| 611 | |
| 612 | /* Clear ROM Protect 0-3 */ |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 613 | for (reg = 0x50; reg < 0x60; reg += 4) { |
Marc Jones | 3af487d | 2008-10-15 17:50:29 +0000 | [diff] [blame] | 614 | old = pci_read_long(dev, reg); |
| 615 | new = old & 0xFFFFFFFC; |
| 616 | if (new != old) { |
| 617 | pci_write_byte(dev, reg, new); |
| 618 | if (pci_read_long(dev, reg) != new) { |
| 619 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x50, new, name); |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | return 0; |
| 625 | } |
| 626 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 627 | static int enable_flash_ck804(struct pci_dev *dev, const char *name) |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 628 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 629 | uint8_t old, new; |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 630 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 631 | old = pci_read_byte(dev, 0x88); |
| 632 | new = old | 0xc0; |
| 633 | if (new != old) { |
| 634 | pci_write_byte(dev, 0x88, new); |
| 635 | if (pci_read_byte(dev, 0x88) != new) { |
| 636 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name); |
| 637 | } |
| 638 | } |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 639 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 640 | old = pci_read_byte(dev, 0x6d); |
| 641 | new = old | 0x01; |
| 642 | if (new == old) |
| 643 | return 0; |
| 644 | pci_write_byte(dev, 0x6d, new); |
| 645 | |
| 646 | if (pci_read_byte(dev, 0x6d) != new) { |
| 647 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name); |
| 648 | return -1; |
| 649 | } |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 650 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 651 | return 0; |
Yinghai Lu | 952dfce | 2005-07-06 17:13:46 +0000 | [diff] [blame] | 652 | } |
| 653 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 654 | /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */ |
| 655 | static int enable_flash_sb400(struct pci_dev *dev, const char *name) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 656 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 657 | uint8_t tmp; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 658 | struct pci_filter f; |
| 659 | struct pci_dev *smbusdev; |
| 660 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 661 | /* Look for the SMBus device. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 662 | pci_filter_init((struct pci_access *)0, &f); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 663 | f.vendor = 0x1002; |
| 664 | f.device = 0x4372; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 665 | |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 666 | for (smbusdev = pacc->devices; smbusdev; smbusdev = smbusdev->next) { |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 667 | if (pci_filter_match(&f, smbusdev)) |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 668 | break; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 669 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 670 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 671 | if (!smbusdev) { |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 672 | fprintf(stderr, "ERROR: SMBus device not found. Aborting.\n"); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 673 | exit(1); |
| 674 | } |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 675 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 676 | /* Enable some SMBus stuff. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 677 | tmp = pci_read_byte(smbusdev, 0x79); |
| 678 | tmp |= 0x01; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 679 | pci_write_byte(smbusdev, 0x79, tmp); |
| 680 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 681 | /* Change southbridge. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 682 | tmp = pci_read_byte(dev, 0x48); |
| 683 | tmp |= 0x21; |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 684 | pci_write_byte(dev, 0x48, tmp); |
| 685 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 686 | /* Now become a bit silly. */ |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 687 | tmp = INB(0xc6f); |
| 688 | OUTB(tmp, 0xeb); |
| 689 | OUTB(tmp, 0xeb); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 690 | tmp |= 0x40; |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 691 | OUTB(tmp, 0xc6f); |
| 692 | OUTB(tmp, 0xeb); |
| 693 | OUTB(tmp, 0xeb); |
Stefan Reinauer | 86de283 | 2006-03-31 11:26:55 +0000 | [diff] [blame] | 694 | |
| 695 | return 0; |
| 696 | } |
| 697 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 698 | static int enable_flash_mcp55(struct pci_dev *dev, const char *name) |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 699 | { |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 700 | uint8_t old, new, byte; |
| 701 | uint16_t word; |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 702 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 703 | /* Set the 0-16 MB enable bits. */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 704 | byte = pci_read_byte(dev, 0x88); |
| 705 | byte |= 0xff; /* 256K */ |
| 706 | pci_write_byte(dev, 0x88, byte); |
| 707 | byte = pci_read_byte(dev, 0x8c); |
| 708 | byte |= 0xff; /* 1M */ |
| 709 | pci_write_byte(dev, 0x8c, byte); |
| 710 | word = pci_read_word(dev, 0x90); |
Carl-Daniel Hailfinger | dca0ab1 | 2007-10-17 22:30:07 +0000 | [diff] [blame] | 711 | word |= 0x7fff; /* 16M */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 712 | pci_write_word(dev, 0x90, word); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 713 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 714 | old = pci_read_byte(dev, 0x6d); |
| 715 | new = old | 0x01; |
| 716 | if (new == old) |
| 717 | return 0; |
| 718 | pci_write_byte(dev, 0x6d, new); |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 719 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 720 | if (pci_read_byte(dev, 0x6d) != new) { |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 721 | printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 722 | return -1; |
| 723 | } |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 724 | |
| 725 | return 0; |
Yinghai Lu | ca78297 | 2007-01-22 20:21:17 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 728 | static int enable_flash_ht1000(struct pci_dev *dev, const char *name) |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 729 | { |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 730 | uint8_t byte; |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 731 | |
Uwe Hermann | e823ee0 | 2007-06-05 15:02:18 +0000 | [diff] [blame] | 732 | /* Set the 4MB enable bit. */ |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 733 | byte = pci_read_byte(dev, 0x41); |
| 734 | byte |= 0x0e; |
| 735 | pci_write_byte(dev, 0x41, byte); |
| 736 | |
| 737 | byte = pci_read_byte(dev, 0x43); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 738 | byte |= (1 << 4); |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 739 | pci_write_byte(dev, 0x43, byte); |
| 740 | |
Stefan Reinauer | c868b9e | 2007-06-05 10:28:39 +0000 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 744 | typedef struct penable { |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 745 | uint16_t vendor, device; |
| 746 | const char *name; |
| 747 | int (*doit) (struct pci_dev *dev, const char *name); |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 748 | } FLASH_ENABLE; |
| 749 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 750 | static const FLASH_ENABLE enables[] = { |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 751 | {0x1039, 0x0630, "SiS630", enable_flash_sis630}, |
Uwe Hermann | 8720345 | 2008-10-26 18:40:42 +0000 | [diff] [blame^] | 752 | {0x8086, 0x122e, "Intel PIIX", enable_flash_piix4}, |
| 753 | {0x8086, 0x7000, "Intel PIIX3", enable_flash_piix4}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 754 | {0x8086, 0x7110, "Intel PIIX4/4E/4M", enable_flash_piix4}, |
| 755 | {0x8086, 0x7198, "Intel 440MX", enable_flash_piix4}, |
| 756 | {0x8086, 0x2410, "Intel ICH", enable_flash_ich_4e}, |
| 757 | {0x8086, 0x2420, "Intel ICH0", enable_flash_ich_4e}, |
| 758 | {0x8086, 0x2440, "Intel ICH2", enable_flash_ich_4e}, |
| 759 | {0x8086, 0x244c, "Intel ICH2-M", enable_flash_ich_4e}, |
| 760 | {0x8086, 0x2480, "Intel ICH3-S", enable_flash_ich_4e}, |
| 761 | {0x8086, 0x248c, "Intel ICH3-M", enable_flash_ich_4e}, |
| 762 | {0x8086, 0x24c0, "Intel ICH4/ICH4-L", enable_flash_ich_4e}, |
| 763 | {0x8086, 0x24cc, "Intel ICH4-M", enable_flash_ich_4e}, |
| 764 | {0x8086, 0x24d0, "Intel ICH5/ICH5R", enable_flash_ich_4e}, |
Claus Gindhart | a00e2a0 | 2008-05-14 12:22:38 +0000 | [diff] [blame] | 765 | {0x8086, 0x25a1, "Intel 6300ESB", enable_flash_ich_4e}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 766 | {0x8086, 0x2640, "Intel ICH6/ICH6R", enable_flash_ich_dc}, |
| 767 | {0x8086, 0x2641, "Intel ICH6-M", enable_flash_ich_dc}, |
Ed Swierk | cd2ed47 | 2008-08-20 20:31:41 +0000 | [diff] [blame] | 768 | {0x8086, 0x5031, "Intel EP80579", enable_flash_ich_dc}, |
Carl-Daniel Hailfinger | 1b18b3c | 2008-05-16 14:39:39 +0000 | [diff] [blame] | 769 | {0x8086, 0x27b0, "Intel ICH7DH", enable_flash_ich7}, |
| 770 | {0x8086, 0x27b8, "Intel ICH7/ICH7R", enable_flash_ich7}, |
| 771 | {0x8086, 0x27b9, "Intel ICH7M", enable_flash_ich7}, |
| 772 | {0x8086, 0x27bd, "Intel ICH7MDH", enable_flash_ich7}, |
| 773 | {0x8086, 0x2810, "Intel ICH8/ICH8R", enable_flash_ich8}, |
| 774 | {0x8086, 0x2811, "Intel ICH8M-E", enable_flash_ich8}, |
| 775 | {0x8086, 0x2812, "Intel ICH8DH", enable_flash_ich8}, |
| 776 | {0x8086, 0x2814, "Intel ICH8DO", enable_flash_ich8}, |
| 777 | {0x8086, 0x2815, "Intel ICH8M", enable_flash_ich8}, |
Carl-Daniel Hailfinger | 6dc1d3b | 2008-05-14 14:51:22 +0000 | [diff] [blame] | 778 | {0x8086, 0x2912, "Intel ICH9DH", enable_flash_ich9}, |
| 779 | {0x8086, 0x2914, "Intel ICH9DO", enable_flash_ich9}, |
| 780 | {0x8086, 0x2916, "Intel ICH9R", enable_flash_ich9}, |
| 781 | {0x8086, 0x2917, "Intel ICH9M-E", enable_flash_ich9}, |
| 782 | {0x8086, 0x2918, "Intel ICH9", enable_flash_ich9}, |
| 783 | {0x8086, 0x2919, "Intel ICH9M", enable_flash_ich9}, |
Carl-Daniel Hailfinger | 28ec74b | 2008-10-10 20:54:41 +0000 | [diff] [blame] | 784 | {0x8086, 0x3a14, "Intel ICH10DO", enable_flash_ich10}, |
| 785 | {0x8086, 0x3a16, "Intel ICH10R", enable_flash_ich10}, |
| 786 | {0x8086, 0x3a18, "Intel ICH10", enable_flash_ich10}, |
| 787 | {0x8086, 0x3a1a, "Intel ICH10D", enable_flash_ich10}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 788 | {0x1106, 0x8231, "VIA VT8231", enable_flash_vt823x}, |
| 789 | {0x1106, 0x3177, "VIA VT8235", enable_flash_vt823x}, |
| 790 | {0x1106, 0x3227, "VIA VT8237", enable_flash_vt823x}, |
Rudolf Marek | 3fdbccf | 2008-06-30 21:38:30 +0000 | [diff] [blame] | 791 | {0x1106, 0x3372, "VIA VT8237S", enable_flash_vt8237s_spi}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 792 | {0x1106, 0x8324, "VIA CX700", enable_flash_vt823x}, |
Uwe Hermann | 190f849 | 2008-10-25 18:03:50 +0000 | [diff] [blame] | 793 | {0x1106, 0x0586, "VIA VT82C586A/B", enable_flash_amd8111}, |
| 794 | {0x1106, 0x0686, "VIA VT82C686A/B", enable_flash_amd8111}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 795 | {0x1078, 0x0100, "AMD CS5530(A)", enable_flash_cs5530}, |
| 796 | {0x100b, 0x0510, "AMD SC1100", enable_flash_sc1100}, |
| 797 | {0x1039, 0x0008, "SiS5595", enable_flash_sis5595}, |
| 798 | {0x1022, 0x2080, "AMD CS5536", enable_flash_cs5536}, |
| 799 | {0x1022, 0x7468, "AMD8111", enable_flash_amd8111}, |
Marc Jones | 3af487d | 2008-10-15 17:50:29 +0000 | [diff] [blame] | 800 | {0x1002, 0x438D, "ATI(AMD) SB600", enable_flash_sb600}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 801 | {0x10B9, 0x1533, "ALi M1533", enable_flash_ali_m1533}, |
| 802 | {0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */ |
| 803 | {0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */ |
| 804 | /* Slave, should not be here, to fix known bug for A01. */ |
| 805 | {0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, |
| 806 | {0x10de, 0x0260, "NVIDIA MCP51", enable_flash_ck804}, |
| 807 | {0x10de, 0x0261, "NVIDIA MCP51", enable_flash_ck804}, |
| 808 | {0x10de, 0x0262, "NVIDIA MCP51", enable_flash_ck804}, |
| 809 | {0x10de, 0x0263, "NVIDIA MCP51", enable_flash_ck804}, |
| 810 | {0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* M57SLI*/ |
| 811 | {0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 812 | {0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 813 | {0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 814 | {0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 815 | {0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 816 | {0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */ |
| 817 | {0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */ |
Stefan Reinauer | 7f27464 | 2008-07-05 09:48:30 +0000 | [diff] [blame] | 818 | {0x10de, 0x0548, "NVIDIA MCP67", enable_flash_mcp55}, |
Uwe Hermann | eac1016 | 2008-03-13 18:52:51 +0000 | [diff] [blame] | 819 | {0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, |
| 820 | {0x1166, 0x0205, "Broadcom HT-1000", enable_flash_ht1000}, |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 821 | }; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 822 | |
Uwe Hermann | e5ac164 | 2008-03-12 11:54:51 +0000 | [diff] [blame] | 823 | void print_supported_chipsets(void) |
| 824 | { |
| 825 | int i; |
| 826 | |
| 827 | printf("\nSupported chipsets:\n\n"); |
| 828 | |
| 829 | for (i = 0; i < ARRAY_SIZE(enables); i++) |
| 830 | printf("%s (%04x:%04x)\n", enables[i].name, |
| 831 | enables[i].vendor, enables[i].device); |
| 832 | } |
| 833 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 834 | int chipset_flash_enable(void) |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 835 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 836 | struct pci_dev *dev = 0; |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 837 | int ret = -2; /* Nothing! */ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 838 | int i; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 839 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 840 | /* Now let's try to find the chipset we have... */ |
Uwe Hermann | e5ac164 | 2008-03-12 11:54:51 +0000 | [diff] [blame] | 841 | for (i = 0; i < ARRAY_SIZE(enables); i++) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 842 | dev = pci_dev_find(enables[i].vendor, enables[i].device); |
| 843 | if (dev) |
| 844 | break; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 845 | } |
| 846 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 847 | if (dev) { |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame] | 848 | printf("Found chipset \"%s\", enabling flash write... ", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 849 | enables[i].name); |
| 850 | |
| 851 | ret = enables[i].doit(dev, enables[i].name); |
| 852 | if (ret) |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame] | 853 | printf("FAILED!\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 854 | else |
Uwe Hermann | ac30934 | 2007-10-10 17:42:20 +0000 | [diff] [blame] | 855 | printf("OK.\n"); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | return ret; |
Ollie Lho | cbbf125 | 2004-03-17 22:22:08 +0000 | [diff] [blame] | 859 | } |