From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d41; helo=mail-io1-xd41.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 5833A2118A5AD for ; Mon, 12 Nov 2018 02:24:04 -0800 (PST) Received: by mail-io1-xd41.google.com with SMTP id h4so1707454iom.5 for ; Mon, 12 Nov 2018 02:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3ZvQFuWoB3ICYcu9ZhDPE9llVxF1quyutOrjZu5ksSc=; b=V95PC+kkOd9+RoBDX6kUpV7d4go8E27J2E174RZkOcNwL/SxRuAvZ4sgt29PEhqo6j SOu069lTExlpYqvWg61HN8hArPutrZRx1Zx5kDyoi3zLsy2MhMkBhM5x0lZkKMd7xenA u+scjnKYLSIyoXhrLf6hssaH6rG0EfBeW8ABA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3ZvQFuWoB3ICYcu9ZhDPE9llVxF1quyutOrjZu5ksSc=; b=aKW//D2G5S6b+YxYvM14YSyel0ZAH1QwnoFbXJIfUYVskyLUt+g/I/9Eo/5BmmP6Tc IbvYo/etqno6YevZiRhHBf2aTnmPg1Ic0HfN92V63Zw9aaI2g1VOtuY2n/wM1rHNIo2Z n4wFgQ+qyHJhC6jxHBQa0/DQjmm4P65/YjeIjT5Hg6WVldq8vcO6vskwP0uFU8udwwy/ 9WfrywVIhqr6BX0zp1rOeOvC6xDERXQ4aCJXnvdacSuGXooLgTe/zuBVRQJZG+ljppmN /s9awV7Uaslg4EWdKcF9JLOnj9PIj6VtkTtJepgdEdLvHxaUr59c2CgnJqsCzN1HOO89 7lpQ== X-Gm-Message-State: AGRZ1gIWiZ7cEXuTVhrdmOi2yRPsS3rlAIta2pbcJYK1QkCEkJHCqd7Y jSqBBR9DE52nMUPD6IKYxQReX8eDWNufwkGst6VcRQ== X-Google-Smtp-Source: AJdET5fbSlrkh9nRIdcuHoffeRt01mMXahmWax1+Gt89c5/lVH46+gpmQhDR2Udx9KLS9UeKqnbzZ3TIQS784KtaGac= X-Received: by 2002:a6b:5d01:: with SMTP id r1mr229511iob.170.1542018243419; Mon, 12 Nov 2018 02:24:03 -0800 (PST) MIME-Version: 1.0 References: <1541804487-27458-1-git-send-email-mw@semihalf.com> <1541804487-27458-4-git-send-email-mw@semihalf.com> In-Reply-To: <1541804487-27458-4-git-send-email-mw@semihalf.com> From: Ard Biesheuvel Date: Mon, 12 Nov 2018 11:23:51 +0100 Message-ID: To: Marcin Wojtas Cc: "edk2-devel@lists.01.org" , Leif Lindholm , "Wu, Hao A" , "Kinney, Michael D" , "Gao, Liming" , Nadav Haklai , =?UTF-8?B?SmFuIETEhWJyb8Wb?= , Tomasz Michalec , Grzegorz Jaszczyk Subject: Re: [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: Mon, 12 Nov 2018 10:24:04 -0000 Content-Type: text/plain; charset="UTF-8" On Sat, 10 Nov 2018 at 00:02, Marcin Wojtas wrote: > > From: Tomasz Michalec > > Some SD Host Controlers need to do additional opperations operations > 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 Reviewed-by: Ard Biesheuvel > --- > 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 >