]> Git Repo - J-u-boot.git/blame - cmd/usb_gadget_sdp.c
common: Drop linux/printk.h from common header
[J-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>
1e94b46f 14#include <linux/printk.h>
2f005695 15
09140113 16static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
2f005695 17{
37fb7cb7 18 int controller_index;
6b84acc9 19 struct udevice *udc;
25ee9246 20 int ret;
2f005695
SA
21
22 if (argc < 2)
23 return CMD_RET_USAGE;
24
37fb7cb7 25 controller_index = simple_strtoul(argv[1], NULL, 0);
6b84acc9
MV
26 ret = udc_device_get_by_index(controller_index, &udc);
27 if (ret)
28 return ret;
2f005695
SA
29
30 g_dnl_clear_detach();
25ee9246
SS
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 }
2f005695 36
6b84acc9 37 ret = sdp_init(udc);
2f005695 38 if (ret) {
24ccd0c8 39 pr_err("SDP init failed: %d\n", ret);
2f005695
SA
40 goto exit;
41 }
42
43 /* This command typically does not return but jumps to an image */
6b84acc9 44 sdp_handle(udc);
24ccd0c8 45 pr_err("SDP ended\n");
2f005695
SA
46
47exit:
48 g_dnl_unregister();
25ee9246 49exit_register:
6b84acc9 50 udc_device_put(udc);
2f005695 51
25ee9246 52 return CMD_RET_FAILURE;
2f005695
SA
53}
54
55U_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.184251 seconds and 4 git commands to generate.