From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.81.107; helo=nam01-by2-obe.outbound.protection.outlook.com; envelope-from=mike.li@bayhubtech.com; receiver=edk2-devel@lists.01.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810107.outbound.protection.outlook.com [40.107.81.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BC69B211B85CC for ; Mon, 28 Jan 2019 17:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=towerbridgetechnology.onmicrosoft.com; s=selector1-bayhubtech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E+VIul5uv0QimhUX0CbkzYzwi2nI+Mjfcuc14ohtLkk=; b=hJIAfDvPsJ9LYChmcJRFjRfhCVm/0HXZrf83b8JSUI5QbtCtKhNIdz8YS/CTPcXYgncAOVwYGT+VDqzAgHBsbOXTi6mp45xLw5BRVikLFGQBbQVhnmHXrOtP+wrQTi+wgX4ms8FGbD5JnAExTPpEwC79PYReTnb9SYWs9tI+EfA= Received: from MWHPR16MB1679.namprd16.prod.outlook.com (10.172.59.149) by MWHPR16MB1534.namprd16.prod.outlook.com (10.175.5.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Tue, 29 Jan 2019 01:47:44 +0000 Received: from MWHPR16MB1679.namprd16.prod.outlook.com ([fe80::151:66e0:7431:2f5d]) by MWHPR16MB1679.namprd16.prod.outlook.com ([fe80::151:66e0:7431:2f5d%10]) with mapi id 15.20.1558.021; Tue, 29 Jan 2019 01:47:43 +0000 From: "Mike Li (WH)" To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH 2/2] add support bh720+emmc chip Thread-Index: AQHUt3SgpoG6DPO7Mka2H/i7DknwTg== Date: Tue, 29 Jan 2019 01:47:43 +0000 Message-ID: References: <89a247208056d3f458a20e9f335d03d9f54c1c9a.1548669154.git.mike.li@bayhubtech.com> In-Reply-To: <89a247208056d3f458a20e9f335d03d9f54c1c9a.1548669154.git.mike.li@bayhubtech.com> Accept-Language: en-AU, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR02CA0189.apcprd02.prod.outlook.com (2603:1096:201:21::25) To MWHPR16MB1679.namprd16.prod.outlook.com (2603:10b6:301:17::21) x-mailer: git-send-email 2.19.1.windows.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=mike.li@bayhubtech.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [223.104.20.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR16MB1534; 6:BRwjNuXm0MsLkc+DedopIJrcotMRfVeEwvp9oOL2JIdSJ2bpa06XdxZbyrJkberoOM7UCGwYvrq+bBEXIVzQ2enOBs9/nf3L103TB25ZDJZoxxQVI/jkOKMnYNZJmVGIAHE1tm8/hVfMDlFKWtq5UICZei7c1JP53AcQckdE3ZmQM2jW/LMd9OzpAhh9gxbt1YmzBih4PJ0JDfijoSO1j4Y9oJk2OExr5S0gmDm/UH9eUQfzGZ05by3QKSzrsY+F5fP0EH4A1iFSadD7eMXGe4Hu816eFzy8o21oFtR9QAL8XbkEXtl3ucAMoS+jwhqvKp0kfDfPz5bFbSzEON1KeMBonLeB9UVjBSt4jBc6GAuZJIpRNmkb92ufsL0mvYl5VP194Rs0gNi9zR9bi7tMSy88odaTaJj0eyDAOlwcowr3dRwBS/AG2kdUJqcpl/h0uakIBCBbifSa4hXr8ohXTA==; 5:UQoL714jKEkOCixQtz/eQST1CQ0lQ30kNU1FUjQKvoLjSGE6wIabc0Q/vB5BU9ePn/WfWhXjPIHJC0mJa0hsPgwrHrqBKiVwdyNRJwTiDu5vZHPtTgYjfNS0TAWsft5Ph81CuMKJ+x9y90b2Dwal+Jovg6heKJy4937DoAEHeKHMLjFSMBH22b8ZwU2/0eiocqGBN5jtCgqiJJ9A94d1JQ==; 7:ZfPCCvjk+2teDT3tnMkg1upPSnooZZPQo9dXAgmziROvw7xjpBNAEqcqXmsFTDNZs3vtSJqRGuC8ioO/Btj1jAhSYOR2wIigjFTZU7CUBVphpfYpZ50uY+lIn8mXdl+dQ6m1oDSubpZuP6Ga0nmSjA== x-ms-office365-filtering-correlation-id: 1b512d27-a888-40ee-04b2-08d6858bc28c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020); SRVR:MWHPR16MB1534; x-ms-traffictypediagnostic: MWHPR16MB1534: x-microsoft-antispam-prvs: x-forefront-prvs: 093290AD39 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(396003)(136003)(376002)(39830400003)(366004)(199004)(189003)(52116002)(30864003)(476003)(76176011)(186003)(2616005)(6512007)(2906002)(71200400001)(316002)(71190400001)(446003)(11346002)(386003)(50226002)(486006)(25786009)(118296001)(97736004)(2351001)(105586002)(508600001)(26005)(14454004)(102836004)(53946003)(6506007)(68736007)(53936002)(106356001)(5640700003)(5024004)(81166006)(256004)(81156014)(7736002)(6486002)(99286004)(3846002)(6116002)(86362001)(36756003)(8936002)(2501003)(305945005)(6916009)(66066001)(8676002)(6436002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR16MB1534; H:MWHPR16MB1679.namprd16.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bayhubtech.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 7+c+crE6rcWv9JXPuC92HnAYHIiXq6EFByJ1mh3R2y/w5uBNkpMC6tKqr7MroUBmuMwbNv+a+1h/oYARJvjf81911GAzDYgg3J0pyrrNjZlBVeRB+blNSU3CIwJxy+za9yIdYJKB1V3yXXU8GhDFEQEi/PlZCbs0VvB5gRHx2sCyWMtEoSQQ3kiBLlLPRg8CifvSTIfK77VrlpRTPIMgjfUaU7rEBNwf1MsBvb0Ckwxh2O7t1lMI3gVqQe/ksiG+hLukDEPleeo9XS12eLHJfqmr0D29n7HuWFDpMXfKCjWzj/EBOXk4HfLvDPY8zX6SxM3F5ZPSB7RVIESmS9hAVP3w3I5MzUXQ9rPlKmMOPg+SnwZZXHgyJTvwIa8HOIcx2WYnSW+vSZoY+0IK7M2d0u854c1MeIaf1kFM+GcsNfE= MIME-Version: 1.0 X-OriginatorOrg: bayhubtech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b512d27-a888-40ee-04b2-08d6858bc28c X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2019 01:47:42.3492 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0a7aae2b-8f2e-44df-ba2f-42de7f93c642 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR16MB1534 Subject: [PATCH 2/2] add support bh720+emmc chip 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: Tue, 29 Jan 2019 01:47:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 147 ++++++++++++++---- .../Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 130 +++++++--------- 2 files changed, 174 insertions(+), 103 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/B= us/Pci/SdMmcPciHcDxe/SdDevice.c index 83e6bf0c90..4f38eca199 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c @@ -319,9 +319,116 @@ SdCardSetRca ( return Status; } =20 +/** + Send command SEND_CSD to the SD device to get the data of the CSD regist= er. + + Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. + + @param[in] PassThru A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL= instance. + @param[in] Slot The slot number of the SD card to send the com= mand to. + @param[in] Rca The relative device address of selected device= . + @param[out] Csd The buffer to store the content of the CSD reg= ister. + Note the caller should ignore the lowest byte = of this + buffer as the content of this byte is meaningl= ess even + if the operation succeeds. + + @retval EFI_SUCCESS The operation is done correctly. + @retval Others The operation fails. + +**/ +EFI_STATUS +SdCardGetCsd ( + IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, + IN UINT8 Slot, + IN UINT16 Rca, + OUT SD_CSD *Csd + ) +{ + EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk; + EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk; + EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet; + EFI_STATUS Status; + + ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk)); + ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk)); + ZeroMem (&Packet, sizeof (Packet)); =20 + Packet.SdMmcCmdBlk =3D &SdMmcCmdBlk; + Packet.SdMmcStatusBlk =3D &SdMmcStatusBlk; + Packet.Timeout =3D SD_MMC_HC_GENERIC_TIMEOUT; =20 + SdMmcCmdBlk.CommandIndex =3D SD_SEND_CSD; + SdMmcCmdBlk.CommandType =3D SdMmcCommandTypeAc; + SdMmcCmdBlk.ResponseType =3D SdMmcResponseTypeR2; + SdMmcCmdBlk.CommandArgument =3D (UINT32)Rca << 16; =20 + Status =3D SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL); + if (!EFI_ERROR (Status)) { + // + // For details, refer to SD Host Controller Simplified Spec 3.0 Table = 2-12. + // + CopyMem (((UINT8*)Csd) + 1, &SdMmcStatusBlk.Resp0, sizeof (SD_CSD) - 1= ); + } + + return Status; +} + +/** + Send command SEND_CSD to the SD device to get the data of the CSD regist= er. + + Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. + + @param[in] PassThru A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL= instance. + @param[in] Slot The slot number of the SD card to send the com= mand to. + @param[in] Rca The relative device address of selected device= . + @param[out] Scr The buffer to store the content of the SCR reg= ister. + + @retval EFI_SUCCESS The operation is done correctly. + @retval Others The operation fails. + +**/ +EFI_STATUS +SdCardGetScr ( + IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, + IN UINT8 Slot, + IN UINT16 Rca, + OUT SD_SCR *Scr + ) +{ + EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk; + EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk; + EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet; + EFI_STATUS Status; + + ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk)); + ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk)); + ZeroMem (&Packet, sizeof (Packet)); + + Packet.SdMmcCmdBlk =3D &SdMmcCmdBlk; + Packet.SdMmcStatusBlk =3D &SdMmcStatusBlk; + Packet.Timeout =3D SD_MMC_HC_GENERIC_TIMEOUT; + + SdMmcCmdBlk.CommandIndex =3D SD_APP_CMD; + SdMmcCmdBlk.CommandType =3D SdMmcCommandTypeAc; + SdMmcCmdBlk.ResponseType =3D SdMmcResponseTypeR1; + SdMmcCmdBlk.CommandArgument =3D (UINT32)Rca << 16; + + Status =3D SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + SdMmcCmdBlk.CommandIndex =3D SD_SEND_SCR; + SdMmcCmdBlk.CommandType =3D SdMmcCommandTypeAdtc; + SdMmcCmdBlk.ResponseType =3D SdMmcResponseTypeR1; + + Packet.InDataBuffer =3D Scr; + Packet.InTransferLength =3D sizeof (SD_SCR); + + Status =3D SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL); + + return Status; +} =20 /** Send command SELECT_DESELECT_CARD to the SD device to select/deselect it= . @@ -785,8 +892,8 @@ SdCardSetBusMode ( UINT8 BusWidth; UINT8 AccessMode; UINT8 HostCtrl1; + UINT8 HostCtrl2; UINT8 SwitchResp[64]; - SD_MMC_BUS_MODE Timing; SD_MMC_HC_PRIVATE_DATA *Private; =20 Private =3D SD_MMC_HC_PRIVATE_FROM_THIS (PassThru); @@ -818,23 +925,18 @@ SdCardSetBusMode ( if (S18A && (Capability->Sdr104 !=3D 0) && ((SwitchResp[13] & BIT3) !=3D= 0)) { ClockFreq =3D 208; AccessMode =3D 3; - Timing =3D SdMmcUhsSdr104; } else if (S18A && (Capability->Sdr50 !=3D 0) && ((SwitchResp[13] & BIT2= ) !=3D 0)) { ClockFreq =3D 100; AccessMode =3D 2; - Timing =3D SdMmcUhsSdr50; } else if (S18A && (Capability->Ddr50 !=3D 0) && ((SwitchResp[13] & BIT4= ) !=3D 0)) { ClockFreq =3D 50; AccessMode =3D 4; - Timing =3D SdMmcUhsDdr50; } else if ((SwitchResp[13] & BIT1) !=3D 0) { ClockFreq =3D 50; AccessMode =3D 1; - Timing =3D SdMmcUhsSdr25; } else { ClockFreq =3D 25; AccessMode =3D 0; - Timing =3D SdMmcUhsSdr12; } =20 Status =3D SdCardSwitch (PassThru, Slot, AccessMode, 0xF, 0xF, 0xF, TRUE= , SwitchResp); @@ -860,32 +962,20 @@ SdCardSetBusMode ( } } =20 - Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = Timing); + HostCtrl2 =3D (UINT8)~0x7; + Status =3D SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (Ho= stCtrl2), &HostCtrl2); if (EFI_ERROR (Status)) { return Status; } - - Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000, Private->B= aseClkFreq[Slot], Private->ControllerVersion[Slot]); + HostCtrl2 =3D AccessMode; + Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (Hos= tCtrl2), &HostCtrl2); if (EFI_ERROR (Status)) { return Status; } =20 - if (mOverride !=3D NULL && mOverride->NotifyPhase !=3D NULL) { - Status =3D mOverride->NotifyPhase ( - Private->ControllerHandle, - Slot, - EdkiiSdMmcSwitchClockFreqPost, - &Timing - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "%a: SD/MMC switch clock freq post notifier callback failed - %r\n= ", - __FUNCTION__, - Status - )); - return Status; - } + Status =3D SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000, *Capabilit= y); + if (EFI_ERROR (Status)) { + return Status; } =20 if ((AccessMode =3D=3D 3) || ((AccessMode =3D=3D 2) && (Capability->Tuni= ngSDR50 !=3D 0))) { @@ -996,10 +1086,9 @@ SdCardIdentification ( return Status; } =20 - if (((ControllerVer & 0xFF) >=3D SD_MMC_HC_CTRL_VER_300) && - ((ControllerVer & 0xFF) <=3D SD_MMC_HC_CTRL_VER_420)) { + if (((ControllerVer & 0xFF) =3D=3D 2) || ((ControllerVer & 0xFF) =3D=3D = 3)) { S18r =3D TRUE; - } else if (((ControllerVer & 0xFF) =3D=3D SD_MMC_HC_CTRL_VER_100) || ((C= ontrollerVer & 0xFF) =3D=3D SD_MMC_HC_CTRL_VER_200)) { + } else if (((ControllerVer & 0xFF) =3D=3D 0) || ((ControllerVer & 0xFF) = =3D=3D 1)) { S18r =3D FALSE; } else { ASSERT (FALSE); @@ -1065,7 +1154,7 @@ SdCardIdentification ( goto Error; } =20 - SdMmcHcInitClockFreq (PciIo, Slot, Private->BaseClkFreq[Slot], Priva= te->ControllerVersion[Slot]); + SdMmcHcInitClockFreq (PciIo, Slot, Private->Capability[Slot]); =20 gBS->Stall (1000); =20 diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModule= Pkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c index 76c32a4dcd..9f635cba78 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c @@ -4,7 +4,6 @@ =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 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -18,8 +17,6 @@ =20 #include "SdMmcPciHcDxe.h" =20 -EDKII_SD_MMC_OVERRIDE *mOverride; - // // Driver Global Variables // @@ -63,9 +60,7 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate =3D { { // MaxCurrent 0, }, - { - 0 // ControllerVersion - } + 0 // ControllerVersion }; =20 SD_DEVICE_PATH mSdDpTemplate =3D { @@ -286,14 +281,14 @@ SdMmcPciHcEnumerateDevice ( // // Reset the specified slot of the SD/MMC Pci Host Controller // - Status =3D SdMmcHcReset (Private, Slot); + Status =3D SdMmcHcReset (Private->PciIo, Slot); if (EFI_ERROR (Status)) { continue; } // // Reinitialize slot and restart identification process for the ne= w attached device // - Status =3D SdMmcHcInitHost (Private, Slot); + Status =3D SdMmcHcInitHost (Private->PciIo, Slot, Private->Capabil= ity[Slot]); if (EFI_ERROR (Status)) { continue; } @@ -314,6 +309,8 @@ SdMmcPciHcEnumerateDevice ( // This card doesn't get initialized correctly. // if (Index =3D=3D RoutineNum) { + + =09 Private->Slot[Slot].Initialized =3D FALSE; } =20 @@ -533,6 +530,8 @@ SdMmcPciHcDriverBindingStart ( UINT32 RoutineNum; BOOLEAN MediaPresent; BOOLEAN Support64BitDma; + UINT16 IntStatus; + UINT32 value; =20 DEBUG ((DEBUG_INFO, "SdMmcPciHcDriverBindingStart: Start\n")); =20 @@ -606,68 +605,17 @@ SdMmcPciHcDriverBindingStart ( goto Done; } =20 - // - // Attempt to locate the singleton instance of the SD/MMC override proto= col, - // which implements platform specific workarounds for non-standard SDHCI - // implementations. - // - if (mOverride =3D=3D NULL) { - Status =3D gBS->LocateProtocol (&gEdkiiSdMmcOverrideProtocolGuid, NULL= , - (VOID **)&mOverride); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: found SD/MMC override protocol\n", - __FUNCTION__)); - } - } - Support64BitDma =3D TRUE; 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->Control= lerVersion[Slot]); - if (EFI_ERROR (Status)) { - continue; - } - Status =3D SdMmcHcGetCapability (PciIo, Slot, &Private->Capability[Slo= t]); if (EFI_ERROR (Status)) { continue; } - - Private->BaseClkFreq[Slot] =3D Private->Capability[Slot].BaseClkFreq; - - if (mOverride !=3D NULL && mOverride->Capability !=3D NULL) { - Status =3D mOverride->Capability ( - Controller, - Slot, - &Private->Capability[Slot], - &Private->BaseClkFreq[Slot] - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "%a: Failed to override capability - %r\n", - __FUNCTION__, Status)); - continue; - } - } DumpCapabilityReg (Slot, &Private->Capability[Slot]); - DEBUG (( - DEBUG_INFO, - "Slot[%d] Base Clock Frequency: %dMHz\n", - Slot, - Private->BaseClkFreq[Slot] - )); =20 - // - // 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; - } + Support64BitDma &=3D Private->Capability[Slot].SysBus64; =20 Status =3D SdMmcHcGetMaxCurrent (PciIo, Slot, &Private->MaxCurrent[Slo= t]); if (EFI_ERROR (Status)) { @@ -683,28 +631,22 @@ SdMmcPciHcDriverBindingStart ( // // Reset the specified slot of the SD/MMC Pci Host Controller // - Status =3D SdMmcHcReset (Private, Slot); + Status =3D SdMmcHcReset (PciIo, Slot); if (EFI_ERROR (Status)) { continue; } // // Check whether there is a SD/MMC card attached // - if (Private->Slot[Slot].SlotType =3D=3D RemovableSlot) { - Status =3D SdMmcHcCardDetect (PciIo, Slot, &MediaPresent); - if (EFI_ERROR (Status) && (Status !=3D EFI_MEDIA_CHANGED)) { - continue; - } else if (!MediaPresent) { - DEBUG (( - DEBUG_INFO, - "SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n", - Slot - )); - continue; - } + Status =3D SdMmcHcCardDetect (PciIo, Slot, &MediaPresent); + if (EFI_ERROR (Status) && (Status !=3D EFI_MEDIA_CHANGED)) { + continue; + } else if (!MediaPresent) { + DEBUG ((DEBUG_INFO, "SdMmcHcCardDetect: No device attached in Slot[%= d]!!!\n", Slot)); + continue; } =20 - Status =3D SdMmcHcInitHost (Private, Slot); + Status =3D SdMmcHcInitHost (PciIo, Slot, Private->Capability[Slot]); if (EFI_ERROR (Status)) { continue; } @@ -725,9 +667,49 @@ SdMmcPciHcDriverBindingStart ( // This card doesn't get initialized correctly. // if (Index =3D=3D RoutineNum) { + + =20 + =20 Private->Slot[Slot].Initialized =3D FALSE; } +=09 } + =20 + if(BhtHostPciSupport(Private->PciIo)){ + + SdMmcHcRwMmio (Private->PciIo,0,0x110,TRUE,sizeof (value),&value); + DbgMsg(L"0x110: 0x%x\n",value); + + SdMmcHcRwMmio (Private->PciIo,0,0x114,TRUE,sizeof (value),&value); + DbgMsg(L"0x114: 0x%x\n",value); +=09 + SdMmcHcRwMmio (Private->PciIo,0,0x1a8,TRUE,sizeof (value),&value); + DbgMsg(L"MEM 1A8: 0x%x\n",value); + SdMmcHcRwMmio (Private->PciIo,0,0x1ac,TRUE,sizeof (value),&value); + DbgMsg(L"MEM 1AC: 0x%x\n",value); + SdMmcHcRwMmio (Private->PciIo,0,0x1B0,TRUE,sizeof (value),&value); + DbgMsg(L"MEM 1B0: 0x%x\n",value); + + DbgMsg(L" - pcr 0x304 =3D 0x%08x\n", PciBhtRead32(Private->PciIo, 0x304))= ; + DbgMsg(L" - pcr 0x328 =3D 0x%08x\n", PciBhtRead32(Private->PciIo, 0x328))= ; + DbgMsg(L" - pcr 0x3e4 =3D 0x%08x\n", PciBhtRead32(Private->PciIo, 0x3e4))= ; + + SdMmcHcRwMmio (Private->PciIo,0,0x040,TRUE,sizeof (value),&value); + DbgMsg(L"0x40: 0x%x\n",value); +=09 + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_PRESENT_STATE,TRUE,sizeof (valu= e),&value); + DbgMsg(L"Present State: 0x%x\n",value); + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL1,TRUE,sizeof (IntStat= us),&IntStatus); + DbgMsg(L"Power&Host1: 0x%x\n",IntStatus); + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_CLOCK_CTRL,TRUE,sizeof (IntStat= us),&IntStatus); + DbgMsg(L"CLK: 0x%x\n",IntStatus); + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_TIMEOUT_CTRL,TRUE,sizeof (IntSt= atus),&IntStatus); + DbgMsg(L"SWR&Timeout: 0x%x\n",IntStatus); + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_NOR_INT_STS,TRUE,sizeof (value)= ,&value); + DbgMsg(L"INR&IER: 0x%x\n",value); + SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL2,TRUE,sizeof (IntStat= us),&IntStatus); + DbgMsg(L"Host2: 0x%x\n",IntStatus); + } =20 // // Enable 64-bit DMA support in the PCI layer if this controller --=20 2.19.1.windows.1