From patchwork Thu May 10 02:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 135381 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp453325lji; Wed, 9 May 2018 19:17:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpjdMGYu5W5lnvDLgLZsqe12miLCpLMzOo2vqcfwfs91r0C58IV1ZqvXlc/NXJ5KNCUZGjH X-Received: by 10.98.220.78 with SMTP id t75mr45755489pfg.139.1525918662995; Wed, 09 May 2018 19:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525918662; cv=none; d=google.com; s=arc-20160816; b=hYJqQQHb1rl5A6gximC+thtFrl+kCYBm1IhSmSkOTXNrI9yCSZZaYIK4wrooO2mYwP 3QhDZ8I3RSwRxwD4g+DmIajmN0ssp/QQkrpbqugzFZWTTM1XBYIf/cO9PSj+2y30OZcx DUtIKo1GheQopsc9cvV+X0v7z07a5u7QAgUk7CzaVfw0RoxyOTmOsMGOe6XlUEPiYuWA 0CY0KakHd/p51BQA26wuWNdbkMYZmREjwULDChN450lZq7BQ1IHCzx/tpCIp2Ax19PRr 4e6TfKQFbpPSCijx4Df8THdQRNaIZZhwrGpa+F9uxrdnGmGtx/1vqwdmh/KyohXqazOl a8nQ== 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=Haa3v/nwq3tSq/KF8OKbFqhgNgDu20flARd1wLaoJaU=; b=ejkDwsBwSQ6WTscDd47CiU+SMqnk+rpxrTcLGFDsT6L2P7sQT39hhMOOP+L3E8fhJA YJAonjsiq6XTCsCsC5lag9tfk6nER/ieE3CyT1ZjVd+QRCzkyS5iP826CmW1HaVuURT8 nQv1a/TqaC8h83GEqcXErNFfRJOr9a/Z60qcKvtbUx2AQVCfVvlOB+MUxesqMWZFutFG kDsFwkS9hjMmfEXQApKNaj+moQ4OpkFsovd0TkxYkhojbhKj87mEx98xgB1k7Zk1xZ1t 093qYqB8iMwIPcdeKLYU1yJdA5kuyMC5SXLywJNtsx93TdI5WMyeeHLpY7qGdxwishTc gfWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bycPfGCH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id w9-v6si22897638pgc.181.2018.05.09.19.17.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 19:17:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bycPfGCH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 9CB2320837990; Wed, 9 May 2018 19:17:42 -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:c00::244; helo=mail-pf0-x244.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (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 60E8620837982 for ; Wed, 9 May 2018 19:17:41 -0700 (PDT) Received: by mail-pf0-x244.google.com with SMTP id c10-v6so289481pfi.12 for ; Wed, 09 May 2018 19:17:41 -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=+3uNxAucNDTLlzrZMxZARW+IBocuaB8Sm+Ywojc4dnc=; b=bycPfGCH5162nH+kHRLsqmP3OfOb5v/cC7nOBwsCRtDNsQfnANA//WNutp/DqgCdG3 HGTKmEHH/Fzyhg7uMhlQC6drhQ5u8vR2+c4q2BZ6KGb43QzZ3Tm/q/iHYEnCx2//jXSj 6jyr62qOfKFGpIplRQrRUXzwz4uj7HWvuWcAc= 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=+3uNxAucNDTLlzrZMxZARW+IBocuaB8Sm+Ywojc4dnc=; b=leguqu5Sh3Lt/CEWWU2c4UJrkHdIAmH1THid3HAFcit1S0pU6vKyI9QTMlt9KxZUNx 4fC0kcTjLSZHqXIIezLI6Tcc3vgEiReOfRMzpvd6obyj2e2a2XwjeR0himqXI7cSvblv IZNPZaD0bdBbzbD3pxDyobHdcSnLui9sauTE3SxM+IBI3iHPMYv2iFjDw6M/ZYOV0ZzO HcBlVF6LrTKM/GrSZZZglhl21VHRkZkPhutIFUcxvAkNI1aAoif0tc08OgmlS3KrSdEd bpmykFeCSXqzNwJGSlfdKaq9q3obvJtIsLGFjMSJYd5v30v+3FspboArozau3Ldp9vgM qLcQ== X-Gm-Message-State: ALKqPweEHac8rL+X6WQdwv7QYRedUTEshhJvBi+Vi7jnWSl/cRu1wsI/ gLwWdVoRV02g/XlTOirz3BrEL2wccHM= X-Received: by 2002:a63:7a48:: with SMTP id j8-v6mr2194810pgn.101.1525918660569; Wed, 09 May 2018 19:17:40 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.93]) by smtp.gmail.com with ESMTPSA id z15-v6sm46351857pgr.55.2018.05.09.19.17.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 19:17:39 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 10 May 2018 10:17:16 +0800 Message-Id: <1525918639-22690-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525918639-22690-1-git-send-email-haojian.zhuang@linaro.org> References: <1525918639-22690-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 3/6] Platform/HiKey960: 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 HiKey960 platform. It checks two conditions, such as pattern in memory and GPIO pin setting. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey960/HiKey960.dsc | 5 ++ Platform/Hisilicon/HiKey960/HiKey960.fdf | 5 ++ .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 98 +++++++++++++++++++++- .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h | 3 + .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 1 + 5 files changed, 111 insertions(+), 1 deletion(-) -- 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/HiKey960/HiKey960.dsc b/Platform/Hisilicon/HiKey960/HiKey960.dsc index 6cc1c1edf453..79e68754976d 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -182,6 +182,11 @@ [Components.common] Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf + # + # Virtual Keyboard + # + EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf b/Platform/Hisilicon/HiKey960/HiKey960.fdf index b7d70b010598..d65f77878575 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.fdf +++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf @@ -123,6 +123,11 @@ [FV.FvMain] INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf + # + # Virtual Keyboard + # + INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf + INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index 154996026737..6ac0d220cf58 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -14,7 +14,8 @@ #include "HiKey960Dxe.h" -STATIC UINTN mBoardId; +STATIC UINTN mBoardId; +STATIC EMBEDDED_GPIO *mGpio; STATIC VOID @@ -142,6 +143,94 @@ OnEndOfDxe ( 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; + } + // + // Configure GPIO68 as GPIO function + // + MmioWrite32 (0xe896c108, 0); + Status = mGpio->Set (mGpio, DETECT_SW_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_SW_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 HiKey960EntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable @@ -175,5 +264,12 @@ HiKey960EntryPoint ( if (EFI_ERROR (Status)) { return Status; } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformVirtualKeyboardProtocolGuid, + EFI_NATIVE_INTERFACE, + &mVirtualKeyboard + ); return Status; } diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h index 2e89d10e2723..2d5349888ed5 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h @@ -33,6 +33,9 @@ #include #include +#include +#include + #define ADC_ADCIN0 0 #define ADC_ADCIN1 1 #define ADC_ADCIN2 2 diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf index a1a7d005ce8b..46a9a5803e3d 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf @@ -39,6 +39,7 @@ [LibraryClasses] [Protocols] gEmbeddedGpioProtocolGuid + gPlatformVirtualKeyboardProtocolGuid [Guids] gEfiEndOfDxeEventGroupGuid