From patchwork Mon May 14 04:34:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 135665 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1253559lji; Sun, 13 May 2018 21:35:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZor13QuPFuwOzJvn8LQaCJ9A4CYMNbvWbrib6t7dxmuYVgL0LRydZOgl5batp1bLLXJdW9+ X-Received: by 2002:a65:49c3:: with SMTP id t3-v6mr7041083pgs.65.1526272504926; Sun, 13 May 2018 21:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526272504; cv=none; d=google.com; s=arc-20160816; b=d1ko8SOPEHr395ky0s/CRjq2vAWX2zPX7F8PS6U/JvyKLcokwOpzitgZit6szyPB5Q d5h7OzghTyheJkQsWjUKv3QnvvVkEpGncB5gKcGXKasAmAA81l9g0OtP8/HYKI26lr7F eVjim2b17DB58A7QHgeEnDqCjJvFc/et/UJjGfv4PMKmVukCfNJBaBghKiVTcv983wzd cMenelLu0yopTlL+QaGTIc+rEbZWqXYf31z3heMpZdL4AjIGrIMSEF434EVvyCffXHVo W7On9K78Ao+uTsw/y/TvG17Bzd/rSz21rf8rkPkA7zRdFbi9XcqLsWZ3DAFWW1BAn/qw jMoQ== 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=h4xkUbFm0aFd2kMNSO21J3WrGc4wfaPCfpc2ipSKoIr4AkvOFkeX9NY6eaIA1uWlwT /mWzUlCiBiQDys+wKnDcOgvPb2wjTcYGVnryVPbUVy7cvBdgdAoPRaM2ORRyzciCmaJd FldAfzESqU6d7n+GYUZk3GJNcYpOMyZy5TWNSdAN4d0T5Wz5cr/E9FCz1+L/pxEAyiZP BjCW5f3BcoBo+it7ivja2DOdpMtwpAdfnwpeefa5m39gUjJ42mNnZ4CaCC2KdF0ulAEV IYAQoIqYsiaTyI2Lv+s1MBGrYTL7mhrGKS4yqjxhkKWu9bUrXCbNT7iMcZwphXjhAxXx hVWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RSHL+W2b; 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 77-v6si8411717pfz.334.2018.05.13.21.35.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 May 2018 21:35: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=RSHL+W2b; 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 BA202207E5413; Sun, 13 May 2018 21:35:03 -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::241; helo=mail-pf0-x241.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (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 07E14207E540E for ; Sun, 13 May 2018 21:35:03 -0700 (PDT) Received: by mail-pf0-x241.google.com with SMTP id v63-v6so5379723pfk.8 for ; Sun, 13 May 2018 21:35:02 -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=RSHL+W2bqsnCfGh5oRBpTP+s90u1MTFDAM1Uae7fuq5dcUaXvHkKC4DMrLoNDGWQ3r 3lQo6QZ4pa7p9fVP0tIpL+otcwSRuOjeLNZ9iT2C5N6Kr/ygl9I/cjiF/1SDH2W0hsdZ 0W4P3eDBFmGMlTTqQ9UGrniA/Qts/BfY46zy4= 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=rQX/BYlqiCYVE0jjOkpPcT4fqGPQQWeF6YapAbcS8tJhXaEpgpbxiFYLH634JIGqkp L3QgfwADxyKkibeFGS1aWxCo5w26Q1vCvu9qk/ve6UjW7Wj51h2b40uODUcXLuTWWj3E xFJkc06kCW8Tw9rLtS4aDZ7vD9mBxM7REs5v/v7oLfJYbBlqIbSrbumcqvju5o9miK5m XcmEJEa6dKjO0yek8vFEHdm3/Lz5tPCbr/TayPFwS9CldhjFKXGHcZUXN0Ue5k0+Srva FFakWIzZIkzHN8RwtXGoVmiOuab5FRutxm2TMg+cxtQnybs0cLk3vGhvVgQowzBmcOmx aJ2w== X-Gm-Message-State: ALKqPweyaHYiYJVD19D+QrfuYst/nBhDbb7Bf9QmKHtXOVn8XHGG91bo L7MTfp3JCEPW3QVKSJ9qXDFUucn8jyg= X-Received: by 2002:a62:990f:: with SMTP id d15-v6mr8755126pfe.115.1526272502419; Sun, 13 May 2018 21:35:02 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.93]) by smtp.gmail.com with ESMTPSA id c11-v6sm15125613pfh.15.2018.05.13.21.34.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 May 2018 21:35:01 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Mon, 14 May 2018 12:34:33 +0800 Message-Id: <1526272473-25565-7-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526272473-25565-1-git-send-email-haojian.zhuang@linaro.org> References: <1526272473-25565-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 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 Reviewed-by: Leif Lindholm 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