xref: /rk3399_rockchip-uboot/cmd/boot.c (revision 46695f436e15bdd7430cc457651b6f10cfb3c072)
1 /*
2  * (C) Copyright 2000-2003
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 /*
9  * Misc boot support
10  */
11 #include <common.h>
12 #include <command.h>
13 #include <net.h>
14 #include <asm/io.h>
15 #include <asm/arch/boot_mode.h>
16 
17 #ifdef CONFIG_CMD_GO
18 
19 /* Allow ports to override the default behavior */
20 __attribute__((weak))
21 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
22 				 char * const argv[])
23 {
24 	return entry (argc, argv);
25 }
26 
27 static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
28 {
29 	ulong	addr, rc;
30 	int     rcode = 0;
31 
32 	if (argc < 2)
33 		return CMD_RET_USAGE;
34 
35 	addr = simple_strtoul(argv[1], NULL, 16);
36 
37 	printf ("## Starting application at 0x%08lX ...\n", addr);
38 
39 	/*
40 	 * pass address parameter as argv[0] (aka command name),
41 	 * and all remaining args
42 	 */
43 	rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
44 	if (rc != 0) rcode = 1;
45 
46 	printf ("## Application terminated, rc = 0x%lX\n", rc);
47 	return rcode;
48 }
49 
50 /* -------------------------------------------------------------------- */
51 
52 U_BOOT_CMD(
53 	go, CONFIG_SYS_MAXARGS, 1,	do_go,
54 	"start application at address 'addr'",
55 	"addr [arg ...]\n    - start application at address 'addr'\n"
56 	"      passing 'arg' as arguments"
57 );
58 #endif
59 
60 static int do_reboot_brom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
61 {
62 	writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
63 	do_reset(NULL, 0, 0, NULL);
64 
65 	return 0;
66 }
67 
68 U_BOOT_CMD_ALWAYS(
69 	rbrom, 1, 0,	do_reboot_brom,
70 	"Perform RESET of the CPU",
71 	""
72 );
73 
74 U_BOOT_CMD(
75 	reset, 2, 0,    do_reset,
76 	"Perform RESET of the CPU",
77 	""
78 );
79 
80 U_BOOT_CMD(
81         reboot, 2, 0,    do_reset,
82         "Perform RESET of the CPU, alias of 'reset'",
83         ""
84 );
85 
86 #ifdef CONFIG_CMD_POWEROFF
87 U_BOOT_CMD(
88 	poweroff, 1, 0,	do_poweroff,
89 	"Perform POWEROFF of the device",
90 	""
91 );
92 #endif
93