blob: 51b245b886262e253f516acb50cabed64437e112 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Agnera3774c12017-08-16 11:00:54 -07002/*
3 * (C) Copyright 2016 Toradex
4 * Author: Stefan Agner <stefan.agner@toradex.com>
Stefan Agnera3774c12017-08-16 11:00:54 -07005 */
6
7#include <common.h>
8#include <spl.h>
9#include <usb.h>
10#include <g_dnl.h>
11#include <sdp.h>
12
Stefan Agnera3774c12017-08-16 11:00:54 -070013static 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) {
Andre Heider24ccd0c2018-02-15 07:08:55 +010024 pr_err("SDP init failed: %d\n", ret);
Stefan Agnera3774c12017-08-16 11:00:54 -070025 return -ENODEV;
26 }
27
Frieder Schrempf2c72ead2019-06-04 21:56:29 +020028 /*
29 * This command either loads a legacy image, jumps and never returns,
30 * or it loads a FIT image and returns it to be handled by the SPL
31 * code.
32 */
33 ret = spl_sdp_handle(controller_index, spl_image);
34 debug("SDP ended\n");
Stefan Agnera3774c12017-08-16 11:00:54 -070035
Frieder Schrempf2c72ead2019-06-04 21:56:29 +020036 return ret;
Stefan Agnera3774c12017-08-16 11:00:54 -070037}
38SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);