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_L 0x0c /* late shell(cli) on BOOTM_STATE_OS_GO */ 21 #define CTRL_M 0x0d /* memory(sysmem/bidram) */ 22 #define CTRL_P 0x10 /* parameter(cmdline) dump */ 23 #define CTRL_R 0x12 /* regulator initial state dump */ 24 #define CTRL_T 0x14 /* print fdt */ 25 is_hotkey(enum hotkey_t id)26bool 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 case HK_BROM_DNL: 38 return gd->console_evt == CTRL_B; 39 #ifndef CONFIG_CONSOLE_DISABLE_CLI 40 case HK_ROCKUSB_DNL: 41 return gd->console_evt == CTRL_D; 42 case HK_FASTBOOT: 43 return gd->console_evt == CTRL_F; 44 #endif 45 default: 46 break; 47 } 48 49 return false; 50 } 51 hotkey_run(enum hotkey_t id)52void hotkey_run(enum hotkey_t id) 53 { 54 switch ((id)) { 55 case HK_SYSMEM: 56 if (gd->console_evt == CTRL_M) { 57 bidram_dump(); 58 sysmem_dump(); 59 } 60 break; 61 case HK_CMDLINE: 62 if (gd->console_evt == CTRL_P) 63 printf("cmdline: %s\n", env_get("bootargs")); 64 break; 65 case HK_INITCALL: 66 if (gd->console_evt == CTRL_I) 67 env_update("bootargs", "initcall_debug debug"); 68 break; 69 case HK_FDT: 70 if (gd->console_evt == CTRL_T) 71 run_command("fdt print", 0); 72 break; 73 case HK_CLI_OS_PRE: 74 if (gd->console_evt == CTRL_A) 75 cli_loop(); 76 break; 77 case HK_CLI_OS_GO: 78 if (gd->console_evt == CTRL_L) 79 cli_loop(); 80 break; 81 default: 82 break; 83 } 84 } 85