1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd 4 */ 5 6 #include <common.h> 7 #include <bidram.h> 8 #include <cli.h> 9 #include <console.h> 10 #include <sysmem.h> 11 #include <asm/arch/hotkey.h> 12 13 DECLARE_GLOBAL_DATA_PTR; 14 15 #define CTRL_A 0x01 /* shell(cli) on BOOTM_STATE_OS_PREP */ 16 #define CTRL_B 0x02 /* bootrom mode */ 17 #define CTRL_D 0x04 /* download mde */ 18 #define CTRL_F 0x06 /* fastboot mode */ 19 #define CTRL_I 0x09 /* inicall debug for kernel */ 20 #define CTRL_M 0x0d /* memory(sysmem/bidram) */ 21 #define CTRL_P 0x10 /* parameter(cmdline) dump */ 22 #define CTRL_R 0x12 /* regulator initial state dump */ 23 #define CTRL_S 0x13 /* shell(cli) on BOOTM_STATE_OS_GO */ 24 #define CTRL_T 0x14 /* print fdt */ 25 26 bool is_hotkey(enum hotkey_t id) 27 { 28 switch (id) { 29 case HK_CMDLINE: 30 return gd->console_evt == CTRL_P; 31 case HK_INITCALL: 32 return gd->console_evt == CTRL_I; 33 case HK_REGULATOR: 34 return gd->console_evt == CTRL_R; 35 case HK_SYSMEM: 36 return gd->console_evt == CTRL_M; 37 #if defined(CONFIG_CONSOLE_DISABLE_CTRLC) && \ 38 defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY <= 0) 39 case HK_BROM_DNL: 40 return gd->console_evt == CTRL_B; 41 case HK_ROCKUSB_DNL: 42 return gd->console_evt == CTRL_D; 43 case HK_FASTBOOT: 44 return gd->console_evt == CTRL_F; 45 #endif 46 default: 47 break; 48 } 49 50 return false; 51 } 52 53 void hotkey_run(enum hotkey_t id) 54 { 55 switch ((id)) { 56 case HK_SYSMEM: 57 if (gd->console_evt == CTRL_M) { 58 bidram_dump(); 59 sysmem_dump(); 60 } 61 break; 62 case HK_CMDLINE: 63 if (gd->console_evt == CTRL_P) 64 printf("cmdline: %s\n", env_get("bootargs")); 65 break; 66 case HK_INITCALL: 67 if (gd->console_evt == CTRL_I) 68 env_update("bootargs", "initcall_debug debug"); 69 break; 70 case HK_FDT: 71 if (gd->console_evt == CTRL_T) 72 run_command("fdt print", 0); 73 break; 74 #if defined(CONFIG_CONSOLE_DISABLE_CTRLC) && \ 75 defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY <= 0) 76 case HK_CLI_OS_PRE: 77 if (gd->console_evt == CTRL_A) 78 cli_loop(); 79 break; 80 case HK_CLI_OS_GO: 81 if (gd->console_evt == CTRL_S) 82 cli_loop(); 83 break; 84 #endif 85 default: 86 break; 87 } 88 } 89