From patchwork Thu May 24 00:46:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 136689 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1556069lji; Wed, 23 May 2018 17:47:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqfL0xt0OaVRJYWLp8pOy/TGyQ4DHr6jWvzXk2I+iRZ4MT4GINNQ0X/wThsegzEzJLAiCIE X-Received: by 2002:a63:9d8e:: with SMTP id i136-v6mr3912349pgd.288.1527122824836; Wed, 23 May 2018 17:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527122824; cv=none; d=google.com; s=arc-20160816; b=A9tOvG+m8k8aF4BcsjTnSXgib3VZoUiFpThISUqMvOEQ0wT9Cx0QUh7xXLVHpejJpT swGCIwMnTptY/ezTjPHnpOTZd11QVl8B9vCxTWqqnVHNn/Sndrd7lLL8AHZyr1xexJ1y ek3+rfCEZVMNkepdvBtM8jSDxg41S6S+VjJyuq1QnocgGr6jMuk0FnYSuwKPlcvHwLbW rYtWQRcBoq2PE+/CQ9CWbAU6Xg0CjYyUe5tJ8AQKPrDoTwR4p5dLEfsP5jJ5y5KRQHK1 APWaRiyeeaPKvzHk6VkOBfP5i2HAOwfGxEricey2kCIVEWA2ZuCwHLKZy9HQKd6dn5Bx a7dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=ZGexLZ7g/2qXc0WLZqUeF/1xLSjZPvEQpyqOwJTsNHw=; b=WlJAJ815Z7Wlnzrz75cO0okLB0EoZxc5M+KujTnX94gAqFFporD47DQzhad/gA+jW6 0NrBehRlxLUbo3CjmY5XYKV8RYa7sYrwZsZJzv4a0hD/K+JUlrl9QuSFFbZTlSkRwCSX lCJOC9KXwKpGpGVEROpmv0GVfi+tqVJ8DhNxfxsbvvu9GStghNFrtLiCN4uZ8UNg8aJV HKoS/Q/5tGf0TzlDrzvrK2Ga1mCq/v+NEb3isFJA4V6XnqYJuLt/DN3jLLm9JXa/g0lB p5PQaEhmIObVdb2rJMOYzT3qYtrABaarZOo6PCh+x72AHI0VfLv9rp9zD7TwlwP9Dgxm UzEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=H+gfPKcG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id z14-v6si2293118pgz.284.2018.05.23.17.47.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 17:47:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=H+gfPKcG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4FB8B2083796D; Wed, 23 May 2018 17:47:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c05::242; helo=mail-pg0-x242.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1070A20837969 for ; Wed, 23 May 2018 17:47:00 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id d14-v6so6562142pgv.8 for ; Wed, 23 May 2018 17:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kake/pGdgz+Qn8Mcty2CKI7rpqnN0/N8dgP96yyUi1w=; b=H+gfPKcGuWmQ8NxYGmL+42mpR9aFlN8HOgk6MkXLRrWv6jAXEHYBilw7/xOrd/MYDw eGshEhGUw0JbUdj+FEb9KNydgSXFyTkX0IdZDXuzXthX5VbtZk0LyXm3FkgaKzP8/dP1 WvzqsumtoLPyRe4DaI8/3t3yc+rsY5zMuzUNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Kake/pGdgz+Qn8Mcty2CKI7rpqnN0/N8dgP96yyUi1w=; b=JSvWh7oUc5OuG2LrsthiOYoL/Esz5rXVQiIsR1dy5UmU5rOmN3x6WaTkXT+pV7N7H3 mOL0FpoKCCeKw6Mes8HZUGT80ReRahG0NzklAnOLAehcfqvn4X46AqTKzxauWR9oPP8B 4spR7DwYr3o/vuzkTwuKIZvR9vn7cSIreymjvngyC1B1LOX4uj0Izphu6f9aKHP9y+bE fJQWYgNxzGy4rnjlD+LNlOIM+4P2TjREyMGFVzH8Unsha95fhKJGw1Atl9CrnTHS8WJ8 5BgGQUD4NW9pSa99mzL76WcCCHRlINJoP8JwOgarOnTD87LcZzKibm0vxc7P7Rd4zY4m pZIA== X-Gm-Message-State: ALKqPwdAqHpMOzoSvLC2aox3GiWZ4qSRfYf6FTPMeTt0n8fXq9yRIaIh wA+BU29M7nDmlulTvjRCRVMpaDnSthc= X-Received: by 2002:a62:bd2:: with SMTP id 79-v6mr4937995pfl.4.1527122820262; Wed, 23 May 2018 17:47:00 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.105]) by smtp.gmail.com with ESMTPSA id y29-v6sm48817471pff.42.2018.05.23.17.46.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 17:46:59 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 24 May 2018 08:46:30 +0800 Message-Id: <1527122790-23592-7-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527122790-23592-1-git-send-email-haojian.zhuang@linaro.org> References: <1527122790-23592-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v6 edk2-platforms 6/6] Platform/HiKey: enable virtual keyboard X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haojian Zhuang , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Enable virtual keyboard on HiKey platform. It detects the pattern in memory and GPIO pin setting, and simulates them into virtual key. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey/HiKey.dsc | 5 ++ Platform/Hisilicon/HiKey/HiKey.fdf | 5 ++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 5 ++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h | 5 ++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 93 ++++++++++++++++++++ 5 files changed, 113 insertions(+) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc b/Platform/Hisilicon/HiKey/HiKey.dsc index 5cc4ff27f01b..83dd68a820b1 100644 --- a/Platform/Hisilicon/HiKey/HiKey.dsc +++ b/Platform/Hisilicon/HiKey/HiKey.dsc @@ -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 # diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf b/Platform/Hisilicon/HiKey/HiKey.fdf index 39020d27dbcd..2bca7232b6e5 100644 --- a/Platform/Hisilicon/HiKey/HiKey.fdf +++ b/Platform/Hisilicon/HiKey/HiKey.fdf @@ -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 # diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf index 34734391b45a..41aa7f8081ed 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf +++ b/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 diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h index 07f9ae6a949a..3d608183fa58 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h @@ -15,10 +15,15 @@ #ifndef __HIKEYDXE_H__ #define __HIKEYDXE_H__ +#include #include #include +#include #include +#include +#include + #include #include diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c index b812f8bd483d..afd2f050896a 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -43,6 +43,8 @@ UartInit ( MmioWrite32 (PMUSSI_ONOFF8_REG, Val); } +STATIC EMBEDDED_GPIO *mGpio; + STATIC VOID MtcmosInit ( @@ -87,6 +89,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 @@ -98,5 +184,12 @@ HiKeyEntryPoint ( if (EFI_ERROR (Status)) { return Status; } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformVirtualKeyboardProtocolGuid, + EFI_NATIVE_INTERFACE, + &mVirtualKeyboard + ); return Status; }