]> Git Repo - J-u-boot.git/blame - cmd/thordown.c
watchdog: kconfig: Enable designware for rk3399
[J-u-boot.git] / cmd / thordown.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
3402b053
ŁM
2/*
3 * cmd_thordown.c -- USB TIZEN "THOR" Downloader gadget
4 *
5 * Copyright (C) 2013 Lukasz Majewski <[email protected]>
6 * All rights reserved.
3402b053
ŁM
7 */
8
9#include <common.h>
10#include <thor.h>
11#include <dfu.h>
12#include <g_dnl.h>
13#include <usb.h>
14
15int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
16{
17 if (argc < 4)
18 return CMD_RET_USAGE;
19
20 char *usb_controller = argv[1];
21 char *interface = argv[2];
22 char *devstring = argv[3];
23
3402b053
ŁM
24 int ret;
25
26 puts("TIZEN \"THOR\" Downloader\n");
27
90fadb57 28 ret = dfu_init_env_entities(interface, devstring);
3402b053 29 if (ret)
90fadb57 30 goto done;
3402b053
ŁM
31
32 int controller_index = simple_strtoul(usb_controller, NULL, 0);
a06955ae 33 ret = usb_gadget_initialize(controller_index);
3402b053 34 if (ret) {
71002b50 35 pr_err("USB init failed: %d\n", ret);
3402b053
ŁM
36 ret = CMD_RET_FAILURE;
37 goto exit;
38 }
39
ed3a37a2
MS
40 ret = g_dnl_register("usb_dnl_thor");
41 if (ret) {
42 pr_err("g_dnl_register failed %d\n", ret);
0896d2ca
MS
43 ret = CMD_RET_FAILURE;
44 goto exit;
ed3a37a2 45 }
3402b053
ŁM
46
47 ret = thor_init();
48 if (ret) {
71002b50 49 pr_err("THOR DOWNLOAD failed: %d\n", ret);
3402b053
ŁM
50 ret = CMD_RET_FAILURE;
51 goto exit;
52 }
53
54 ret = thor_handle();
55 if (ret) {
71002b50 56 pr_err("THOR failed: %d\n", ret);
3402b053
ŁM
57 ret = CMD_RET_FAILURE;
58 goto exit;
59 }
60
61exit:
62 g_dnl_unregister();
a06955ae 63 usb_gadget_release(controller_index);
90fadb57 64done:
3402b053
ŁM
65 dfu_free_entities();
66
67 return ret;
68}
69
70U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
71 "TIZEN \"THOR\" downloader",
72 "<USB_controller> <interface> <dev>\n"
c8087f67 73 " - device software upgrade via LTHOR TIZEN download\n"
3402b053
ŁM
74 " program via <USB_controller> on device <dev>,\n"
75 " attached to interface <interface>\n"
76);
This page took 0.298488 seconds and 4 git commands to generate.