FT232H: Handle the EEPROM Bit for Enter Powerdsave on ACBUS7
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Fri, 17 Jun 2011 17:49:25 +0000 (19:49 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 28 Jun 2011 14:31:34 +0000 (16:31 +0200)
src/ftdi.c
src/ftdi.h

index 76e6f42..ed2bbe0 100644 (file)
@@ -2663,6 +2663,10 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
                 output[0x00] |= DRIVER_VCPH;
             else
                 output[0x00] &= ~DRIVER_VCPH;
+            if (eeprom->powersave)
+                output[0x01] |= POWER_SAVE_DISABLE_H;
+            else
+                output[0x01] &= ~POWER_SAVE_DISABLE_H;
 
             if (eeprom->group0_drive > DRIVE_16MA)
                 output[0x0c] |= DRIVE_16MA;
@@ -2925,6 +2929,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
     {
         eeprom->channel_a_type   = buf[0x00] & 0xf;
         eeprom->channel_a_driver = (buf[0x00] & DRIVER_VCPH)?DRIVER_VCP:0;
+        eeprom->powersave      =  buf[0x01]       & POWER_SAVE_DISABLE_H;
         eeprom->group0_drive   =  buf[0x0c]       & DRIVE_16MA;
         eeprom->group0_schmitt =  buf[0x0c]       & IS_SCHMITT;
         eeprom->group0_slew    =  buf[0x0c]       & SLOW_SLEW;
@@ -2963,6 +2968,11 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
             fprintf(stdout, "Suspend on DBUS7\n");
         if (eeprom->suspend_pull_downs)
             fprintf(stdout, "Pull IO pins low during suspend\n");
+        if(eeprom->powersave)
+        {
+            if(ftdi->type >= TYPE_232H)
+                fprintf(stdout,"Enter low power state on ACBUS7\n");
+        } 
         if (eeprom->remote_wakeup)
             fprintf(stdout, "Enable Remote Wake Up\n");
         fprintf(stdout, "PNP: %d\n",(eeprom->is_not_pnp)?0:1);
@@ -3175,6 +3185,9 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu
         case GROUP3_SLEW:
             *value = ftdi->eeprom->group3_slew;
             break;
+         case POWER_SAVE:
+            *value = ftdi->eeprom->powersave;
+            break;
         case CHIP_TYPE:
             *value = ftdi->eeprom->chip;
             break;
@@ -3314,6 +3327,9 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu
         case CHIP_TYPE:
             ftdi->eeprom->chip = value;
             break;
+         case POWER_SAVE:
+            ftdi->eeprom->powersave = value;
+            break;
         case CHIP_SIZE:
             ftdi_error_return(-2, "EEPROM Value can't be changed");
         default :
index cd3f63b..dd442df 100644 (file)
@@ -272,6 +272,8 @@ struct ftdi_eeprom
     int group3_schmitt;
     int group3_slew;
 
+    int powersave;
+
     /** eeprom size in bytes. This doesn't get stored in the eeprom
         but is the only way to pass it to ftdi_eeprom_build. */
     int size;
@@ -384,7 +386,8 @@ enum ftdi_eeprom_value
     GROUP3_SCHMITT     = 36,
     GROUP3_SLEW        = 37,
     CHIP_SIZE          = 38,
-    CHIP_TYPE          = 39
+    CHIP_TYPE          = 39,
+    POWER_SAVE         = 40
 };
 
 /**
@@ -398,6 +401,8 @@ struct ftdi_device_list
     struct libusb_device *dev;
 };
 
+#define POWER_SAVE_DISABLE_H 0x80
+
 #define USE_SERIAL_NUM 0x08
 enum ftdi_cbus_func {/* FIXME: Recheck value, especially the last */
     CBUS_TXDEN = 0, CBUS_PWREN = 1, CBUS_RXLED = 2, CBUS_TXLED = 3, CBUS_TXRXLED = 4,