]> Git Repo - J-u-boot.git/blame - cmd/thordown.c
Merge tag 'u-boot-amlogic-20221122' of https://source.denx.de/u-boot/custodians/u...
[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>
09140113 10#include <command.h>
3402b053
ŁM
11#include <thor.h>
12#include <dfu.h>
13#include <g_dnl.h>
14#include <usb.h>
15
09140113 16int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
3402b053
ŁM
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
3402b053
ŁM
25 int ret;
26
27 puts("TIZEN \"THOR\" Downloader\n");
28
90fadb57 29 ret = dfu_init_env_entities(interface, devstring);
3402b053 30 if (ret)
90fadb57 31 goto done;
3402b053
ŁM
32
33 int controller_index = simple_strtoul(usb_controller, NULL, 0);
a06955ae 34 ret = usb_gadget_initialize(controller_index);
3402b053 35 if (ret) {
71002b50 36 pr_err("USB init failed: %d\n", ret);
3402b053
ŁM
37 ret = CMD_RET_FAILURE;
38 goto exit;
39 }
40
ed3a37a2
MS
41 ret = g_dnl_register("usb_dnl_thor");
42 if (ret) {
43 pr_err("g_dnl_register failed %d\n", ret);
0896d2ca
MS
44 ret = CMD_RET_FAILURE;
45 goto exit;
ed3a37a2 46 }
3402b053
ŁM
47
48 ret = thor_init();
49 if (ret) {
71002b50 50 pr_err("THOR DOWNLOAD failed: %d\n", ret);
3402b053
ŁM
51 ret = CMD_RET_FAILURE;
52 goto exit;
53 }
54
e47431aa
MS
55 do {
56 ret = thor_handle();
57 if (ret == THOR_DFU_REINIT_NEEDED) {
58 dfu_free_entities();
59 ret = dfu_init_env_entities(interface, devstring);
60 }
61 if (ret) {
62 pr_err("THOR failed: %d\n", ret);
63 ret = CMD_RET_FAILURE;
64 goto exit;
65 }
66 } while (ret == 0);
3402b053
ŁM
67exit:
68 g_dnl_unregister();
a06955ae 69 usb_gadget_release(controller_index);
90fadb57 70done:
3402b053
ŁM
71 dfu_free_entities();
72
73 return ret;
74}
75
76U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
77 "TIZEN \"THOR\" downloader",
78 "<USB_controller> <interface> <dev>\n"
c8087f67 79 " - device software upgrade via LTHOR TIZEN download\n"
3402b053
ŁM
80 " program via <USB_controller> on device <dev>,\n"
81 " attached to interface <interface>\n"
82);
This page took 0.371723 seconds and 4 git commands to generate.