From nobody Thu Apr 25 08:56:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1534384180939948.9022054847576; Wed, 15 Aug 2018 18:49:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B90AA210F2D15; Wed, 15 Aug 2018 18:49:39 -0700 (PDT) Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::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 57D72210F2D12 for ; Wed, 15 Aug 2018 18:49:38 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id b90-v6so1276742plb.0 for ; Wed, 15 Aug 2018 18:49:38 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.56]) by smtp.gmail.com with ESMTPSA id c1-v6sm45536108pfg.25.2018.08.15.18.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 18:49:36 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org 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=KlhCeodt1xfKUoPcsSqSK6p69G62B9kqO+HK9WcNEgw=; b=fGQqsRUrH24NIR5GBcwHClhVNiin7mRAixfURfvIc0+hPYHO3uPZAKBBU9fjSUZHH+ JfHzV/ki4xq9gHnOcQIbY2Ih3jYEyv499XgLmN2iHQuU7yX2tf6HGao9UuM9JtWyS5fm luPbAY/aLT+GfUhy+DQY+nKUGCWv1F6vhPQHw= 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=KlhCeodt1xfKUoPcsSqSK6p69G62B9kqO+HK9WcNEgw=; b=J3xT0V52XqXSsiO+HacJKqjtwfuBNtmk7Wh+2vUbMRDeSBYrnJWl63HVlDOu4I3Hsn 6WhiJfgOZo2upBMV8uoF0WDQA2ZmDtTQpKLYgO5DrnhbA0G+RHC9XafEMqkm23GIFOko qwa5dgSTzM3d+4EfCDjbIEbTjxiEllufzSenlIka5zPBZnVyOOKlsygi7hwUsGHEHWcY lr0ZJ/nkSts3ck8vlzjLqIR8sTZbVIIAemF6dmlCYMTq+1fPX7N2XRBaXSruUQL2j1+q YGbcNVWu5Eh/whUCdk2UJTxIS5oqplWPqAjgIQNTDWilP0JrFlwH78eB19S4o3Gzy4IA gQCQ== X-Gm-Message-State: AOUpUlG9rcFmt7sCtVDHXuLTkSW6d4zuKvTm4xlYXymB9Hymlqrm2wK6 mie5gPkh4ekP72ji5GT6B5B1l+IU5h5ZPg== X-Google-Smtp-Source: AA+uWPxM9zsovxKHmP+RDzxkTFtPH6TmqKyAq1wJ6Kyhz6aWLhnhuBwnNrE3sDItggKl/AY2A+N8vA== X-Received: by 2002:a17:902:bb97:: with SMTP id m23-v6mr20447717pls.215.1534384177662; Wed, 15 Aug 2018 18:49:37 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 16 Aug 2018 09:49:25 +0800 Message-Id: <1534384166-15673-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> References: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 edk-platforms 2/3] Platform/HiKey960: enable SD controller X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Enable DwMmcHcDxe driver on HiKey960 platform. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey960/HiKey960.dsc | 8 ++ Platform/Hisilicon/HiKey960/HiKey960.fdf | 8 ++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 1 + Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf | 46 +++++++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 15 +++ Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c | 125 ++++++= ++++++++++++++ 6 files changed, 203 insertions(+) diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc b/Platform/Hisilicon/= HiKey960/HiKey960.dsc index be13714b9c19..1ce306da5b50 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -193,6 +193,14 @@ [Components.common] # EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf =20 + # + # MMC/SD + # + Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf + EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.= inf + EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf =20 # diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf b/Platform/Hisilicon/= HiKey960/HiKey960.fdf index d65f77878575..d4fe4c46b818 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.fdf +++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf @@ -128,6 +128,14 @@ [FV.FvMain] # INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf =20 + # + # MMC/SD + # + INF Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf + INF EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDevice= Dxe.inf + INF EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf =20 # diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Plat= form/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf index 54105bdb3c94..9d66c028832e 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf @@ -33,6 +33,7 @@ [LibraryClasses] CacheMaintenanceLib DxeServicesTableLib IoLib + NonDiscoverableDeviceRegistrationLib PcdLib TimerLib UefiBootManagerLib diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf = b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf new file mode 100644 index 000000000000..3e4bc807956e --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf @@ -0,0 +1,46 @@ +#/** @file +# +# Copyright (c) 2018, Linaro. All rights reserved. +# +# This program and the accompanying materials are licensed and made avail= able +# 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 IM= PLIED. +# +# +#**/ + +[Defines] + INF_VERSION =3D 0x00010019 + BASE_NAME =3D HiKey960MmcDxe + FILE_GUID =3D e10d1dea-2f00-4eea-ac5d-9d6cfa7831a0 + MODULE_TYPE =3D UEFI_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D HiKey960MmcEntryPoint + +[Sources.common] + HiKey960MmcDxe.c + +[LibraryClasses] + DebugLib + IoLib + TimerLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiDriverBindingProtocolGuid + gEmbeddedGpioProtocolGuid + gPlatformDwMmcProtocolGuid + +[Packages] + EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Hisilicon/Hi3660/Hi3660.dec + +[Depex] + TRUE diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platfo= rm/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index 47ec879861bd..75627d5d6665 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include =20 @@ -447,6 +449,19 @@ HiKey960EntryPoint ( return Status; } =20 + Status =3D RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeSdhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + 0xFF37F000, // SD + SIZE_4KB + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status =3D gBS->InstallProtocolInterface ( &ImageHandle, &gPlatformVirtualKeyboardProtocolGuid, diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c b/= Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c new file mode 100644 index 000000000000..0a2b60edf352 --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c @@ -0,0 +1,125 @@ +/** @file +* +* Copyright (c) 2018, Linaro. All rights reserved. +* +* This program and the accompanying materials are licensed and made avail= able +* 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 IM= PLIED. +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define DETECT_SD_CARD 203 // GPIO 25_3 + +DW_MMC_HC_SLOT_CAP +DwMmcCapability[] =3D { + { + .HighSpeed =3D 1, + .BusWidth =3D 4, + .SlotType =3D RemovableSlot, + .CardType =3D SdCardType, + .Voltage30 =3D 1, + .BaseClkFreq =3D 3200 + } +}; + +EFI_STATUS +EFIAPI +HiKey960GetCapability ( + IN EFI_HANDLE Controller, + IN UINT8 Slot, + OUT DW_MMC_HC_SLOT_CAP *Capability + ) +{ + if (Capability =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if (DwMmcCapability[0].Controller =3D=3D 0) { + DwMmcCapability[0].Controller =3D Controller; + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else if (DwMmcCapability[0].Controller =3D=3D Controller) { + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else { + return EFI_INVALID_PARAMETER; + } + return EFI_SUCCESS; +} + +BOOLEAN +EFIAPI +HiKey960CardDetect ( + IN EFI_HANDLE Controller, + IN UINT8 Slot + ) +{ + EFI_STATUS Status; + EMBEDDED_GPIO *Gpio; + UINTN Value; + + if (Slot =3D=3D 0) { + Status =3D gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOI= D **)&Gpio); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO protocol: %r\n", Status)); + goto Exit; + } + Status =3D Gpio->Set (Gpio, DETECT_SD_CARD, GPIO_MODE_INPUT); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to sed GPIO as input mode: %r\n", Statu= s)); + goto Exit; + } + Status =3D Gpio->Get (Gpio, DETECT_SD_CARD, &Value); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO value: %r\n", Status)); + goto Exit; + } + if (Value =3D=3D 0) { + return TRUE; + } + } +Exit: + return FALSE; +} + +PLATFORM_DW_MMC_PROTOCOL mDwMmcDevice =3D { + HiKey960GetCapability, + HiKey960CardDetect +}; + +EFI_STATUS +EFIAPI +HiKey960MmcEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformDwMmcProtocolGuid, + EFI_NATIVE_INTERFACE, + &mDwMmcDevice + ); + if (EFI_ERROR (Status)) { + return Status; + } + return Status; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel