]> Git Repo - J-u-boot.git/blob - common/spl/spl_sdp.c
Merge tag 'u-boot-imx-master-20250127' of https://gitlab.denx.de/u-boot/custodians...
[J-u-boot.git] / common / spl / spl_sdp.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2016 Toradex
4  * Author: Stefan Agner <[email protected]>
5  */
6
7 #include <log.h>
8 #include <spl.h>
9 #include <usb.h>
10 #include <g_dnl.h>
11 #include <sdp.h>
12 #include <linux/printk.h>
13
14 static int spl_sdp_load_image(struct spl_image_info *spl_image,
15                               struct spl_boot_device *bootdev)
16 {
17         const int controller_index = CONFIG_SPL_SDP_USB_DEV;
18         struct udevice *udc;
19         int ret;
20
21         ret = udc_device_get_by_index(controller_index, &udc);
22         if (ret)
23                 return ret;
24
25         board_usb_init(controller_index, USB_INIT_DEVICE);
26
27         g_dnl_clear_detach();
28         ret = g_dnl_register("usb_dnl_sdp");
29         if (ret) {
30                 pr_err("SDP dnl register failed: %d\n", ret);
31                 goto err_detach;
32         }
33
34         ret = sdp_init(udc);
35         if (ret) {
36                 pr_err("SDP init failed: %d\n", ret);
37                 goto err_unregister;
38         }
39
40         /*
41          * This command either loads a legacy image, jumps and never returns,
42          * or it loads a FIT image and returns it to be handled by the SPL
43          * code.
44          */
45         ret = spl_sdp_handle(udc, spl_image, bootdev);
46         debug("SDP ended\n");
47
48 err_unregister:
49         g_dnl_unregister();
50 err_detach:
51         udc_device_put(udc);
52         return ret;
53 }
54 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
This page took 0.023921 seconds and 4 git commands to generate.