From b44a007d5c37ec60e40320f0fe48e8ba31e0e86c Mon Sep 17 00:00:00 2001 From: hailfinger Date: Mon, 1 Jun 2009 00:02:11 +0000 Subject: 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. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@559 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- dummyflasher.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'dummyflasher.c') diff --git a/dummyflasher.c b/dummyflasher.c index edcaf7a..ba3c633 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -20,16 +20,52 @@ #include #include +#include #include #include #include #include #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; } -- cgit v1.2.1