From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] scripts/rk-usb-loader: Add support for rk3588
Date: Wed, 5 Jun 2024 20:25:39 +0300 [thread overview]
Message-ID: <20240605172539.251490-1-eagle.alexander923@gmail.com> (raw)
This adds support for rk3588 CPU for rk-usb-loader.
Instead of 0x350a PID, the rk3588 uses 0x350b, so lets use mask
to be compatible with both CPUs.
Tested with 3588OK-C Forlinx board.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
scripts/rk-usb-loader.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/scripts/rk-usb-loader.c b/scripts/rk-usb-loader.c
index 9c2367ed28..ad70cfe271 100644
--- a/scripts/rk-usb-loader.c
+++ b/scripts/rk-usb-loader.c
@@ -66,7 +66,9 @@ static void log_debug(char *fmt, ...)
va_end(va);
}
-static libusb_device_handle *rk_usb_open(libusb_context *ctx, uint16_t vendor, uint16_t product)
+static libusb_device_handle *rk_usb_open(libusb_context *ctx,
+ uint16_t vendor, uint16_t vmask,
+ uint16_t product, uint16_t pmask)
{
libusb_device **devlist;
libusb_device_handle *handle;
@@ -74,8 +76,8 @@ static libusb_device_handle *rk_usb_open(libusb_context *ctx, uint16_t vendor, u
ssize_t count, i;
int ret;
- log_info("scanning for USB device matching %04hx:%04hx...\n",
- vendor, product);
+ log_info("scanning for USB device matching %04hx/%04hx:%04hx/%04hx...\n",
+ vendor, vmask, product, pmask);
while (1) {
if ((count = libusb_get_device_list(ctx, &devlist)) < 0) {
@@ -93,11 +95,11 @@ static libusb_device_handle *rk_usb_open(libusb_context *ctx, uint16_t vendor, u
return NULL;
}
- if (desc.idVendor != vendor)
+ if ((desc.idVendor & vmask) != (vendor & vmask))
continue;
if (product) {
- if (desc.idProduct != product)
+ if ((desc.idProduct & pmask) != (product & pmask))
continue;
goto found;
}
@@ -113,7 +115,8 @@ static libusb_device_handle *rk_usb_open(libusb_context *ctx, uint16_t vendor, u
ret = libusb_open(devlist[i], &handle);
if (ret < 0) {
log_error("failed to open USB device %04hx:%04hx: %s\n",
- vendor, product, libusb_error_name(ret));
+ desc.idVendor, desc.idProduct,
+ libusb_error_name(ret));
libusb_free_device_list(devlist, 1);
return NULL;
}
@@ -124,7 +127,8 @@ static libusb_device_handle *rk_usb_open(libusb_context *ctx, uint16_t vendor, u
return NULL;
}
- log_info("successfully opened %04hx:%04hx\n", vendor, product);
+ log_info("successfully opened %04hx:%04hx\n",
+ desc.idVendor, desc.idProduct);
return handle;
}
@@ -231,7 +235,7 @@ static int upload_image(const char *filename)
return ret;
}
- dev = rk_usb_open(ctx, 0x2207, 0x350a);
+ dev = rk_usb_open(ctx, 0x2207, 0xffff, 0x350a, 0xfffe);
if (!dev) {
libusb_exit(ctx);
return 1;
--
2.38.2
next reply other threads:[~2024-06-05 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 17:25 Alexander Shiyan [this message]
2024-06-10 12:22 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240605172539.251490-1-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox