[PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3

Boon Khai Ng posted 1 patch 10 months, 2 weeks ago
There is a newer version of this series
drivers/usb/serial/ftdi_sio.c     | 14 ++++++++++++++
drivers/usb/serial/ftdi_sio_ids.h | 13 +++++++++++++
2 files changed, 27 insertions(+)
[PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Boon Khai Ng 10 months, 2 weeks ago
The Altera on board USB Blaster 3 utilizes a FT2232 and FT4232
chip.

Add VID/PID for the on board USB Blaster 3 so it can be used
as a serial device via ftdi_sio.

Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
---
 drivers/usb/serial/ftdi_sio.c     | 14 ++++++++++++++
 drivers/usb/serial/ftdi_sio_ids.h | 13 +++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index e07c5e3eb18c..3edce9c62213 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1079,6 +1079,20 @@ static const struct usb_device_id id_table_combined[] = {
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
 	/* GMC devices */
 	{ USB_DEVICE(GMC_VID, GMC_Z216C_PID) },
+	/* Altera USB Blaster 3 */
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6022_PID, 1) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6025_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6026_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6026_PID, 3) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6029_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602A_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602A_PID, 3) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602C_PID, 1) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602D_PID, 1) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602D_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 1) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 2) },
+	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 3) },
 	{ }					/* Terminating entry */
 };
 
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 5ee60ba2a73c..673e0cf84bdc 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -1612,3 +1612,16 @@
  */
 #define GMC_VID				0x1cd7
 #define GMC_Z216C_PID			0x0217 /* GMC Z216C Adapter IR-USB */
+
+/*
+ *  Altera USB Blaster 3 (http://www.altera.com).
+ */
+#define ALTR_UB3_VID			0x09fb
+#define ALTR_UB3_6022_PID		0x6022
+#define ALTR_UB3_6025_PID		0x6025
+#define ALTR_UB3_6026_PID		0x6026
+#define ALTR_UB3_6029_PID		0x6029
+#define ALTR_UB3_602A_PID		0x602A
+#define ALTR_UB3_602C_PID		0x602C
+#define ALTR_UB3_602D_PID		0x602D
+#define ALTR_UB3_602E_PID		0x602E
-- 
2.25.1
Re: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Johan Hovold 9 months, 2 weeks ago
On Mon, Feb 03, 2025 at 04:48:22PM +0800, Boon Khai Ng wrote:
> The Altera on board USB Blaster 3 utilizes a FT2232 and FT4232
> chip.

I assume it's either an FT2243 or an FT4232 and not both?

> Add VID/PID for the on board USB Blaster 3 so it can be used
> as a serial device via ftdi_sio.

Can you say something more about these devices? I guess they are used
for programming FPGAs? Are they embedded in other products? And can the
same PID be used for more than one type of device that they are embedded
in?

Or are the PIDs tied to different types of "USB Blaster 3"s? If so this,
should also be reflected in the naming of the defines.

> Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
> ---
>  drivers/usb/serial/ftdi_sio.c     | 14 ++++++++++++++
>  drivers/usb/serial/ftdi_sio_ids.h | 13 +++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index e07c5e3eb18c..3edce9c62213 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1079,6 +1079,20 @@ static const struct usb_device_id id_table_combined[] = {
>  		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
>  	/* GMC devices */
>  	{ USB_DEVICE(GMC_VID, GMC_Z216C_PID) },
> +	/* Altera USB Blaster 3 */
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6022_PID, 1) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6025_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6026_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6026_PID, 3) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_6029_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602A_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602A_PID, 3) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602C_PID, 1) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602D_PID, 1) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602D_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 1) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 2) },
> +	{ USB_DEVICE_INTERFACE_NUMBER(ALTR_UB3_VID, ALTR_UB3_602E_PID, 3) },
>  	{ }					/* Terminating entry */
>  };
>  
> diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
> index 5ee60ba2a73c..673e0cf84bdc 100644
> --- a/drivers/usb/serial/ftdi_sio_ids.h
> +++ b/drivers/usb/serial/ftdi_sio_ids.h
> @@ -1612,3 +1612,16 @@
>   */
>  #define GMC_VID				0x1cd7
>  #define GMC_Z216C_PID			0x0217 /* GMC Z216C Adapter IR-USB */
> +
> +/*
> + *  Altera USB Blaster 3 (http://www.altera.com).
> + */
> +#define ALTR_UB3_VID			0x09fb

This is a generic Altera VID so should just be name ALTERA_VID.

> +#define ALTR_UB3_6022_PID		0x6022
> +#define ALTR_UB3_6025_PID		0x6025
> +#define ALTR_UB3_6026_PID		0x6026
> +#define ALTR_UB3_6029_PID		0x6029
> +#define ALTR_UB3_602A_PID		0x602A
> +#define ALTR_UB3_602C_PID		0x602C
> +#define ALTR_UB3_602D_PID		0x602D
> +#define ALTR_UB3_602E_PID		0x602E

Please use lower case hex notation consistently for the values here.

But depending on the answer to my questions above, either these defines
should be renamed to reflect the Blaster type or product they are part
of, or just be dropped.

Johan
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
> I assume it's either an FT2243 or an FT4232 and not both?

Hi John, you are right, it is either FT2243 or FT4232. Will re-word that

> Can you say something more about these devices? I guess they are used for
> programming FPGAs? Are they embedded in other products? 

There are 2 type of designs, USB Blaster 3 cable or On-Board USB Blaster 3.
They are mainly used to connect debug or configuration software. Supported host
software includes Quartus programmer, System Console, SignalTap, 
Nios debugger.

> And can the
> same PID be used for more than one type of device that they are embedded
> in?
> Or are the PIDs tied to different types of "USB Blaster 3"s? If so this, should
> also be reflected in the naming of the defines.

The PID is associated with how the ports are connected, and
which FDTI Chip are used for example:

PID: 0x6020
Description: One JTAG Port
FTDI Chip FT2232
Port A: USB Blaster 3
Port B: Not used

PID: 0x6021
Description: Two JTAG Port
FTDI Chip FT2232
Port A: USB Blaster 3
Port B: USB Blaster 3

...

PID: 0x602E
Description: One JTAG Port + UART (Port B, C, D)
FTDI Chip FT2232
Port A: USB Blaster 3
Port B: UART
Port C: UART 
Port D: UART

 
> This is a generic Altera VID so should just be name ALTERA_VID.

Will update in the next version.

> 
> > +#define ALTR_UB3_6022_PID		0x6022
> > +#define ALTR_UB3_6025_PID		0x6025
> > +#define ALTR_UB3_6026_PID		0x6026
> > +#define ALTR_UB3_6029_PID		0x6029
> > +#define ALTR_UB3_602A_PID		0x602A
> > +#define ALTR_UB3_602C_PID		0x602C
> > +#define ALTR_UB3_602D_PID		0x602D
> > +#define ALTR_UB3_602E_PID		0x602E
> 
> Please use lower case hex notation consistently for the values here.


Will update in the next version.

> 
> But depending on the answer to my questions above, either these defines
> should be renamed to reflect the Blaster type or product they are part of, or
> just be dropped.

The PID are not tied to specific product, however it is tied with how the Port are connected
and how which FDTI chip are used. (FT2243 or FT4232).

> 
> Johan
Re: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Johan Hovold 9 months, 2 weeks ago
On Thu, Mar 06, 2025 at 03:22:53AM +0000, Ng, Boon Khai wrote:
> > I assume it's either an FT2243 or an FT4232 and not both?
> 
> Hi John, you are right, it is either FT2243 or FT4232. Will re-word that
> 
> > Can you say something more about these devices? I guess they are used for
> > programming FPGAs? Are they embedded in other products? 
> 
> There are 2 type of designs, USB Blaster 3 cable or On-Board USB Blaster 3.
> They are mainly used to connect debug or configuration software. Supported host
> software includes Quartus programmer, System Console, SignalTap, 
> Nios debugger.

Thanks for the background. It would be good to have something like this
in the commit message.

> > And can the
> > same PID be used for more than one type of device that they are embedded
> > in?
> > Or are the PIDs tied to different types of "USB Blaster 3"s? If so this, should
> > also be reflected in the naming of the defines.
> 
> The PID is associated with how the ports are connected, and
> which FDTI Chip are used for example:
> 
> PID: 0x6020
> Description: One JTAG Port
> FTDI Chip FT2232
> Port A: USB Blaster 3
> Port B: Not used
> 
> PID: 0x6021
> Description: Two JTAG Port
> FTDI Chip FT2232
> Port A: USB Blaster 3
> Port B: USB Blaster 3
> 
> ...
> 
> PID: 0x602E
> Description: One JTAG Port + UART (Port B, C, D)
> FTDI Chip FT2232
> Port A: USB Blaster 3
> Port B: UART
> Port C: UART 
> Port D: UART

Got it, thanks. Also here it would be good to include something like the
above, or a compact table like you provided in your reply to David, in
the commit message to have some overview of the configurations that the
patch is adding.

> > > +#define ALTR_UB3_6022_PID		0x6022
> > > +#define ALTR_UB3_6025_PID		0x6025
> > > +#define ALTR_UB3_6026_PID		0x6026
> > > +#define ALTR_UB3_6029_PID		0x6029
> > > +#define ALTR_UB3_602A_PID		0x602A
> > > +#define ALTR_UB3_602C_PID		0x602C
> > > +#define ALTR_UB3_602D_PID		0x602D
> > > +#define ALTR_UB3_602E_PID		0x602E

> > But depending on the answer to my questions above, either these defines
> > should be renamed to reflect the Blaster type or product they are part of, or
> > just be dropped.
> 
> The PID are not tied to specific product, however it is tied with how the Port are connected
> and how which FDTI chip are used. (FT2243 or FT4232).

Then it should be fine to keep the PID in the define name. Just replace
"ALTR" with "ALTERA" for consistency with the renamed VID define.

Johan
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
> > There are 2 type of designs, USB Blaster 3 cable or On-Board USB Blaster 3.
> > They are mainly used to connect debug or configuration software.
> > Supported host software includes Quartus programmer, System Console,
> > SignalTap, Nios debugger.
> 
> Thanks for the background. It would be good to have something like this in the
> commit message.
> 

Will add that in the next version.

> Got it, thanks. Also here it would be good to include something like the above,
> or a compact table like you provided in your reply to David, in the commit
> message to have some overview of the configurations that the patch is
> adding.
> 

Sure, adding that in the next version as well.
 
> Then it should be fine to keep the PID in the define name. Just replace "ALTR"
> with "ALTERA" for consistency with the renamed VID define.
> 

Okay, will update all ALTR define, to ALTERA, to align with the proposed
VID define earlier.
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
Hi All,

Thank you for the kind review and for your patience in going through the patch.
Really appreciate the feedback, and based on the comments I have submitted
a v2 patch at the link below with the necessary improvements. Let me know if 
if there is anything else I should refine. 
 
https://patchwork.kernel.org/project/linux-usb/patch/20250307154355.30772-1-boon.khai.ng@intel.com/

Regards,
Boon Khai.
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
> PID: 0x602E
> Description: One JTAG Port + UART (Port B, C, D)
> FTDI Chip FT2232 

Correction: FTDI Chip FT4232

> Port A: USB Blaster 3 
> Port B: UART 
> Port C: UART
> Port D: UART
Re: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by David Laight 9 months, 2 weeks ago
On Wed, 5 Mar 2025 15:24:53 +0100
Johan Hovold <johan@kernel.org> wrote:

> On Mon, Feb 03, 2025 at 04:48:22PM +0800, Boon Khai Ng wrote:
> > The Altera on board USB Blaster 3 utilizes a FT2232 and FT4232
> > chip.  
> 
> I assume it's either an FT2243 or an FT4232 and not both?
> 
> > Add VID/PID for the on board USB Blaster 3 so it can be used
> > as a serial device via ftdi_sio.  
> 
> Can you say something more about these devices? I guess they are used
> for programming FPGAs? Are they embedded in other products? And can the
> same PID be used for more than one type of device that they are embedded
> in?

Also, is there any actual software that can use them through this driver?
The Altera 'quartus' software that is usually used to program (etc) the
fpga is pretty proprietary.
I think some bits have been reverse engineered, but only for a few simple
actions.

I'm not even sure the Altera code even loads a driver - just uses the userspace
USB library.
I'll have used it on a system with a custom kernel to program (etc) a CycloneV.
No hint of needing to recompile a driver.
(The sheer amount of software you need to command-line program a device is
stunning! - I had to parcel it all up so we could use a usb to jtag cable
to in-situ program one of the smaller PLD devices on a small board.)

So what is the real 'use case'?

	David

> 
> Or are the PIDs tied to different types of "USB Blaster 3"s? If so this,
> should also be reflected in the naming of the defines.
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
Hi Greg, Johan,

I hope you are doing well.

I'm writing to follow up on this patch I submitted for the USB FDTI driver to update the VID and PID about a month ago. 

I wanted to kindly check in and inquire if there are any updates regarding the review or integration of the patch.
If there are any issues or additional information required from my side, please let me know how I can assist in moving it forward.

I completely understand that you have a lot on your plates, but I would appreciate any guidance on the next steps to get the patch reviewed and potentially merged.

Thank you for your time and attention to this, and I look forward to your feedback.

Regards,
Boon Khai
Re: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Greg Kroah-Hartman 9 months, 2 weeks ago
On Tue, Mar 04, 2025 at 05:25:38AM +0000, Ng, Boon Khai wrote:
> Hi Greg, Johan,
> 
> I hope you are doing well.
> 
> I'm writing to follow up on this patch I submitted for the USB FDTI driver to update the VID and PID about a month ago. 
> 
> I wanted to kindly check in and inquire if there are any updates regarding the review or integration of the patch.
> If there are any issues or additional information required from my side, please let me know how I can assist in moving it forward.
> 
> I completely understand that you have a lot on your plates, but I would appreciate any guidance on the next steps to get the patch reviewed and potentially merged.
> 
> Thank you for your time and attention to this, and I look forward to your feedback.


Should be in Johan's queue somewhere, if not, please just resend it.

thanks,

greg k-h
Re: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Johan Hovold 9 months, 2 weeks ago
On Tue, Mar 04, 2025 at 06:32:46AM +0100, Greg Kroah-Hartman wrote:
> On Tue, Mar 04, 2025 at 05:25:38AM +0000, Ng, Boon Khai wrote:

> > I'm writing to follow up on this patch I submitted for the USB FDTI driver to update the VID and PID about a month ago. 
> > 
> > I wanted to kindly check in and inquire if there are any updates regarding the review or integration of the patch.
> > If there are any issues or additional information required from my side, please let me know how I can assist in moving it forward.

> Should be in Johan's queue somewhere, if not, please just resend it.

It's still in my queue. I plan to do another pass this week so I'll get
back to you shortly.

Johan
RE: [PATCH v1] USB: serial: ftdi_sio: add support for Altera USB Blaster 3
Posted by Ng, Boon Khai 9 months, 2 weeks ago
> Should be in Johan's queue somewhere, if not, please just resend it.
> thanks,
> greg k-h

> It's still in my queue. I plan to do another pass this week so I'll get back to you
> shortly.
> 
> Johan

Hi Greg, Johan.
Thanks for the update! I appreciate you taking the time to review it. I look forward to hearing back from you after that.