diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-01 00:02:11 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-01 00:02:11 +0000 |
commit | 3504b539bfa33693510d83402a344b1eafd7a592 (patch) | |
tree | 188831bf4243fd81eb83eb983a06731d21021529 /dummyflasher.c | |
parent | 211fa97ce8c3cf9c527fbf2d004f9f98420f8a60 (diff) | |
download | ast2050-flashrom-3504b539bfa33693510d83402a344b1eafd7a592.zip ast2050-flashrom-3504b539bfa33693510d83402a344b1eafd7a592.tar.gz |
Add bus type support to the dummy external programmer
The syntax is explained in the man page.
Example: flashrom -p dummy=lpc,fwh
Tested, works perfectly. ;-)
As a nice benefit, it allows easy testing of the "probe only compatible
flashes" patch.
Corresponding to flashrom svn r559.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'dummyflasher.c')
-rw-r--r-- | dummyflasher.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/dummyflasher.c b/dummyflasher.c index edcaf7a..ba3c633 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -20,16 +20,52 @@ #include <string.h> #include <stdlib.h> +#include <ctype.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include "flash.h" +char *dummytype = NULL; + int dummy_init(void) { + int i; printf_debug("%s\n", __func__); - spi_controller = SPI_CONTROLLER_DUMMY; + + /* "all" is equivalent to specifying no type. */ + if (!strcmp(dummytype, "all")) { + free(dummytype); + dummytype = NULL; + } + if (!dummytype) + dummytype = strdup("parallel,lpc,fwh,spi"); + /* Convert the parameters to lowercase. */ + for (i = 0; dummytype[i] != '\0'; i++) + dummytype[i] = (char)tolower(dummytype[i]); + + buses_supported = CHIP_BUSTYPE_NONE; + if (strstr(dummytype, "parallel")) { + buses_supported |= CHIP_BUSTYPE_PARALLEL; + printf_debug("Enabling support for %s flash.\n", "parallel"); + } + if (strstr(dummytype, "lpc")) { + buses_supported |= CHIP_BUSTYPE_LPC; + printf_debug("Enabling support for %s flash.\n", "LPC"); + } + if (strstr(dummytype, "fwh")) { + buses_supported |= CHIP_BUSTYPE_FWH; + printf_debug("Enabling support for %s flash.\n", "FWH"); + } + if (strstr(dummytype, "spi")) { + buses_supported |= CHIP_BUSTYPE_SPI; + spi_controller = SPI_CONTROLLER_DUMMY; + printf_debug("Enabling support for %s flash.\n", "SPI"); + } + if (buses_supported == CHIP_BUSTYPE_NONE) + printf_debug("Support for all flash bus types disabled.\n"); + free(dummytype); return 0; } |