Hi,

here is the 2nd version of the patch against current trunk.
Changes:
- renamed some vars
- JTAGkey is now displayed as "JTAGkey" instead of "4232H"
- and documented in manpage


Signed-off-by: Joerg Fischer <[email protected]>



Index: flashrom.8
===================================================================
--- flashrom.8  (Revision 1109)
+++ flashrom.8  (Arbeitskopie)
@@ -177,11 +177,11 @@
 .sp
 .BR "* atahpt" " (for flash ROMs on Highpoint ATA/RAID controllers)"
 .sp
-.BR "* it87spi" " (for flash ROMs behind an ITE IT87xx Super I/O LPC/SPI\
+.BR "* it87spi" " (for flash ROMs behind an ITE IT87xx Super I/O LPC/SPI \
 translation unit)"
 .sp
-.BR "* ft2232_spi" " (for SPI flash ROMs attached to a FT2232H/FT4232H based\
-USB SPI programmer)"
+.BR "* ft2232_spi" " (for SPI flash ROMs attached to a FT2232H/FT4232H/JTAGkey 
\
+based USB SPI programmer)"
 .sp
 .BR "* serprog" " (for flash ROMs attached to a programmer speaking serprog)"
 .sp
@@ -351,7 +351,7 @@
 syntax where
 .B model
 can be any of
-.BR 2232H ", or " 4232H
+.BR 2232H ", "JTAGkey ", or " 4232H
 and
 .B interface
 can be any of
Index: ft2232_spi.c
===================================================================
--- ft2232_spi.c        (Revision 1109)
+++ ft2232_spi.c        (Arbeitskopie)
@@ -45,8 +45,31 @@
 #define BITMODE_BITBANG_NORMAL 1
 #define BITMODE_BITBANG_SPI    2
 
+        /* Set data bits low-byte command:
+         *  value: 0x08  CS=high, DI=low, DO=low, SK=low
+         *    dir: 0x0b  CS=output, DI=input, DO=output, SK=output
+         *
+         * Jtagkey(2) needs to enable its output via Bit4 / GPIOL0
+         *  value: 0x18  OE=high, CS=high, DI=low, DO=low, SK=low
+         *    dir: 0x1b  OE=output, CS=output, DI=input, DO=output, SK=output
+         *
+         */
+static unsigned char cs_bits = 0x08;
+static unsigned char pindir = 0x0b;
 static struct ftdi_context ftdic_context;
 
+#define AMONTEC_JTAGKEY_PID    0xCFF8
+
+static const char * getFT2232name(int ft2232_type)
+{
+       switch(ft2232_type)  {
+               case FTDI_FT2232H: return "2232H"; 
+               case AMONTEC_JTAGKEY_PID: return "JTAGkey";
+               default: return "4232H";
+       }
+       return "4232H";
+}
+
 static int send_buf(struct ftdi_context *ftdic, const unsigned char *buf, int 
size)
 {
        int r;
@@ -86,6 +109,12 @@
                        ft2232_type = FTDI_FT2232H;
                else if (!strcasecmp(arg, "4232H"))
                        ft2232_type = FTDI_FT4232H;
+               else if (!strcasecmp(arg, "jtagkey")) {
+                       ft2232_type = AMONTEC_JTAGKEY_PID;
+                       ft2232_interface = INTERFACE_A;
+                       cs_bits = 0x18;
+                       pindir  = 0x1b;
+               }
                else {
                        msg_perr("Error: Invalid device type specified.\n");
                        free(arg);
@@ -110,7 +139,7 @@
        }
        free(arg);
        msg_pdbg("Using device type %s ",
-                    (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H");
+                    getFT2232name(ft2232_type));
        msg_pdbg("interface %s\n",
                     (ft2232_interface == INTERFACE_A) ? "A" : "B");
 
@@ -178,14 +207,9 @@
                return -1;
 
        msg_pdbg("Set data bits\n");
-       /* Set data bits low-byte command:
-        *  value: 0x08  CS=high, DI=low, DO=low, SK=low
-        *    dir: 0x0b  CS=output, DI=input, DO=output, SK=output
-        */
-#define CS_BIT 0x08
        buf[0] = SET_BITS_LOW;
-       buf[1] = CS_BIT;
-       buf[2] = 0x0b;
+       buf[1] = cs_bits;
+       buf[2] = pindir;
        if (send_buf(ftdic, buf, 3))
                return -1;
 
@@ -230,8 +254,8 @@
         */
        msg_pspew("Assert CS#\n");
        buf[i++] = SET_BITS_LOW;
-       buf[i++] = 0 & ~CS_BIT; /* assertive */
-       buf[i++] = 0x0b;
+       buf[i++] = 0 & ~cs_bits; /* assertive */
+       buf[i++] = pindir;
 
        if (writecnt) {
                buf[i++] = 0x11;
@@ -272,8 +296,8 @@
 
        msg_pspew("De-assert CS#\n");
        buf[i++] = SET_BITS_LOW;
-       buf[i++] = CS_BIT;
-       buf[i++] = 0x0b;
+       buf[i++] = cs_bits;
+       buf[i++] = pindir;
        ret = send_buf(ftdic, buf, i);
        failed |= ret;
        if (ret)
_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to