From patchwork Thu Mar 8 13:30:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 131011 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6481161lja; Thu, 8 Mar 2018 05:30:52 -0800 (PST) X-Google-Smtp-Source: AG47ELvQKFwU5xYbdaZYGpOSVCeL8BxbwSwXNiLh9u0i9uwhZ7E1TrXFJ5LN0/97sN0BVbDNGCg/ X-Received: by 2002:a17:902:bc3:: with SMTP id 61-v6mr24462654plr.398.1520515852208; Thu, 08 Mar 2018 05:30:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520515852; cv=none; d=google.com; s=arc-20160816; b=DXDryI1CytFzVFj/iotTzTKw1s3bo5O1mzEFyh9rqcT7tUtd5c9IVJIXp2nT3IqGIe gr4Oid5fLYhYtHcjVuyi8DeOEDWT1AVBlTLqn9P/4onTpbi7RDYTlbjanosUCwrMwIrO 9+7hAAyEMjXbjdam8lS4svNJbjLgvvwZNz/w3IEjENcWKCzVhXR9ECj8utrFjmTDYalU q5JibsAxCoF1zB+flDHW+8lscqYP95gGVDwG3aL+7lGlVz2d3gJsvpQk6oU7vodLGQBX Tj79Z8qpdJ62Lxckg8sT+jUEcOifymlKM+QXZ+a8gLm1nyUKwYKgEPSQtzl6QUKqVz+3 z9ow== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=/ihWcIKx1HzG9KAVWiX7VhynIvYtHffy+p+EG6Fhb+c=; b=xWdqik1EzDOGXOGd0uIsPOScqEpLxydf94GGeOoK1YJGY/alT5D3s2w2OSMUZIsx0b YRxiic7zxY9/QvItVXV9SES3VQMUv6kxin5CYijBClbrWZZCygiSOL41jAooQqKQ68hw 2a8W6N2BOBgSf3+Gb0kEmVjEQMvv+RdRYYaM9BSp9mGp+w4jfmeNXMjpJd7F1CDgrCIu jpN1mbx8rxdVX1loItufGuZCefGq/M6wETHl4ePrXlt+NozhHO/pXKO/sMz0nm1+8qac rgOL/lCzbdWzQPnISC9Y/xkhajxRsoMZ+gmDCk8K/svsbZ4vxhWo20xU2QaMM1iMI1NX TcoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WNVcA0H+; 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 r26si13155777pgd.654.2018.03.08.05.30.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 05:30:52 -0800 (PST) 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=WNVcA0H+; 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 492E521ED1C79; Thu, 8 Mar 2018 05:24:35 -0800 (PST) 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 C6914209574F3 for ; Thu, 8 Mar 2018 05:24:33 -0800 (PST) Received: by mail-pl0-x242.google.com with SMTP id d9-v6so3303838plo.8 for ; Thu, 08 Mar 2018 05:30:50 -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; bh=79PCTYYs3mwPvnkTJNNeCwsfvw5aecg7j33Aexgu8o8=; b=WNVcA0H+MTG/OZfakK0MEkkHCRssK6FE2VxnU+dgAmtOUpqUH9PM/J5gLpZZBpMy3h xUhkmYgJNeKulICOuKmPUZ/ognCKKO7g19GSNb942tswi6YVn45w1BcGzWGCmj5fGpWm d3C/ii7fHTtHgF6NmrqIud/DNqOgvYQ5X38JA= 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; bh=79PCTYYs3mwPvnkTJNNeCwsfvw5aecg7j33Aexgu8o8=; b=Gq2hTStJD9lwh2qoo+ZFwnXT3dbUGZhr38f3cdlJHjg8T8fyfdmMDVFGMRF3Dnm5wU f3+R9p38hEr8nAUUR2XhlLfFLvOnRFu6HqPw09JRmM1s9yVQs324ZTH8mveS4Hw7TC8j 8yrUJUZbWEtF3qTWGXLcXuREKGAB50nW0gRXbLeGZCpe7MJSqsWCBKO2VAtv9fPX8Zl8 U1K3pzzSqRkU9qMFsEgufaysQGL0wlBOv70E94OL8WjlxFe+UGqJQzu80+CijhNYR5gv tM9NboYm2R9vhrEHvaGh9WmSLKzywPkf2QR/sQa7FaM+g38ipLtnGMkHcegcTcrpwJOo 70nA== X-Gm-Message-State: AElRT7EcGMiwgbHnzLXKHr5TvF+8JZ9Bz1p8bkn3hjJB28II/TLjkwl0 6GID1Oz5GGP4s3M2eO7cIqI/Z7SV4IE= X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr11218542pld.2.1520515849432; Thu, 08 Mar 2018 05:30:49 -0800 (PST) Received: from localhost.localdomain ([64.64.108.52]) by smtp.gmail.com with ESMTPSA id b5sm43854448pfc.12.2018.03.08.05.30.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 05:30:48 -0800 (PST) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 8 Mar 2018 21:30:28 +0800 Message-Id: <1520515828-29629-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [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: , Cc: 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 --- Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf | 36 +++++++++++ Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c | 68 ++++++++++++++++++++ 2 files changed, 104 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/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; +}