1 /* 2 * cmd_sdp.c -- sdp command 3 * 4 * Copyright (C) 2016 Toradex 5 * Author: Stefan Agner <stefan.agner@toradex.com> 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ 9 10 #include <common.h> 11 #include <g_dnl.h> 12 #include <sdp.h> 13 #include <usb.h> 14 15 static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 16 { 17 int ret = CMD_RET_FAILURE; 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 board_usb_init(controller_index, USB_INIT_DEVICE); 25 26 g_dnl_clear_detach(); 27 g_dnl_register("usb_dnl_sdp"); 28 29 ret = sdp_init(controller_index); 30 if (ret) { 31 error("SDP init failed: %d", ret); 32 goto exit; 33 } 34 35 /* This command typically does not return but jumps to an image */ 36 sdp_handle(controller_index); 37 error("SDP ended"); 38 39 exit: 40 g_dnl_unregister(); 41 board_usb_cleanup(controller_index, USB_INIT_DEVICE); 42 43 return ret; 44 } 45 46 U_BOOT_CMD(sdp, 2, 1, do_sdp, 47 "Serial Downloader Protocol", 48 "<USB_controller>\n" 49 " - serial downloader protocol via <USB_controller>\n" 50 ); 51