Subject: [PATCH] Fix detection of some Olimex cables

From: Benjamin Herrenschmidt <[email-masked]>
Date: Thu, 23 Sep 2021 10:41:12 +1000

Currently, we have two cases where we try to "re-use" the urj_cable_driver_t
structure for two different USB variants. This doesnt' actually work however
at least not for 

 URJ_DECLARE_FTDX_CABLE(0x15BA, 0x002A, "-mpsse", "ARM-USB-TINY-H", armusbtiny_h)

Since the name doesn't match the name in the driver.

To avoid confusion, this just duplicates the structures and keep a 1:1 relationship
between URJ_DECLARE_FTDX_CABLE entries and urj_cable_driver_t structures.

Signed-off-by: Benjamin Herrenschmidt <[email-masked]>
---

diff --git a/urjtag/src/tap/cable/ft2232.c b/urjtag/src/tap/cable/ft2232.c
index 5e24090c..9cb69ca4 100644
--- a/urjtag/src/tap/cable/ft2232.c
+++ b/urjtag/src/tap/cable/ft2232.c
@@ -2593,7 +2593,7 @@ URJ_DECLARE_FTDX_CABLE(0x0000, 0x0000, "-mpsse", "FT2232", ft2232)
 
 const urj_cable_driver_t urj_tap_cable_ft2232_armusbocd_driver = {
     "ARM-USB-OCD",
-    N_("Olimex ARM-USB-OCD[-TINY] (FT2232) Cable"),
+    N_("Olimex ARM-USB-OCD (FT2232) Cable"),
     URJ_CABLE_DEVICE_USB,
     { .usb = ft2232_connect, },
     urj_tap_cable_generic_disconnect,
@@ -2610,10 +2610,29 @@ const urj_cable_driver_t urj_tap_cable_ft2232_armusbocd_driver = {
     ftdx_usbcable_help
 };
 URJ_DECLARE_FTDX_CABLE(0x15BA, 0x0003, "-mpsse", "ARM-USB-OCD", armusbocd)
-URJ_DECLARE_FTDX_CABLE(0x15BA, 0x0004, "-mpsse", "ARM-USB-OCD", armusbocdtiny)
+
+const urj_cable_driver_t urj_tap_cable_ft2232_armusbocdtiny_driver = {
+    "ARM-USB-OCD-TINY",
+    N_("Olimex ARM-USB-OCD-TINY (FT2232) Cable"),
+    URJ_CABLE_DEVICE_USB,
+    { .usb = ft2232_connect, },
+    urj_tap_cable_generic_disconnect,
+    ft2232_cable_free,
+    ft2232_armusbocd_init,
+    ft2232_armusbocd_done,
+    ft2232_set_frequency,
+    ft2232_clock,
+    ft2232_get_tdo,
+    ft2232_transfer,
+    ft2232_set_signal,
+    urj_tap_cable_generic_get_signal,
+    ft2232_flush,
+    ftdx_usbcable_help
+};
+URJ_DECLARE_FTDX_CABLE(0x15BA, 0x0004, "-mpsse", "ARM-USB-OCD-TINY", armusbocdtiny)
 
 const urj_cable_driver_t urj_tap_cable_ft2232_armusbtiny_h_driver = {
-    "ARM-USB-OCD-H",
+    "ARM-USB-TINY-H",
     N_("Olimex ARM-USB-TINY-H (FT2232H) Cable"),
     URJ_CABLE_DEVICE_USB,
     { .usb = ft2232_connect, },
@@ -2631,6 +2650,25 @@ const urj_cable_driver_t urj_tap_cable_ft2232_armusbtiny_h_driver = {
     ftdx_usbcable_help
 };
 URJ_DECLARE_FTDX_CABLE(0x15BA, 0x002A, "-mpsse", "ARM-USB-TINY-H", armusbtiny_h)
+
+const urj_cable_driver_t urj_tap_cable_ft2232_armusbocd_h_driver = {
+    "ARM-USB-OCD-H",
+    N_("Olimex ARM-USB-OCD-H (FT2232H) Cable"),
+    URJ_CABLE_DEVICE_USB,
+    { .usb = ft2232_connect, },
+    urj_tap_cable_generic_disconnect,
+    ft2232_cable_free,
+    ft2232_armusbtiny_h_init,
+    ft2232_armusbocd_done,
+    ft2232h_set_frequency,
+    ft2232_clock,
+    ft2232_get_tdo,
+    ft2232_transfer,
+    ft2232_set_signal,
+    urj_tap_cable_generic_get_signal,
+    ft2232_flush,
+    ftdx_usbcable_help
+};
 URJ_DECLARE_FTDX_CABLE(0x15BA, 0x002B, "-mpsse", "ARM-USB-OCD-H", armusbocd_h)
 
 const urj_cable_driver_t urj_tap_cable_ft2232_gnice_driver = {
diff --git a/urjtag/src/tap/cable_list.h b/urjtag/src/tap/cable_list.h
index b321901c..e629b9f1 100644
--- a/urjtag/src/tap/cable_list.h
+++ b/urjtag/src/tap/cable_list.h
@@ -48,7 +48,9 @@ _URJ_CABLE(ep9307)
 #ifdef ENABLE_CABLE_FT2232
 _URJ_CABLE(ft2232)
 _URJ_CABLE(ft2232_armusbocd)
+_URJ_CABLE(ft2232_armusbocdtiny)
 _URJ_CABLE(ft2232_armusbtiny_h)
+_URJ_CABLE(ft2232_armusbocd_h)
 _URJ_CABLE(ft2232_flyswatter)
 _URJ_CABLE(ft2232_gnice)
 _URJ_CABLE(ft2232_gniceplus)