rockchip: board: add and use conosle hotkey interface

Change-Id: I9c7b3ce75b9b7652cdd60d0d94d55d34f0a7011e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-04-30 09:23:01 +08:00 committed by Jianhong Chen
parent 92298dbc5d
commit c664909e96
5 changed files with 74 additions and 3 deletions

View File

@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2019 Rockchip Electronics Co., Ltd
*/
#ifndef _ROCKCHIP_HOTKEY_H_
#define _ROCKCHIP_HOTKEY_H_
enum hotkey_t {
HK_INVAL,
HK_BROM_DNL,
HK_FASTBOOT,
HK_ROCKUSB_DNL,
HK_SYSMEM,
};
bool is_hotkey(enum hotkey_t id);
void hotkey_run(enum hotkey_t id);
#endif

View File

@ -25,6 +25,7 @@ obj-y += board.o
obj-y += chip_info.o
obj-y += iomem.o
obj-y += memblk.o
obj-y += hotkey.o
obj-$(CONFIG_ROCKCHIP_CRC) += rockchip_crc.o
obj-$(CONFIG_ROCKCHIP_SMCCC) += rockchip_smccc.o

View File

@ -20,6 +20,7 @@
#include <asm/arch/clock.h>
#include <asm/arch/periph.h>
#include <asm/arch/boot_mode.h>
#include <asm/arch/hotkey.h>
#include <asm/arch/rk_atags.h>
#include <asm/arch/param.h>
#ifdef CONFIG_DM_CHARGE_DISPLAY
@ -231,7 +232,7 @@ static void early_bootrom_download(void)
gd->console_evt = getc();
#if (CONFIG_ROCKCHIP_BOOT_MODE_REG > 0)
/* ctrl+b */
if (gd->console_evt == CONSOLE_EVT_CTRL_B) {
if (is_hotkey(HK_BROM_DNL)) {
printf("Enter bootrom download...");
flushc();
writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);

View File

@ -8,6 +8,7 @@
#include <adc.h>
#include <asm/io.h>
#include <asm/arch/boot_mode.h>
#include <asm/arch/hotkey.h>
#include <asm/arch/param.h>
#include <cli.h>
#include <dm.h>
@ -131,7 +132,7 @@ void rockchip_dnl_mode_check(void)
{
/* recovery key or "ctrl+d" */
if (rockchip_dnl_key_pressed() ||
gd->console_evt == CONSOLE_EVT_CTRL_D) {
is_hotkey(HK_ROCKUSB_DNL)) {
printf("download key pressed... ");
if (rockchip_u2phy_vbus_detect() > 0) {
printf("entering download mode...\n");
@ -164,7 +165,7 @@ void rockchip_dnl_mode_check(void)
printf("recovery key pressed, entering recovery mode!\n");
env_set("reboot_mode", "recovery");
}
} else if (gd->console_evt == CONSOLE_EVT_CTRL_F) {
} else if (is_hotkey(HK_FASTBOOT)) {
env_set("reboot_mode", "fastboot");
}
}

View File

@ -0,0 +1,49 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
*/
#include <common.h>
#include <bidram.h>
#include <console.h>
#include <sysmem.h>
#include <asm/arch/hotkey.h>
DECLARE_GLOBAL_DATA_PTR;
#define CTRL_B 0x02
#define CTRL_D 0x04
#define CTRL_F 0x06
#define CTRL_M 0x0d
bool is_hotkey(enum hotkey_t id)
{
switch (id) {
case HK_BROM_DNL:
return gd->console_evt == CTRL_B;
case HK_FASTBOOT:
return gd->console_evt == CTRL_F;
case HK_ROCKUSB_DNL:
return gd->console_evt == CTRL_D;
case HK_SYSMEM:
return gd->console_evt == CTRL_M;
default:
break;
}
return false;
}
void hotkey_run(enum hotkey_t id)
{
switch ((id)) {
case HK_SYSMEM:
if (gd->console_evt == CTRL_M) {
bidram_dump();
sysmem_dump();
}
break;
default:
break;
}
}