From 4740c6ff3c230c83fa618557f94cc6675c5ab3b1 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 16 Sep 2009 10:09:21 +0000 Subject: Allow to exclude each of the external programmer drivers from being compiled in Example make commandline if you want only internal programmers: make CONFIG_FT2232SPI=no CONFIG_SERPROG=no CONFIG_NIC3COM=no CONFIG_SATASII=no CONFIG_DRKAISER=no CONFIG_DUMMY=no Of course, all of the CONFIG_* symbols can be mixed and matched as needed. CONFIG_FT2232SPI is special because even if it is enabled, make will check if the headers are available and skip it otherwise. Corresponding to flashrom svn r724. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Stefan Reinauer --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++---- flash.h | 15 +++++++++++++-- flashrom.c | 26 ++++++++++++++++++++------ internal.c | 17 ++++++++++++----- print.c | 7 +++++++ spi.c | 4 ++++ 6 files changed, 97 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 0a6eb79..1b50d87 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,7 @@ OBJS = chipset_enable.o board_enable.o udelay.o jedec.o stm50flw0x0x.o \ sst49lfxxxc.o sst_fwhub.o layout.o cbtable.o flashchips.o physmap.o \ flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \ ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \ - dummyflasher.o pcidev.o nic3com.o satasii.o ft2232_spi.o \ - print.o drkaiser.o + pcidev.o print.o all: pciutils features dep $(PROGRAM) @@ -67,7 +66,22 @@ RELEASENAME ?= $(VERSION) SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' # Always enable serprog for now. Needs to be disabled on Windows. -CONFIG_SERPROG = yes +CONFIG_SERPROG ?= yes + +# Always enable 3Com NICs for now. +CONFIG_NIC3COM ?= yes + +# Always enable SiI SATA controllers for now. +CONFIG_SATASII ?= yes + +# Always enable FT2232 SPI dongles for now. +CONFIG_FT2232SPI ?= yes + +# Always enable dummy tracing for now. +CONFIG_DUMMY ?= yes + +# Always enable Dr. Kaiser for now. +CONFIG_DRKAISER ?= yes ifeq ($(CONFIG_SERPROG), yes) FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' @@ -77,9 +91,32 @@ LIBS += -lsocket endif endif -FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'FT2232_SPI_SUPPORT=1'") +ifeq ($(CONFIG_NIC3COM), yes) +FEATURE_CFLAGS += -D'NIC3COM_SUPPORT=1' +OBJS += nic3com.o +endif +ifeq ($(CONFIG_SATASII), yes) +FEATURE_CFLAGS += -D'SATASII_SUPPORT=1' +OBJS += satasii.o +endif + +ifeq ($(CONFIG_FT2232SPI), yes) +# This is a totally ugly hack. +FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'FT2232_SPI_SUPPORT=1'") FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-lftdi") +OBJS += ft2232_spi.o +endif + +ifeq ($(CONFIG_DUMMY), yes) +FEATURE_CFLAGS += -D'DUMMY_SUPPORT=1' +OBJS += dummyflasher.o +endif + +ifeq ($(CONFIG_DRKAISER), yes) +FEATURE_CFLAGS += -D'DRKAISER_SUPPORT=1' +OBJS += drkaiser.o +endif $(PROGRAM): $(OBJS) $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) $(FEATURE_LIBS) diff --git a/flash.h b/flash.h index dce0e41..2a54806 100644 --- a/flash.h +++ b/flash.h @@ -82,10 +82,18 @@ typedef unsigned long chipaddr; enum programmer { PROGRAMMER_INTERNAL, +#if DUMMY_SUPPORT == 1 PROGRAMMER_DUMMY, +#endif +#if NIC3COM_SUPPORT == 1 PROGRAMMER_NIC3COM, +#endif +#if DRKAISER_SUPPORT == 1 PROGRAMMER_DRKAISER, +#endif +#if SATASII_SUPPORT == 1 PROGRAMMER_SATASII, +#endif PROGRAMMER_IT87SPI, #if FT2232_SPI_SUPPORT == 1 PROGRAMMER_FT2232SPI, @@ -375,10 +383,11 @@ uint8_t mmio_readb(void *addr); uint16_t mmio_readw(void *addr); uint32_t mmio_readl(void *addr); void internal_delay(int usecs); -int fallback_shutdown(void); +int noop_shutdown(void); void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); void fallback_unmap(void *virt_addr, size_t len); -void fallback_chip_writeb(uint8_t val, chipaddr addr); +uint8_t noop_chip_readb(const chipaddr addr); +void noop_chip_writeb(uint8_t val, chipaddr addr); void fallback_chip_writew(uint16_t val, chipaddr addr); void fallback_chip_writel(uint32_t val, chipaddr addr); void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); @@ -474,7 +483,9 @@ enum spi_controller { #if FT2232_SPI_SUPPORT == 1 SPI_CONTROLLER_FT2232, #endif +#if DUMMY_SUPPORT == 1 SPI_CONTROLLER_DUMMY, +#endif SPI_CONTROLLER_INVALID /* This must always be the last entry. */ }; extern const int spi_programmer_count; diff --git a/flashrom.c b/flashrom.c index 6c03d93..fc69f25 100644 --- a/flashrom.c +++ b/flashrom.c @@ -54,6 +54,7 @@ const struct programmer_entry programmer_table[] = { .delay = internal_delay, }, +#if DUMMY_SUPPORT == 1 { .name = "dummy", .init = dummy_init, @@ -70,7 +71,9 @@ const struct programmer_entry programmer_table[] = { .chip_writen = dummy_chip_writen, .delay = internal_delay, }, +#endif +#if NIC3COM_SUPPORT == 1 { .name = "nic3com", .init = nic3com_init, @@ -87,7 +90,9 @@ const struct programmer_entry programmer_table[] = { .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif +#if DRKAISER_SUPPORT == 1 { .name = "drkaiser", .init = drkaiser_init, @@ -104,7 +109,9 @@ const struct programmer_entry programmer_table[] = { .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif +#if SATASII_SUPPORT == 1 { .name = "satasii", .init = satasii_init, @@ -121,18 +128,19 @@ const struct programmer_entry programmer_table[] = { .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif { .name = "it87spi", .init = it87spi_init, - .shutdown = fallback_shutdown, + .shutdown = noop_shutdown, .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, - .chip_readb = dummy_chip_readb, + .chip_readb = noop_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn, - .chip_writeb = fallback_chip_writeb, + .chip_writeb = noop_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen, @@ -143,14 +151,14 @@ const struct programmer_entry programmer_table[] = { { .name = "ft2232spi", .init = ft2232_spi_init, - .shutdown = fallback_shutdown, + .shutdown = noop_shutdown, /* Missing shutdown */ .map_flash_region = fallback_map, .unmap_flash_region = fallback_unmap, - .chip_readb = dummy_chip_readb, + .chip_readb = noop_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, .chip_readn = fallback_chip_readn, - .chip_writeb = fallback_chip_writeb, + .chip_writeb = noop_chip_writeb, .chip_writew = fallback_chip_writew, .chip_writel = fallback_chip_writel, .chip_writen = fallback_chip_writen, @@ -793,9 +801,15 @@ int main(int argc, char *argv[]) print_supported_boards(); printf("\nSupported PCI devices flashrom can use " "as programmer:\n\n"); +#if NIC3COM_SUPPORT == 1 print_supported_pcidevs(nics_3com); +#endif +#if DRKAISER_SUPPORT == 1 print_supported_pcidevs(drkaiser_pcidev); +#endif +#if SATASII_SUPPORT == 1 print_supported_pcidevs(satas_sii); +#endif exit(0); } diff --git a/internal.c b/internal.c index a3b2ae5..ea12bbc 100644 --- a/internal.c +++ b/internal.c @@ -222,8 +222,8 @@ void internal_delay(int usecs) } } -/* Fallback shutdown() for programmers which don't need special handling */ -int fallback_shutdown(void) +/* No-op shutdown() for programmers which don't need special handling */ +int noop_shutdown(void) { return 0; } @@ -231,16 +231,23 @@ int fallback_shutdown(void) /* Fallback map() for programmers which don't need special handling */ void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) { + /* FIXME: Should return phys_addr. */ return 0; } -/* Fallback unmap() for programmers which don't need special handling */ +/* No-op/fallback unmap() for programmers which don't need special handling */ void fallback_unmap(void *virt_addr, size_t len) { } -/* No-op fallback for drivers not supporting addr/data pair accesses */ -void fallback_chip_writeb(uint8_t val, chipaddr addr) +/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ +uint8_t noop_chip_readb(const chipaddr addr) +{ + return 0xff; +} + +/* No-op chip_writeb() for drivers not supporting addr/data pair accesses */ +void noop_chip_writeb(uint8_t val, chipaddr addr) { } diff --git a/print.c b/print.c index ce46e1b..a86ea05 100644 --- a/print.c +++ b/print.c @@ -731,8 +731,15 @@ void print_wiki_tables(void) print_supported_chipsets_wiki(); print_supported_boards_wiki(); printf("%s", programmer_section); +#if NIC3COM_SUPPORT == 1 print_supported_pcidevs_wiki(nics_3com); +#endif +#if DRKAISER_SUPPORT == 1 + /* FIXME: drkaiser_pcidev is missing here. */ +#endif +#if SATASII_SUPPORT == 1 print_supported_pcidevs_wiki(satas_sii); +#endif printf("\n|}\n"); } diff --git a/spi.c b/spi.c index 86ffe69..73709f2 100644 --- a/spi.c +++ b/spi.c @@ -91,12 +91,14 @@ const struct spi_programmer spi_programmer[] = { }, #endif +#if DUMMY_SUPPORT == 1 { /* SPI_CONTROLLER_DUMMY */ .command = dummy_spi_send_command, .multicommand = default_spi_send_multicommand, .read = NULL, .write_256 = NULL, }, +#endif {}, /* This entry corresponds to SPI_CONTROLLER_INVALID. */ }; @@ -301,7 +303,9 @@ int probe_spi_rdid4(struct flashchip *flash) #if FT2232_SPI_SUPPORT == 1 case SPI_CONTROLLER_FT2232: #endif +#if DUMMY_SUPPORT == 1 case SPI_CONTROLLER_DUMMY: +#endif return probe_spi_rdid_generic(flash, 4); default: printf_debug("4b ID not supported on this SPI controller\n"); -- cgit v1.1