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 static int do_reboot_brom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 51 { 52 writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG); 53 do_reset(NULL, 0, 0, NULL); 54 55 return 0; 56 } 57 58 /* -------------------------------------------------------------------- */ 59 60 U_BOOT_CMD( 61 go, CONFIG_SYS_MAXARGS, 1, do_go, 62 "start application at address 'addr'", 63 "addr [arg ...]\n - start application at address 'addr'\n" 64 " passing 'arg' as arguments" 65 ); 66 67 U_BOOT_CMD_ALWAYS( 68 rbrom, 1, 0, do_reboot_brom, 69 "Perform RESET of the CPU", 70 "" 71 ); 72 73 #endif 74 75 U_BOOT_CMD( 76 reset, 2, 0, do_reset, 77 "Perform RESET of the CPU", 78 "" 79 ); 80 81 U_BOOT_CMD( 82 reboot, 2, 0, do_reset, 83 "Perform RESET of the CPU, alias of 'reset'", 84 "" 85 ); 86 87 #ifdef CONFIG_CMD_POWEROFF 88 U_BOOT_CMD( 89 poweroff, 1, 0, do_poweroff, 90 "Perform POWEROFF of the device", 91 "" 92 ); 93 #endif 94