rockchip: Remove ARCH= references from documentation
[oweals/u-boot.git] / cmd / thordown.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * cmd_thordown.c -- USB TIZEN "THOR" Downloader gadget
4  *
5  * Copyright (C) 2013 Lukasz Majewski <l.majewski@samsung.com>
6  * All rights reserved.
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <thor.h>
12 #include <dfu.h>
13 #include <g_dnl.h>
14 #include <usb.h>
15
16 int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
17 {
18         if (argc < 4)
19                 return CMD_RET_USAGE;
20
21         char *usb_controller = argv[1];
22         char *interface = argv[2];
23         char *devstring = argv[3];
24
25         int ret;
26
27         puts("TIZEN \"THOR\" Downloader\n");
28
29         ret = dfu_init_env_entities(interface, devstring);
30         if (ret)
31                 goto done;
32
33         int controller_index = simple_strtoul(usb_controller, NULL, 0);
34         ret = usb_gadget_initialize(controller_index);
35         if (ret) {
36                 pr_err("USB init failed: %d\n", ret);
37                 ret = CMD_RET_FAILURE;
38                 goto exit;
39         }
40
41         ret = g_dnl_register("usb_dnl_thor");
42         if (ret) {
43                 pr_err("g_dnl_register failed %d\n", ret);
44                 ret = CMD_RET_FAILURE;
45                 goto exit;
46         }
47
48         ret = thor_init();
49         if (ret) {
50                 pr_err("THOR DOWNLOAD failed: %d\n", ret);
51                 ret = CMD_RET_FAILURE;
52                 goto exit;
53         }
54
55         ret = thor_handle();
56         if (ret) {
57                 pr_err("THOR failed: %d\n", ret);
58                 ret = CMD_RET_FAILURE;
59                 goto exit;
60         }
61
62 exit:
63         g_dnl_unregister();
64         usb_gadget_release(controller_index);
65 done:
66         dfu_free_entities();
67
68         return ret;
69 }
70
71 U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
72            "TIZEN \"THOR\" downloader",
73            "<USB_controller> <interface> <dev>\n"
74            "  - device software upgrade via LTHOR TIZEN download\n"
75            "    program via <USB_controller> on device <dev>,\n"
76            "    attached to interface <interface>\n"
77 );