jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / jtag / drivers / stlink_usb.c
index ee629542ba7f3f153f3aaa11143040a4c73370c3..b14fbf1f38ec5c87c6ab13a8f676bca58284e5af 100644 (file)
@@ -84,6 +84,8 @@
 #define STLINK_V3S_PID          (0x374F)
 #define STLINK_V3_2VCP_PID      (0x3753)
 #define STLINK_V3E_NO_MSD_PID   (0x3754)
+#define STLINK_V3P_USBLOADER_PID (0x3755)
+#define STLINK_V3P_PID           (0x3757)
 
 /*
  * ST-Link/V1, ST-Link/V2 and ST-Link/V2.1 are full-speed USB devices and
@@ -454,7 +456,7 @@ static inline int stlink_usb_xfer_noerrcheck(void *handle, const uint8_t *buf, i
 #define STLINK_DEBUG_PORT_ACCESS            0xffff
 
 #define STLINK_TRACE_SIZE               4096
-#define STLINK_TRACE_MAX_HZ             2000000
+#define STLINK_TRACE_MAX_HZ             2250000
 #define STLINK_V3_TRACE_MAX_HZ          24000000
 
 #define STLINK_V3_MAX_FREQ_NB               10
@@ -1297,8 +1299,8 @@ static int stlink_usb_version(void *handle)
                break;
        }
 
-       /* STLINK-V3 requires a specific command */
-       if (v == 3 && x == 0 && y == 0) {
+       /* STLINK-V3 & STLINK-V3P require a specific command */
+       if (v >= 3 && x == 0 && y == 0) {
                stlink_usb_init_buffer(handle, h->rx_ep, 16);
 
                h->cmdbuf[h->cmdidx++] = STLINK_APIV3_GET_VERSION_EX;
@@ -1414,6 +1416,41 @@ static int stlink_usb_version(void *handle)
                if (h->version.jtag >= 6)
                        flags |= STLINK_F_HAS_RW8_512BYTES;
 
+               break;
+       case 4:
+               /* STLINK-V3P use api-v3 */
+               h->version.jtag_api = STLINK_JTAG_API_V3;
+
+               /* STLINK-V3P is a superset of ST-LINK/V3 */
+
+               /* API for trace */
+               /* API for target voltage */
+               flags |= STLINK_F_HAS_TRACE;
+
+               /* preferred API to get last R/W status */
+               flags |= STLINK_F_HAS_GETLASTRWSTATUS2;
+
+               /* API to access DAP registers */
+               flags |= STLINK_F_HAS_DAP_REG;
+
+               /* API to read/write memory at 16 bit */
+               /* API to write memory without address increment */
+               flags |= STLINK_F_HAS_MEM_16BIT;
+
+               /* API required to init AP before any AP access */
+               flags |= STLINK_F_HAS_AP_INIT;
+
+               /* API required to return proper error code on close AP */
+               flags |= STLINK_F_FIX_CLOSE_AP;
+
+               /* Banked regs (DPv1 & DPv2) support */
+               /* API to read memory without address increment */
+               /* Memory R/W supports CSW */
+               flags |= STLINK_F_HAS_DPBANKSEL;
+
+               /* 8bit read/write max packet size 512 bytes */
+               flags |= STLINK_F_HAS_RW8_512BYTES;
+
                break;
        default:
                break;
@@ -3369,7 +3406,7 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
          in order to become operational.
         */
        do {
-               if (jtag_libusb_open(param->vid, param->pid,
+               if (jtag_libusb_open(param->vid, param->pid, NULL,
                                &h->usb_backend_priv.fd, stlink_usb_get_alternate_serial) != ERROR_OK) {
                        LOG_ERROR("open failed");
                        return ERROR_FAIL;
@@ -3402,6 +3439,8 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
                        case STLINK_V3S_PID:
                        case STLINK_V3_2VCP_PID:
                        case STLINK_V3E_NO_MSD_PID:
+                       case STLINK_V3P_USBLOADER_PID:
+                       case STLINK_V3P_PID:
                                h->version.stlink = 3;
                                h->tx_ep = STLINK_V2_1_TX_EP;
                                h->trace_ep = STLINK_V2_1_TRACE_EP;
@@ -3820,7 +3859,7 @@ static int stlink_config_trace(void *handle, bool enabled,
                return ERROR_FAIL;
        }
 
-       unsigned int max_trace_freq = (h->version.stlink == 3) ?
+       unsigned int max_trace_freq = (h->version.stlink >= 3) ?
                        STLINK_V3_TRACE_MAX_HZ : STLINK_TRACE_MAX_HZ;
 
        /* Only concern ourselves with the frequency if the STlink is processing it. */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)