From patchwork Thu May 24 00:46:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 136684 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1555850lji; Wed, 23 May 2018 17:46:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFfT4x1ev5sZq00HJU47sDyLgVI26hbpToJAh2VHO/3eauVUbZmh2/IsOCczwTU7wXEb9n X-Received: by 2002:a17:902:8b85:: with SMTP id ay5-v6mr4903560plb.30.1527122806782; Wed, 23 May 2018 17:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527122806; cv=none; d=google.com; s=arc-20160816; b=DPh/BsfeZYrRpLJbbZD+H2ER5VcHhSIjO8I2DNK0avRtdYgzjfYmsuikh/ZPB9OU63 W2qQKTPIL4loAY5DVfO0SJ+uSpt28hqJNeajA3nGr8zIOshZNFCmCGUV+SLjthYqiYdK kqsC2lp8CfM+u/WYIdaD0ECpsjLyc3YC51l0KgkLtc4WoPTrGimMpVJGSxJK0q7aUaYD xWyByGd74GXIdnia+3BpqO1wN1gPeSl7WapsEDZEUwjKKZ20VVVm75ks44hfJbqqAeHq qfs5jazksuCqsTL8ePCXNEciiKffuDEflIRe580uCwOOkzO0vG8brpoUYsZt0Hqco1fd J3Pw== 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=VT3+VPdUSP253Kg1aXLSG3sEd4DDeRRFOR3zGjNGgUY=; b=rjoNUBLqdL4+FGsRgGzxB1zozRYmtvWpcP+1VfkWlH7id/uCm5cVWVv4cbGwOSBHmP E52z4CYIKi6pz7RBGs0AaSVYtYHqFfAFIQ2XGQi/NVlQMhjzZqLGff4H1XqmYAoZb6PU 2KG+rCaP8gdukdIxMN70zrtFMRv/2Qzww+zggegNdDIULN6NF6bep7Wpp6RwKVgARP4z NOzL6UtFtXK6M/2B1pFu/ldHJGBI15RT7u4+UyrJ/ufVFkZ62zPr4dYVS+KgcvQ4V7HC k+/i/qPLdlBw7RjBrYzY7kuDYW7nANZCdzWIH60U+ERpv9b/JwLrq+CVh/NJ2kcNjlWA ywZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E2t/N0j0; 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 y7-v6si8824123pgs.259.2018.05.23.17.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 17:46:46 -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=E2t/N0j0; 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 5C7DA207E6361; Wed, 23 May 2018 17:46:46 -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::242; helo=mail-pl0-x242.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (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 40AD8207E4E10 for ; Wed, 23 May 2018 17:46:45 -0700 (PDT) Received: by mail-pl0-x242.google.com with SMTP id c11-v6so14041252plr.5 for ; Wed, 23 May 2018 17:46:45 -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=T6Tcq4WtZva2i/n5lhRAHiNmunOsRktJ3uTaebKCPvI=; b=E2t/N0j0meNmn7PKLqBCsyQ97c7t44MfNrlxMKcCBZ2qn3DrN9Wf0uCtygI+yNN15x r25VqO+BPNVl8KPu5qQq4AQvwzCY9+sDUcHGSQH7KbkKiUs521bgIBCSyLcHsK/UFHcK OfDOupIsKI8ObNIDcPi1n7fCPnwW0oEE1nh/k= 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=T6Tcq4WtZva2i/n5lhRAHiNmunOsRktJ3uTaebKCPvI=; b=iB8c/63FrogNy83UkKutsH9KrOszCvDLUx/zNny56E81JKRTGymS75r5P+d0aTvyPU padVRUkCu3Oei7smbq7oU8AVWRRetA5nF9/68VWeSPd8rcPhZlqcHvZbEXZBEk6QmQx+ X4tod9s6mNVuqT9KtZOpBFacMTdv9v85b109Jk/ejFl54niNl7CrmolKi8n1rbkhkd7x UgIgmJm3maZ0hQZgixvhG6fd2mEKxBjLxotonp/gQGvepXj1gNPTTgNcLZACXjqDWcK2 Avt2fhHTMLnJFnCrzq7MAWVfhtAq/RbhcauI+KTfkQhzAwlIxts2ed4RwloAs25rPoHW pa3Q== X-Gm-Message-State: ALKqPwexHzzpB29oJAOXQlUMxFh1FLfmjzmWhDS9tbxlrC2ZvMHyuNQp 0i66wnBg8ERa25Mm0y8iIv1Y4u9iclc= X-Received: by 2002:a17:902:164:: with SMTP id 91-v6mr5097727plb.134.1527122804593; Wed, 23 May 2018 17:46:44 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.105]) by smtp.gmail.com with ESMTPSA id y29-v6sm48817471pff.42.2018.05.23.17.46.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 17:46:43 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 24 May 2018 08:46:25 +0800 Message-Id: <1527122790-23592-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527122790-23592-1-git-send-email-haojian.zhuang@linaro.org> References: <1527122790-23592-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v6 edk2-platforms 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver 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" Add gpio platform driver to enable GPIO in HiKey960 platform. 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 | 1 + Platform/Hisilicon/HiKey960/HiKey960.fdf | 1 + Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf | 35 +++++++++ Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c | 83 ++++++++++++++++++++ 4 files changed, 120 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 36f43956ab40..3da1b8556321 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -179,6 +179,7 @@ [Components.common] # # GPIO # + Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf b/Platform/Hisilicon/HiKey960/HiKey960.fdf index 655032a36c53..162dbaaf2646 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.fdf +++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf @@ -120,6 +120,7 @@ [FV.FvMain] # # GPIO # + INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf new file mode 100644 index 000000000000..5ea3747321d8 --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf @@ -0,0 +1,35 @@ +# +# Copyright (c) 2018, Linaro. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +[Defines] + INF_VERSION = 0x0001001a + BASE_NAME = HiKey960GpioDxe + FILE_GUID = 6aa12592-7e36-4aec-acf8-2ac2fd13815c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = HiKey960GpioEntryPoint + +[Sources] + HiKey960GpioDxe.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + +[Protocols] + gPlatformGpioProtocolGuid + +[Depex] + TRUE diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c new file mode 100644 index 000000000000..b196455072cc --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c @@ -0,0 +1,83 @@ +/** @file +* +* Copyright (c) 2018, Linaro. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include + +#include + +GPIO_CONTROLLER gGpioDevice[] = { + // + // { base address, gpio index, gpio count } + // + { 0xe8a0b000, 0, 8 }, // GPIO0 + { 0xe8a0c000, 8, 8 }, // GPIO1 + { 0xe8a0d000, 16, 8 }, // GPIO2 + { 0xe8a0e000, 24, 8 }, // GPIO3 + { 0xe8a0f000, 32, 8 }, // GPIO4 + { 0xe8a10000, 40, 8 }, // GPIO5 + { 0xe8a11000, 48, 8 }, // GPIO6 + { 0xe8a12000, 56, 8 }, // GPIO7 + { 0xe8a13000, 64, 8 }, // GPIO8 + { 0xe8a14000, 72, 8 }, // GPIO9 + { 0xe8a15000, 80, 8 }, // GPIO10 + { 0xe8a16000, 88, 8 }, // GPIO11 + { 0xe8a17000, 96, 8 }, // GPIO12 + { 0xe8a18000, 104, 8 }, // GPIO13 + { 0xe8a19000, 112, 8 }, // GPIO14 + { 0xe8a1a000, 120, 8 }, // GPIO15 + { 0xe8a1b000, 128, 8 }, // GPIO16 + { 0xe8a1c000, 136, 8 }, // GPIO17 + { 0xff3b4000, 144, 8 }, // GPIO18 + { 0xff3b5000, 152, 8 }, // GPIO19 + { 0xe8a1f000, 160, 8 }, // GPIO20 + { 0xe8a20000, 168, 8 }, // GPIO21 + { 0xfff0b000, 176, 8 }, // GPIO22 + { 0xfff0c000, 184, 8 }, // GPIO23 + { 0xfff0d000, 192, 8 }, // GPIO24 + { 0xfff0e000, 200, 8 }, // GPIO25 + { 0xfff0f000, 208, 8 }, // GPIO26 + { 0xfff10000, 216, 8 }, // GPIO27 + { 0xfff1d000, 224, 8 }, // GPIO28 +}; + +PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = { + // + // { global gpio count, gpio controller count, GPIO_CONTROLLER } + // + 232, 29, gGpioDevice +}; + +EFI_STATUS +EFIAPI +HiKey960GpioEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + // Install the Embedded Platform GPIO Protocol onto a new handle + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces( + &Handle, + &gPlatformGpioProtocolGuid, &gPlatformGpioDevice, + NULL + ); + if (EFI_ERROR(Status)) { + Status = EFI_OUT_OF_RESOURCES; + } + + return Status; +}