From nobody Thu May 2 13:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47832+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47832+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1569227861; cv=none; d=zoho.com; s=zohoarc; b=Lu0fxIkpZaOiWm7lsJgxLxEyAG+XiAW2hNyxDl+1FpP2vG9wBGLRy8QJuer7a8QgOijN07KM1DWLF4njxGdRE/QBhesoW6WXxNY3uBAJhIEj8ruxjKBy7cpzzxpe4ITU2F/7LucNQ2W4yPGSVRS7RjWjsUEi0mkrV3dkQQ7CRF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227861; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=pwSPie7XdojFaGCnqp2fPCSMQ96xc61eUzsytjefPeA=; b=fmIgoPsn6d9KTicIvq47mKax0fURlBtgxSWclRDSOQyhQ4lu1QGxEc45EiBgcbHOdbgaRzn2gNnSP2ubM27T1TYBgBD/N4zx7cMKB7gMGxTiw6kx+cdWeX+g16N4dXc3kUQmSNtPajy/rGPnsN42zryVU5OSQh1ShSJFqvVk2p8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47832+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569227861411700.1068919350603; Mon, 23 Sep 2019 01:37:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xUGEYY1788612xjVHqnihlp7; Mon, 23 Sep 2019 01:37:41 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Mon, 23 Sep 2019 01:37:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 01:37:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="339648252" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by orsmga004.jf.intel.com with ESMTP; 23 Sep 2019 01:37:37 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: "Albecki, Mateusz" , Hao A Wu , Marcin Wojtas Subject: [edk2-devel] [PATCH 1/1] MdeModulePkg/SdMmcPciHcDxe: Fix bus timing switch sequence Date: Mon, 23 Sep 2019 10:37:01 +0200 Message-Id: <20190923083701.1496-2-mateusz.albecki@intel.com> In-Reply-To: <20190923083701.1496-1-mateusz.albecki@intel.com> References: <20190923083701.1496-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: hewoTTkyUXAueEznTqPnl63Xx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569227861; bh=JAlQdedEmEdblxPF8gC1XcjZKCjPB371Yev3z2iJHFc=; h=Cc:Date:From:Reply-To:Subject:To; b=eKftfUya2az0wc8+XVSmxj9HfYHT6yLdsICCayajR8pzmPHm7CWF+Kc64ol7MFFVV2j SiF4e/e2CVZjCAr/PU6a9Utv46FXaZWAHAV1BUXgHrZ3nM7H/yAk8JVPipG+PxbNsVGrP 2I3zu/0eR0xMk2i3nALJJKsiQpAbmx7Pa/Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" SD specification recommends switching card bus timing before switching bus timing in controller. Emmc driver used to do this switch other way around. This commit adds controller timing switch in EmmcSwitchBusTiming function to enforce this order and removes all controller timing programing from EmmcSwitchToXXX functions. Signed-off-by: Mateusz Albecki Cc: Hao A Wu Cc: Marcin Wojtas Tested-by: Marcin Wojtas --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 79 +++++++--------------= ---- 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg= /Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c index 3f4a8e5413..06ee1208be 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -671,6 +671,7 @@ EmmcSwitchBusTiming ( UINT8 CmdSet; UINT32 DevStatus; SD_MMC_HC_PRIVATE_DATA *Private; + UINT8 HostCtrl1; =20 Private =3D SD_MMC_HC_PRIVATE_FROM_THIS (PassThru); // @@ -704,6 +705,25 @@ EmmcSwitchBusTiming ( return Status; } =20 + if (BusTiming =3D=3D SdMmcMmcHsSdr || BusTiming =3D=3D SdMmcMmcHsDdr) { + HostCtrl1 =3D BIT2; + Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (H= ostCtrl1), &HostCtrl1); + if (EFI_ERROR (Status)) { + return Status; + } + } else { + HostCtrl1 =3D (UINT8)~BIT2; + Status =3D SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (= HostCtrl1), &HostCtrl1); + if (EFI_ERROR (Status)) { + return Status; + } + } + + Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = BusTiming); + if (EFI_ERROR (Status)) { + return Status; + } + // // Convert the clock freq unit from MHz to KHz. // @@ -772,7 +792,6 @@ EmmcSwitchToHighSpeed ( ) { EFI_STATUS Status; - UINT8 HostCtrl1; SD_MMC_HC_PRIVATE_DATA *Private; BOOLEAN IsDdr; =20 @@ -794,20 +813,6 @@ EmmcSwitchToHighSpeed ( return Status; } =20 - // - // Set to High Speed timing - // - HostCtrl1 =3D BIT2; - Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (Hos= tCtrl1), &HostCtrl1); - if (EFI_ERROR (Status)) { - return Status; - } - - Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = BusMode->BusTiming); - if (EFI_ERROR (Status)) { - return Status; - } - return EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverS= trength, BusMode->BusTiming, BusMode->ClockFreq); } =20 @@ -837,7 +842,6 @@ EmmcSwitchToHS200 ( ) { EFI_STATUS Status; - UINT16 ClockCtrl; SD_MMC_HC_PRIVATE_DATA *Private; =20 Private =3D SD_MMC_HC_PRIVATE_FROM_THIS (PassThru); @@ -851,39 +855,6 @@ EmmcSwitchToHS200 ( if (EFI_ERROR (Status)) { return Status; } - // - // Stop bus clock at first - // - Status =3D SdMmcHcStopClock (PciIo, Slot); - if (EFI_ERROR (Status)) { - return Status; - } - - Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = BusMode->BusTiming); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Wait Internal Clock Stable in the Clock Control register to be 1 befo= re set SD Clock Enable bit - // - Status =3D SdMmcHcWaitMmioSet ( - PciIo, - Slot, - SD_MMC_HC_CLOCK_CTRL, - sizeof (ClockCtrl), - BIT1, - BIT1, - SD_MMC_HC_GENERIC_TIMEOUT - ); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Set SD Clock Enable in the Clock Control register to 1 - // - ClockCtrl =3D BIT2; - Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (Clo= ckCtrl), &ClockCtrl); =20 Status =3D EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->Dri= verStrength, BusMode->BusTiming, BusMode->ClockFreq); if (EFI_ERROR (Status)) { @@ -945,11 +916,6 @@ EmmcSwitchToHS400 ( // Set to High Speed timing and set the clock frequency to a value less = than or equal to 52MHz. // This step is necessary to be able to switch Bus into 8 bit DDR mode w= hich is unsupported in HS200. // - Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = SdMmcMmcHsSdr); - if (EFI_ERROR (Status)) { - return Status; - } - HsFreq =3D BusMode->ClockFreq < 52 ? BusMode->ClockFreq : 52; Status =3D EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->Dri= verStrength, SdMmcMmcHsSdr, HsFreq); if (EFI_ERROR (Status)) { @@ -961,11 +927,6 @@ EmmcSwitchToHS400 ( return Status; } =20 - Status =3D SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, = BusMode->BusTiming); - if (EFI_ERROR (Status)) { - return Status; - } - return EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverS= trength, BusMode->BusTiming, BusMode->ClockFreq); } =20 --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47832): https://edk2.groups.io/g/devel/message/47832 Mute This Topic: https://groups.io/mt/34262004/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-