blob: a54c7479d0b0d084fbdb7112d31e4585bf5cfb33 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Agnerd0d9d212017-08-16 11:00:54 -07002/*
3 * (C) Copyright 2016 Toradex
4 * Author: Stefan Agner <stefan.agner@toradex.com>
Stefan Agnerd0d9d212017-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 Agnerd0d9d212017-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
Frank Lia36d93e2020-04-29 10:35:10 +080019 board_usb_init(0, USB_INIT_DEVICE);
20
Stefan Agnerd0d9d212017-08-16 11:00:54 -070021 g_dnl_clear_detach();
Sjoerd Simons24d8ab32019-06-04 21:01:55 +020022 ret = g_dnl_register("usb_dnl_sdp");
23 if (ret) {
24 pr_err("SDP dnl register failed: %d\n", ret);
25 return ret;
26 }
Stefan Agnerd0d9d212017-08-16 11:00:54 -070027
28 ret = sdp_init(controller_index);
29 if (ret) {
Andre Heiderb841e972018-02-15 07:08:55 +010030 pr_err("SDP init failed: %d\n", ret);
Stefan Agnerd0d9d212017-08-16 11:00:54 -070031 return -ENODEV;
32 }
33
Frieder Schrempf09580e22019-06-04 21:56:29 +020034 /*
35 * This command either loads a legacy image, jumps and never returns,
36 * or it loads a FIT image and returns it to be handled by the SPL
37 * code.
38 */
39 ret = spl_sdp_handle(controller_index, spl_image);
40 debug("SDP ended\n");
Stefan Agnerd0d9d212017-08-16 11:00:54 -070041
Frieder Schrempf09580e22019-06-04 21:56:29 +020042 return ret;
Stefan Agnerd0d9d212017-08-16 11:00:54 -070043}
44SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);