summaryrefslogtreecommitdiffstats
path: root/scripts/imx/imx-usb-loader.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-07-14 09:27:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-08 14:19:12 +0200
commit23e2203150b6eeede27d467399743efbba99c73d (patch)
treea063f9d8525d0318969db7e2d7a97bd30325d1f5 /scripts/imx/imx-usb-loader.c
parent1828a5921c8ba22e1c42608b7530f8ea6ffacbfc (diff)
downloadbarebox-23e2203150b6eeede27d467399743efbba99c73d.tar.gz
barebox-23e2203150b6eeede27d467399743efbba99c73d.tar.xz
imx-usb-loader: Add i.MX8MP support
For the i.MX8MP NXP dropped the SDP protocol used on other SoCs. Instead the image is just sent straight to the device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220714072722.2863571-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/imx/imx-usb-loader.c')
-rw-r--r--scripts/imx/imx-usb-loader.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index 5f7dc3bc0b..c20e223a35 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -74,6 +74,7 @@ struct mach_id {
#define DEV_IMX 0
#define DEV_MXS 1
unsigned char dev_type;
+ unsigned char hid_endpoint;
};
struct usb_work {
@@ -182,6 +183,14 @@ static const struct mach_id imx_ids[] = {
.max_transfer = 1024,
}, {
.vid = 0x1fc9,
+ .pid = 0x0146,
+ .name = "i.MX8MP",
+ .header_type = HDR_MX53,
+ .max_transfer = 1020,
+ .mode = MODE_HID,
+ .hid_endpoint = 1,
+ }, {
+ .vid = 0x1fc9,
.pid = 0x012b,
.name = "i.MX8MQ",
.header_type = HDR_MX53,
@@ -470,15 +479,22 @@ static int transfer(int report, unsigned char *p, unsigned cnt, int *last_trans)
if (report < 3) {
memcpy(&tmp[1], p, cnt);
- err = libusb_control_transfer(usb_dev_handle,
- CTRL_OUT,
- HID_SET_REPORT,
- (HID_REPORT_TYPE_OUTPUT << 8) | report,
- 0,
- tmp, cnt + 1, 1000);
- *last_trans = (err > 0) ? err - 1 : 0;
- if (err > 0)
- err = 0;
+ if (mach_id->hid_endpoint) {
+ int trans;
+ err = libusb_interrupt_transfer(usb_dev_handle,
+ mach_id->hid_endpoint, tmp, cnt + 1, &trans, 1000);
+ *last_trans = trans - 1;
+ } else {
+ err = libusb_control_transfer(usb_dev_handle,
+ CTRL_OUT,
+ HID_SET_REPORT,
+ (HID_REPORT_TYPE_OUTPUT << 8) | report,
+ 0,
+ tmp, cnt + 1, 1000);
+ *last_trans = (err > 0) ? err - 1 : 0;
+ if (err > 0)
+ err = 0;
+ }
} else {
*last_trans = 0;
memset(&tmp[1], 0, cnt);
@@ -1353,6 +1369,9 @@ static int do_irom_download(struct usb_work *curr, int verify)
header_offset = ret;
+ if (mach_id->hid_endpoint)
+ return send_buf(buf + header_offset, fsize - header_offset);
+
if (plugin && (!curr->plug)) {
printf("Only plugin header found\n");
ret = -1;