From patchwork Wed May 23 15:14:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 136674 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1023652lji; Wed, 23 May 2018 08:15:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqUIrkshOiPqeSFHoWY93g6NVFQnNZH1MlY5vIIihRCh2BahJoEOE7mYTScUQoXTHgX8CP9 X-Received: by 2002:a63:2647:: with SMTP id m68-v6mr2704037pgm.56.1527088522839; Wed, 23 May 2018 08:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527088522; cv=none; d=google.com; s=arc-20160816; b=GnQKIYbpfyiXCJ/+y6E7gN5L3s2vquzqZrvF0BAus53RBuBpekwMxWSDYyBKqzaFu7 XwFE9Bvktqv3Jzim7kCpgr6tRBHi2o3yPgWpOavBj6uQitMqMyxTK7eCEEwARk4NAZdg kXlq8naS4O1ACxdn6rDzJFtv2rwojv1urXVSU90vqjIX2vyJt2kBJHjQwFapZZ5sbP2e MjKY3dAg3XZYOnVJbtIGt85oZApRDcm50ODSP9FhAFTyWiSF8lB/3tmxUl88l9J34oe5 K3IhG5RZbzLfWF15TZe5XguKt7EtWTnUnCeQRwX/bRtGHwMWKSWnRCH8T2pSI8vbpDob NJ6Q== 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=TkfeMPpDAB21zh8e3UCHy5G31ACWjoBx4prSLUjnjFU=; b=Z4i3KzPXIHrYv0eU5tcxGk+daSCyNIZ1M40f9eS+PFFan48HA85RpbVeCPOe0qgw5r OaIHUbLORVavZZi3jPDV42QFR0/lSVlIxZFi0SxdSAb7oRwxcfa51kei//QdsNXcPg5m gDVQd/Jv9aW2ijWS4c9bxvMlUWAP9OXkq+fwJxpxDsJxQ1PFf8h5FeBxJZ2MzcEcuHQN a4VOe3E2T2Ns12+MzhLmlxT0UdcCahpeHEJPkmLh1hxGgvd2bsdYlsYPYY3qM9UDMdD5 0R82usyAb/jV7TRdmlPNK88MpL2GJrdNX6EGXLdxo7BedOGsgL+c5VCtXTqPgXalJWMI qLEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=P53EAOk/; 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 189-v6si15130355pgi.254.2018.05.23.08.15.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 08:15:22 -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=P53EAOk/; 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 C6D9C207E4E0D; Wed, 23 May 2018 08:15:21 -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::244; helo=mail-pl0-x244.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (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 07BC1209603DB for ; Wed, 23 May 2018 08:15:20 -0700 (PDT) Received: by mail-pl0-x244.google.com with SMTP id w19-v6so13217796plq.4 for ; Wed, 23 May 2018 08:15:20 -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=9CGbBwVxG7sKC8oXitbv4nAWzEZFKoIjig+wo75Z7a0=; b=P53EAOk//hHjasy3BBf446hHcjbSvBxweJ1Sx0rVb6SHyytn8FO9CSwTdVPuaVxW6I ofvWwYTsKUIdtpz9liSmKeI/9+KCUJrNUxTYKjw2Iu3FrTJVw8xOqjYZ/pqtsnMHAxmH Y92bGtzaV11TDGhKgUzB/bKLN24LmFcyxgo54= 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=9CGbBwVxG7sKC8oXitbv4nAWzEZFKoIjig+wo75Z7a0=; b=EejlJPRIs9YZf2GBMUHFuc5/O45IPlzAP8EMatX8M481enRrOh+X1fnmNIBE1hDXBq NAF5yRYUg1cmZMBC5sP/2GZHvM+o5G8vA8TvziWl790kYENJC+v2CyMzajDtatwRvx6t JgOpENgAmVkJBZ1gxnx6E+TOTyO1iwcmwVf1Bf+X49p4y1I4QuF0kzIGwOe8JHpI0pql UMYRDtXpj1dhQnlDg385p8KaJiC5YWq65p5Z7ynL17lhLZJ2hoYJ3RZzp5iXJS8hHtD6 4SAoLWaQ5wpjcI9ZjGlXsk+0iARHqo4vgOF/lWrYiv2Oa69B1Y/9j3eQo2zjKgbSNBBC Ichg== X-Gm-Message-State: ALKqPwfJ7Va0tFaQPj29k4jTh2de9ysF6YbCAhd+GhSwWpSPO2E8tjKE Kp6b4R9VAuN1vmhpgsV8xc0VuaCSLuc= X-Received: by 2002:a17:902:2bc5:: with SMTP id l63-v6mr3282784plb.299.1527088519324; Wed, 23 May 2018 08:15:19 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.17]) by smtp.gmail.com with ESMTPSA id s16-v6sm30466511pfm.114.2018.05.23.08.15.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 08:15:18 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Wed, 23 May 2018 23:14:55 +0800 Message-Id: <1527088497-495-5-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527088497-495-1-git-send-email-haojian.zhuang@linaro.org> References: <1527088497-495-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v5 4/6] Platform/Hisilicon/HiKey: 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 HiKey platform. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang Reviewed-by: Leif Lindholm --- .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c | 74 ++++++++++++++++++++++ .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf | 36 +++++++++++ 2 files changed, 110 insertions(+) create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf -- 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/HiKeyGpioDxe/HiKeyGpioDxe.c b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c new file mode 100644 index 000000000000..be535f8f1903 --- /dev/null +++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c @@ -0,0 +1,74 @@ +/** @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 } + // + { 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 = { + // + // { global gpio count, gpio controller counter, GPIO_CONTROLLER } + // + 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; +} diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf new file mode 100644 index 000000000000..2791b9f44cad --- /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 = 0x0001001a + 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