Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of the flashrom project. | 2 * This file is part of the flashrom project. |
| 3 * | 3 * |
| 4 * Copyright (C) 2009 Carl-Daniel Hailfinger | 4 * Copyright (C) 2009 Carl-Daniel Hailfinger |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
| 8 * the Free Software Foundation; either version 2 of the License, or | 8 * the Free Software Foundation; either version 2 of the License, or |
| 9 * (at your option) any later version. | 9 * (at your option) any later version. |
| 10 * | 10 * |
| 11 * This program is distributed in the hope that it will be useful, | 11 * This program is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 * GNU General Public License for more details. | 14 * GNU General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU General Public License | 16 * You should have received a copy of the GNU General Public License |
| 17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
| 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include <stdio.h> | |
| 21 #include <string.h> | 22 #include <string.h> |
| 22 #include <stdlib.h> | 23 #include <stdlib.h> |
| 24 #include <stdarg.h> | |
| 25 | |
| 23 #include "flash.h" | 26 #include "flash.h" |
| 24 #include "programmer.h" | 27 #include "programmer.h" |
| 25 | 28 |
| 26 #if NEED_PCI == 1 | 29 #if NEED_PCI == 1 |
| 27 struct pci_dev *pci_dev_find_filter(struct pci_filter filter) | 30 struct pci_dev *pci_dev_find_filter(struct pci_filter filter) |
| 28 { | 31 { |
| 29 struct pci_dev *temp; | 32 struct pci_dev *temp; |
| 30 | 33 |
| 31 for (temp = pacc->devices; temp; temp = temp->next) | 34 for (temp = pacc->devices; temp; temp = temp->next) |
| 32 if (pci_filter_match(&filter, temp)) | 35 if (pci_filter_match(&filter, temp)) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 /* Winbond Super I/O code is not yet available. */ | 112 /* Winbond Super I/O code is not yet available. */ |
| 110 if (superio.vendor == SUPERIO_VENDOR_NONE) | 113 if (superio.vendor == SUPERIO_VENDOR_NONE) |
| 111 superio = probe_superio_winbond(); | 114 superio = probe_superio_winbond(); |
| 112 #endif | 115 #endif |
| 113 } | 116 } |
| 114 #endif | 117 #endif |
| 115 | 118 |
| 116 int is_laptop = 0; | 119 int is_laptop = 0; |
| 117 enum chipbustype target_bus; | 120 enum chipbustype target_bus; |
| 118 | 121 |
| 122 #if defined(__i386__) || defined(__x86_64__) | |
| 123 #define BUFSIZE 256 | |
| 124 static char buffer[BUFSIZE]; | |
| 125 | |
| 126 static void | |
| 127 pci_error(char *msg, ...) | |
| 128 { | |
| 129 va_list args; | |
| 130 | |
| 131 va_start(args, msg); | |
| 132 vsnprintf(buffer, BUFSIZE, msg, args); | |
| 133 va_end(args); | |
| 134 | |
| 135 msg_perr("pcilib: %s\n", buffer); | |
| 136 | |
| 137 /* libpci requires us to exit. TODO cleanup? */ | |
| 138 exit(1); | |
| 139 } | |
| 140 | |
| 141 static void | |
| 142 pci_warning(char *msg, ...) | |
| 143 { | |
| 144 va_list args; | |
| 145 | |
| 146 va_start(args, msg); | |
| 147 vsnprintf(buffer, BUFSIZE, msg, args); | |
| 148 va_end(args); | |
| 149 | |
| 150 msg_pinfo("pcilib: %s\n", buffer); | |
| 151 } | |
| 152 | |
| 153 static void | |
| 154 pci_debug(char *msg, ...) | |
| 155 { | |
| 156 va_list args; | |
| 157 | |
| 158 va_start(args, msg); | |
| 159 vsnprintf(buffer, BUFSIZE, msg, args); | |
| 160 va_end(args); | |
| 161 | |
| 162 msg_pdbg("pcilib: %s\n", buffer); | |
| 163 } | |
| 164 #endif | |
| 165 | |
| 119 int internal_init(void) | 166 int internal_init(void) |
| 120 { | 167 { |
| 121 #if __FLASHROM_LITTLE_ENDIAN__ | 168 #if __FLASHROM_LITTLE_ENDIAN__ |
| 122 int ret = 0; | 169 int ret = 0; |
| 123 #endif | 170 #endif |
| 124 int force_laptop = 0; | 171 int force_laptop = 0; |
| 125 char *arg; | 172 char *arg; |
| 126 int probe_target_bus_later = 0; | 173 int probe_target_bus_later = 0; |
| 127 | 174 |
| 128 arg = extract_programmer_param("boardenable"); | 175 arg = extract_programmer_param("boardenable"); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 } | 233 } |
| 187 | 234 |
| 188 free(arg); | 235 free(arg); |
| 189 } else { | 236 } else { |
| 190 /* The pacc must be initialized before access pci devices. */ | 237 /* The pacc must be initialized before access pci devices. */ |
| 191 probe_target_bus_later = 1; | 238 probe_target_bus_later = 1; |
| 192 } | 239 } |
| 193 | 240 |
| 194 get_io_perms(); | 241 get_io_perms(); |
| 195 | 242 |
| 243 #if defined(__i386__) || defined(__x86_64__) | |
| 196 /* Initialize PCI access for flash enables */ | 244 /* Initialize PCI access for flash enables */ |
| 197 pacc = pci_alloc(); /* Get the pci_access structure */ | 245 pacc = pci_alloc(); /* Get the pci_access structure */ |
| 246 pacc->error = pci_error; | |
| 247 pacc->warning = pci_warning; | |
| 248 pacc->debug = pci_debug; | |
| 249 | |
| 198 /* Set all options you want -- here we stick with the defaults */ | 250 /* Set all options you want -- here we stick with the defaults */ |
| 199 pci_init(pacc); /* Initialize the PCI library */ | 251 pci_init(pacc); /* Initialize the PCI library */ |
| 200 pci_scan_bus(pacc); /* We want to get the list of devices */ | 252 pci_scan_bus(pacc); /* We want to get the list of devices */ |
| 253 #endif | |
|
Stefan Reinauer
2011/03/25 16:57:47
everything up to here in internal.c should be drop
Louis
2011/03/29 07:55:02
Done.
| |
| 201 | 254 |
| 202 if (processor_flash_enable()) { | 255 if (processor_flash_enable()) { |
| 203 msg_perr("Processor detection/init failed.\n" | 256 msg_perr("Processor detection/init failed.\n" |
| 204 "Aborting.\n"); | 257 "Aborting.\n"); |
| 205 return 1; | 258 return 1; |
| 206 } | 259 } |
| 207 | 260 |
| 208 #if defined(__i386__) || defined(__x86_64__) | 261 #if defined(__i386__) || defined(__x86_64__) |
| 209 /* We look at the cbtable first to see if we need a | 262 /* We look at the cbtable first to see if we need a |
| 210 * mainboard specific flash enable sequence. | 263 * mainboard specific flash enable sequence. |
| 211 */ | 264 */ |
| 212 coreboot_init(); | 265 coreboot_init(); |
| 213 | 266 |
| 214 dmi_init(); | 267 dmi_init(); |
| 215 | 268 |
| 216 if (probe_target_bus_later) { | 269 if (probe_target_bus_later) { |
| 217 /* read the target bus value from register. */ | 270 /* read the target bus value from register. */ |
| 218 if (get_target_bus_from_chipset(&target_bus)) { | 271 if (get_target_bus_from_chipset(&target_bus)) { |
| 219 msg_perr("Cannot get target bus from %s programmer.\n", | 272 msg_perr("Cannot get target bus from %s programmer.\n", |
| 220 programmer_table[programmer].name); | 273 programmer_table[programmer].name); |
| 221 return 1; | 274 return 1; |
| 222 } | 275 } |
| 223 } | 276 } |
| 224 | 277 |
| 225 /* Probe for the Super I/O chip and fill global struct superio. */ | 278 /* Probe for the Super I/O chip and fill global struct superio. */ |
| 226 probe_superio(); | 279 probe_superio(); |
| 280 | |
| 281 #elif defined(__arm__) | |
| 282 /* We look at the cbtable first to see if we need a | |
| 283 * mainboard specific flash enable sequence. | |
| 284 */ | |
| 285 coreboot_init(); | |
| 286 | |
| 227 #else | 287 #else |
| 228 /* FIXME: Enable cbtable searching on all non-x86 platforms supported | 288 /* FIXME: Enable cbtable searching on all non-x86 platforms supported |
| 229 * by coreboot. | 289 * by coreboot. |
| 230 * FIXME: Find a replacement for DMI on non-x86. | 290 * FIXME: Find a replacement for DMI on non-x86. |
| 231 * FIXME: Enable Super I/O probing once port I/O is possible. | 291 * FIXME: Enable Super I/O probing once port I/O is possible. |
| 232 */ | 292 */ |
| 233 #endif | 293 #endif |
| 234 | 294 |
| 235 /* Warn if a laptop is detected. */ | 295 /* Warn if a laptop is detected. */ |
| 236 if (is_laptop) { | 296 if (is_laptop) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 249 if (force_laptop) { | 309 if (force_laptop) { |
| 250 msg_perr("Proceeding anyway because user specified " | 310 msg_perr("Proceeding anyway because user specified " |
| 251 "laptop=force_I_want_a_brick\n"); | 311 "laptop=force_I_want_a_brick\n"); |
| 252 } else { | 312 } else { |
| 253 msg_perr("Aborting.\n"); | 313 msg_perr("Aborting.\n"); |
| 254 exit(1); | 314 exit(1); |
| 255 } | 315 } |
| 256 } | 316 } |
| 257 | 317 |
| 258 #if __FLASHROM_LITTLE_ENDIAN__ | 318 #if __FLASHROM_LITTLE_ENDIAN__ |
| 319 | |
| 320 #if defined(__i386__) || defined(__x86_64__) | |
| 259 /* try to enable it. Failure IS an option, since not all motherboards | 321 /* try to enable it. Failure IS an option, since not all motherboards |
| 260 * really need this to be done, etc., etc. | 322 * really need this to be done, etc., etc. |
| 261 */ | 323 */ |
| 262 ret = chipset_flash_enable(); | 324 ret = chipset_flash_enable(); |
| 263 if (ret == -2) { | 325 if (ret == -2) { |
| 264 msg_perr("WARNING: No chipset found. Flash detection " | 326 msg_perr("WARNING: No chipset found. Flash detection " |
| 265 "will most likely fail.\n"); | 327 "will most likely fail.\n"); |
| 266 } | 328 } |
| 329 #endif | |
| 267 | 330 |
| 268 #if defined(__i386__) || defined(__x86_64__) | 331 #if defined(__i386__) || defined(__x86_64__) |
| 269 /* Probe unconditionally for IT87* LPC->SPI translation and for | 332 /* Probe unconditionally for IT87* LPC->SPI translation and for |
| 270 * IT87* Parallel write enable. | 333 * IT87* Parallel write enable. |
| 271 */ | 334 */ |
| 272 init_superio_ite(); | 335 init_superio_ite(); |
| 273 | 336 |
| 274 /* probe for programmers that bridge LPC <--> SPI */ | 337 /* probe for programmers that bridge LPC <--> SPI */ |
| 275 if (target_bus == CHIP_BUSTYPE_LPC || | 338 if (target_bus == CHIP_BUSTYPE_LPC || |
| 276 target_bus == CHIP_BUSTYPE_FWH) { | 339 target_bus == CHIP_BUSTYPE_FWH) { |
| 277 it85xx_probe_spi_flash(NULL); | 340 it85xx_probe_spi_flash(NULL); |
| 278 wpce775x_probe_spi_flash(NULL); | 341 wpce775x_probe_spi_flash(NULL); |
| 279 mec1308_probe_spi_flash(NULL); | 342 mec1308_probe_spi_flash(NULL); |
| 280 } | 343 } |
| 281 | 344 |
| 282 #endif | 345 #endif |
| 283 | 346 |
| 347 #if defined(__i386__) || defined(__x86_64__) | |
| 348 msg_perr("Board_flash_enable\n"); | |
| 349 | |
| 284 board_flash_enable(lb_vendor, lb_part); | 350 board_flash_enable(lb_vendor, lb_part); |
| 351 #endif | |
| 285 | 352 |
| 286 /* Even if chipset init returns an error code, we don't want to abort. | 353 /* Even if chipset init returns an error code, we don't want to abort. |
| 287 * The error code might have been a warning only. | 354 * The error code might have been a warning only. |
| 288 * Besides that, we don't check the board enable return code either. | 355 * Besides that, we don't check the board enable return code either. |
| 289 */ | 356 */ |
| 290 #if defined(__i386__) || defined(__x86_64__) || defined (__mips) | 357 #if defined(__i386__) || defined(__x86_64__) || defined (__mips) || \ |
| 358 defined(__arm__) | |
| 291 return 0; | 359 return 0; |
| 292 #else | 360 #else |
| 293 msg_perr("Your platform is not supported yet for the internal " | 361 msg_perr("Your platform is not supported yet for the internal " |
| 294 "programmer due to missing\n" | 362 "programmer due to missing\n" |
| 295 "flash_base and top/bottom alignment information.\n" | 363 "flash_base and top/bottom alignment information.\n" |
| 296 "Aborting.\n"); | 364 "Aborting.\n"); |
| 297 return 1; | 365 return 1; |
| 298 #endif | 366 #endif |
| 299 #else | 367 #else |
| 300 /* FIXME: Remove this unconditional abort once all PCI drivers are | 368 /* FIXME: Remove this unconditional abort once all PCI drivers are |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 314 release_io_perms(); | 382 release_io_perms(); |
| 315 | 383 |
| 316 #if defined(__i386__) || defined(__x86_64__) | 384 #if defined(__i386__) || defined(__x86_64__) |
| 317 if (target_bus == CHIP_BUSTYPE_LPC || | 385 if (target_bus == CHIP_BUSTYPE_LPC || |
| 318 target_bus == CHIP_BUSTYPE_FWH) { | 386 target_bus == CHIP_BUSTYPE_FWH) { |
| 319 it85xx_shutdown(); | 387 it85xx_shutdown(); |
| 320 wpce775x_shutdown(); | 388 wpce775x_shutdown(); |
| 321 mec1308_shutdown(); | 389 mec1308_shutdown(); |
| 322 } | 390 } |
| 323 #endif | 391 #endif |
| 324 | 392 #if defined(__arm__) |
| 393 » if (spi_controller == SPI_CONTROLLER_TEGRA2) | |
| 394 » » tegra2_spi_shutdown(); | |
| 395 #endif | |
| 325 return 0; | 396 return 0; |
| 326 } | 397 } |
| 327 #endif | 398 #endif |
| 328 | 399 |
| 329 void internal_chip_writeb(uint8_t val, chipaddr addr) | 400 void internal_chip_writeb(uint8_t val, chipaddr addr) |
| 330 { | 401 { |
| 331 mmio_writeb(val, (void *) addr); | 402 mmio_writeb(val, (void *) addr); |
| 332 } | 403 } |
| 333 | 404 |
| 334 void internal_chip_writew(uint16_t val, chipaddr addr) | 405 void internal_chip_writew(uint16_t val, chipaddr addr) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 354 uint32_t internal_chip_readl(const chipaddr addr) | 425 uint32_t internal_chip_readl(const chipaddr addr) |
| 355 { | 426 { |
| 356 return mmio_readl((void *) addr); | 427 return mmio_readl((void *) addr); |
| 357 } | 428 } |
| 358 | 429 |
| 359 void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len) | 430 void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len) |
| 360 { | 431 { |
| 361 memcpy(buf, (void *)addr, len); | 432 memcpy(buf, (void *)addr, len); |
| 362 return; | 433 return; |
| 363 } | 434 } |
| OLD | NEW |