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 #ifdef CONFIG_CPU_V7 25 ulong addr = (ulong)entry | 1; 26 entry = (void *)addr; 27 #endif 28 return entry (argc, argv); 29 } 30 31 static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 32 { 33 ulong addr, rc; 34 int rcode = 0; 35 36 if (argc < 2) 37 return CMD_RET_USAGE; 38 39 addr = simple_strtoul(argv[1], NULL, 16); 40 41 printf ("## Starting application at 0x%08lX ...\n", addr); 42 43 /* 44 * pass address parameter as argv[0] (aka command name), 45 * and all remaining args 46 */ 47 rc = do_go_exec ((void *)addr, argc - 1, argv + 1); 48 if (rc != 0) rcode = 1; 49 50 printf ("## Application terminated, rc = 0x%lX\n", rc); 51 return rcode; 52 } 53 54 /* -------------------------------------------------------------------- */ 55 56 U_BOOT_CMD( 57 go, CONFIG_SYS_MAXARGS, 1, do_go, 58 "start application at address 'addr'", 59 "addr [arg ...]\n - start application at address 'addr'\n" 60 " passing 'arg' as arguments" 61 ); 62 #endif 63 64 static int do_reboot_brom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 65 { 66 writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG); 67 do_reset(NULL, 0, 0, NULL); 68 69 return 0; 70 } 71 72 U_BOOT_CMD_ALWAYS( 73 rbrom, 1, 0, do_reboot_brom, 74 "Perform RESET of the CPU", 75 "" 76 ); 77 78 U_BOOT_CMD( 79 reset, 2, 0, do_reset, 80 "Perform RESET of the CPU", 81 "" 82 ); 83 84 U_BOOT_CMD( 85 reboot, 2, 0, do_reset, 86 "Perform RESET of the CPU, alias of 'reset'", 87 "" 88 ); 89 90 #ifdef CONFIG_CMD_POWEROFF 91 U_BOOT_CMD( 92 poweroff, 1, 0, do_poweroff, 93 "Perform POWEROFF of the device", 94 "" 95 ); 96 #endif 97