Commit 52f2acc5e065b52499ee4a8e6baf886b8f5fa6da
Committed by
Marek Vasut
1 parent
05341a8764
Exists in
v2017.01-smarct4x
and in
25 other branches
spl: dfu: adding dfu support functions for SPL-DFU
Adding support functions to run dfu spl commands. Signed-off-by: Ravi Babu <ravibabu@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
Showing 3 changed files with 66 additions and 0 deletions Side-by-side Diff
common/spl/Makefile
common/spl/spl_dfu.c
1 | +/* | |
2 | + * (C) Copyright 2016 | |
3 | + * Texas Instruments, <www.ti.com> | |
4 | + * | |
5 | + * Ravi B <ravibabu@ti.com> | |
6 | + * | |
7 | + * SPDX-License-Identifier: GPL-2.0+ | |
8 | + */ | |
9 | +#include <common.h> | |
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> | |
18 | +#include <environment.h> | |
19 | + | |
20 | +static int run_dfu(int usb_index, char *interface, char *devstring) | |
21 | +{ | |
22 | + int ret; | |
23 | + | |
24 | + ret = dfu_init_env_entities(interface, devstring); | |
25 | + if (ret) { | |
26 | + dfu_free_entities(); | |
27 | + goto exit; | |
28 | + } | |
29 | + | |
30 | + run_usb_dnl_gadget(usb_index, "usb_dnl_dfu"); | |
31 | +exit: | |
32 | + dfu_free_entities(); | |
33 | + return ret; | |
34 | +} | |
35 | + | |
36 | +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr) | |
37 | +{ | |
38 | + char *str_env; | |
39 | + int ret; | |
40 | + | |
41 | + /* set default environment */ | |
42 | + set_default_env(0); | |
43 | + str_env = getenv(dfu_alt_info); | |
44 | + if (!str_env) { | |
45 | + error("\"dfu_alt_info\" env variable not defined!\n"); | |
46 | + return -EINVAL; | |
47 | + } | |
48 | + | |
49 | + ret = setenv("dfu_alt_info", str_env); | |
50 | + if (ret) { | |
51 | + error("unable to set env variable \"dfu_alt_info\"!\n"); | |
52 | + return -EINVAL; | |
53 | + } | |
54 | + | |
55 | + /* invoke dfu command */ | |
56 | + return run_dfu(usbctrl, interface, devstr); | |
57 | +} |
include/spl.h
... | ... | @@ -144,5 +144,13 @@ |
144 | 144 | */ |
145 | 145 | bool spl_was_boot_source(void); |
146 | 146 | |
147 | +/** | |
148 | + * spl_dfu_cmd- run dfu command with chosen mmc device interface | |
149 | + * @param usb_index - usb controller number | |
150 | + * @param mmc_dev - mmc device nubmer | |
151 | + * | |
152 | + * @return 0 on success, otherwise error code | |
153 | + */ | |
154 | +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr); | |
147 | 155 | #endif |