aboutsummaryrefslogtreecommitdiff
path: root/cmd/usb_gadget_sdp.c
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2017-08-16 11:00:53 -0700
committerStefano Babic <sbabic@denx.de>2017-08-23 10:41:58 +0200
commit2f005695df7b03d25a367f6bedc41c015088ee29 (patch)
treec91c6570e4a833cab68e1704d02c481d05adc24a /cmd/usb_gadget_sdp.c
parentccd7a4d2f42df7ebc8fd0fbbd31d5e6534cb590c (diff)
downloadu-boot-2f005695df7b03d25a367f6bedc41c015088ee29.zip
u-boot-2f005695df7b03d25a367f6bedc41c015088ee29.tar.gz
u-boot-2f005695df7b03d25a367f6bedc41c015088ee29.tar.bz2
cmd: add sdp command
Add a new command to start USB Serial Download Protocol (SDP) state machine. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Reviewed-by: Ɓukasz Majewski <lukma@denx.de> Reviewed-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'cmd/usb_gadget_sdp.c')
-rw-r--r--cmd/usb_gadget_sdp.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
new file mode 100644
index 0000000..b1d8b28
--- /dev/null
+++ b/cmd/usb_gadget_sdp.c
@@ -0,0 +1,50 @@
+/*
+ * cmd_sdp.c -- sdp command
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner <stefan.agner@toradex.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <g_dnl.h>
+#include <sdp.h>
+#include <usb.h>
+
+static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int ret = CMD_RET_FAILURE;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ char *usb_controller = argv[1];
+ int controller_index = simple_strtoul(usb_controller, NULL, 0);
+ board_usb_init(controller_index, USB_INIT_DEVICE);
+
+ g_dnl_clear_detach();
+ g_dnl_register("usb_dnl_sdp");
+
+ ret = sdp_init(controller_index);
+ if (ret) {
+ error("SDP init failed: %d", ret);
+ goto exit;
+ }
+
+ /* This command typically does not return but jumps to an image */
+ sdp_handle(controller_index);
+ error("SDP ended");
+
+exit:
+ g_dnl_unregister();
+ board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+
+ return ret;
+}
+
+U_BOOT_CMD(sdp, 2, 1, do_sdp,
+ "Serial Downloader Protocol",
+ "<USB_controller>\n"
+ " - serial downloader protocol via <USB_controller>\n"
+);