@@ -192,6 +192,11 @@ [Components.common]
Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
+ #
+ # Virtual Keyboard
+ #
+ EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
#
@@ -123,6 +123,11 @@ [FV.FvMain]
INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
+ #
+ # Virtual Keyboard
+ #
+ INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
#
@@ -28,11 +28,16 @@ [Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
+ CacheMaintenanceLib
DebugLib
IoLib
UefiLib
UefiDriverEntryPoint
+[Protocols]
+ gEmbeddedGpioProtocolGuid
+ gPlatformVirtualKeyboardProtocolGuid
+
[Guids]
gEfiEndOfDxeEventGroupGuid
@@ -12,10 +12,15 @@
*
**/
+#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
+#include <Protocol/EmbeddedGpio.h>
+#include <Protocol/PlatformVirtualKeyboard.h>
+
#include <Hi6220.h>
#include <Hi6220RegsPeri.h>
@@ -50,6 +55,8 @@ UartInit (
MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
}
+STATIC EMBEDDED_GPIO *mGpio;
+
STATIC
VOID
MtcmosInit (
@@ -94,6 +101,90 @@ HiKeyInitPeripherals (
EFI_STATUS
EFIAPI
+VirtualKeyboardRegister (
+ IN VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (
+ &gEmbeddedGpioProtocolGuid,
+ NULL,
+ (VOID **) &mGpio
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+ IN VOID
+ )
+{
+ EFI_STATUS Status;
+
+ if (mGpio == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+ return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+ IN VIRTUAL_KBD_KEY *VirtualKey
+ )
+{
+ EFI_STATUS Status;
+ UINTN Value = 0;
+
+ if ((VirtualKey == NULL) || (mGpio == NULL)) {
+ return FALSE;
+ }
+ if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+ goto Done;
+ } else {
+ Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, &Value);
+ if (EFI_ERROR (Status) || (Value != 0)) {
+ return FALSE;
+ }
+ }
+Done:
+ VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+ VirtualKey->Key.ScanCode = SCAN_NULL;
+ VirtualKey->Key.UnicodeChar = L'f';
+ return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+ IN VIRTUAL_KBD_KEY *VirtualKey
+ )
+{
+ if (VirtualKey == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+ MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+ WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+ }
+ return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+ VirtualKeyboardRegister,
+ VirtualKeyboardReset,
+ VirtualKeyboardQuery,
+ VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
HiKeyEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
@@ -105,5 +196,12 @@ HiKeyEntryPoint (
if (EFI_ERROR (Status)) {
return Status;
}
+
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
+ &gPlatformVirtualKeyboardProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mVirtualKeyboard
+ );
return Status;
}