From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4864:20::243; helo=mail-lj1-x243.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5376921A00AE6 for ; Fri, 9 Nov 2018 15:02:04 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id s15-v6so2967367lji.3 for ; Fri, 09 Nov 2018 15:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oYgug9aYornLwZPQZzIYiPm4IiOi1UaLF5YgIb6//aA=; b=oUj4MHAF5n+9rh37GVDwF/gY6AsZwwe6Gxdoj9Nup1LDxKwVkwE+Yvz9MdCmckqJZE VuFu291hVQcYuXKqNv6mCMUruj/3VZxqTL/u4cBT6jk6jMkY+UhjmE+h4arXrH4idggu NuSRMrjZZPlabzOmhQLVzyJKGfdvSfISAv4SjpF8ifWDIqfw62aOihK8PGXMU/R9UNFt CocTyzMqgnFrWFzAa67dmrxisi2KenPrl0V0M1kmG67ENIXGLl5UvMOC9DMop13FnqQr VhktIYnBzO67+l+icWgFf35ax3NaWj7UdwyeFS+nGPTR9arFWImgfD+qlfxVlK+WSJOF Om7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oYgug9aYornLwZPQZzIYiPm4IiOi1UaLF5YgIb6//aA=; b=YkHzTjIvQtZlLGtWcMYJu3UtPekQA8ykjiSnOlR28jyGq+zAH+JEWRHooJS9FeeWTA ODavgKbLRCIsreg0Tjkhv9iUu06RlhD3optjyaNubwJP97CGhstcjdiUizLwWNVh4+e6 6wgh8AI2OXYkoYoEdz2wwqac/lGb9Wk09ht3BoFHcP5y2XBjlwv4ic6PaxkS8xt0orSV lqpYmBWYIJ05ZvT+bqJ6t33n/gP3BhdNCEotTYUu9dfIVlr8VCCHifcUNXOtdRh8CPlN VBNBby2eMDiVjf8OwSkEZPsHAFUANDTER454DbLfgSPkqBmm4fUqYFdQF2oSsGuh21Kc oP1A== X-Gm-Message-State: AGRZ1gIh+/MwFXv0tQQGpww+1giHe0fdHgp7vp5q427IQLIrul7zb/68 g//2FfCl9+iyO+q4u/QeLEjxWWtWUA4= X-Google-Smtp-Source: AJdET5fJf4IiAxqGznVJ627ydvzSOvaFES64DlBxkFue1xNZ7l+gNigPc4LCpYUjOBVpdUnqQcIKIw== X-Received: by 2002:a2e:98c9:: with SMTP id s9-v6mr1715496ljj.166.1541804521859; Fri, 09 Nov 2018 15:02:01 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id c22sm1574318lfd.88.2018.11.09.15.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Nov 2018 15:02:01 -0800 (PST) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, hao.a.wu@intel.com, michael.d.kinney@intel.com, liming.gao@intel.com, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, tm@semihalf.com, jaz@semihalf.com Date: Sat, 10 Nov 2018 00:01:26 +0100 Message-Id: <1541804487-27458-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541804487-27458-1-git-send-email-mw@semihalf.com> References: <1541804487-27458-1-git-send-email-mw@semihalf.com> Subject: [PATCH v4 3/4] MdeModulePkg/SdMmcPciHcDxe: Add SwitchClockFreqPost to SdMmcOverride 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: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 X-List-Received-Date: Fri, 09 Nov 2018 23:02:04 -0000 From: Tomasz Michalec Some SD Host Controlers need to do additional opperations after clock frequency switch. This patch add new callback type to NotifyPhase of the SdMmcOverride protocol. It is called after SdMmcHcClockSupply. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- MdeModulePkg/Include/Protocol/SdMmcOverride.h | 1 + MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 31 +++++++++++++++++--- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 18 ++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Include/Protocol/SdMmcOverride.h b/MdeModulePkg/Include/Protocol/SdMmcOverride.h index f948bef..6160b5b 100644 --- a/MdeModulePkg/Include/Protocol/SdMmcOverride.h +++ b/MdeModulePkg/Include/Protocol/SdMmcOverride.h @@ -48,6 +48,7 @@ typedef enum { EdkiiSdMmcInitHostPre, EdkiiSdMmcInitHostPost, EdkiiSdMmcUhsSignaling, + EdkiiSdMmcSwitchClockFreqPost, } EDKII_SD_MMC_PHASE_TYPE; /** diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c index db4e8a1..b75a9bb 100755 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -651,6 +651,7 @@ EmmcSwitchBusWidth ( @param[in] Slot The slot number of the SD card to send the command to. @param[in] Rca The relative device address to be assigned. @param[in] HsTiming The value to be written to HS_TIMING field of EXT_CSD register. + @param[in] Timing The bus mode timing indicator. @param[in] ClockFreq The max clock frequency to be set, the unit is MHz. @retval EFI_SUCCESS The operation is done correctly. @@ -664,6 +665,7 @@ EmmcSwitchClockFreq ( IN UINT8 Slot, IN UINT16 Rca, IN UINT8 HsTiming, + IN SD_MMC_BUS_MODE Timing, IN UINT32 ClockFreq ) { @@ -706,6 +708,27 @@ EmmcSwitchClockFreq ( // Convert the clock freq unit from MHz to KHz. // Status = SdMmcHcClockSupply (PciIo, Slot, ClockFreq * 1000, Private->Capability[Slot]); + if (EFI_ERROR (Status)) { + return Status; + } + + if (mOverride != NULL && mOverride->NotifyPhase != NULL) { + Status = 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; + } + } return Status; } @@ -775,7 +798,7 @@ EmmcSwitchToHighSpeed ( } HsTiming = 1; - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq); return Status; } @@ -863,7 +886,7 @@ EmmcSwitchToHS200 ( Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl); HsTiming = 2; - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq); if (EFI_ERROR (Status)) { return Status; } @@ -913,7 +936,7 @@ EmmcSwitchToHS400 ( // Set to Hight Speed timing and set the clock frequency to a value less than 52MHz. // HsTiming = 1; - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, 52); + Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, SdMmcMmcHsSdr, 52); if (EFI_ERROR (Status)) { return Status; } @@ -933,7 +956,7 @@ EmmcSwitchToHS400 ( } HsTiming = 3; - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq); return Status; } diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c index 55b3564..32fd416 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c @@ -869,6 +869,24 @@ SdCardSetBusMode ( return Status; } + if (mOverride != NULL && mOverride->NotifyPhase != NULL) { + Status = 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; + } + } + if ((AccessMode == 3) || ((AccessMode == 2) && (Capability->TuningSDR50 != 0))) { Status = SdCardTuningClock (PciIo, PassThru, Slot); if (EFI_ERROR (Status)) { -- 2.7.4