1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2016 Toradex
4  * Author: Stefan Agner <stefan.agner@toradex.com>
5  */
6 
7 #include <common.h>
8 #include <spl.h>
9 #include <usb.h>
10 #include <g_dnl.h>
11 #include <sdp.h>
12 
spl_sdp_load_image(struct spl_image_info * spl_image,struct spl_boot_device * bootdev)13 static int spl_sdp_load_image(struct spl_image_info *spl_image,
14 			      struct spl_boot_device *bootdev)
15 {
16 	int ret;
17 	const int controller_index = 0;
18 
19 	g_dnl_clear_detach();
20 	g_dnl_register("usb_dnl_sdp");
21 
22 	ret = sdp_init(controller_index);
23 	if (ret) {
24 		pr_err("SDP init failed: %d\n", ret);
25 		return -ENODEV;
26 	}
27 
28 	/* This command typically does not return but jumps to an image */
29 	sdp_handle(controller_index);
30 	pr_err("SDP ended\n");
31 
32 	return -EINVAL;
33 }
34 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
35