Re: [PATCH] ftdi_sio: add support for FT-X series devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "Jim" == Jim Paris <jim@xxxxxxxx> writes:

    Jim> Add PID 0x6015, corresponding to the new series of FT-X chips
    Jim> (FT220XD, FT201X, FT220X, FT221X, FT230X, FT231X, FT240X).  They
    Jim> all appear as serial devices, and seem indistinguishable except for
    Jim> the default product string stored in their EEPROM.  The baudrate
    Jim> generation matches FT232RL devices.

    Jim> Tested with a FT201X and FT230X at various baudrates (100 -
    Jim> 3000000).

I have nearly the same patch, see appended

...


    Jim> Unfortunately, the existing ftdi_determine_type considers anything
    Jim> with bcdDevice >= 0x0900 to be a FT232H, which means that the
    Jim> baudrate generation is incorrect if we just add a VID/PID.  Would
    Jim> this still be appropriate for -stable?  Or maybe a stripped down
    Jim> version with just the bare minimum to get it working (new VID/PID,
    Jim> and force FT232RL chip type when bcdDevice == 0x1000)?

Adding a seperate code path is a better i.m.h.o. That's easier if some
subtile problems surface later.

But how do you keep e.g. a FT20x from being handled as USART? I added a
quirk in my approach, looking for the string "FT23" in the device product
description . More explanations in the code...

Bye

-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index f770415..b7f907b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -103,6 +103,7 @@ static int   ftdi_mtxorb_hack_setup(struct usb_serial *serial);
 static int   ftdi_NDI_device_setup(struct usb_serial *serial);
 static int   ftdi_stmclite_probe(struct usb_serial *serial);
 static int   ftdi_8u2232c_probe(struct usb_serial *serial);
+static int   ftdi_ft2xxX_probe(struct usb_serial *serial);
 static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);
 static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
 
@@ -134,6 +135,10 @@ static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
 	.probe	= ftdi_8u2232c_probe,
 };
 
+static struct ftdi_sio_quirk ftdi_ft2xxX_quirk = {
+	.probe	= ftdi_ft2xxX_probe,
+};
+
 /*
  * The 8U232AM has the same API as the sio except for:
  * - it can support MUCH higher baudrates; up to:
@@ -188,6 +193,8 @@ static struct usb_device_id id_table_combined [] = {
 		.driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk },
 	{ USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_232H_PID) },
+	{ USB_DEVICE(FTDI_VID, FTDI_FT2xxX_PID) ,
+		.driver_info = (kernel_ulong_t)&ftdi_ft2xxX_quirk },
 	{ USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
@@ -868,7 +875,8 @@ static const char *ftdi_chip_name[] = {
 	[FT232RL] = "FT232RL",
 	[FT2232H] = "FT2232H",
 	[FT4232H] = "FT4232H",
-	[FT232H]  = "FT232H"
+	[FT232H]  = "FT232H",
+	[FT23xX]  = "FT23xX"
 };
 
 
@@ -1170,6 +1178,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
 	case FT232BM: /* FT232BM chip */
 	case FT2232C: /* FT2232C chip */
 	case FT232RL:
+	case FT23xX:
 		if (baud <= 3000000) {
 			__u16 product_id = le16_to_cpu(
 				port->serial->dev->descriptor.idProduct);
@@ -1458,9 +1467,12 @@ static void ftdi_determine_type(struct usb_serial_port *port)
 	} else if (version < 0x900) {
 		/* Assume it's an FT232RL */
 		priv->chip_type = FT232RL;
-	} else {
+	} else if (version < 0x1000) {
 		/* Assume it's an FT232H */
 		priv->chip_type = FT232H;
+	} else {
+		/* Assume it's an FT23xX */
+		priv->chip_type = FT23xX;
 	}
 	dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
 }
@@ -1587,6 +1599,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
 		    (priv->chip_type == FT232BM ||
 		     priv->chip_type == FT2232C ||
 		     priv->chip_type == FT232RL ||
+		     priv->chip_type == FT23xX  ||
 		     priv->chip_type == FT2232H ||
 		     priv->chip_type == FT4232H ||
 		     priv->chip_type == FT232H)) {
@@ -1609,6 +1622,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
 		if (priv->chip_type == FT232BM ||
 		    priv->chip_type == FT2232C ||
 		    priv->chip_type == FT232RL ||
+		    priv->chip_type == FT23xX  ||
 		    priv->chip_type == FT2232H ||
 		    priv->chip_type == FT4232H ||
                     priv->chip_type == FT232H) {
@@ -1769,6 +1783,27 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
 	return 0;
 }
 
+static int ftdi_ft2xxX_probe(struct usb_serial *serial)
+{
+	struct usb_device *udev = serial->dev;
+
+	dbg("%s", __func__);
+
+/* All devices in the FT2xxX family have the same PID. Use the product string
+ * to distinguish. The evaluation modules use their own descriptions and
+ * obviously vary, e.g for the UMFT230XB module the datasheet tells
+ * UMFT230XB" while an actual sample has "UMFT230XB-01"
+ * So search for "FT23" as a common expected characteristic. This should
+ * match all FTDI delivered FT-X chips and modules for now (March 2012)
+ *
+ * If manufacturers decide to name their own product somehow else, we will
+ * need extra clauses
+ */
+	if (strstr(udev->product, "FT23") == 0)
+		return 0;
+	return -ENODEV;
+}
+
 /*
  * First and second port on STMCLiteadaptors is reserved for JTAG interface
  * and the forth port for pio
@@ -2285,6 +2320,7 @@ static int ftdi_tiocmget(struct tty_struct *tty)
 	case FT232BM:
 	case FT2232C:
 	case FT232RL:
+	case FT23xX:
 	case FT2232H:
 	case FT4232H:
 	case FT232H:
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 19584fa..e783737 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -157,7 +157,8 @@ enum ftdi_chip_type {
 	FT232RL = 5,
 	FT2232H = 6,
 	FT4232H = 7,
-	FT232H  = 8
+	FT232H  = 8,
+	FT23xX  = 9
 };
 
 enum ftdi_sio_baudrate {
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 6f6058f..d3efebc 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -23,6 +23,7 @@
 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
 #define FTDI_232H_PID  0x6014 /* Single channel hi-speed device */
+#define FTDI_FT2xxX_PID	0x6015 /* Single channel FT-X device */
 #define FTDI_SIO_PID	0x8372	/* Product Id SIO application of 8U100AX */
 #define FTDI_232RL_PID  0xFBFA  /* Product ID for FT232RL */

Signed-off-by: Jim Paris <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> 
 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux