blob: c4b35114587d09d8badcbb8703480d12d823b9f4 [file] [log] [blame]
Lukasz Majewski3402b052013-10-08 14:30:44 +02001/*
2 * cmd_thordown.c -- USB TIZEN "THOR" Downloader gadget
3 *
4 * Copyright (C) 2013 Lukasz Majewski <l.majewski@samsung.com>
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
11#include <thor.h>
12#include <dfu.h>
13#include <g_dnl.h>
14#include <usb.h>
15
16int do_thor_down(cmd_tbl_t *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 const char *s = "thor";
26 int ret;
27
28 puts("TIZEN \"THOR\" Downloader\n");
29
30 ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
31 NULL, 10));
32 if (ret)
33 return ret;
34
35 int controller_index = simple_strtoul(usb_controller, NULL, 0);
36 ret = board_usb_init(controller_index, USB_INIT_DEVICE);
37 if (ret) {
38 error("USB init failed: %d", ret);
39 ret = CMD_RET_FAILURE;
40 goto exit;
41 }
42
43 g_dnl_register(s);
44
45 ret = thor_init();
46 if (ret) {
47 error("THOR DOWNLOAD failed: %d", ret);
48 ret = CMD_RET_FAILURE;
49 goto exit;
50 }
51
52 ret = thor_handle();
53 if (ret) {
54 error("THOR failed: %d", ret);
55 ret = CMD_RET_FAILURE;
56 goto exit;
57 }
58
59exit:
60 g_dnl_unregister();
61 dfu_free_entities();
62
63 return ret;
64}
65
66U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
67 "TIZEN \"THOR\" downloader",
68 "<USB_controller> <interface> <dev>\n"
69 " - device software upgrade via LTHOR TIZEN dowload\n"
70 " program via <USB_controller> on device <dev>,\n"
71 " attached to interface <interface>\n"
72);