Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 Toradex |
| 4 | * Author: Stefan Agner <stefan.agner@toradex.com> |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <spl.h> |
| 9 | #include <usb.h> |
| 10 | #include <g_dnl.h> |
| 11 | #include <sdp.h> |
| 12 | |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 13 | static 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(); |
Sjoerd Simons | 24d8ab3 | 2019-06-04 21:01:55 +0200 | [diff] [blame] | 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 | } |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 25 | |
| 26 | ret = sdp_init(controller_index); |
| 27 | if (ret) { |
Andre Heider | b841e97 | 2018-02-15 07:08:55 +0100 | [diff] [blame] | 28 | pr_err("SDP init failed: %d\n", ret); |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 29 | return -ENODEV; |
| 30 | } |
| 31 | |
Frieder Schrempf | 09580e2 | 2019-06-04 21:56:29 +0200 | [diff] [blame] | 32 | /* |
| 33 | * This command either loads a legacy image, jumps and never returns, |
| 34 | * or it loads a FIT image and returns it to be handled by the SPL |
| 35 | * code. |
| 36 | */ |
| 37 | ret = spl_sdp_handle(controller_index, spl_image); |
| 38 | debug("SDP ended\n"); |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 39 | |
Frieder Schrempf | 09580e2 | 2019-06-04 21:56:29 +0200 | [diff] [blame] | 40 | return ret; |
Stefan Agner | d0d9d21 | 2017-08-16 11:00:54 -0700 | [diff] [blame] | 41 | } |
| 42 | SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image); |