]> Git Repo - u-boot.git/blame - cmd/usb_gadget_sdp.c
Merge tag 'ti-v2021.10-rc2' of https://source.denx.de/u-boot/custodians/u-boot-ti
[u-boot.git] / cmd / usb_gadget_sdp.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
2f005695
SA
2/*
3 * cmd_sdp.c -- sdp command
4 *
5 * Copyright (C) 2016 Toradex
6 * Author: Stefan Agner <[email protected]>
2f005695
SA
7 */
8
9#include <common.h>
09140113 10#include <command.h>
2f005695
SA
11#include <g_dnl.h>
12#include <sdp.h>
13#include <usb.h>
14
09140113 15static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
2f005695 16{
25ee9246 17 int ret;
2f005695
SA
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);
a06955ae 24 usb_gadget_initialize(controller_index);
2f005695
SA
25
26 g_dnl_clear_detach();
25ee9246
SS
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 }
2f005695
SA
32
33 ret = sdp_init(controller_index);
34 if (ret) {
24ccd0c8 35 pr_err("SDP init failed: %d\n", ret);
2f005695
SA
36 goto exit;
37 }
38
39 /* This command typically does not return but jumps to an image */
40 sdp_handle(controller_index);
24ccd0c8 41 pr_err("SDP ended\n");
2f005695
SA
42
43exit:
44 g_dnl_unregister();
25ee9246 45exit_register:
a06955ae 46 usb_gadget_release(controller_index);
2f005695 47
25ee9246 48 return CMD_RET_FAILURE;
2f005695
SA
49}
50
51U_BOOT_CMD(sdp, 2, 1, do_sdp,
52 "Serial Downloader Protocol",
53 "<USB_controller>\n"
54 " - serial downloader protocol via <USB_controller>\n"
55);
This page took 0.104878 seconds and 4 git commands to generate.