rockchip: rkimg: use menu key to enter bootrom download mode

It's possible that USB is disabled due to developer needs
a critial size of u-boot.bin.

Disabling USB makes vbus can't be detected any more, so that
we add menu key and the events trigger are changed:

- rockusb mode(fallback to bootrom mode):
	"recovery key pressed + vbus=1" => "menu key pressed"

- recovery mode:
	"recovery key pressed + vbus=0" => "recovery key pressed"

At the most time, USB is enabled and this feature is not applied.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I9da8f17987742cea3267dbb35ee88d57a00c578a
This commit is contained in:
Joseph Chen 2020-06-17 17:05:21 +08:00 committed by Jianhong Chen
parent 766120444d
commit 3017074fb2
1 changed files with 29 additions and 2 deletions

View File

@ -248,7 +248,26 @@ void rockchip_set_bootdev(struct blk_desc *desc)
__weak int rockchip_dnl_key_pressed(void)
{
#if defined(CONFIG_DM_KEY)
#ifdef CONFIG_CMD_ROCKUSB
return key_is_pressed(key_read(KEY_VOLUMEUP));
#else
/*
* It's possible that USB is disabled due to developer needs
* a critial size of u-boot.bin.
*
* Disabling USB makes vbus can't be detected any more, so that
* we add menu key and the events trigger are changed:
*
* - rockusb mode(fallback to bootrom mode):
* "recovery key pressed + vbus=1" => "menu key pressed"
*
* - recovery mode:
* "recovery key pressed + vbus=0" => "recovery key pressed"
*
* At the most time, USB is enabled and this feature is not applied.
*/
return key_is_pressed(key_read(KEY_MENU));
#endif
#elif defined(CONFIG_ADC)
const void *blob = gd->fdt_blob;
@ -275,13 +294,21 @@ __weak int rockchip_dnl_key_pressed(void)
void setup_download_mode(void)
{
int vbus = 1;
boot_devtype_init();
/* recovery key or "ctrl+d" */
if (rockchip_dnl_key_pressed() || is_hotkey(HK_ROCKUSB_DNL)) {
printf("download key pressed... ");
if (rockchip_u2phy_vbus_detect() > 0) {
printf("entering download mode...\n");
#ifdef CONFIG_CMD_ROCKUSB
vbus = rockchip_u2phy_vbus_detect();
#endif
if (vbus > 0) {
printf("%sentering download mode...\n",
IS_ENABLED(CONFIG_CMD_ROCKUSB) ?
"" : "no rockusb, ");
/* try rockusb download and brom download */
run_command("download", 0);
} else {