rockchip: Remove ARCH= references from documentation
[oweals/u-boot.git] / cmd / usb_gadget_sdp.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * cmd_sdp.c -- sdp command
4  *
5  * Copyright (C) 2016 Toradex
6  * Author: Stefan Agner <stefan.agner@toradex.com>
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <g_dnl.h>
12 #include <sdp.h>
13 #include <usb.h>
14
15 static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
16 {
17         int ret;
18
19         if (argc < 2)
20                 return CMD_RET_USAGE;
21
22         char *usb_controller = argv[1];
23         int controller_index = simple_strtoul(usb_controller, NULL, 0);
24         usb_gadget_initialize(controller_index);
25
26         g_dnl_clear_detach();
27         ret = g_dnl_register("usb_dnl_sdp");
28         if (ret) {
29                 pr_err("SDP dnl register failed: %d\n", ret);
30                 goto exit_register;
31         }
32
33         ret = sdp_init(controller_index);
34         if (ret) {
35                 pr_err("SDP init failed: %d\n", ret);
36                 goto exit;
37         }
38
39         /* This command typically does not return but jumps to an image */
40         sdp_handle(controller_index);
41         pr_err("SDP ended\n");
42
43 exit:
44         g_dnl_unregister();
45 exit_register:
46         usb_gadget_release(controller_index);
47
48         return CMD_RET_FAILURE;
49 }
50
51 U_BOOT_CMD(sdp, 2, 1, do_sdp,
52         "Serial Downloader Protocol",
53         "<USB_controller>\n"
54         "  - serial downloader protocol via <USB_controller>\n"
55 );