2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-07-28 12:09:16 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2016
|
|
|
|
* Texas Instruments, <www.ti.com>
|
|
|
|
*
|
|
|
|
* Ravi B <ravibabu@ti.com>
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2016-07-28 12:09:16 +00:00
|
|
|
#include <spl.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
#include <console.h>
|
|
|
|
#include <g_dnl.h>
|
|
|
|
#include <usb.h>
|
|
|
|
#include <dfu.h>
|
2023-09-15 00:21:46 +00:00
|
|
|
#include <linux/printk.h>
|
2016-07-28 12:09:16 +00:00
|
|
|
|
|
|
|
static int run_dfu(int usb_index, char *interface, char *devstring)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = dfu_init_env_entities(interface, devstring);
|
|
|
|
if (ret) {
|
|
|
|
dfu_free_entities();
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
run_usb_dnl_gadget(usb_index, "usb_dnl_dfu");
|
|
|
|
exit:
|
|
|
|
dfu_free_entities();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
|
|
|
|
{
|
|
|
|
char *str_env;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* set default environment */
|
2019-08-01 15:47:00 +00:00
|
|
|
env_set_default(NULL, 0);
|
2017-08-03 18:22:12 +00:00
|
|
|
str_env = env_get(dfu_alt_info);
|
2016-07-28 12:09:16 +00:00
|
|
|
if (!str_env) {
|
2019-05-25 20:50:35 +00:00
|
|
|
pr_err("\"%s\" env variable not defined!\n", dfu_alt_info);
|
2016-07-28 12:09:16 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-08-03 18:22:09 +00:00
|
|
|
ret = env_set("dfu_alt_info", str_env);
|
2016-07-28 12:09:16 +00:00
|
|
|
if (ret) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("unable to set env variable \"dfu_alt_info\"!\n");
|
2016-07-28 12:09:16 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* invoke dfu command */
|
|
|
|
return run_dfu(usbctrl, interface, devstr);
|
|
|
|
}
|