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 0A53C21A07A82 for ; Wed, 7 Nov 2018 17:59:01 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id j4-v6so16550982ljc.12 for ; Wed, 07 Nov 2018 17:59:00 -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=kGoDG0rZm32bYnnXw+1HDtqNlc9vrn2+qimf0vBvWdA=; b=vQsV+jq67pcTqrDFcxdrkLqpNjE5LQzqekHcf/nbYoTmQ9I1Cu9Hm04e6uaRF4LYJJ ZRuiEXO/Q9UJ+eUcfJLuPXi2Si93r7tzMXwN+L4QTkLaL42WJ/XpTta5bcZ/NEjW8dD9 34ElEAHChi//4pdBxr2CyWkvl0f/OxSV0aRkdvHPDpRCLKrNgmcK7RONqfkROrYuIQTq cbaj+WLn1gemYpOtdKQDW5qlQru340k/XhNQDaiFe8HLsPIcOfSI3ZzX9BqyTSIRbkGi leTVtgSSa+V9gDHMCLPw4cTdb5cJpg2dN504D8I8FlCdeuh0JMql5Qzcn9+76dBghv08 OLeQ== 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=kGoDG0rZm32bYnnXw+1HDtqNlc9vrn2+qimf0vBvWdA=; b=Z/Kj1oQFRUblv49BGFXt/tIMV9tDg9wTXkeTb1LuND/yLF/LylQDD+eYZN0CV4jBDZ xoyLNxIdygyqhpy6VBM3yWpBFA94g/0OqySXcqIl19jBOkdL8RVAODd+lj8dqNfOAUMa 2/rcFl1TY0kRNK0uJL0S2atJRorrQeTj7qKYvOlLb1Gjo5gNXC+55xAxtwYNHG5iBcy4 CtEEh77pp5NUWmtqpaPxtlCZSHLVdxTF3XdH3ezS/+A+ozXjnIAz6KJGYNfhDbQaQkZp Z+7wvm2qHgVzMd3SuOyf9diHWD7n+iX85In2xVpV8Nt7E87bv6gbqHih9GUQ02GMM2I+ lOuw== X-Gm-Message-State: AGRZ1gLPHy+etuOkChrrSGCOu4LEHAhUoYWVvtYBNj80CHPzhl2wrlRr 2P+yX38ucyLa2SG7Q97iLm3Git9j2xo= X-Google-Smtp-Source: AJdET5fHviN2y4BFgYtpUU/yLOG2e6/J6BbZ+McFeOwqu0eZDfPySzlK4RTA1jCj+z3cTKdAkIsUrw== X-Received: by 2002:a2e:7c13:: with SMTP id x19-v6mr1524518ljc.83.1541642338965; Wed, 07 Nov 2018 17:58:58 -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 r22-v6sm386223ljg.82.2018.11.07.17.58.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Nov 2018 17:58:58 -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: Thu, 8 Nov 2018 02:57:34 +0100 Message-Id: <1541642255-15602-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541642255-15602-1-git-send-email-mw@semihalf.com> References: <1541642255-15602-1-git-send-email-mw@semihalf.com> Subject: [PATCH v3 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: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -0000 X-List-Received-Date: Thu, 08 Nov 2018 01:59:01 -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 EmmcSwitchClockFreq and 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 | 60 ++++++++++++++++++++ MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 18 ++++++ 3 files changed, 79 insertions(+) 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 473df8d..6fc6871 100755 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -794,6 +794,27 @@ EmmcSwitchToHighSpeed ( HsTiming = 1; Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + 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; } @@ -904,6 +925,24 @@ EmmcSwitchToHS200 ( 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; + } + } + Status = EmmcTuningClkForHs200 (PciIo, PassThru, Slot, BusWidth); return Status; @@ -988,6 +1027,27 @@ EmmcSwitchToHS400 ( HsTiming = 3; Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + 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; } diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c index 850ad26..5408bbc 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c @@ -887,6 +887,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