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::236; helo=mail-lj1-x236.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) (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 40C5C2110E89A for ; Sun, 2 Sep 2018 21:54:31 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id p10-v6so14295374ljg.2 for ; Sun, 02 Sep 2018 21:54:31 -0700 (PDT) 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=Att34C2kwzaydtfJGOzdbCAGM46j2d3bByR/blbh6u4=; b=uz4VgVRnNxgZuztwO7JP8y4aBoWmnOzSufufsnm+/EtExN4wbQADrk73jGoC/6OTrO Cq+/oJ3HOvZxAWnDeaNkClnHwqIb5Mbwx5CCjqC9N07IUERSDImjCPRKJS0qEZmPQ0Zl Q2eUxTxo80NL04vzSdkqbWLPhNXlDh7Cbafaiut6L10t9I1uk8cBG/kfrP7orUwfTfnr O4zOrfcz6xs7JxQhw3xz1QOGH8n3wUyDdurIWl2tLDTFb7WwtkmVZXbhoNyNLrwrsGyI qOTnaV1ODXhhiyyeu9LuJbEl7RrCE8Paxov1i/RPdzaQ4ebuCzghyRSYyzNOI5QQds7W z3KQ== 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=Att34C2kwzaydtfJGOzdbCAGM46j2d3bByR/blbh6u4=; b=DUQlk8D77RboH2hfyZKuQjqSvS4dTuRyPCE9+J3ZMh9XooS1t/kOaVU0Y104zzA6qb avJBCy1LGvcaJZIpQIMtq0uvnbFh7gfXOd4F67v5k/IPgXxunwjihccSY+kQksMfx3Pe fItvm2xg322llT9ZhStUYuW6YgMQyukPMzMOADKodJA0XbFUO+NorSkkarBFRYtKT3mS jww6zrwZ9mco2g+6yi7y3+RRf/HI5YkU7SulriKb/Us1R6juG7DlKso5h/upm4GOb9D0 205lmANgt1R4l2bkE+j/hgWYMqxYbv32IqVB4o7P6F5o2P1zLs+2sgff2mjglI6VvD0U v5Ug== X-Gm-Message-State: APzg51BMTTkkKPUtYeuKp/1SECZkb62UOOWQnOOgZsERlPbf9sZ/IZGS 2EOHwNOZ9DZUw7nSxLh7ghmxWYX15tQ= X-Google-Smtp-Source: ANB0VdatInqEgPCod6y+4d5cCO/WNsYDlQpoLRJtYjSp7A6B157FjJ2rfBtjDv1conmEVPSGx7+vag== X-Received: by 2002:a2e:990b:: with SMTP id v11-v6mr16043498lji.87.1535950469181; Sun, 02 Sep 2018 21:54:29 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id h16-v6sm3196658ljh.26.2018.09.02.21.54.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Sep 2018 21:54:28 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: feng.tian@intel.com, michael.d.kinney@intel.com, liming.gao@intel.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, Tomasz Michalec Date: Mon, 3 Sep 2018 06:54:09 +0200 Message-Id: <1535950453-27147-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535950453-27147-1-git-send-email-mw@semihalf.com> References: <1535950453-27147-1-git-send-email-mw@semihalf.com> Subject: [PATCH 3/7] 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, 03 Sep 2018 04:54:31 -0000 From: Tomasz Michalec Some SD Host Controlers need to do additional opperations after clock frequency switch. This patch add new callback to SdMmcOverride protocol. The SwitchClockFreqPost callback is called after EmmcSwitchClockFreq and SdMmcHcClockSupply. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- MdeModulePkg/Include/Protocol/SdMmcOverride.h | 33 ++++++++++-- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 57 ++++++++++++++++++++ MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 17 ++++++ 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Include/Protocol/SdMmcOverride.h b/MdeModulePkg/Include/Protocol/SdMmcOverride.h index a7a57e8..6ba1c43 100644 --- a/MdeModulePkg/Include/Protocol/SdMmcOverride.h +++ b/MdeModulePkg/Include/Protocol/SdMmcOverride.h @@ -99,23 +99,48 @@ EFI_STATUS IN SD_MMC_UHS_TIMING Timing ); +/** + + Additional operations specific for host controller + + @param[in] ControllerHandle The EFI_HANDLE of the controller. + @param[in] Slot The 0 based slot index. + @param[in] Timing The timing which should be set by + host controller. + + @retval EFI_SUCCESS The override function completed successfully. + @retval EFI_NOT_FOUND The specified controller or slot does not exist. + +**/ +typedef +EFI_STATUS +(EFIAPI * EDKII_SD_MMC_POST_CLOCK_FREQ_SWITCH) ( + IN EFI_HANDLE ControllerHandle, + IN UINT8 Slot, + IN SD_MMC_UHS_TIMING Timing + ); + struct _EDKII_SD_MMC_OVERRIDE { // // Protocol version of this implementation // - UINTN Version; + UINTN Version; // // Callback to override SD/MMC host controller capability bits // - EDKII_SD_MMC_CAPABILITY Capability; + EDKII_SD_MMC_CAPABILITY Capability; // // Callback to invoke SD/MMC override hooks // - EDKII_SD_MMC_NOTIFY_PHASE NotifyPhase; + EDKII_SD_MMC_NOTIFY_PHASE NotifyPhase; // // Callback to override SD/MMC host controller uhs signaling // - EDKII_SD_MMC_UHS_SIGNALING UhsSignaling; + EDKII_SD_MMC_UHS_SIGNALING UhsSignaling; + // + // Callback to add host controller specific operations after SwitchClockFreq + // + EDKII_SD_MMC_POST_CLOCK_FREQ_SWITCH SwitchClockFreqPost; }; extern EFI_GUID gEdkiiSdMmcOverrideProtocolGuid; diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c index d285249..78ee3a5 100755 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -795,6 +795,26 @@ EmmcSwitchToHighSpeed ( HsTiming = 1; Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + if (EFI_ERROR (Status)) { + return Status; + } + + if (mOverride != NULL && mOverride->SwitchClockFreqPost != NULL) { + Status = mOverride->SwitchClockFreqPost ( + Private->ControllerHandle, + Slot, + 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; } @@ -881,6 +901,23 @@ EmmcSwitchToHS200 ( return Status; } + if (mOverride != NULL && mOverride->SwitchClockFreqPost != NULL) { + Status = mOverride->SwitchClockFreqPost ( + Private->ControllerHandle, + Slot, + 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; @@ -964,6 +1001,26 @@ EmmcSwitchToHS400 ( HsTiming = 3; Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); + if (EFI_ERROR (Status)) { + return Status; + } + + if (mOverride != NULL && mOverride->SwitchClockFreqPost != NULL) { + Status = mOverride->SwitchClockFreqPost ( + Private->ControllerHandle, + Slot, + 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 f45a367..777cf08 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c @@ -886,6 +886,23 @@ SdCardSetBusMode ( return Status; } + if (mOverride != NULL && mOverride->SwitchClockFreqPost != NULL) { + Status = mOverride->SwitchClockFreqPost ( + Private->ControllerHandle, + Slot, + 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