flashrom: split flash_enable.c into chipset_enable.c and board_enable.c

This splits up the ROM Write enable code into chipset specific and
board specific parts. This of course means that a lot of code is
plainly moved about.

* Allows for linuxbios name matching and pci-subsystem id matching.
  The latter uses a double set to properly distuinguish boards despite
  of some known vendors being lax about it.
* Fixes GPIO15 being raised on every VT8235 southbridge, regardless of what
  that line actually controls; rom on EPIA-M, backlight on mitac 8999 laptop.
* Adds flashrom support for Asus A7V400-MX (KM400 + VT8235)
* Island aruma was renamed agami aruma, the board specific code now got
  adjusted. A set of pci-ids was retrieved from source code.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2581 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Luc Verhaegen
2007-04-04 22:45:58 +00:00
committed by Stefan Reinauer
parent 17d667b411
commit b8c6437811
5 changed files with 466 additions and 210 deletions

View File

@@ -35,6 +35,15 @@
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <pci/pci.h>
/* for iopl */
#if defined (__sun) && (defined(__i386) || defined(__amd64))
#include <strings.h>
#include <sys/sysi86.h>
#include <sys/psw.h>
#include <asm/sunddi.h>
#endif
#include "flash.h"
#include "lbtable.h"
@@ -42,10 +51,54 @@
#include "debug.h"
char *chip_to_probe = NULL;
struct pci_access *pacc; /* For board and chipset_enable */
int exclude_start_page, exclude_end_page;
int force=0, verbose=0;
/*
*
*/
struct pci_dev *
pci_dev_find(uint16_t vendor, uint16_t device)
{
struct pci_dev *temp;
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
for (temp = pacc->devices; temp; temp = temp->next)
if (pci_filter_match(&filter, temp))
return temp;
return NULL;
}
/*
*
*/
struct pci_dev *
pci_card_find(uint16_t vendor, uint16_t device,
uint16_t card_vendor, uint16_t card_device)
{
struct pci_dev *temp;
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
for (temp = pacc->devices; temp; temp = temp->next)
if (pci_filter_match(&filter, temp)) {
if ((card_vendor == pci_read_word(temp, 0x2C)) &&
(card_device == pci_read_word(temp, 0x2E)))
return temp;
}
return NULL;
}
struct flashchip *probe_flash(struct flashchip *flash)
{
int fd_mem;
@@ -72,10 +125,11 @@ struct flashchip *probe_flash(struct flashchip *flash)
__FUNCTION__, flash->total_size * 1024,
(unsigned long) size);
}
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
fd_mem, (off_t) (0xffffffff - size + 1));
if (bios == MAP_FAILED) {
perror("Error: Can't mmap /dev/mem.");
perror("Error: Can't mmap " MEM_DEV ".");
exit(1);
}
flash->virt_addr = bios;
@@ -92,7 +146,7 @@ struct flashchip *probe_flash(struct flashchip *flash)
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
fd_mem, (off_t) (0x9400000));
if (bios == MAP_FAILED) {
perror("Error: Can't mmap /dev/mem.");
perror("Error: Can't mmap " MEM_DEV ".");
exit(1);
}
flash->virt_addr = bios;
@@ -281,6 +335,22 @@ int main(int argc, char *argv[])
if (optind < argc)
filename = argv[optind++];
/* First get full io access */
#if defined (__sun) && (defined(__i386) || defined(__amd64))
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0){
#else
if (iopl(3) != 0) {
#endif
fprintf(stderr, "ERROR: iopl failed: \"%s\"\n", strerror(errno));
exit(1);
}
/* Initialize PCI access for flash enables */
pacc = pci_alloc(); /* Get the pci_access structure */
/* Set all options you want -- here we stick with the defaults */
pci_init(pacc); /* Initialize the PCI library */
pci_scan_bus(pacc); /* We want to get the list of devices */
printf("Calibrating delay loop... ");
myusec_calibrate_delay();
printf("ok\n");
@@ -293,7 +363,13 @@ int main(int argc, char *argv[])
/* try to enable it. Failure IS an option, since not all motherboards
* really need this to be done, etc., etc.
*/
(void) enable_flash_write();
ret = chipset_flash_enable();
if (ret == -2)
printf("WARNING: No chipset found. Flash detection "
"will most likely fail.\n");
board_flash_enable(lb_vendor, lb_part);
if ((flash = probe_flash(flashchips)) == NULL) {
printf("No EEPROM/flash device found.\n");