From patchwork Wed May 9 09:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 135244 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5427182lji; Wed, 9 May 2018 02:55:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6W84VSnC9xvP/F6u3Nz1P9F0zPt4UvSYbqBwJx1dY0d5uywZ72e6YI+3OSgd1KIYg+uwD X-Received: by 10.98.75.22 with SMTP id y22mr43488236pfa.29.1525859729544; Wed, 09 May 2018 02:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525859729; cv=none; d=google.com; s=arc-20160816; b=fT/Mi/TwoW2x3Bu/K/FemUQMNrOkxU+zn5FMnRD665H/B/dTMT4g8RBoCdjnVDQ9AG 3e+vgFEy+bENIGt9BHgBzXls08M/y54Jm62dWOS7TLLXZda+bz9W6wnSDRuVAausCG/o l2Z0Ffl2gBBQayekoYafXO5wxunaG0IYppQuinQvWfAxs7/TcTi61vd9YDDPngDI4AjC v/UqSOij1DFTpGhB2ncbsfr449GI9JsRIGUMqpEiCwart9YVRCyyEj6N5qtt0Up6dFS+ N4N1U/Jm2ZGQwAyhzqZZIRIfbYMeJagyRO1sI+3IP1zK+W81w+axcABJCA4S2G19w03G iU8Q== 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=pkeicgX2Fu+wHSCQBTs/PLx/CytkRwRJkRHV7M6XDoE=; b=KaML2S1GQtletevG1+QvKP4nTxGqIYA+Ozb+6t51cpClwDYV+1G2M2xGTcuKUcuMac qhPY7VwmxkeIYtyJimr2eZ7bFe50DLTJVIB4YTJapep1/wyhQXETu+YS3nSSkzU8dwMI CbS/XNAti5YJwRk/Xy6AszDj/eA+9WpcxUjEIrFTJ4iNGWOUoim0IxZ/KbwEtumBY/k9 nLeYFmG2hYptK2coG3F5hLlxZPrzt2/SZWuKMeWO9karg4DRgAF1vGefpA3q+NxxvUI1 /bW8jhhm666IshVAPB6VQ3kJnLAbYRKKOlDuGxAsZPMDoWAqUb7Ar8rCm9sE9Zx1G+f6 m61w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G447Ki/p; 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 y6-v6si20218147pgv.520.2018.05.09.02.55.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 02:55:29 -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=G447Ki/p; 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 77BB520945DB1; Wed, 9 May 2018 02:55:28 -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 C78DA203B85B8 for ; Wed, 9 May 2018 02:55:27 -0700 (PDT) Received: by mail-pl0-x243.google.com with SMTP id a39-v6so3997571pla.10 for ; Wed, 09 May 2018 02:55:27 -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=BJmZc//LTMfHCTOFvQUYc0FfOBsdXwz3aMX/66wkoEM=; b=G447Ki/prUfZN0D30c0liSw466QG/R8IRv8J4SD8EGQwQFQFRcaxhD9OVcBNKe8kp3 M2PyF5pL+fvrxbuqg5o9i4AuysP0/nXSDCdaZTOComd0WTCbaim52p18/8BVIf4r4fkm DAG6FxHZ0K6UenKUc8psQMseXFCpSVapJOyOw= 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=BJmZc//LTMfHCTOFvQUYc0FfOBsdXwz3aMX/66wkoEM=; b=QbzW3RDj4rscv5CMuqlQ6p7EH9KmRnDo2iwNlSHUaI50KkmIvIoJgpoBLzfqdfOlMI ePqTszBNiFFpqoyk8NIcGlEIBHqDH/8XMjtwcQ3s7cJkNyQtDwJ3HjZpKEvunhUCZZKD tPHLvM3Wrn6eyhNHUq+gcKJ+lYlO0srEBACNh5xj6yNllWZ6zRcLD0mhXgvzbnSZvlRh vzOvuv6GNVeJUbWzf/ce12Cx3Cx7QTcwsDJxUERWDx6KwPVumlyH7MJR4BxlMfF36Ptz BqETCP9qlzRIm3wzhqjOLcDw7K3oZbOL8Ys2S9uI4t8ubMfp2RiWU7tv3WRseAXVwhdn vgYg== X-Gm-Message-State: ALQs6tCgVQH+rTvpP8dn5NaKluro0vXgDNVIsVcy87EzA4bLEV52IDBs w26CB0qJo4hgsOWO+nVh3pBd2kdiqf0= X-Received: by 2002:a17:902:76c1:: with SMTP id j1-v6mr44597129plt.284.1525859727132; Wed, 09 May 2018 02:55:27 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.170]) by smtp.gmail.com with ESMTPSA id k1-v6sm17966139pgt.88.2018.05.09.02.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 02:55:25 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Wed, 9 May 2018 17:54:59 +0800 Message-Id: <1525859699-16888-7-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525859699-16888-1-git-send-email-haojian.zhuang@linaro.org> References: <1525859699-16888-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 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.c | 98 ++++++++++++++++++++++++++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 5 ++ 4 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.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c index 19987e0b29c3..8f4f9157835c 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -12,10 +12,15 @@ * **/ +#include #include #include +#include #include +#include +#include + #include #include @@ -31,6 +36,8 @@ #define ADB_REBOOT_BOOTLOADER 0x77665500 #define ADB_REBOOT_NONE 0x77665501 +STATIC EMBEDDED_GPIO *mGpio; + STATIC VOID UartInit ( @@ -104,6 +111,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 @@ -115,5 +206,12 @@ HiKeyEntryPoint ( if (EFI_ERROR (Status)) { return Status; } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformVirtualKeyboardProtocolGuid, + EFI_NATIVE_INTERFACE, + &mVirtualKeyboard + ); return Status; } 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