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 25 #if defined(CONFIG_CONSOLE_DISABLE_CTRLC) && \ 26 defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY <= 0) 27 bool is_hotkey(enum hotkey_t id) { return false; } 28 void hotkey_run(enum hotkey_t id) { } 29 #else 30 bool is_hotkey(enum hotkey_t id) 31 { 32 switch (id) { 33 case HK_BROM_DNL: 34 return gd->console_evt == CTRL_B; 35 case HK_CMDLINE: 36 return gd->console_evt == CTRL_P; 37 case HK_FASTBOOT: 38 return gd->console_evt == CTRL_F; 39 case HK_INITCALL: 40 return gd->console_evt == CTRL_I; 41 case HK_REGULATOR: 42 return gd->console_evt == CTRL_R; 43 case HK_ROCKUSB_DNL: 44 return gd->console_evt == CTRL_D; 45 case HK_SYSMEM: 46 return gd->console_evt == CTRL_M; 47 default: 48 break; 49 } 50 51 return false; 52 } 53 54 void hotkey_run(enum hotkey_t id) 55 { 56 switch ((id)) { 57 case HK_SYSMEM: 58 if (gd->console_evt == CTRL_M) { 59 bidram_dump(); 60 sysmem_dump(); 61 } 62 break; 63 case HK_CMDLINE: 64 if (gd->console_evt == CTRL_P) 65 printf("cmdline: %s\n", env_get("bootargs")); 66 break; 67 case HK_INITCALL: 68 if (gd->console_evt == CTRL_I) 69 env_update("bootargs", "initcall_debug debug"); 70 break; 71 case HK_CLI_OS_PRE: 72 if (gd->console_evt == CTRL_A) 73 cli_loop(); 74 break; 75 case HK_CLI_OS_GO: 76 if (gd->console_evt == CTRL_S) 77 cli_loop(); 78 break; 79 default: 80 break; 81 } 82 } 83 #endif 84