aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2019-09-27 12:12:32 -0700
committerTim Newsome <tim@sifive.com>2019-09-27 12:12:32 -0700
commit53b87ddfc5ea01d87d7218b2417359e695428927 (patch)
treeebd0196c92b13c48f9f0f1e1fdf5921a81dc091d /src
parent9aac179cf28fe2af49efd6eeccc6cfcea9b2db3b (diff)
downloadriscv-openocd-53b87ddfc5ea01d87d7218b2417359e695428927.zip
riscv-openocd-53b87ddfc5ea01d87d7218b2417359e695428927.tar.gz
riscv-openocd-53b87ddfc5ea01d87d7218b2417359e695428927.tar.bz2
Update libjaylink.
Change-Id: I9b8d7a5b9356c962d625e541f917c5dd74f47a98
Diffstat (limited to 'src')
-rw-r--r--src/jtag/drivers/libjaylink/configure.ac2
-rw-r--r--src/jtag/drivers/libjaylink/libjaylink/device.c61
-rw-r--r--src/jtag/drivers/libjaylink/libjaylink/libjaylink.h36
3 files changed, 97 insertions, 2 deletions
diff --git a/src/jtag/drivers/libjaylink/configure.ac b/src/jtag/drivers/libjaylink/configure.ac
index de5919c..7fc2a1f 100644
--- a/src/jtag/drivers/libjaylink/configure.ac
+++ b/src/jtag/drivers/libjaylink/configure.ac
@@ -50,7 +50,7 @@ PKG_PROG_PKG_CONFIG
# Checks for libraries.
# Check for libusb-1.0 which is always needed.
-PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9],
+PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.16],
[HAVE_LIBUSB=yes], [HAVE_LIBUSB=no])
AS_IF([test "x$HAVE_LIBUSB" = "xyes"],
diff --git a/src/jtag/drivers/libjaylink/libjaylink/device.c b/src/jtag/drivers/libjaylink/libjaylink/device.c
index a3bddf6..3a5f7d2 100644
--- a/src/jtag/drivers/libjaylink/libjaylink/device.c
+++ b/src/jtag/drivers/libjaylink/libjaylink/device.c
@@ -68,6 +68,9 @@
#define REG_MAX_SIZE 0x200
/** Size of a connection entry in bytes. */
#define REG_CONN_INFO_SIZE 16
+
+/* The maximum path depth according to the USB 3.0 specification. */
+#define MAX_USB_PATH_DEPTH 7
/** @endcond */
/** @private */
@@ -286,6 +289,64 @@ JAYLINK_API int jaylink_device_get_usb_address(
}
/**
+ * Get the USB bus and port numbers of a device.
+ *
+ * @param[in] dev Device instance.
+ * @param[out] bus The bus number of the device on success and undefined on
+ * failure.
+ * @param[out] ports Newly allocated array which contains the port numbers on
+ * success and is undefined on failure. The array must be
+ * free'd by the caller.
+ * @param[out] length Length of the port array on success and undefined on
+ * failure.
+ *
+ * @retval JAYLINK_OK Success.
+ * @retval JAYLINK_ERR_ARG Invalid arguments.
+ * @retval JAYLINK_ERR_MALLOC Memory allocation error.
+ * @retval JAYLINK_ERR_NOT_SUPPORTED Supported for devices with host interface
+ * #JAYLINK_HIF_USB only.
+ *
+ * @since 0.2.0
+ */
+JAYLINK_API int jaylink_device_get_usb_bus_ports(
+ const struct jaylink_device *dev, uint8_t *bus,
+ uint8_t **ports, size_t *length)
+{
+ if (!dev || !bus || !ports || !length)
+ return JAYLINK_ERR_ARG;
+
+ if (dev->iface != JAYLINK_HIF_USB)
+ return JAYLINK_ERR_NOT_SUPPORTED;
+
+#ifdef HAVE_LIBUSB
+ struct jaylink_context *ctx = dev->ctx;
+ int ret;
+
+ *ports = malloc(MAX_USB_PATH_DEPTH * sizeof(uint8_t));
+
+ if (!*ports) {
+ return JAYLINK_ERR_MALLOC;
+ }
+
+ ret = libusb_get_port_numbers(dev->usb_dev, *ports,
+ MAX_USB_PATH_DEPTH);
+
+ if (ret == LIBUSB_ERROR_OVERFLOW) {
+ log_err(ctx, "Failed to get port numbers: %s.",
+ libusb_error_name(ret));
+ return JAYLINK_ERR_ARG;
+ }
+
+ *length = ret;
+ *bus = libusb_get_bus_number(dev->usb_dev);
+
+ return JAYLINK_OK;
+#else
+ return JAYLINK_ERR_NOT_SUPPORTED;
+#endif
+}
+
+/**
* Get the IPv4 address string of a device.
*
* @param[in] dev Device instance.
diff --git a/src/jtag/drivers/libjaylink/libjaylink/libjaylink.h b/src/jtag/drivers/libjaylink/libjaylink/libjaylink.h
index 223aa84..1de95c9 100644
--- a/src/jtag/drivers/libjaylink/libjaylink/libjaylink.h
+++ b/src/jtag/drivers/libjaylink/libjaylink/libjaylink.h
@@ -169,7 +169,38 @@ enum jaylink_hardware_info {
/** Current consumption of the target in mA. */
JAYLINK_HW_INFO_ITARGET = (1 << 2),
/** Peak current consumption of the target in mA. */
- JAYLINK_HW_INFO_ITARGET_PEAK = (1 << 3)
+ JAYLINK_HW_INFO_ITARGET_PEAK = (1 << 3),
+ /**
+ * Device's IPv4 address in network byte order.
+ *
+ * If the address is 0.0.0.0 and DHCP is enabled, no address is
+ * assigned (yet).
+ *
+ * @note The value is valid only if the device is configured in DHCP
+ * mode.
+ */
+ JAYLINK_HW_INFO_IPV4_ADDRESS = (1 << 16),
+ /**
+ * IPv4 netmask in network byte order.
+ *
+ * @note The value is valid only if the device is configured in DHCP
+ * mode.
+ */
+ JAYLINK_HW_INFO_IPV4_NETMASK = (1 << 17),
+ /**
+ * Gateway IPv4 address in network byte order.
+ *
+ * @note The value is valid only if the device is configured in DHCP
+ * mode.
+ */
+ JAYLINK_HW_INFO_IPV4_GATEWAY = (1 << 18),
+ /**
+ * DNS server IPv4 address in network byte order.
+ *
+ * @note The value is valid only if the device is configured in DHCP
+ * mode.
+ */
+ JAYLINK_HW_INFO_IPV4_DNS = (1 << 19)
};
/** Device counters. */
@@ -430,6 +461,9 @@ JAYLINK_API int jaylink_device_get_serial_number(
JAYLINK_API int jaylink_device_get_usb_address(
const struct jaylink_device *dev,
enum jaylink_usb_address *address);
+JAYLINK_API int jaylink_device_get_usb_bus_ports(
+ const struct jaylink_device *dev, uint8_t *bus,
+ uint8_t **ports, size_t *length);
JAYLINK_API int jaylink_device_get_ipv4_address(
const struct jaylink_device *dev, char *address);
JAYLINK_API int jaylink_device_get_mac_address(