From patchwork Thu May 31 03:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 137313 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6067627lji; Wed, 30 May 2018 20:10:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKtQ1EUhS7U8Ee1btRGZSTBpeYw8szEMhF9uhjp/aM9agnNL6M47FMS7SvkIldLZByX3g9g X-Received: by 2002:a63:85c8:: with SMTP id u191-v6mr3944557pgd.300.1527736232268; Wed, 30 May 2018 20:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527736232; cv=none; d=google.com; s=arc-20160816; b=f8uER+vYzfoYQ6u6Ir3cFPGL+D05h/5Q0679oE3DSGH6uOK3x+pqx3VofATx6M/icH nBwGwhBPHUmRp0Q59ayCQv2Pw1ph/aXhzLAe252t+m9hH6gm44rv10Wy5kwycFta0eYg 7XrOf3ecWLQkQO0tBlQ1jymrJgpi6IuCOnOHa3RTLozwiCCgYrz1lAZOfjLKF+2FMoWM WggXahgFLeqM1js5UsuZGlDxEbueYRDe9hU2X+TjIWz0/NJqSIcKrWn/nNW227T9JDlD pS7fEd9AqB4/leHvJxFaqf2THCYJQs0eSueZBWnwO5TFNabNob/nrWx8yDslmPIj357b jsQg== 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=5rA4bjWm0CYBG4yGIWUToV0pqbJg+Y6AyCkOKPz6zF4=; b=AK/8MztrOpwWP6RfbzAHHbKMMU2pqta6lCgHrTyVdw8H6sPxArhx4sHSEJXnV36iyu 2l7FXdkvt2nWuJQA6ZPKPte3+LIduuSq8wn0b9bF7amYtTptJ1O+gdywYu+uQH1Bogz0 K5WxseVfynIi4KICLoiXEW6S3ayYNZSp1nmSqsWFSyaf4QVjaxr9XihDjAPzhuuG14oU MMKuHsrSF0EC/zp0lrWH19SFmCS2cxDeu3hU/b0UpcZjKEDlAeJYYtseB2hlUMWLPXHB TN/7Qt3GLakOp69Q01Ug4AoD84rBs0U75ZSp55JnPnDRoi291+YW1+G0zy33powXWbrV HvXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=O8d/y9gw; 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 q28-v6si14184945pgc.672.2018.05.30.20.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 20:10:32 -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=O8d/y9gw; 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 DD011210CEA2D; Wed, 30 May 2018 20:10:31 -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:c01::243; helo=mail-pl0-x243.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::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 70A6520965DC7 for ; Wed, 30 May 2018 20:10:30 -0700 (PDT) Received: by mail-pl0-x243.google.com with SMTP id 30-v6so12294306pld.13 for ; Wed, 30 May 2018 20:10:30 -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=nv4iC6LHzM7SAQ3TkxuB5XSpLwelhxdA0ihcL47IQKs=; b=O8d/y9gwlqmCnP4V/B9iKaHA6PzOhN4rkj5YuJTBcg/xPdwUQVUoHM2nvG0vTupdqv PzjBH5OiAWaYNTlTJNOy+Utyh8xKIKZs8Qlh5bjisGJ15UV+6uwjSpClvuYVkgEthzR8 J4vSAQQcKTJCnPEXAoMbFNRRZVjggEp5cYvWk= 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=nv4iC6LHzM7SAQ3TkxuB5XSpLwelhxdA0ihcL47IQKs=; b=Ygu/oFUIsAxBN63CGAP6MCCORT9gWfkLa4vJIUgT5dHnFaAPeODyRq0RzID6SF0zHM X9mWd5bQN0+puUBz/jwvJUNB1OKPVvhFU1Lh56DYIllC1mEyzs4GPGfoWY0ektBqyglB OHX6bGFVJAG/7x9nPJvaecILe71tGYEIW28dslYz6+rBgoPoz1oa7hg1478f5zXQlGVE VEHibLBaV9mUAvAKjgPifQk3AsKZYtiPO0V7zZlElbCdqmG+P4fn1c+/Q316LZ/1XJdv Dq0Ulsk1P7WXKPPcxnr6B504I6vmTSpITUVFeacOT3gQMZjqqNO+R8BrTPKKHXbgzXmD 6DfA== X-Gm-Message-State: ALKqPwdi7Wl57XH4iyoYIKIAXxqEuW2H9H/8JLfkNFnVE2wRObdAkpmJ Atnu5ribRgC9Rh+Z1689B2c9V740/aQ= X-Received: by 2002:a17:902:694b:: with SMTP id k11-v6mr5292248plt.334.1527736229729; Wed, 30 May 2018 20:10:29 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.182]) by smtp.gmail.com with ESMTPSA id q75-v6sm77114646pfj.94.2018.05.30.20.10.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 May 2018 20:10:28 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 31 May 2018 11:10:07 +0800 Message-Id: <1527736210-17133-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527736210-17133-1-git-send-email-haojian.zhuang@linaro.org> References: <1527736210-17133-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v7 edk-platforms 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. Since code is ported from non-open The hardcoding code is taken from non-open reference code. Can't fix it for lack of documents. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang Reviewed-by: Leif Lindholm --- Platform/Hisilicon/HiKey960/HiKey960.dsc | 5 + Platform/Hisilicon/HiKey960/HiKey960.fdf | 5 + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 1 + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h | 24 +++++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 97 ++++++++++++++++++++ 5 files changed, 132 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/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.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 diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h index ae8bdd5c8140..211eea55aa54 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h @@ -15,6 +15,30 @@ #ifndef __HIKEY960DXE_H__ #define __HIKEY960DXE_H__ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define ADB_REBOOT_ADDRESS 0x32100000 +#define ADB_REBOOT_BOOTLOADER 0x77665500 +#define ADB_REBOOT_NONE 0x77665501 + +#define DETECT_SW_FASTBOOT 68 // GPIO8_4 + enum { BOOT_MODE_RECOVERY = 0, BOOT_MODE_MASK = 1, diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index e88bad2167c6..13d6dda680c6 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -28,6 +28,8 @@ #include "HiKey960Dxe.h" +STATIC EMBEDDED_GPIO *mGpio; + STATIC VOID InitSdCard ( @@ -180,6 +182,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 @@ -208,5 +298,12 @@ HiKey960EntryPoint ( if (EFI_ERROR (Status)) { return Status; } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformVirtualKeyboardProtocolGuid, + EFI_NATIVE_INTERFACE, + &mVirtualKeyboard + ); return Status; }