From 2de299f86541c1aa0e490239193ff8c0f4ad799c Mon Sep 17 00:00:00 2001 From: Haojian Zhuang Date: Tue, 13 Jun 2017 09:08:19 +0800 Subject: Platforms/HiKey: enable ram keyboard Send out 'f' hotkey if adb reboot bootloader pattern is detected. Then UEFI enters AndroidFastbootApp. Signed-off-by: Haojian Zhuang --- Platforms/Hisilicon/HiKey/HiKey.dsc | 5 ++ Platforms/Hisilicon/HiKey/HiKey.fdf | 5 ++ Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 67 ++++++++++++++++++++++++- Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 2 + 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Platforms/Hisilicon/HiKey/HiKey.dsc b/Platforms/Hisilicon/HiKey/HiKey.dsc index 1cf24eb..67ebdf5 100644 --- a/Platforms/Hisilicon/HiKey/HiKey.dsc +++ b/Platforms/Hisilicon/HiKey/HiKey.dsc @@ -421,6 +421,11 @@ # OpenPlatformPkg/Drivers/Keyboard/GpioKeyboardDxe/GpioKeyboardDxe.inf + # + # RAM Keyboard + # + OpenPlatformPkg/Drivers/Keyboard/RamKeyboardDxe/RamKeyboardDxe.inf + OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf # diff --git a/Platforms/Hisilicon/HiKey/HiKey.fdf b/Platforms/Hisilicon/HiKey/HiKey.fdf index bd80c79..428815f 100644 --- a/Platforms/Hisilicon/HiKey/HiKey.fdf +++ b/Platforms/Hisilicon/HiKey/HiKey.fdf @@ -125,6 +125,11 @@ READ_LOCK_STATUS = TRUE # INF OpenPlatformPkg/Drivers/Keyboard/GpioKeyboardDxe/GpioKeyboardDxe.inf + # + # RAM Keyboard + # + INF OpenPlatformPkg/Drivers/Keyboard/RamKeyboardDxe/RamKeyboardDxe.inf + INF OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf # diff --git a/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c index 174dfca..5815c95 100644 --- a/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,11 @@ #define DETECT_J15_FASTBOOT 24 // GPIO3_0 +#define ADB_REBOOT_ADDRESS 0x05F01000 +#define ADB_REBOOT_BOOTLOADER 0x77665500 +#define ADB_REBOOT_NONE 0x77665501 + + typedef struct { UINT64 Magic; UINT64 Data; @@ -264,6 +270,56 @@ PLATFORM_GPIO_KBD_PROTOCOL mGpioKeyboard = { GpioKeyboardRegister }; +EFI_STATUS +EFIAPI +RamKeyboardRegister ( + IN OUT RAM_KBD_KEY *RamKey + ) +{ + if (RamKey == NULL) { + return EFI_INVALID_PARAMETER; + } + RamKey->Signature = RAM_KBD_KEY_NEXT_SIGNATURE; + RamKey->Base = ADB_REBOOT_ADDRESS; + RamKey->Key.ScanCode = SCAN_NULL; + RamKey->Key.UnicodeChar = L'f'; + return EFI_SUCCESS; +} + +BOOLEAN +EFIAPI +RamKeyboardQuery ( + IN RAM_KBD_KEY *RamKey + ) +{ + if ((RamKey == NULL) || (RamKey->Base == 0)) { + return FALSE; + } + if (MmioRead32 (RamKey->Base) != ADB_REBOOT_BOOTLOADER) { + return FALSE; + } + return TRUE; +} + +EFI_STATUS +EFIAPI +RamKeyboardClear ( + IN RAM_KBD_KEY *RamKey + ) +{ + if ((RamKey == NULL) || (RamKey->Base == 0)) { + return FALSE; + } + MmioWrite32 (RamKey->Base, ADB_REBOOT_NONE); + return EFI_SUCCESS; +} + +PLATFORM_RAM_KBD_PROTOCOL mRamKeyboard = { + RamKeyboardRegister, + RamKeyboardQuery, + RamKeyboardClear +}; + EFI_STATUS EFIAPI HiKeyEntryPoint ( @@ -294,6 +350,15 @@ HiKeyEntryPoint ( EFI_NATIVE_INTERFACE, &mGpioKeyboard ); -DEBUG ((DEBUG_ERROR, "#%a, %d, Status:%r\n", __func__, __LINE__, Status)); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformRamKeyboardProtocolGuid, + EFI_NATIVE_INTERFACE, + &mRamKeyboard + ); return Status; } diff --git a/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf index dcc2b9e..4b1b8e9 100644 --- a/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf +++ b/Platforms/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf @@ -29,6 +29,7 @@ MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec OpenPlatformPkg/Drivers/Keyboard/GpioKeyboardDxe/GpioKeyboardDxe.dec + OpenPlatformPkg/Drivers/Keyboard/RamKeyboardDxe/RamKeyboardDxe.dec OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKey.dec [LibraryClasses] @@ -52,6 +53,7 @@ gAbootimgProtocolGuid gEfiBlockIoProtocolGuid gPlatformGpioKeyboardProtocolGuid + gPlatformRamKeyboardProtocolGuid [Guids] gEfiEndOfDxeEventGroupGuid -- cgit v1.2.3