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::229; helo=mail-lj1-x229.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (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 E96C421163248 for ; Fri, 5 Oct 2018 06:25:32 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id j4-v6so7821697ljc.12 for ; Fri, 05 Oct 2018 06:25:32 -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=1Sf7dpkIqJ5njiIJUDFzvCaF3i9PeOM+a4123UI1HUY=; b=Pv2yMoLthKHFBuwEoBbB2TJsxIH1puvDxrXslbM1/btDajgalalnryBfyEpOR+5NKi oec2zJJp/UzNT7NclU6MsbQbCTT5VHkTApcO0fdCWXwesbJGQb9kYCBWAa3mQAznwQvi p6ph8Xc8FlWD0I5YAF4CVbDZHJG6vczhpscpOTJUafUTHsVUoNpTvzECglnbfvHKmj9N 58V3p5q8xv9fKUxNZZ+85ooTqe6TkiXDFVOJHnH6992DaieUdLkC/LUW7r4ZwzbIYZmB IZQhwg/yxz0XrKMQwZyVqh0z5F9lTj3P2XNalLvFRJscbEvPRp9hVBWu6NcCtB1iCRS8 UbKQ== 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=1Sf7dpkIqJ5njiIJUDFzvCaF3i9PeOM+a4123UI1HUY=; b=c0Vmf5ZgJKKW05lx7YWgVFQCZg4jLEEhd4ltRH4O1aD5nelCEX9N9TCS1gF7r+onV4 ReSolUOsZzbORL086wxLdR8KMwzewmdO3zbqlcdtKJFX1+u9erpl0kzMjAU+fM9oMVsP sboBZ5ZgGjRiQ2YomvVYVQDSrnWWQORMaoShw52cJmAoYhZfh81u1Z6DZ6NZtFMIISvK OK33oWKYZbj7pXKb60hkKWG0+bhjlS+neZHh3jjZc/BqKyHLrPONwvCOQ3nJ4m5kVGG6 TTQ45GOQBhwvvWeJdgV3TuXuLqtwdAGMont3VKO8ZjAkbli/p7ZffkPFFwLKxEjqhCbd zIbQ== X-Gm-Message-State: ABuFfojgh48CD7syPVW2gRJtCQlQYxlZe+ifk6o/1OtDdU76gc3ae8R7 g6+tOPHkT93RGW1O/iRpqSEjTRgsXaE= X-Google-Smtp-Source: ACcGV62MkgmZE4AIqsmX8QvpeLifbtkXC3WpztkZNdzv4jdPr3HxDBMBTmeJfqFovtE5q0vciXdnZg== X-Received: by 2002:a2e:9bd0:: with SMTP id w16-v6mr7480103ljj.55.1538745930630; Fri, 05 Oct 2018 06:25:30 -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 l14-v6sm1836581ljc.68.2018.10.05.06.25.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Oct 2018 06:25:29 -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, hao.a.wu@intel.com, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, tm@semihalf.com Date: Fri, 5 Oct 2018 15:25:10 +0200 Message-Id: <1538745911-22484-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538745911-22484-1-git-send-email-mw@semihalf.com> References: <1538745911-22484-1-git-send-email-mw@semihalf.com> Subject: [PATCH v2 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, 05 Oct 2018 13:25:33 -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 25db98a..d9daada 100644 --- a/MdeModulePkg/Include/Protocol/SdMmcOverride.h +++ b/MdeModulePkg/Include/Protocol/SdMmcOverride.h @@ -33,6 +33,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 05bd4a0..7e75283 100755 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -796,6 +796,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; } @@ -905,6 +926,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; @@ -989,6 +1028,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 5645a71..057a4e2 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