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 112A821A07A82 for ; Mon, 19 Nov 2018 12:33:17 -0800 (PST) Received: from hkpgpgate101.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 20 Nov 2018 04:33:16 +0800 Received: from HKMAIL103.nvidia.com ([10.18.16.12]) by hkpgpgate101.nvidia.com (PGP Universal service); Mon, 19 Nov 2018 12:33:15 -0800 X-PGP-Universal: processed; by hkpgpgate101.nvidia.com on Mon, 19 Nov 2018 12:33:15 -0800 Received: from HKMAIL104.nvidia.com (10.18.16.13) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 19 Nov 2018 20:33:14 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (216.32.180.22) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Mon, 19 Nov 2018 20:33:14 +0000 Received: from BN7PR12MB2740.namprd12.prod.outlook.com (20.176.178.96) by BN7PR12MB2658.namprd12.prod.outlook.com (20.176.176.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Mon, 19 Nov 2018 20:32:55 +0000 Received: from BN7PR12MB2740.namprd12.prod.outlook.com ([fe80::bd6d:d427:7872:e6c2]) by BN7PR12MB2740.namprd12.prod.outlook.com ([fe80::bd6d:d427:7872:e6c2%5]) with mapi id 15.20.1339.021; Mon, 19 Nov 2018 20:32:55 +0000 From: Ashish Singhal To: "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH 2/2] MdeModulePkg/SdMmcPciHcDxe: Add V4 64bit ADMA2 support. Thread-Index: AQHUd5S1/yTaQabCrUa6INIHJ2aYPKVSHQ6AgAWBbcA= Date: Mon, 19 Nov 2018 20:32:54 +0000 Message-ID: References: <4d91387d2b96ec0b20b2aa78aaacc921ae258d0f.1541703096.git.ashishsingha@nvidia.com> <389f4c6aa77dc85f23d70a524f2fda4e4212a74a.1541703096.git.ashishsingha@nvidia.com> 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-11-19T20:32:53.2098226Z; 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: [216.228.112.21] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BN7PR12MB2658; 6:cO5hz+i1TJPy1QvkzGB89AaIYfLNlhCecsd5udqKvC1Hv/jTy8uVhJhPQQIUPU1/eJ7hGrlMbpRwM6lVledFPbiTMnnPCmWn9yqfHXv8r/ulIrSJ0rpfJcDHiEauExbcH1SMSAor85bwhwTgqHYJGBsltj6RJl7ooBPAbCz0lTU8g6LH0OyYugEQyaZbg10RnLsMPbKgrvYtowmoLitb8HKtT1/LW3L91BsIl/F4XJm6c0VgIWMWeJK3ES2kPV0/vMyxXJtHtRMyIWyUve1AbTGl93p9fLgQIHaa8hoR1DiGKIaPxwjSeheo4l12eomAXpYBQ/DLqPUDgDJdSA9vdH1BkdXh1eDFHGaLTBrqEDNyatluHy2dfOQ3UjoWW9pbP+QqAeQTPwYdmTCXxFbfN+4skTxswCKNHWhjcaadvbR1Ut0Oef8XsgwUdfE/R3jSvX15EXS24Wg4BYJrLPsiOg==; 5:94I8oRyescTICqGEPXAKHbbrCL4t76wWj3qz9Zi9IFoA3MGhYqEYGgeJHym3pnjyIGjee+VXzW0YpMW0m+lD0Ii3TsQ1qAhu0RAC0NzXLd5bDIQm1EC0roYCWkEES7qmkFPbsjAYKRqcmryedhGL7/4oMhxvau2e9l/d6esgUq0=; 7:Aa3UldZku/+V3MVsRCmL3He3zMMsczEjoaElDBS/+jX+jjNazk/LIqyfVDo6cbo8UVLtVpFcAP9AGWd2ewYfJeW+XpKINLAWKLH1VM78O+sLgnSsR7wNXlUtliOTBs2woqwa4a8dFxw+hqpLS9Mlbg== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: be8b0011-b619-4c4b-76d1-08d64e5e2f8e x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BN7PR12MB2658; x-ms-traffictypediagnostic: BN7PR12MB2658: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231437)(944501410)(52105112)(3002001)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:BN7PR12MB2658; BCL:0; PCL:0; RULEID:; SRVR:BN7PR12MB2658; x-forefront-prvs: 08617F610C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(346002)(136003)(376002)(366004)(396003)(39850400004)(51874003)(189003)(199004)(13464003)(305945005)(478600001)(316002)(110136005)(229853002)(105586002)(106356001)(7736002)(966005)(97736004)(2900100001)(2501003)(5660300001)(25786009)(33656002)(74316002)(14444005)(19627235002)(256004)(68736007)(3846002)(6116002)(53546011)(6506007)(26005)(186003)(102836004)(81156014)(7696005)(76176011)(6246003)(8936002)(53936002)(14454004)(6436002)(8676002)(55016002)(66066001)(53946003)(6306002)(2906002)(4744004)(446003)(11346002)(9686003)(71200400001)(71190400001)(476003)(81166006)(86362001)(99286004)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR12MB2658; H:BN7PR12MB2740.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-microsoft-antispam-message-info: K1N5wDWk3vkfqXMXE8RgJsJxxSKSOTS/bAsk7J0XudihHzUbAD6xrZR2k4+yPH3lHdF0v4R77zlvpAjg2I3PmnJP8QbpaA8a0eHxvYgniw0oxXY7dnUDJWqIv1N52Y8vwfFNPMA75VjEMrUzV8mhGq7aaivrmj28MvORcAfnKg0kor+xklVssPGlgRKmmzB5sCsfHaxXPpiXxekChggD/xSdQTqk2kNLf7AgWDg99FKSEEAipo4XJmW6Gu1XaAvcRPYSYmUBW+Rz0uP0r8F/DQF2T+WETiVj8vK05wI2ZJmIt4deEKinFpjVaGdSoEGwKv2QjwTlQKciX/+neiIL0CKFcNVTN/7G9yGfVd+BWE8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: be8b0011-b619-4c4b-76d1-08d64e5e2f8e X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2018 20:32:55.0371 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2658 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1542659596; bh=Yab1E0JWTGrY905+VCUPFVkRIkIIRrGv4ofn0hQQ/hs=; 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-ms-exchange-senderadcheck:x-exchange-antispam-report-cfa-test: x-forefront-prvs:x-forefront-antispam-report:received-spf: 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=IS1tdd+V49CuYWvun+XpwvYykRSXAk5GNUEpc20b4H1MMZMCLEA8h9fpjhziGmc5W IXeqsHEeb2YE/DulLNTJVk1GoUvQjzFgCm4VakvBL/RmJREsZRBXX80eI4AF2cIR1h fnpwXUk5yZiT97CiaST1sIDo7NfYMbBpwV3wJjXzmEFMTKf9/YtqzJUWJNDXSD0x97 iCUpLgntedeb1HiR46km/3kUxm19DUYTgA+PF27VV5bSn8RpS2fyF1A4XH9jTAqfDo 0seUoZdxslxGiIEe33DGNNGgn5LK5gT+FV5JTEb8GackVUZaSDOw4KSan5vvKDdOCs pgEmfocaABUow== Subject: Re: [PATCH 2/2] MdeModulePkg/SdMmcPciHcDxe: Add V4 64bit ADMA2 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: Mon, 19 Nov 2018 20:33:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I was planning on submitting SDMA changes as a separate patch but that wo= uld have broken SDMA if only ADMA2 patch would have been picked. I have s= ent V2 patches which combine SDMA as well as ADMA2 changes. I have tested= =20the changes to be working on V3 as well V4 mode usage both with and wi= thout enabling 64b addressing support. Thanks Ashish -----Original Message----- From: Wu, Hao A =20 Sent: Friday, November 16, 2018 1:27 AM To: Ashish Singhal ; edk2-devel@lists.01.org Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/SdMmcPciHcDxe: Add V4 64bit = ADMA2 support. > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = > Ashish Singhal > Sent: Friday, November 09, 2018 2:58 AM > To: edk2-devel@lists.01.org > Cc: Ashish Singhal > Subject: [edk2] [PATCH 2/2] MdeModulePkg/SdMmcPciHcDxe: Add V4 64bit > ADMA2 support. >=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. Hi, I have a quick check on the SD Host Controller Simplified Specification V= ersion 4.20. When the 'Host Version 4 Enable' bit in the HC2 Register is = set, for host controller with version newer than 3.0: SDMA mode transfer no longer use SDMA System Address Register for system = address, and this SDMA System Address Register will be used as 32-bit Blo= ck Count instead under certain case. So I think the way to start an SDMA mode transfer is not the same between= =20host controllers with different versions. However, I do not see this p= atch handle this potential behavior change. Please correct me if my under= standing is incorrect here. Also, could you help to provide information on what tests have been perfo= rmed on this series? Thanks in advance. Best Regards, Hao Wu >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ashish Singhal > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 4 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 183 > +++++++++++++++++---- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 28 +++- > 3 files changed, 183 insertions(+), 32 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > index c683600..22795df 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 @@ -144,7=20 > +145,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 e506875..bcd2707 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 @@ -418,6 +419,36 @@ 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. > @@ -776,18 +807,18 @@ 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); > + Status =3D SdMmcHcGetControllerVersion (PciIo, Slot, &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 0) || (ControllerVer =3D=3D 1)) { > // > // Only the most significant bit can be used as divisor. > // > @@ -935,6 +966,41 @@ SdMmcHcSetBusWidth ( } >=20 > /** > + Configure V4 64 bit system address support at initialization. > + > + @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] Capability The capability of the slot. > + > + @retval EFI_SUCCESS The clock is supplied successfully. > + > +**/ > +EFI_STATUS > +SdMmcHcV4Init64BitSupport ( > + IN EFI_PCI_IO_PROTOCOL *PciIo, > + IN UINT8 Slot, > + IN SD_MMC_HC_SLOT_CAP Capability > + ) > +{ > + EFI_STATUS Status; > + UINT16 HostCtrl2; > + > + // > + // Check if V4 64bit support is available // if=20 > + (Capability.SysBus64V4 =3D=3D TRUE) { > + HostCtrl2 =3D SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN; > + Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeo= f > (HostCtrl2), &HostCtrl2); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + DEBUG ((DEBUG_INFO, "Enabled V4 64 bit system bus support\n")); =20 > + } > + > + return EFI_SUCCESS; > +} > + > +/** > Supply SD/MMC card with lowest clock frequency at initialization. >=20 > @param[in] PciIo The PCI IO protocol instance. > @@ -1101,6 +1167,11 @@ SdMmcHcInitHost ( > PciIo =3D Private->PciIo; > Capability =3D Private->Capability[Slot]; >=20 > + Status =3D SdMmcHcV4Init64BitSupport (PciIo, Slot, Capability); if = > + (EFI_ERROR (Status)) { > + return Status; > + } > + > Status =3D SdMmcHcInitClockFreq (PciIo, Slot, Capability); > if (EFI_ERROR (Status)) { > return Status; > @@ -1169,7 +1240,7 @@ 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.= >=20 > @@ -1187,49 +1258,69 @@ BuildAdmaDescTable ( > UINT64 Entries; > UINT32 Index; > UINT64 Remaining; > - UINT32 Address; > + UINT64 Address; > UINTN TableSize; > EFI_PCI_IO_PROTOCOL *PciIo; > EFI_STATUS Status; > UINTN Bytes; > + UINT16 ControllerVer; > + BOOLEAN AddressingMode64 =3D FALSE; > + UINTN DescSize =3D sizeof (SD_MMC_HC_ADMA_32_DES= C_LINE); > + VOID *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 > { > + Status =3D SdMmcHcGetControllerVersion (PciIo, Trb->Slot,=20 > + &ControllerVer); if (EFI_ERROR (Status)) { > + return Status; > + } > + if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_400) { > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, 0x2, > + =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 =3D=3D FALSE && > + ((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. > // > if ((Data & (BIT0 | BIT1)) !=3D 0) { > DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is=20 > not aligned to 4 bytes boundary!\n", Data)); > } >=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)); > + 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 > @@ -1242,12 +1333,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 =3D=3D FALSE) && > + (UINT64)(UINTN)Trb->AdmaDescPhy > 0x100000000ul) { > // > // The ADMA doesn't support 64bit addressing. > // > @@ -1258,25 +1350,49 @@ 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 =3D=3D FALSE) { > + 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 =3D=3D FALSE) { > + if (Remaining < ADMA_MAX_DATA_PER_LINE) { > + Trb->Adma32Desc[Index].Valid =3D 1; > + Trb->Adma32Desc[Index].Act =3D 2; > + Trb->Adma32Desc[Index].Length =3D (UINT16)Remaining; > + Trb->Adma32Desc[Index].Address =3D (UINT32)Address; > + break; > + } else { > + Trb->Adma32Desc[Index].Valid =3D 1; > + Trb->Adma32Desc[Index].Act =3D 2; > + Trb->Adma32Desc[Index].Length =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 < ADMA_MAX_DATA_PER_LINE) { > + Trb->Adma64Desc[Index].Valid =3D 1; > + Trb->Adma64Desc[Index].Act =3D 2; > + Trb->Adma64Desc[Index].Length =3D (UINT16)Remaining; > + Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)(Address & > MAX_UINT32); > + Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)(Address>>32);= > + break; > + } else { > + Trb->Adma64Desc[Index].Valid =3D 1; > + Trb->Adma64Desc[Index].Act =3D 2; > + Trb->Adma64Desc[Index].Length =3D 0; > + Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)(Address & > MAX_UINT32); > + Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)(Address>>32);= > + } > } >=20 > Remaining -=3D ADMA_MAX_DATA_PER_LINE; @@ -1286,7 +1402,7 @@=20 > BuildAdmaDescTable ( > // > // 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 > @@ -1430,11 +1546,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) { > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > index cc138fc..a6234f1 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 @@ -78,6=20 > +79,9 @@ typedef enum { // > #define ADMA_MAX_DATA_PER_LINE 0x10000 >=20 > +// > +// ADMA descriptor for 32b addressing. > +// > typedef struct { > UINT32 Valid:1; > UINT32 End:1; > @@ -87,7 +91,23 @@ typedef struct { > UINT32 Reserved1:10; > UINT32 Length: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 Reserved1:10; > + UINT32 Length:16; > + UINT32 LowerAddress; > + UINT32 UpperAddress; > + UINT32 Reserved2; > +} 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)) > @@ -145,6 +165,12 @@ typedef struct { > #define SD_MMC_HC_CTRL_VER_410 0x04 > #define SD_MMC_HC_CTRL_VER_420 0x05 >=20 > +// > +// SD Host controller V4 Support > +// > +#define SD_MMC_HC_V4_EN BIT12 > +#define SD_MMC_HC_64_ADDR_EN BIT13 > + > /** > Dump the content of SD/MMC host controller's Capability Register. >=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. -------------------------------------------------------------------------= ----------