Makefile: test-compile a small program to check whether ftdi.h
defines TYPE_4232H;  define CONFIG_LIBFTDI_HS=1 if so.

ft2232_spi: omit checking for 2232H or 4232H chip types if libftdi
is too old to report them.  In that case, assume the chip supports
the disable-divide-by-5 command, which was the previous behaviour
before chip type-checking was introduced.

Signed-off-by: Alex Badea <[email protected]>
---
Apologies for the late reply. Test-built with libftdi-dev 0.17-1 (ubuntu
lucid) and 0.13-2 (debian lenny).

I added the .featuretest2.c cruft because for some reason .featuretest.c
contained the utsname program at the time gcc ran.  I lack the
necessary make-Fu to figure out why.

Cheers,
Alex

 Makefile     |    9 ++++++++-
 ft2232_spi.c |    2 ++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 3215992..82aaad1 100644
--- a/Makefile
+++ b/Makefile
@@ -225,6 +225,7 @@ ifeq ($(CONFIG_FT2232_SPI), yes)
 FTDILIBS := $(shell pkg-config --libs libftdi 2>/dev/null || printf "%s" 
"-lftdi -lusb")
 # This is a totally ugly hack.
 FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && 
printf "%s" "-D'CONFIG_FT2232_SPI=1'")
+FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDIHSSUPPORT := yes" .features && 
printf "%s" "-D'CONFIG_LIBFTDI_HS=1'")
 FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && 
printf "%s" "$(FTDILIBS)")
 PROGRAMMER_OBJS += ft2232_spi.o
 endif
@@ -401,6 +402,12 @@ features: compiler
        @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o 
.featuretest$(EXEC_SUFFIX) $(FTDILIBS) $(LIBS) >/dev/null 2>&1 &&     \
                ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) 
||        \
                ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )
+       @printf "Checking for FTDI high-speed chip support... "
+       @$(shell ( echo "#include <ftdi.h>";               \
+                  echo "int type = TYPE_4232H;"; ) > .featuretest2.c )
+       @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest2.c -c -o 
.featuretest$(EXEC_SUFFIX) >/dev/null 2>&1 &&     \
+               ( echo "found."; echo "FTDIHSSUPPORT := yes" >> .features.tmp ) 
||      \
+               ( echo "not found."; echo "FTDIHSSUPPORT := no" >> 
.features.tmp )
        @printf "Checking for utsname support... "
        @$(shell ( echo "#include <sys/utsname.h>";                \
                   echo "struct utsname osinfo;";          \
@@ -410,7 +417,7 @@ features: compiler
                ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) ||    
\
                ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )
        @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp 
|| mv .features.tmp .features
-       @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
+       @rm -f .featuretest.c .featuretest2.c .featuretest$(EXEC_SUFFIX)
 else
 features: compiler
        @echo "FEATURES := yes" > .features.tmp
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 7373624..dad116f 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -196,11 +196,13 @@ int ft2232_spi_init(void)
                exit(-1); // TODO
        }
 
+#if CONFIG_LIBFTDI_HS
        if (ftdic->type != TYPE_2232H && ftdic->type != TYPE_4232H) {
                msg_pdbg("FTDI chip type %d is not high-speed\n",
                        ftdic->type);
                clock_5x = 0;
        }
+#endif
 
        if (ftdi_set_interface(ftdic, ft2232_interface) < 0) {
                msg_perr("Unable to select interface: %s\n",
-- 
1.7.0.4


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to