]> Git Repo - J-u-boot.git/blame - common/spl/spl_dfu.c
Merge tag 'u-boot-imx-20210502' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[J-u-boot.git] / common / spl / spl_dfu.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
52f2acc5
R
2/*
3 * (C) Copyright 2016
4 * Texas Instruments, <www.ti.com>
5 *
6 * Ravi B <[email protected]>
52f2acc5
R
7 */
8#include <common.h>
9fb625ce 9#include <env.h>
52f2acc5
R
10#include <spl.h>
11#include <linux/compiler.h>
12#include <errno.h>
13#include <watchdog.h>
14#include <console.h>
15#include <g_dnl.h>
16#include <usb.h>
17#include <dfu.h>
52f2acc5
R
18
19static int run_dfu(int usb_index, char *interface, char *devstring)
20{
21 int ret;
22
23 ret = dfu_init_env_entities(interface, devstring);
24 if (ret) {
25 dfu_free_entities();
26 goto exit;
27 }
28
29 run_usb_dnl_gadget(usb_index, "usb_dnl_dfu");
30exit:
31 dfu_free_entities();
32 return ret;
33}
34
35int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
36{
37 char *str_env;
38 int ret;
39
40 /* set default environment */
0ac7d722 41 env_set_default(NULL, 0);
00caae6d 42 str_env = env_get(dfu_alt_info);
52f2acc5 43 if (!str_env) {
634931fe 44 pr_err("\"%s\" env variable not defined!\n", dfu_alt_info);
52f2acc5
R
45 return -EINVAL;
46 }
47
382bee57 48 ret = env_set("dfu_alt_info", str_env);
52f2acc5 49 if (ret) {
9b643e31 50 pr_err("unable to set env variable \"dfu_alt_info\"!\n");
52f2acc5
R
51 return -EINVAL;
52 }
53
54 /* invoke dfu command */
55 return run_dfu(usbctrl, interface, devstr);
56}
This page took 0.23508 seconds and 4 git commands to generate.