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::141; helo=mail-lf1-x141.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) (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 294892110E898 for ; Sun, 2 Sep 2018 21:54:28 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id x26-v6so14115837lfi.7 for ; Sun, 02 Sep 2018 21:54:27 -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=Dzw9xOmWvq/P39lwPj0Ca6v1kkyxABpYdiyRT+U9Zus=; b=DVliLFgRk0Otzc6WqozkxV1xxPY5RDteZX1fE63G1DyDoLqYMcL69ImSY6r2nPtNV8 kPR02aXuveMJnZkV/AnNMVKFJHugqIJ4ySi0ZezMzia9EK1p5Fv9WD7HpzF2u7ar8cfD XYgH4c+Mk2Cs2T32YB3O95i68+M3upb2JTVG02mwK1odDNbLKqmr8t1XWlnZ8ympz8ql O3kKcZR0OY8DnALV8jWB1a5Zd8tQrppqtW0mp5cZ9DY2nMwJ6f0ZSgZe6dyWZN+O64LY dAD7jmFf4O11InAjxs4ZYCAEfLgVChlxT+E2Qqu3Heyb9+rg65II0hvKNfSr7yzKu9SY Gpuw== 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=Dzw9xOmWvq/P39lwPj0Ca6v1kkyxABpYdiyRT+U9Zus=; b=Y3flkPJW2MEnxj09mQCKC2abQiOpHrEEjqZd0Osqlu6rnZtVS6dTFd6A7FLfFRO6eO HLRG+MEg7hlRih8OLO/QOZPqnTyiTR0PJOrA15FwAasllxFUFBJeaOi92AtL8aJpva09 ljLRGuWOh+JkiQn+SER6kn14OL8hh+lg0ayxOIjBWUJT+jjAVpx1eU6ORLaEkzKYsTM8 rRKrqZom4yzaWxp5eYWRL+1oorZoKKFYxuKKiAeq/3nWQEsWdsmwY2BZNnXJk6ja9e44 Fdky9ytf9zlbXJjAj312RZj72HjsUXOScSn/46Jg1Id0Yee8RzSl8VhWnbASoY7+ViIX pFHg== X-Gm-Message-State: APzg51BOAXqRUx83gUQkiheV0xTRVk6hc5MHcbGWikQ4sqbdm9sIekzY VYQPEE/kbw3IaSOmfeVi2q7Ef+vWqsA= X-Google-Smtp-Source: ANB0VdY2oD/hlJ+ujw+WmY26dMCbxtEutUCkE/OVS3VShynBJQ6JKMHlka18mRsDSXrbNJn0hfMUkw== X-Received: by 2002:a19:9bcc:: with SMTP id d195-v6mr17563360lfe.123.1535950465602; Sun, 02 Sep 2018 21:54:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Sep 2018 21:54:24 -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 Date: Mon, 3 Sep 2018 06:54:07 +0200 Message-Id: <1535950453-27147-2-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 1/7] MdeModulePkg/SdMmcPciHcDxe: Fix HS200 operation 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:28 -0000 When switching to any of high speed modes (HS, HS200, HS400) there is need to set HS_ENABLE bit in Host Control 1 register which allow Host Controller to output CMD and DAT lines on both edges of clock. In Linux it is done after switching bus width in sdhci_set_ios(). Also according to JESD84-B50-1 chapter 6.6.4 "HS200 timing mode selection" (documentation about eMMC4.5 standard) there is no need to disable clock when switching to HS200. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 5 ++++ MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 30 +++----------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h index e389d52..e3fadb5 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h @@ -63,6 +63,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define SD_MMC_HC_CTRL_VER 0xFE // +// SD Host Control 1 Register bits description +// +#define SD_MMC_HC_HOST_CTRL1_HS_ENABLE (1 << 2) + +// // The transfer modes supported by SD Host Controller // Simplified Spec 3.0 Table 1-2 // diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c index c5fd214..b3903b4 100755 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -816,8 +816,8 @@ EmmcSwitchToHS200 ( { EFI_STATUS Status; UINT8 HsTiming; + UINT8 HostCtrl1; UINT8 HostCtrl2; - UINT16 ClockCtrl; if ((BusWidth != 4) && (BusWidth != 8)) { return EFI_INVALID_PARAMETER; @@ -828,12 +828,10 @@ EmmcSwitchToHS200 ( return Status; } // - // Set to HS200/SDR104 timing - // - // - // Stop bus clock at first + // Set to High Speed timing // - Status = SdMmcHcStopClock (PciIo, Slot); + HostCtrl1 = SD_MMC_HC_HOST_CTRL1_HS_ENABLE; + Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (HostCtrl1), &HostCtrl1); if (EFI_ERROR (Status)) { return Status; } @@ -853,26 +851,6 @@ EmmcSwitchToHS200 ( if (EFI_ERROR (Status)) { return Status; } - // - // Wait Internal Clock Stable in the Clock Control register to be 1 before set SD Clock Enable bit - // - Status = SdMmcHcWaitMmioSet ( - PciIo, - Slot, - SD_MMC_HC_CLOCK_CTRL, - sizeof (ClockCtrl), - BIT1, - BIT1, - SD_MMC_HC_GENERIC_TIMEOUT - ); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Set SD Clock Enable in the Clock Control register to 1 - // - ClockCtrl = BIT2; - Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl); HsTiming = 2; Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq); -- 2.7.4