xref: /OK3568_Linux_fs/u-boot/common/spl/spl_sdp.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * (C) Copyright 2016 Toradex
3  * Author: Stefan Agner <stefan.agner@toradex.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <spl.h>
10 #include <usb.h>
11 #include <g_dnl.h>
12 #include <sdp.h>
13 
14 DECLARE_GLOBAL_DATA_PTR;
15 
spl_sdp_load_image(struct spl_image_info * spl_image,struct spl_boot_device * bootdev)16 static int spl_sdp_load_image(struct spl_image_info *spl_image,
17 			      struct spl_boot_device *bootdev)
18 {
19 	int ret;
20 	const int controller_index = 0;
21 
22 	g_dnl_clear_detach();
23 	g_dnl_register("usb_dnl_sdp");
24 
25 	ret = sdp_init(controller_index);
26 	if (ret) {
27 		pr_err("SDP init failed: %d\n", ret);
28 		return -ENODEV;
29 	}
30 
31 	/*
32 	 * This command either loads a legacy image, jumps and never returns,
33 	 * or it loads a FIT image and returns it to be handled by the SPL
34 	 * code.
35 	 */
36 	ret = spl_sdp_handle(controller_index, spl_image);
37 	debug("SDP ended\n");
38 
39 	return ret;
40 }
41 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
42