From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=203.18.50.4; helo=nat-hk.nvidia.com; envelope-from=ashishsingha@nvidia.com; receiver=edk2-devel@lists.01.org Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6889B2194D3B8 for ; Wed, 26 Dec 2018 13:24:32 -0800 (PST) Received: from hkpgpgate102.nvidia.com (Not Verified[10.18.92.9]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 27 Dec 2018 05:24:31 +0800 Received: from HKMAIL104.nvidia.com ([10.18.16.13]) by hkpgpgate102.nvidia.com (PGP Universal service); Wed, 26 Dec 2018 13:24:29 -0800 X-PGP-Universal: processed; by hkpgpgate102.nvidia.com on Wed, 26 Dec 2018 13:24:29 -0800 Received: from DRBGMAIL104.nvidia.com (10.18.16.23) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 26 Dec 2018 21:24:27 +0000 Received: from HKMAIL102.nvidia.com (10.18.16.11) by DRBGMAIL104.nvidia.com (10.18.16.23) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 26 Dec 2018 21:24:19 +0000 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (104.47.48.58) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Wed, 26 Dec 2018 21:24:18 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com (20.177.125.220) by BYAPR12MB2757.namprd12.prod.outlook.com (20.177.125.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.21; Wed, 26 Dec 2018 21:24:16 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::48d0:7a19:5dfb:fae2]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::48d0:7a19:5dfb:fae2%5]) with mapi id 15.20.1446.026; Wed, 26 Dec 2018 21:24:16 +0000 From: Ashish Singhal To: "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH v7] MdeModulePkg/SdMmcPciHcDxe: Add SDMMC HC v4 and above Support. Thread-Index: AQHUlzzRaSFXBZYgDUi2nbPlBg2Q+KWRlAyg Date: Wed, 26 Dec 2018 21:24:15 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Enabled=True; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SiteId=43083d15-7273-40c1-b7db-39efd9ccc17a; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Owner=ashishsingha@nvidia.com; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SetDate=2018-12-26T21:24:13.8095598Z; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Name=Unrestricted; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Application=Microsoft Azure Information Protection; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Extended_MSFT_Method=Automatic; Sensitivity=Unrestricted authentication-results: spf=none (sender IP is ) smtp.mailfrom=ashishsingha@nvidia.com; x-originating-ip: [8.46.90.104] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR12MB2757; 6:Kq7lvfzETtygR0c2MI9Nd4b1qJz2bN8k+w0HYmwLVsqKF9Qfzv31EBnfwv3mvqz2J3fm74Ako1OSyiIwT8Eg+8fDgzU4TuCmZhm7nP0aBXTn8GeqaL5RduR9K1UWNuGP71+fx98OyD6NJuBeFdhhgw9E+gFJyvU2AEnMx0AE2i7Ww0u4szmsUnvUdl6vSVWHK0j7KYVx7H7QI4gj+nLtT2SzaIrgT1SAmdB5NXzuCQFEIAn8fKJNHRAwO4ZgTElxvU/OgF0ftMzkz1OMYY4Vc5w0vUdOQFUK/3G/jd2qLM2S/xQtVIw4Fdx/yQ7BhiPJvuB+bDUFkakF+asAYwiY4emALm/0oO219X8r+ESueOmx+/YlaN9jt9J20sMnLLYOdGMSHhI7wZfIcsCVAL/jfYPxyoH3ZQtGKDquhv466o7Wm72lTzzBAROmy2TSeJY5XRXmX8y1/WAbeLNfkbK6zQ==; 5:R+B507Lo0Fsyh6PgUIPIXmvIZMoJFpxzrrX4yVQM9QG2A1ZX825bPQdEmnDzpiGIXjCYab9I4abExswXyejr1JtEjuDOpcXF3M0PIhEC3uxVf/dh75I2mWPsR4mure5Y9vp0M5gSpvsjOG5RBXDvOfFzdEc4TYE4Ao+LczhJe/U=; 7:Iknuuq6Wz38RHiYG28ngzIIZ/Ja2IAWh+zEiJYRKlaMwjPmKkqC9cr/RuUHrhRvWnpIAGYsarnT8Aesrq4DgMS+iI4uRYAAbL8RISFHDMCJi6HKrvOkXl6D4W/DzmLk1tF3Iz19qcQ7M8zjsKHLFzA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: f40e6a9d-2368-437d-f4ce-08d66b787d59 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR12MB2757; x-ms-traffictypediagnostic: BYAPR12MB2757: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(3002001)(93006095)(93001095)(10201501046)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:BYAPR12MB2757; BCL:0; PCL:0; RULEID:; SRVR:BYAPR12MB2757; x-forefront-prvs: 0898A6E028 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(366004)(136003)(39860400002)(346002)(376002)(396003)(189003)(199004)(13464003)(2501003)(486006)(966005)(7696005)(186003)(110136005)(71200400001)(106356001)(53546011)(6506007)(4744004)(25786009)(6116002)(99286004)(102836004)(26005)(3846002)(478600001)(76176011)(71190400001)(229853002)(105586002)(5660300001)(11346002)(6436002)(446003)(9686003)(55016002)(6306002)(316002)(97736004)(53946003)(14454004)(53936002)(8936002)(6246003)(68736007)(476003)(81156014)(8676002)(305945005)(81166006)(256004)(14444005)(74316002)(86362001)(2906002)(66066001)(19627235002)(7736002)(33656002)(559001)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB2757; H:BYAPR12MB2743.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: O8x6BfmtyesqY4dnVHxRVw6DzWvESq7/uvM0SMN2gVg2T2cnTor53b82af05+5U472qRH0FVT2Fba7MV6P89K1CY/C+q7jKeK34fEHTj+semDN8VJc5jEm87kQ2Dj02riKLPWnc8vVZK1dZJlGmU010jw7LV4HjbpZAx6FAOs/63+iIV6Ay5rj3gcDlZO5r1tCYBIS/X+ZXsa/Ly5957hq02Hvyaia/jPPutYWYw4PxfO1AOv5VTYhwTljQMmcI2QPL0k/rOx4gMdfPI6CK66aLGw5+7JmkcWIQnNAEkUBE0LeJtjk4bM2yKOId7YHCk spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f40e6a9d-2368-437d-f4ce-08d66b787d59 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Dec 2018 21:24:16.0817 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2757 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1545859471; bh=KYUBcRObte96UY4Qx9bwuSZJIPfaf3jg8+ABR9MQGOI=; h=X-PGP-Universal:From:To:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:msip_labels:authentication-results: x-originating-ip:x-ms-publictraffictype: x-microsoft-exchange-diagnostics: x-ms-exchange-antispam-srfa-diagnostics: x-ms-office365-filtering-correlation-id:x-microsoft-antispam: x-ms-traffictypediagnostic:x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test:x-forefront-prvs: x-forefront-antispam-report:received-spf: x-ms-exchange-senderadcheck:x-microsoft-antispam-message-info: spamdiagnosticoutput:spamdiagnosticmetadata:MIME-Version: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg: Content-Language:Content-Type:Content-Transfer-Encoding; b=N4kM5RICMM/pKpBgie8sv9rWixBu7dfTbsOlKV0Bp2IKivqSg618cJ/QkrIQ9q7c/ bH9HO6cKq7xjZKGg1UwFX4CLPb3Vz+l36J7lo25ZGy0JxHY81Cdk9No1iNd5HujrNV RpPBch49YzEpM8n+xAwu9rACu3m0rLrFO/SkaMcSUUtTnIUdNpodthixoim8IO5rSv SDSZKnjiabfS9yGFd+ZTAXbgcJ7pre0HjtJiODs52XQVPPqnE/EizCWRFkIGZNkEc+ ZRn9v7VrZFsIAIz5wFMKsf3h1lLrUbVonI9Zss+w7oCjl/d5PjAGpiEhdqurvEyeld jAUM6lgNSvlEw== Subject: Re: [PATCH v7] MdeModulePkg/SdMmcPciHcDxe: Add SDMMC HC v4 and above Support. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Dec 2018 21:24:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello Hao, Do you happen to have any update on this? Thanks Ashish -----Original Message----- From: Wu, Hao A =20 Sent: Tuesday, December 18, 2018 6:47 PM To: Ashish Singhal ; edk2-devel@lists.01.org Subject: RE: [edk2] [PATCH v7] MdeModulePkg/SdMmcPciHcDxe: Add SDMMC HC v= 4 and above Support. Hi, Could you grant me some time for reviewing this patch? I will try to give you the feedbacks before the end of WW01 2019. Sorry f= or the potential delay. Best Regards, Hao Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = > Ashish Singhal > Sent: Wednesday, December 19, 2018 5:29 AM > To: edk2-devel@lists.01.org > Cc: Ashish Singhal > Subject: [edk2] [PATCH v7] MdeModulePkg/SdMmcPciHcDxe: Add SDMMC HC v4 = > and above Support. >=20 > Add SDMA, ADMA2 and 26b data length support. >=20 > If V4 64 bit address mode is enabled in compatibility register,=20 > program controller to enable V4 host mode and use appropriate SDMA=20 > registers supporting 64 bit addresses. >=20 > If V4 64 bit address mode is enabled in compatibility register,=20 > program controller to enable V4 host mode and use appropriate ADMA=20 > descriptors supporting 64 bit addresses. >=20 > If host controller version is above V4.0, enable ADMA2 with 26b data=20 > length support for better performance. HC 2 register is configured to=20 > use 26 bit data lengths and ADMA2 descriptors are configured appropriat= ely. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ashish Singhal > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 2 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 4 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 21 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 7 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 328 > +++++++++++++++++---- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 84 ++++-- > 6 files changed, 363 insertions(+), 83 deletions(-) mode change=20 > 100755 =3D> 100644 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > old mode 100755 > new mode 100644 > index 2d3fb68..0c5646f > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > @@ -707,7 +707,7 @@ EmmcSwitchClockFreq ( > // > // Convert the clock freq unit from MHz to KHz. > // > - Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000,=20 > Private- > >BaseClkFreq[Slot]); > + Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000,=20 > + Private- > >BaseClkFreq[Slot], Private->ControllerVersion[Slot]); > if (EFI_ERROR (Status)) { > return Status; > } > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c > index 68485c8..cdcdfa3 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c > @@ -864,7 +864,7 @@ SdCardSetBusMode ( > return Status; > } >=20 > - Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000,=20 > Private- > >BaseClkFreq[Slot]); > + Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000,=20 > + Private- > >BaseClkFreq[Slot], Private->ControllerVersion[Slot]); > if (EFI_ERROR (Status)) { > return Status; > } > @@ -1064,7 +1064,7 @@ SdCardIdentification ( > goto Error; > } >=20 > - SdMmcHcInitClockFreq (PciIo, Slot, Private->BaseClkFreq[Slot]); > + SdMmcHcInitClockFreq (PciIo, Slot, Private->BaseClkFreq[Slot],=20 > + Private- > >ControllerVersion[Slot]); >=20 > gBS->Stall (1000); >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index a87f8de..b5bc260 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -62,7 +62,9 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate =3D { > { // MaxCurrent > 0, > }, > - 0 // ControllerVersion > + { > + 0 // ControllerVersion > + } > }; >=20 > SD_DEVICE_PATH mSdDpTemplate =3D { > @@ -621,6 +623,14 @@ SdMmcPciHcDriverBindingStart ( > for (Slot =3D FirstBar; Slot < (FirstBar + SlotNum); Slot++) { > Private->Slot[Slot].Enable =3D TRUE; >=20 > + // > + // Get SD/MMC Pci Host Controller Version > + // > + Status =3D SdMmcHcGetControllerVersion (PciIo, Slot, &Private- > >ControllerVersion[Slot]); > + if (EFI_ERROR (Status)) { > + goto Done; > + } > + > Status =3D SdMmcHcGetCapability (PciIo, Slot, &Private->Capability= [Slot]); > if (EFI_ERROR (Status)) { > continue; > @@ -649,7 +659,14 @@ SdMmcPciHcDriverBindingStart ( > Private->BaseClkFreq[Slot] > )); >=20 > - Support64BitDma &=3D Private->Capability[Slot].SysBus64; > + // > + // If any of the slots does not support 64b system bus > + // do not enable 64b DMA in the PCI layer. > + // > + if (Private->Capability[Slot].SysBus64V3 =3D=3D 0 && > + Private->Capability[Slot].SysBus64V4 =3D=3D 0) { > + Support64BitDma =3D FALSE; > + } >=20 > Status =3D SdMmcHcGetMaxCurrent (PciIo, Slot, &Private- > >MaxCurrent[Slot]); > if (EFI_ERROR (Status)) { > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > index 8c1a589..1bb701a 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > @@ -2,6 +2,7 @@ >=20 > Provides some data structure definitions used by the SD/MMC host=20 > controller driver. >=20 > +Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015, Intel Corporation. All rights reserved.
This = > program and the accompanying materials are licensed and made=20 > available under the terms and conditions of the BSD License @@ -116,8=20 > +117,7 @@ typedef struct { > SD_MMC_HC_SLOT Slot[SD_MMC_HC_MAX_SLOT]; > SD_MMC_HC_SLOT_CAP Capability[SD_MMC_HC_MAX_SLOT]; > UINT64 MaxCurrent[SD_MMC_HC_MAX_SLOT]; > - > - UINT32 ControllerVersion; > + UINT16 ControllerVersion[SD_MMC_HC_MAX_= SLOT]; >=20 > // > // Some controllers may require to override base clock frequency @@ = > -150,7 +150,8 @@ typedef struct { > BOOLEAN Started; > UINT64 Timeout; >=20 > - SD_MMC_HC_ADMA_DESC_LINE *AdmaDesc; > + SD_MMC_HC_ADMA_32_DESC_LINE *Adma32Desc; > + SD_MMC_HC_ADMA_64_DESC_LINE *Adma64Desc; > EFI_PHYSICAL_ADDRESS AdmaDescPhy; > VOID *AdmaMap; > UINT32 AdmaPages; > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > index ddf6dcf..6086720 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > @@ -4,6 +4,7 @@ >=20 > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. >=20 > + Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved. > This program and the accompanying materials > are licensed and made available under the terms and conditions of=20 > the BSD License @@ -45,7 +46,8 @@ DumpCapabilityReg ( > DEBUG ((DEBUG_INFO, " Voltage 3.3 %a\n", Capability->Voltage= 33 ? > "TRUE" : "FALSE")); > DEBUG ((DEBUG_INFO, " Voltage 3.0 %a\n", Capability->Voltage= 30 ? > "TRUE" : "FALSE")); > DEBUG ((DEBUG_INFO, " Voltage 1.8 %a\n", Capability->Voltage= 18 ? > "TRUE" : "FALSE")); > - DEBUG ((DEBUG_INFO, " 64-bit Sys Bus %a\n", Capability->SysBus6= 4 ? > "TRUE" : "FALSE")); > + DEBUG ((DEBUG_INFO, " V4 64-bit Sys Bus %a\n", Capability- > >SysBus64V4 ? "TRUE" : "FALSE")); > + DEBUG ((DEBUG_INFO, " V3 64-bit Sys Bus %a\n", Capability- > >SysBus64V3 ? "TRUE" : "FALSE")); > DEBUG ((DEBUG_INFO, " Async Interrupt %a\n", Capability->AsyncIn= t ? > "TRUE" : "FALSE")); > DEBUG ((DEBUG_INFO, " SlotType ")); > if (Capability->SlotType =3D=3D 0x00) { @@ -417,6 +419,36 @@=20 > SdMmcHcWaitMmioSet ( } >=20 > /** > + Get the controller version information from the specified slot. > + > + @param[in] PciIo The PCI IO protocol instance. > + @param[in] Slot The slot number of the SD card to send t= he > command to. > + @param[out] Version The buffer to store the version informat= ion. > + > + @retval EFI_SUCCESS The operation executes successfully. > + @retval Others The operation fails. > + > +**/ > +EFI_STATUS > +SdMmcHcGetControllerVersion ( > + IN EFI_PCI_IO_PROTOCOL *PciIo, > + IN UINT8 Slot, > + OUT UINT16 *Version > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CTRL_VER, TRUE, > sizeof (UINT16), Version); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + *Version &=3D 0xFF; > + > + return EFI_SUCCESS; > +} > + > +/** > Software reset the specified SD/MMC host controller and enable all=20 > interrupts. >=20 > @param[in] Private A pointer to the SD_MMC_HC_PRIVATE_DATA > instance. > @@ -722,6 +754,7 @@ SdMmcHcStopClock ( > @param[in] Slot The slot number of the SD card to send the= =20command > to. > @param[in] ClockFreq The max clock frequency to be set. The uni= t is KHz. > @param[in] BaseClkFreq The base clock frequency of host controlle= r in > MHz. > + @param[in] ControllerVer The version of host controller. >=20 > @retval EFI_SUCCESS The clock is supplied successfully. > @retval Others The clock isn't supplied successfully. > @@ -732,14 +765,14 @@ SdMmcHcClockSupply ( > IN EFI_PCI_IO_PROTOCOL *PciIo, > IN UINT8 Slot, > IN UINT64 ClockFreq, > - IN UINT32 BaseClkFreq > + IN UINT32 BaseClkFreq, > + IN UINT16 ControllerVer > ) > { > EFI_STATUS Status; > UINT32 SettingFreq; > UINT32 Divisor; > UINT32 Remainder; > - UINT16 ControllerVer; > UINT16 ClockCtrl; >=20 > // > @@ -775,18 +808,15 @@ SdMmcHcClockSupply ( >=20 > DEBUG ((DEBUG_INFO, "BaseClkFreq %dMHz Divisor %d ClockFreq=20 > %dKhz\n", BaseClkFreq, Divisor, ClockFreq)); >=20 > - Status =3D SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CTRL_VER, TRUE,=20 > sizeof (ControllerVer), &ControllerVer); > - if (EFI_ERROR (Status)) { > - return Status; > - } > // > // Set SDCLK Frequency Select and Internal Clock Enable fields in=20 > Clock Control register. > // > - if (((ControllerVer & 0xFF) >=3D SD_MMC_HC_CTRL_VER_300) && > - ((ControllerVer & 0xFF) <=3D SD_MMC_HC_CTRL_VER_420)) { > + if ((ControllerVer >=3D SD_MMC_HC_CTRL_VER_300) && > + (ControllerVer <=3D SD_MMC_HC_CTRL_VER_420)) { > ASSERT (Divisor <=3D 0x3FF); > ClockCtrl =3D ((Divisor & 0xFF) << 8) | ((Divisor & 0x300) >> 2); > - } else if (((ControllerVer & 0xFF) =3D=3D 0) || ((ControllerVer & 0x= FF)=20 > =3D=3D 1)) { > + } else if ((ControllerVer =3D=3D SD_MMC_HC_CTRL_VER_100) || > + (ControllerVer =3D=3D SD_MMC_HC_CTRL_VER_200)) { > // > // Only the most significant bit can be used as divisor. > // > @@ -934,11 +964,62 @@ SdMmcHcSetBusWidth ( } >=20 > /** > + Configure V4 controller enhancements at initialization. > + > + @param[in] PciIo The PCI IO protocol instance. > + @param[in] Slot The slot number of the SD card to send the= > command to. > + @param[in] Capability The capability of the slot. > + @param[in] ControllerVer The version of host controller. > + > + @retval EFI_SUCCESS The clock is supplied successfully. > + > +**/ > +EFI_STATUS > +SdMmcHcInitV4Enhancements ( > + IN EFI_PCI_IO_PROTOCOL *PciIo, > + IN UINT8 Slot, > + IN SD_MMC_HC_SLOT_CAP Capability, > + IN UINT16 ControllerVer > + ) > +{ > + EFI_STATUS Status; > + UINT16 HostCtrl2; > + > + // > + // Check if controller version V4 or higher // if (ControllerVer=20 > + >=3D SD_MMC_HC_CTRL_VER_400) { > + HostCtrl2 =3D SD_MMC_HC_V4_EN; > + // > + // Check if V4 64bit support is available > + // > + if (Capability.SysBus64V4 !=3D 0) { > + HostCtrl2 |=3D SD_MMC_HC_64_ADDR_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 64 bit system bus support\n")); > + } > + // > + // Check if controller version V4.10 or higher > + // > + if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_410) { > + HostCtrl2 |=3D SD_MMC_HC_26_DATA_LEN_ADMA_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 26 bit data length ADMA > support\n")); > + } > + Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeo= f > (HostCtrl2), &HostCtrl2); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + } > + > + return EFI_SUCCESS; > +} > + > +/** > Supply SD/MMC card with lowest clock frequency at initialization. >=20 > @param[in] PciIo The PCI IO protocol instance. > @param[in] Slot The slot number of the SD card to send the= =20command > to. > @param[in] BaseClkFreq The base clock frequency of host controlle= r in > MHz. > + @param[in] ControllerVer The version of host controller. >=20 > @retval EFI_SUCCESS The clock is supplied successfully. > @retval Others The clock isn't supplied successfully. > @@ -948,7 +1029,8 @@ EFI_STATUS > SdMmcHcInitClockFreq ( > IN EFI_PCI_IO_PROTOCOL *PciIo, > IN UINT8 Slot, > - IN UINT32 BaseClkFreq > + IN UINT32 BaseClkFreq, > + IN UINT16 ControllerVer > ) > { > EFI_STATUS Status; > @@ -970,7 +1052,7 @@ SdMmcHcInitClockFreq ( > // Supply 400KHz clock frequency at initialization phase. > // > InitFreq =3D 400; > - Status =3D SdMmcHcClockSupply (PciIo, Slot, InitFreq, BaseClkFreq); > + Status =3D SdMmcHcClockSupply (PciIo, Slot, InitFreq, BaseClkFreq, > ControllerVer); > return Status; > } >=20 > @@ -1104,7 +1186,12 @@ SdMmcHcInitHost ( > PciIo =3D Private->PciIo; > Capability =3D Private->Capability[Slot]; >=20 > - Status =3D SdMmcHcInitClockFreq (PciIo, Slot,=20 > Private->BaseClkFreq[Slot]); > + Status =3D SdMmcHcInitV4Enhancements (PciIo, Slot, Capability,=20 > + Private- > >ControllerVersion[Slot]); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status =3D SdMmcHcInitClockFreq (PciIo, Slot,=20 > + Private->BaseClkFreq[Slot], > Private->ControllerVersion[Slot]); > if (EFI_ERROR (Status)) { > return Status; > } > @@ -1262,9 +1349,10 @@ SdMmcHcLedOnOff ( > /** > Build ADMA descriptor table for transfer. >=20 > - Refer to SD Host Controller Simplified spec 3.0 Section 1.13 for det= ails. > + Refer to SD Host Controller Simplified spec 4.2 Section 1.13 for det= ails. >=20 > @param[in] Trb The pointer to the SD_MMC_HC_TRB instance.= > + @param[in] ControllerVer The version of host controller. >=20 > @retval EFI_SUCCESS The ADMA descriptor table is created succe= ssfully. > @retval Others The ADMA descriptor table isn't created su= ccessfully. > @@ -1272,7 +1360,8 @@ SdMmcHcLedOnOff ( **/ EFI_STATUS =20 > BuildAdmaDescTable ( > - IN SD_MMC_HC_TRB *Trb > + IN SD_MMC_HC_TRB *Trb, > + IN UINT16 ControllerVer > ) > { > EFI_PHYSICAL_ADDRESS Data; > @@ -1280,49 +1369,93 @@ BuildAdmaDescTable ( > UINT64 Entries; > UINT32 Index; > UINT64 Remaining; > - UINT32 Address; > + UINT64 Address; > UINTN TableSize; > EFI_PCI_IO_PROTOCOL *PciIo; > EFI_STATUS Status; > UINTN Bytes; > + BOOLEAN AddressingMode64; > + BOOLEAN DataLength26; > + UINT32 AdmaMaxDataPerLine; > + UINT32 DescSize; > + VOID *AdmaDesc; > + > + AddressingMode64 =3D FALSE; > + DataLength26 =3D FALSE; > + AdmaMaxDataPerLine =3D ADMA_MAX_DATA_PER_LINE_16B; > + DescSize =3D sizeof (SD_MMC_HC_ADMA_32_DESC_LINE); > + AdmaDesc =3D NULL; >=20 > Data =3D Trb->DataPhy; > DataLen =3D Trb->DataLen; > PciIo =3D Trb->Private->PciIo; > + > // > - // Only support 32bit ADMA Descriptor Table > + // Detect whether 64bit addressing is supported. > // > - if ((Data >=3D 0x100000000ul) || ((Data + DataLen) > 0x100000000ul))= =20 > { > + if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_400) { > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > + =20 > + SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN, > SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN); > + if (!EFI_ERROR (Status)) { > + AddressingMode64 =3D TRUE; > + DescSize =3D sizeof (SD_MMC_HC_ADMA_64_DESC_LINE); > + } > + } > + // > + // Check for valid ranges in 32bit ADMA Descriptor Table // if=20 > + (!AddressingMode64 && > + ((Data >=3D 0x100000000ul) || ((Data + DataLen) >=20 > + 0x100000000ul))) { > return EFI_INVALID_PARAMETER; > } > // > - // Address field shall be set on 32-bit boundary (Lower 2-bit is=20 > always set to > 0) > - // for 32-bit address descriptor table. > + // Check address field alignment > // > - if ((Data & (BIT0 | BIT1)) !=3D 0) { > - DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is n= ot > aligned to 4 bytes boundary!\n", Data)); > + if (AddressingMode64) { > + // > + // Address field shall be set on 64-bit boundary (Lower 3-bit is=20 > + always set > to 0) > + // > + if ((Data & (BIT0 | BIT1 | BIT2)) !=3D 0) { > + DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc=20 > + is > not aligned to 8 bytes boundary!\n", Data)); > + } > + } else { > + // > + // Address field shall be set on 32-bit boundary (Lower 2-bit is=20 > + always set > to 0) > + // > + if ((Data & (BIT0 | BIT1)) !=3D 0) { > + DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc=20 > + is > not aligned to 4 bytes boundary!\n", Data)); > + } > + } > + // > + // Detect whether 26bit data length is supported. > + // > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > + SD_MMC_HC_26_DATA_LEN_ADMA_EN, > SD_MMC_HC_26_DATA_LEN_ADMA_EN); > + if (!EFI_ERROR (Status)) { > + DataLength26 =3D TRUE; > + AdmaMaxDataPerLine =3D ADMA_MAX_DATA_PER_LINE_26B; > } >=20 > - Entries =3D DivU64x32 ((DataLen + ADMA_MAX_DATA_PER_LINE - 1), > ADMA_MAX_DATA_PER_LINE); > - TableSize =3D (UINTN)MultU64x32 (Entries, sizeof=20 > (SD_MMC_HC_ADMA_DESC_LINE)); > + Entries =3D DivU64x32 ((DataLen + AdmaMaxDataPerLine - 1), > AdmaMaxDataPerLine); > + TableSize =3D (UINTN)MultU64x32 (Entries, DescSize); > Trb->AdmaPages =3D (UINT32)EFI_SIZE_TO_PAGES (TableSize); > Status =3D PciIo->AllocateBuffer ( > PciIo, > AllocateAnyPages, > EfiBootServicesData, > EFI_SIZE_TO_PAGES (TableSize), > - (VOID **)&Trb->AdmaDesc, > + (VOID **)&AdmaDesc, > 0 > ); > if (EFI_ERROR (Status)) { > return EFI_OUT_OF_RESOURCES; > } > - ZeroMem (Trb->AdmaDesc, TableSize); > + ZeroMem (AdmaDesc, TableSize); > Bytes =3D TableSize; > Status =3D PciIo->Map ( > PciIo, > EfiPciIoOperationBusMasterCommonBuffer, > - Trb->AdmaDesc, > + AdmaDesc, > &Bytes, > &Trb->AdmaDescPhy, > &Trb->AdmaMap > @@ -1335,12 +1468,13 @@ BuildAdmaDescTable ( > PciIo->FreeBuffer ( > PciIo, > EFI_SIZE_TO_PAGES (TableSize), > - Trb->AdmaDesc > + AdmaDesc > ); > return EFI_OUT_OF_RESOURCES; > } >=20 > - if ((UINT64)(UINTN)Trb->AdmaDescPhy > 0x100000000ul) { > + if ((!AddressingMode64) && > + (UINT64)(UINTN)Trb->AdmaDescPhy > 0x100000000ul) { > // > // The ADMA doesn't support 64bit addressing. > // > @@ -1351,35 +1485,71 @@ BuildAdmaDescTable ( > PciIo->FreeBuffer ( > PciIo, > EFI_SIZE_TO_PAGES (TableSize), > - Trb->AdmaDesc > + AdmaDesc > ); > return EFI_DEVICE_ERROR; > } >=20 > Remaining =3D DataLen; > - Address =3D (UINT32)Data; > + Address =3D Data; > + if (!AddressingMode64) { > + Trb->Adma32Desc =3D AdmaDesc; > + Trb->Adma64Desc =3D NULL; > + } else { > + Trb->Adma64Desc =3D AdmaDesc; > + Trb->Adma32Desc =3D NULL; > + } > for (Index =3D 0; Index < Entries; Index++) { > - if (Remaining <=3D ADMA_MAX_DATA_PER_LINE) { > - Trb->AdmaDesc[Index].Valid =3D 1; > - Trb->AdmaDesc[Index].Act =3D 2; > - Trb->AdmaDesc[Index].Length =3D (UINT16)Remaining; > - Trb->AdmaDesc[Index].Address =3D Address; > - break; > + if (!AddressingMode64) { > + if (Remaining <=3D AdmaMaxDataPerLine) { > + Trb->Adma32Desc[Index].Valid =3D 1; > + Trb->Adma32Desc[Index].Act =3D 2; > + if (DataLength26) { > + Trb->Adma32Desc[Index].UpperLength =3D (UINT16)(Remaining >>= =2016); > + } > + Trb->Adma32Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > + Trb->Adma32Desc[Index].Address =3D (UINT32)Address; > + break; > + } else { > + Trb->Adma32Desc[Index].Valid =3D 1; > + Trb->Adma32Desc[Index].Act =3D 2; > + if (DataLength26) { > + Trb->Adma32Desc[Index].UpperLength =3D 0; > + } > + Trb->Adma32Desc[Index].LowerLength =3D 0; > + Trb->Adma32Desc[Index].Address =3D (UINT32)Address; > + } > } else { > - Trb->AdmaDesc[Index].Valid =3D 1; > - Trb->AdmaDesc[Index].Act =3D 2; > - Trb->AdmaDesc[Index].Length =3D 0; > - Trb->AdmaDesc[Index].Address =3D Address; > + if (Remaining <=3D AdmaMaxDataPerLine) { > + Trb->Adma64Desc[Index].Valid =3D 1; > + Trb->Adma64Desc[Index].Act =3D 2; > + if (DataLength26) { > + Trb->Adma64Desc[Index].UpperLength =3D (UINT16)(Remaining >= > 16); > + } > + Trb->Adma64Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > + Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)(Address >> 32= ); > + break; > + } else { > + Trb->Adma64Desc[Index].Valid =3D 1; > + Trb->Adma64Desc[Index].Act =3D 2; > + if (DataLength26) { > + Trb->Adma64Desc[Index].UpperLength =3D 0; > + } > + Trb->Adma64Desc[Index].LowerLength =3D 0; > + Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)(Address >> 32= ); > + } > } >=20 > - Remaining -=3D ADMA_MAX_DATA_PER_LINE; > - Address +=3D ADMA_MAX_DATA_PER_LINE; > + Remaining -=3D AdmaMaxDataPerLine; > + Address +=3D AdmaMaxDataPerLine; > } >=20 > // > // Set the last descriptor line as end of descriptor table > // > - Trb->AdmaDesc[Index].End =3D 1; > + AddressingMode64 ? (Trb->Adma64Desc[Index].End =3D 1) : (Trb- > >Adma32Desc[Index].End =3D 1); > return EFI_SUCCESS; > } >=20 > @@ -1477,7 +1647,7 @@ SdMmcCreateTrb ( > Trb->Mode =3D SdMmcNoData; > } else if (Private->Capability[Slot].Adma2 !=3D 0) { > Trb->Mode =3D SdMmcAdmaMode; > - Status =3D BuildAdmaDescTable (Trb); > + Status =3D BuildAdmaDescTable (Trb,=20 > + Private->ControllerVersion[Slot]); > if (EFI_ERROR (Status)) { > PciIo->Unmap (PciIo, Trb->DataMap); > goto Error; > @@ -1523,11 +1693,18 @@ SdMmcFreeTrb ( > Trb->AdmaMap > ); > } > - if (Trb->AdmaDesc !=3D NULL) { > + if (Trb->Adma32Desc !=3D NULL) { > + PciIo->FreeBuffer ( > + PciIo, > + Trb->AdmaPages, > + Trb->Adma32Desc > + ); > + } > + if (Trb->Adma64Desc !=3D NULL) { > PciIo->FreeBuffer ( > PciIo, > Trb->AdmaPages, > - Trb->AdmaDesc > + Trb->Adma64Desc > ); > } > if (Trb->DataMap !=3D NULL) { > @@ -1667,12 +1844,15 @@ SdMmcExecTrb ( > UINT16 Cmd; > UINT16 IntStatus; > UINT32 Argument; > - UINT16 BlkCount; > + UINT32 BlkCount; > UINT16 BlkSize; > UINT16 TransMode; > UINT8 HostCtrl1; > - UINT32 SdmaAddr; > + UINT64 SdmaAddr; > UINT64 AdmaAddr; > + BOOLEAN AddressingMode64; > + > + AddressingMode64 =3D FALSE; >=20 > Packet =3D Trb->Packet; > PciIo =3D Trb->Private->PciIo; > @@ -1705,13 +1885,28 @@ SdMmcExecTrb ( >=20 > SdMmcHcLedOnOff (PciIo, Trb->Slot, TRUE); >=20 > + if (Private->ControllerVersion[Trb->Slot] >=3D=20 > + SD_MMC_HC_CTRL_VER_400) > { > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > + =20 > + SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN, > SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN); > + if (!EFI_ERROR (Status)) { > + AddressingMode64 =3D TRUE; > + } > + } > + > if (Trb->Mode =3D=3D SdMmcSdmaMode) { > - if ((UINT64)(UINTN)Trb->DataPhy >=3D 0x100000000ul) { > + if ((!AddressingMode64) && > + ((UINT64)(UINTN)Trb->DataPhy >=3D 0x100000000ul)) { > return EFI_INVALID_PARAMETER; > } >=20 > - SdmaAddr =3D (UINT32)(UINTN)Trb->DataPhy; > - Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, SD_MMC_HC_SDMA_ADDR,= > FALSE, sizeof (SdmaAddr), &SdmaAddr); > + SdmaAddr =3D (UINT64)(UINTN)Trb->DataPhy; > + > + if (Private->ControllerVersion[Trb->Slot] >=3D=20 > + SD_MMC_HC_CTRL_VER_400) > { > + Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, > SD_MMC_HC_ADMA_SYS_ADDR, FALSE, sizeof (UINT64), &SdmaAddr); > + } else { > + Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, > SD_MMC_HC_SDMA_ADDR, FALSE, sizeof (UINT32), &SdmaAddr); > + } > + > if (EFI_ERROR (Status)) { > return Status; > } > @@ -1741,9 +1936,13 @@ SdMmcExecTrb ( > // > // Calcuate Block Count. > // > - BlkCount =3D (UINT16)(Trb->DataLen / Trb->BlockSize); > + BlkCount =3D (Trb->DataLen / Trb->BlockSize); } if=20 > + (Private->ControllerVersion[Trb->Slot] >=3D SD_MMC_HC_CTRL_VER_410) > { > + Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, SD_MMC_HC_SDMA_ADDR, > FALSE, sizeof (UINT32), &BlkCount); > + } else { > + Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, SD_MMC_HC_BLK_COUNT, > FALSE, sizeof (UINT16), &BlkCount); > } > - Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, SD_MMC_HC_BLK_COUNT, > FALSE, sizeof (BlkCount), &BlkCount); > if (EFI_ERROR (Status)) { > return Status; > } > @@ -1839,7 +2038,7 @@ SdMmcCheckTrbResult ( > EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; > UINT16 IntStatus; > UINT32 Response[4]; > - UINT32 SdmaAddr; > + UINT64 SdmaAddr; > UINT8 Index; > UINT8 SwReset; > UINT32 PioLength; > @@ -1963,8 +2162,19 @@ SdMmcCheckTrbResult ( > // > // Update SDMA Address register. > // > - SdmaAddr =3D SD_MMC_SDMA_ROUND_UP ((UINT32)(UINTN)Trb- > >DataPhy, SD_MMC_SDMA_BOUNDARY); > - Status =3D SdMmcHcRwMmio ( > + SdmaAddr =3D SD_MMC_SDMA_ROUND_UP ((UINTN)Trb->DataPhy, > SD_MMC_SDMA_BOUNDARY); > + > + if (Private->ControllerVersion[Trb->Slot] >=3D=20 > + SD_MMC_HC_CTRL_VER_400) > { > + Status =3D SdMmcHcRwMmio ( > + Private->PciIo, > + Trb->Slot, > + SD_MMC_HC_ADMA_SYS_ADDR, > + FALSE, > + sizeof (UINT64), > + &SdmaAddr > + ); > + } else { > + Status =3D SdMmcHcRwMmio ( > Private->PciIo, > Trb->Slot, > SD_MMC_HC_SDMA_ADDR, @@ -1972,10 +2182,12 @@=20 > SdMmcCheckTrbResult ( > sizeof (UINT32), > &SdmaAddr > ); > + } > + > if (EFI_ERROR (Status)) { > goto Done; > } > - Trb->DataPhy =3D (UINT32)(UINTN)SdmaAddr; > + Trb->DataPhy =3D (UINT64)(UINTN)SdmaAddr; > } >=20 > if ((Packet->SdMmcCmdBlk->CommandType !=3D SdMmcCommandTypeAdtc) && = > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > index dd45cbd..d157f2c 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > @@ -2,6 +2,7 @@ >=20 > Provides some data structure definitions used by the SD/MMC host=20 > controller driver. >=20 > +Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015, Intel Corporation. All rights reserved.
This = > program and the accompanying materials are licensed and made=20 > available under the terms and conditions of the BSD License @@ -91,18=20 > +92,38 @@ typedef enum { // // The maximum data length of each=20 > descriptor line // > -#define ADMA_MAX_DATA_PER_LINE 0x10000 > +#define ADMA_MAX_DATA_PER_LINE_16B SIZE_64KB > +#define ADMA_MAX_DATA_PER_LINE_26B SIZE_64MB >=20 > +// > +// ADMA descriptor for 32b addressing. > +// > typedef struct { > UINT32 Valid:1; > UINT32 End:1; > UINT32 Int:1; > UINT32 Reserved:1; > UINT32 Act:2; > - UINT32 Reserved1:10; > - UINT32 Length:16; > + UINT32 UpperLength:10; > + UINT32 LowerLength:16; > UINT32 Address; > -} SD_MMC_HC_ADMA_DESC_LINE; > +} SD_MMC_HC_ADMA_32_DESC_LINE; > + > +// > +// ADMA descriptor for 64b addressing. > +// > +typedef struct { > + UINT32 Valid:1; > + UINT32 End:1; > + UINT32 Int:1; > + UINT32 Reserved:1; > + UINT32 Act:2; > + UINT32 UpperLength:10; > + UINT32 LowerLength:16; > + UINT32 LowerAddress; > + UINT32 UpperAddress; > + UINT32 Reserved1; > +} SD_MMC_HC_ADMA_64_DESC_LINE; >=20 > #define SD_MMC_SDMA_BOUNDARY 512 * 1024 > #define SD_MMC_SDMA_ROUND_UP(x, n) (((x) + n) & ~(n - 1)) > @@ -129,36 +150,43 @@ typedef struct { > UINT32 Voltage33:1; // bit 24 > UINT32 Voltage30:1; // bit 25 > UINT32 Voltage18:1; // bit 26 > - UINT32 Reserved3:1; // bit 27 > - UINT32 SysBus64:1; // bit 28 > + UINT32 SysBus64V4:1; // bit 27 > + UINT32 SysBus64V3:1; // bit 28 > UINT32 AsyncInt:1; // bit 29 > UINT32 SlotType:2; // bit 30:31 > UINT32 Sdr50:1; // bit 32 > UINT32 Sdr104:1; // bit 33 > UINT32 Ddr50:1; // bit 34 > - UINT32 Reserved4:1; // bit 35 > + UINT32 Reserved3:1; // bit 35 > UINT32 DriverTypeA:1; // bit 36 > UINT32 DriverTypeC:1; // bit 37 > UINT32 DriverTypeD:1; // bit 38 > UINT32 DriverType4:1; // bit 39 > UINT32 TimerCount:4; // bit 40:43 > - UINT32 Reserved5:1; // bit 44 > + UINT32 Reserved4:1; // bit 44 > UINT32 TuningSDR50:1; // bit 45 > UINT32 RetuningMod:2; // bit 46:47 > UINT32 ClkMultiplier:8; // bit 48:55 > - UINT32 Reserved6:7; // bit 56:62 > + UINT32 Reserved5:7; // bit 56:62 > UINT32 Hs400:1; // bit 63 > } SD_MMC_HC_SLOT_CAP; >=20 > // > // SD Host controller version > // > -#define SD_MMC_HC_CTRL_VER_100 0x00 > -#define SD_MMC_HC_CTRL_VER_200 0x01 > -#define SD_MMC_HC_CTRL_VER_300 0x02 > -#define SD_MMC_HC_CTRL_VER_400 0x03 > -#define SD_MMC_HC_CTRL_VER_410 0x04 > -#define SD_MMC_HC_CTRL_VER_420 0x05 > +#define SD_MMC_HC_CTRL_VER_100 0x00 > +#define SD_MMC_HC_CTRL_VER_200 0x01 > +#define SD_MMC_HC_CTRL_VER_300 0x02 > +#define SD_MMC_HC_CTRL_VER_400 0x03 > +#define SD_MMC_HC_CTRL_VER_410 0x04 > +#define SD_MMC_HC_CTRL_VER_420 0x05 > + > +// > +// SD Host controller V4 enhancements // > +#define SD_MMC_HC_V4_EN BIT12 > +#define SD_MMC_HC_64_ADDR_EN BIT13 > +#define SD_MMC_HC_26_DATA_LEN_ADMA_EN BIT10 >=20 > /** > Dump the content of SD/MMC host controller's Capability Register. > @@ -323,6 +351,24 @@ SdMmcHcWaitMmioSet ( > ); >=20 > /** > + Get the controller version information from the specified slot. > + > + @param[in] PciIo The PCI IO protocol instance. > + @param[in] Slot The slot number of the SD card to send t= he > command to. > + @param[out] Version The buffer to store the version informat= ion. > + > + @retval EFI_SUCCESS The operation executes successfully. > + @retval Others The operation fails. > + > +**/ > +EFI_STATUS > +SdMmcHcGetControllerVersion ( > + IN EFI_PCI_IO_PROTOCOL *PciIo, > + IN UINT8 Slot, > + OUT UINT16 *Version > + ); > + > +/** > Set all interrupt status bits in Normal and Error Interrupt Status E= nable > register. >=20 > @@ -424,6 +470,7 @@ SdMmcHcStopClock ( > @param[in] Slot The slot number of the SD card to send the= =20command > to. > @param[in] ClockFreq The max clock frequency to be set. The uni= t is KHz. > @param[in] BaseClkFreq The base clock frequency of host controlle= r in > MHz. > + @param[in] ControllerVer The version of host controller. >=20 > @retval EFI_SUCCESS The clock is supplied successfully. > @retval Others The clock isn't supplied successfully. > @@ -434,7 +481,8 @@ SdMmcHcClockSupply ( > IN EFI_PCI_IO_PROTOCOL *PciIo, > IN UINT8 Slot, > IN UINT64 ClockFreq, > - IN UINT32 BaseClkFreq > + IN UINT32 BaseClkFreq, > + IN UINT16 ControllerVer > ); >=20 > /** > @@ -483,6 +531,7 @@ SdMmcHcSetBusWidth ( > @param[in] PciIo The PCI IO protocol instance. > @param[in] Slot The slot number of the SD card to send the= =20command > to. > @param[in] BaseClkFreq The base clock frequency of host controlle= r in > MHz. > + @param[in] ControllerVer The version of host controller. >=20 > @retval EFI_SUCCESS The clock is supplied successfully. > @retval Others The clock isn't supplied successfully. > @@ -492,7 +541,8 @@ EFI_STATUS > SdMmcHcInitClockFreq ( > IN EFI_PCI_IO_PROTOCOL *PciIo, > IN UINT8 Slot, > - IN UINT32 BaseClkFreq > + IN UINT32 BaseClkFreq, > + IN UINT16 ControllerVer > ); >=20 > /** > -- > 2.7.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ----------