blob: 2dd750928e41ad39c2a924b38140c898f5c114e7 [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
Lukasz Majewski3402b052013-10-08 14:30:44 +020025 int ret;
26
27 puts("TIZEN \"THOR\" Downloader\n");
28
29 ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
30 NULL, 10));
31 if (ret)
32 return ret;
33
34 int controller_index = simple_strtoul(usb_controller, NULL, 0);
35 ret = board_usb_init(controller_index, USB_INIT_DEVICE);
36 if (ret) {
37 error("USB init failed: %d", ret);
38 ret = CMD_RET_FAILURE;
39 goto exit;
40 }
41
Mateusz Zalegac4d0e852014-04-28 21:13:28 +020042 g_dnl_register("usb_dnl_thor");
Lukasz Majewski3402b052013-10-08 14:30:44 +020043
44 ret = thor_init();
45 if (ret) {
46 error("THOR DOWNLOAD failed: %d", ret);
47 ret = CMD_RET_FAILURE;
48 goto exit;
49 }
50
51 ret = thor_handle();
52 if (ret) {
53 error("THOR failed: %d", ret);
54 ret = CMD_RET_FAILURE;
55 goto exit;
56 }
57
58exit:
59 g_dnl_unregister();
60 dfu_free_entities();
61
62 return ret;
63}
64
65U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
66 "TIZEN \"THOR\" downloader",
67 "<USB_controller> <interface> <dev>\n"
68 " - device software upgrade via LTHOR TIZEN dowload\n"
69 " program via <USB_controller> on device <dev>,\n"
70 " attached to interface <interface>\n"
71);