[PATCH v2] FT232R EEPROM: Add External oscillator enable bit

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2] FT232R EEPROM: Add External oscillator enable bit

Raphael Assenat
FT232R EEPROM: Add External oscillator enable bit (patch v2)

To use an external oscillator on FT232R/FT245R an eeprom bit must be
set. This patch adds support for it in the library.

This is an updated version of the original patch which was missing
the ftdi_set_eeprom_value implementation.

Signed-off-by: Raphael Assenat <[hidden email]>

diff --git a/src/ftdi.c b/src/ftdi.c
index 68489ea..6f152f2 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -2833,6 +2833,8 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
         case TYPE_R:
             if (eeprom->high_current == HIGH_CURRENT_DRIVE_R)
                 output[0x00] |= HIGH_CURRENT_DRIVE_R;
+            if (eeprom->external_oscillator)
+                output[0x00] |= 0x02;
             output[0x01] = 0x40; /* Hard coded Endpoint Size*/
 
             if (eeprom->suspend_pull_downs)
@@ -3318,6 +3320,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
         /* TYPE_R flags D2XX, not VCP as all others*/
         eeprom->channel_a_driver = ~buf[0x00] & DRIVER_VCP;
         eeprom->high_current     = buf[0x00] & HIGH_CURRENT_DRIVE_R;
+        eeprom->external_oscillator = buf[0x00] & 0x02;
         if ( (buf[0x01]&0x40) != 0x40)
             fprintf(stderr,
                     "TYPE_R EEPROM byte[0x01] Bit 6 unexpected Endpoint size."
@@ -3431,8 +3434,10 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
         if (eeprom->serial)
             fprintf(stdout, "Serial:       %s\n",eeprom->serial);
         fprintf(stdout,     "Checksum      : %04x\n", checksum);
-        if (ftdi->type == TYPE_R)
+        if (ftdi->type == TYPE_R) {
             fprintf(stdout,     "Internal EEPROM\n");
+            fprintf(stdout,"Oscillator: %s\n", eeprom->external_oscillator?"External":"Internal");
+ }
         else if (eeprom->chip >= 0x46)
             fprintf(stdout,     "Attached EEPROM: 93x%02x\n", eeprom->chip);
         if (eeprom->suspend_dbus7)
@@ -3752,6 +3757,9 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu
         case CHIP_SIZE:
             *value = ftdi->eeprom->size;
             break;
+        case EXTERNAL_OSCILLATOR:
+            *value = ftdi->eeprom->external_oscillator;
+            break;
         default:
             ftdi_error_return(-1, "Request for unknown EEPROM value");
     }
@@ -3942,6 +3950,9 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu
         case CHIP_SIZE:
             ftdi_error_return(-2, "EEPROM Value can't be changed");
             break;
+        case EXTERNAL_OSCILLATOR:
+            ftdi->eeprom->external_oscillator = value;
+            break;
 
         default :
             ftdi_error_return(-1, "Request to unknown EEPROM value");
diff --git a/src/ftdi.h b/src/ftdi.h
index debf053..5aaeb6c 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -332,6 +332,7 @@ enum ftdi_eeprom_value
     CHANNEL_C_RS485    = 53,
     CHANNEL_D_RS485    = 54,
     RELEASE_NUMBER     = 55,
+    EXTERNAL_OSCILLATOR= 56,
 };
 
 /**
diff --git a/src/ftdi_i.h b/src/ftdi_i.h
index 19d8dd5..060a877 100644
--- a/src/ftdi_i.h
+++ b/src/ftdi_i.h
@@ -98,6 +98,8 @@ struct ftdi_eeprom
     int high_current_b;
     /** Select inversion of data lines (bitmask). */
     int invert;
+    /** Enable external oscillator. */
+    int external_oscillator;
 
     /*2232H/4432H Group specific values */
     /* Group0 is AL on 2322H and A on 4232H

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2] FT232R EEPROM: Add External oscillator enable bit

Thomas Jarosch
Hi Raphael,

On Friday, 14. August 2015 16:13:58 Raphael Assenat wrote:
> FT232R EEPROM: Add External oscillator enable bit (patch v2)
>
> To use an external oscillator on FT232R/FT245R an eeprom bit must be
> set. This patch adds support for it in the library.
>
> This is an updated version of the original patch which was missing
> the ftdi_set_eeprom_value implementation.

thanks, applied! I just did a minor tab -> space tweak.

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Loading...