From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6C92D22568607 for ; Thu, 8 Mar 2018 05:30:07 -0800 (PST) Received: by mail-pl0-x243.google.com with SMTP id y8-v6so3298325pll.13 for ; Thu, 08 Mar 2018 05:36:23 -0800 (PST) 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=79PCTYYs3mwPvnkTJNNeCwsfvw5aecg7j33Aexgu8o8=; b=hcnJ8WmHjmU+E+NdWInZ04kEC1UQIJGBHySf41LPgnkoeJfZGr5Jjk9k/dTZJsuzcL 9ZWWLI8xdIDZvVoDRRCWu63bO4wFjms8tuWY/R4ZV8gcPW6rD88Jy8SyWGelJo9pi6u1 jZ1R9wUMFMOpwJumpwi4mHLBGpyiyBroz8Igg= 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=79PCTYYs3mwPvnkTJNNeCwsfvw5aecg7j33Aexgu8o8=; b=OUU18kQ/O5HQP/L8wpy0QOni+TGRdeaf8nWI0syvgRlve1sgB7W2buNCoxYCPbsuzi 1hhKBVrzjiiyOn3t41rs2eING4zXfrc6U+H5mCSiAuK5eES5RSFj3hb5mgHCIIFPGWgu kETEDL/GWmJ8PS7p6GB6Rgr7LXpzx1wS0BJnfxwDiueGg1VSDGyM5oQdoButxxvc/o90 CeOm2OHJzKF4VIZElXXVnNVkkI7DKVnvG2Dj9ZqDAgzhN9LRSKmLYnoXjl1JxMjtAOOo Yvz9g9toLXxWTuirwqPtY7hBgrj/uLXurjTEWDnRLVqi/FCi3eVOhP3xqAOSxbCdI3ZY N0SQ== X-Gm-Message-State: AElRT7GI9gjJV2zKGX3xtEnh0/ELvZ+PNVwI7A0ron6GN/iAAKNL15la WFi/5PEQxRaFSWu8odyhEe59GSC518g= X-Google-Smtp-Source: AG47ELt2HK+cSRHePmxu+eLiPr7BOYXquShPg4XXc6gB0PrCcUuSjJEAaBz2dhDa93wmiU52EmWbSw== X-Received: by 2002:a17:902:8f8f:: with SMTP id z15-v6mr6309590plo.315.1520516183056; Thu, 08 Mar 2018 05:36:23 -0800 (PST) Received: from localhost.localdomain ([64.64.108.52]) by smtp.gmail.com with ESMTPSA id e5sm31098083pgs.17.2018.03.08.05.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 05:36:21 -0800 (PST) From: Haojian Zhuang To: edk2-devel@lists.01.org Cc: Haojian Zhuang , Leif Lindholm , Ard Biesheuvel Date: Thu, 8 Mar 2018 21:35:32 +0800 Message-Id: <1520516133-30066-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520516133-30066-1-git-send-email-haojian.zhuang@linaro.org> References: <1520516133-30066-1-git-send-email-haojian.zhuang@linaro.org> Subject: [PATCH v2 edk-platforms 3/4] Platform/Hisilicon/HiKey: add gpio platform driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Mar 2018 13:30:07 -0000 Add gpio platform driver to enable GPIO in HiKey platform. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf | 36 +++++++++++ Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c | 68 ++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf new file mode 100644 index 000000000000..272ed1c0cea2 --- /dev/null +++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf @@ -0,0 +1,36 @@ +# +# 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 = 0x00010019 + BASE_NAME = HiKeyGpio + FILE_GUID = b51a851c-7bf7-463f-b261-cfb158b7f699 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = HiKeyGpioEntryPoint + +[Sources.common] + HiKeyGpioDxe.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + UefiDriverEntryPoint + +[Protocols] + gPlatformGpioProtocolGuid + +[Depex] + TRUE diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c new file mode 100644 index 000000000000..543f65d7b12d --- /dev/null +++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c @@ -0,0 +1,68 @@ +/** @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[]= { + { 0xf8011000, 0, 8 }, // GPIO0 + { 0xf8012000, 8, 8 }, // GPIO1 + { 0xf8013000, 16, 8 }, // GPIO2 + { 0xf8014000, 24, 8 }, // GPIO3 + { 0xf7020000, 32, 8 }, // GPIO4 + { 0xf7021000, 40, 8 }, // GPIO5 + { 0xf7022000, 48, 8 }, // GPIO6 + { 0xf7023000, 56, 8 }, // GPIO7 + { 0xf7024000, 64, 8 }, // GPIO8 + { 0xf7025000, 72, 8 }, // GPIO9 + { 0xf7026000, 80, 8 }, // GPIO10 + { 0xf7027000, 88, 8 }, // GPIO11 + { 0xf7028000, 96, 8 }, // GPIO12 + { 0xf7029000, 104, 8 }, // GPIO13 + { 0xf702a000, 112, 8 }, // GPIO14 + { 0xf702b000, 120, 8 }, // GPIO15 + { 0xf702c000, 128, 8 }, // GPIO16 + { 0xf702d000, 136, 8 }, // GPIO17 + { 0xf702e000, 144, 8 }, // GPIO18 + { 0xf702f000, 152, 8 } // GPIO19 +}; + +PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = { + 160, 20, gGpioDevice +}; + +EFI_STATUS +EFIAPI +HiKeyGpioEntryPoint ( + 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; +} -- 2.7.4