]> Git Repo - u-boot.git/blob - cmd/usb_gadget_sdp.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[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 <[email protected]>
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <g_dnl.h>
12 #include <sdp.h>
13 #include <usb.h>
14 #include <linux/printk.h>
15
16 static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
17 {
18         int controller_index;
19         struct udevice *udc;
20         int ret;
21
22         if (argc < 2)
23                 return CMD_RET_USAGE;
24
25         controller_index = simple_strtoul(argv[1], NULL, 0);
26         ret = udc_device_get_by_index(controller_index, &udc);
27         if (ret)
28                 return ret;
29
30         g_dnl_clear_detach();
31         ret = g_dnl_register("usb_dnl_sdp");
32         if (ret) {
33                 pr_err("SDP dnl register failed: %d\n", ret);
34                 goto exit_register;
35         }
36
37         ret = sdp_init(udc);
38         if (ret) {
39                 pr_err("SDP init failed: %d\n", ret);
40                 goto exit;
41         }
42
43         /* This command typically does not return but jumps to an image */
44         sdp_handle(udc);
45         pr_err("SDP ended\n");
46
47 exit:
48         g_dnl_unregister();
49 exit_register:
50         udc_device_put(udc);
51
52         return CMD_RET_FAILURE;
53 }
54
55 U_BOOT_CMD(sdp, 2, 1, do_sdp,
56         "Serial Downloader Protocol",
57         "<USB_controller>\n"
58         "  - serial downloader protocol via <USB_controller>\n"
59 );
This page took 0.030934 seconds and 4 git commands to generate.