]> git.ipfire.org Git - thirdparty/u-boot.git/blame - common/spl/spl_sdp.c
usb: gadget: error out if g_dnl registration fails
[thirdparty/u-boot.git] / common / spl / spl_sdp.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
a3774c1c
SA
2/*
3 * (C) Copyright 2016 Toradex
4 * Author: Stefan Agner <stefan.agner@toradex.com>
a3774c1c
SA
5 */
6
7#include <common.h>
8#include <spl.h>
9#include <usb.h>
10#include <g_dnl.h>
11#include <sdp.h>
12
a3774c1c
SA
13static 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();
25ee9246
SS
20 ret = g_dnl_register("usb_dnl_sdp");
21 if (ret) {
22 pr_err("SDP dnl register failed: %d\n", ret);
23 return ret;
24 }
a3774c1c
SA
25
26 ret = sdp_init(controller_index);
27 if (ret) {
24ccd0c8 28 pr_err("SDP init failed: %d\n", ret);
a3774c1c
SA
29 return -ENODEV;
30 }
31
32 /* This command typically does not return but jumps to an image */
33 sdp_handle(controller_index);
24ccd0c8 34 pr_err("SDP ended\n");
a3774c1c
SA
35
36 return -EINVAL;
37}
38SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);