From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 071CF2034863F for ; Mon, 21 May 2018 02:48:13 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id k5-v6so3252554wrn.3 for ; Mon, 21 May 2018 02:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OKxL8E8apigGjbasF6OVpzkpFW9UGkr4w42U+lUkRkw=; b=j4jaA3te7FpcsDAGLKChilAJ0CtKUH6PQYehCc4pL4Ihd7ecEA0GOn+7EK6CbyPP5w EjTWANDo9uvx62J4nrUQ28QVgFlFwvcULQWfeBpr0drIzn2FCagzWH5EyeHWbFlKMJV9 u5UbhakT8J3QnP7XhFa1bURb8EY3CTIBjfLms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OKxL8E8apigGjbasF6OVpzkpFW9UGkr4w42U+lUkRkw=; b=EYJRiFIsWn+G/S8sC86/ehyNEyk68dVYKdx5OUACmar2QJaA1FOPZKKk3341rgkNvv rIvRTYdrcgTsPhPOHLHlGItRyN7L3hBsyLAeFYZlvoeBIa48yq54KnBWduUo5MxqWdAk ScjG2X/MhU849e6RGtDiBb1/fIfDhB+pkfIND+2pILuiIYA4OgU5w13lNOim6ddCcD9C 8CeTxGOSLt51SKFGBZ/AYlgz+s0j58inYNAzNLATh8uQVFTsAyHTNLvlfxJmC5gAYFu4 upsaLb4aefqvP3NMVfWfCWUMv9qhXEXcf+OoxdwtSNvB2R+MYIgKTZUzY2FP3X1w+TX/ lo9A== X-Gm-Message-State: ALKqPwfUM1hXi2ai4gzx7E4mHRgBdznsUjJpGI6gxjEjpFr5/hcL/Htk Ny+94W7OLBUNCjn2QcqDlCvhZw== X-Google-Smtp-Source: AB8JxZo+hannz9Ix9kd1d1Z4j97xnq/L8PvYCpOfzPe9TUrH+iOzMl/gGtsAkBmr7timNGZ48X1vXQ== X-Received: by 2002:adf:e501:: with SMTP id j1-v6mr3743976wrm.186.1526896091733; Mon, 21 May 2018 02:48:11 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id k126-v6sm16694515wmg.6.2018.05.21.02.48.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 02:48:10 -0700 (PDT) Date: Mon, 21 May 2018 10:48:09 +0100 From: Leif Lindholm To: Haojian Zhuang Cc: edk2-devel@lists.01.org, Ard Biesheuvel Message-ID: <20180521094809.kufngqgubapxrcf6@bivouac.eciton.net> References: <1526272473-25565-1-git-send-email-haojian.zhuang@linaro.org> <1526272473-25565-4-git-send-email-haojian.zhuang@linaro.org> MIME-Version: 1.0 In-Reply-To: <1526272473-25565-4-git-send-email-haojian.zhuang@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v4 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: , X-List-Received-Date: Mon, 21 May 2018 09:48:14 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 14, 2018 at 12:34:30PM +0800, Haojian Zhuang wrote: > Enable virtual keyboard on HiKey960 platform. It checks two > conditions, such as pattern in memory and GPIO pin setting. Please add a comment to commit message regarding use of hardcoded values from reference code, same as for 2/6. / Leif > 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 | 97 ++++++++++++++++++++++ > .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h | 3 + > .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 1 + > 5 files changed, 111 insertions(+) > > 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 fae68feca89d..60d0e380e0b1 100644 > --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c > +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c > @@ -14,6 +14,8 @@ > > #include "HiKey960Dxe.h" > > +STATIC EMBEDDED_GPIO *mGpio; > + > STATIC > VOID > InitSdCard ( > @@ -154,6 +156,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 > @@ -182,5 +272,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 > -- > 2.7.4 >