From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web11.21378.1594737845139276135 for ; Tue, 14 Jul 2020 07:44:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=iOKX8bLU; spf=pass (domain: nuviainc.com, ip: 209.85.221.67, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f67.google.com with SMTP id f18so22146110wrs.0 for ; Tue, 14 Jul 2020 07:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=eDMUz3fYRaQ87a+G1KlzwvxZMdppnhGKV7K5GSWVXsk=; b=iOKX8bLUus1l66lJpx+heBzLkNeb25zYp2pSrIvufE2lJNv8W12lS183zbDDrkb/tO oQ+QwcRhZSo9HTMviDvPB4s1PNJvUDWsXTfqltZPPqWi7vXmFOVpbrELjSaj6Ea5oUwD 712UgQ7Q2RptZTpWVqI6z4jcPRc/pp5eLDIW/jYLMcGFAnHfvmBM+6NoPE4wqi9UYyQC iH+J0dnLErNFMooJfY1lCrtGsLW07gm4NmkbwOPBysIp71fiVRWQ8DUEM2I6uD978Hr6 D9XAJttcOhmsj7rx9EpAe9JKS4V20UiHO1j4daZzPWJVVojkPqOqnF2fRc3/4b59v+Ln YafQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=eDMUz3fYRaQ87a+G1KlzwvxZMdppnhGKV7K5GSWVXsk=; b=sGyQTLIY8+sNo8oqWMA4YkXg1RaLMo8jwrTldDHRSYXQiA9h9cJ+nvBqlvWR16J3Y2 sU/SX65qXIHZLZFtVEkMJAncSNR+qn2l+Lvdj1hhJpBKDUFZUjatRZaH7+Hf3fQiJLNr uQ7El1lsDMNs3kx0hqRMIP1/7e/wHlzv4qBVslf8FF6g8S0/dt6vFllmrZdCKT7DJ6vM XXFJpTGTb9alPm4M/rq4R/pOrQB71ewWeG6jsmJ9qOI3ji5N4NTs3EbtuF8IH8aoLEp6 WNEtf/5ZtP2bz1XmUc/kA/YCMN03BJ8eiMmrmDakT9DV34vDbmo9IFV838o12nWjznVk RSjw== X-Gm-Message-State: AOAM530j2uHAfgWzQ8WPxxPiWjX5K2l55ERYPLgYk9TLfQhWTRlmUKwt F4gLb5QzYk0qN7tzN9MDqz1X1Q== X-Google-Smtp-Source: ABdhPJxa1BNRNRRfjb5R3poF0gb+JipcELHiCIvwzuK+DH8bff5S+lCoTofaiDQUbFXthAw+B6+Jdg== X-Received: by 2002:adf:82b8:: with SMTP id 53mr6552954wrc.172.1594737843517; Tue, 14 Jul 2020 07:44:03 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id j14sm29310341wrs.75.2020.07.14.07.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 07:44:02 -0700 (PDT) Date: Tue, 14 Jul 2020 15:44:00 +0100 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@arm.com, awarkentin@vmware.com, Andrei Warkentin Subject: Re: [edk2-platforms][PATCH v3 1/1] Platform/RaspberryPi/Drivers: Add SD/(e)MMC card detection Message-ID: <20200714144400.GY12303@vanye> References: <20200713111620.3596-1-pete@akeo.ie> <20200713111620.3596-2-pete@akeo.ie> <20200714132534.GW12303@vanye> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 14, 2020 at 14:49:21 +0100, Pete Batard wrote: > On 2020.07.14 14:25, Leif Lindholm wrote: > > On Mon, Jul 13, 2020 at 12:16:20 +0100, Pete Batard wrote: > > > The Raspberry Pi 3 and Pi 4 platforms (with latest EEPROM) can boot > > > straight from USB, without the need for an SD card being present. > > > However, the IsCardPresent () calls from the ArasanMmcHost and SdHost > > > drivers are currently hardwired to return TRUE, which results in > > > straight to USB boot failing due to the SD drivers looping on > > > errors while trying to poke at a non-existent card... > > > > > > Ideally, we would use the Card Detect signal from the uSD slot, to > > > report on the presence or absence of a card, but the Raspberry Pi > > > Foundation did not wire those signals in the Pi 2 and subsequent > > > models, leaving us with only potentially interfering SD commands > > > as means to perform card detection. > > > > > > As a result of this, we are left with no other choice but limit > > > detection to occurring only once, prior to formal SD card init, > > > and then return the detected value for subsequent calls. This, > > > however, is more than good enough for the intended purpose, which > > > is to allow straight to USB boot. The sequence is a simplified > > > variant of the identification code in MmcDxe. > > > > > > Tested on Raspberry Pi 2B, 3B and CM3 (for both SD controllers) > > > and Pi 4 (for Arasan, as that's the only controller available today) > > > > > > Addresses pftf/RPi3#13, pftf/RPi3#14, pftf/RPi4#37. > > > > > > Co-authored-by: Andrei Warkentin > > > Signed-off-by: Pete Batard > > > > Some minor style comments below, I'm happy to fix them before pushing > > if you're OK with these: > > I agree with the proposed changes. Thanks for volunteering to fix these. > > I just tested your diff with a Pi 4, for good measure, and everything looks > good. Thanks! With that Reviewed-by: Leif Lindholm Pushed as 225426271bb0. > Regards, > > /Pete > > > > > > --- > > > Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c | 86 ++++++++++++++++++-- > > > Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c | 75 +++++++++++++++-- > > > Platform/RaspberryPi/Include/Protocol/RpiMmcHost.h | 6 ++ > > > 3 files changed, 150 insertions(+), 17 deletions(-) > > > > > > diff --git a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > > index 6d706af6f276..d2a8ffddbb66 100644 > > > --- a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > > +++ b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > > @@ -11,7 +11,8 @@ > > > #define DEBUG_MMCHOST_SD DEBUG_VERBOSE > > > -BOOLEAN PreviousIsCardPresent = FALSE; > > > +BOOLEAN CardIsPresent = FALSE; > > > +CARD_DETECT_STATE CardDetectState = CardDetectRequired; > > > > Global variables, so add 'm' prefix? > > Also, add STATIC (which also matches SdHostDxe version)? > > > > > UINT32 LastExecutedCommand = (UINT32) -1; > > > STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; > > > @@ -239,14 +240,6 @@ CalculateClockFrequencyDivisor ( > > > return EFI_SUCCESS; > > > } > > > -BOOLEAN > > > -MMCIsCardPresent ( > > > - IN EFI_MMC_HOST_PROTOCOL *This > > > -) > > > -{ > > > - return TRUE; > > > -} > > > - > > > BOOLEAN > > > MMCIsReadOnly ( > > > IN EFI_MMC_HOST_PROTOCOL *This > > > @@ -418,6 +411,10 @@ MMCNotifyState ( > > > DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCNotifyState(State: %d)\n", State)); > > > + // Stall all operations except init until card detection has occurred. > > > + if (State != MmcHwInitializationState && CardDetectState != CardDetectCompleted) > > > + return EFI_NOT_READY; > > > + > > > > Add {}? > > > > > switch (State) { > > > case MmcHwInitializationState: > > > { > > > @@ -489,6 +486,77 @@ MMCNotifyState ( > > > return EFI_SUCCESS; > > > } > > > +BOOLEAN > > > +MMCIsCardPresent ( > > > + IN EFI_MMC_HOST_PROTOCOL *This > > > +) > > > +{ > > > + EFI_STATUS Status; > > > + > > > + // > > > + // If we are already in progress (we may get concurrent calls) > > > + // or completed the detection, just return the current value. > > > + // > > > + if (CardDetectState != CardDetectRequired) > > > + return CardIsPresent; > > > > Add {}? > > > > > + > > > + CardDetectState = CardDetectInProgress; > > > + CardIsPresent = FALSE; > > > + > > > + // > > > + // The two following commands should succeed even if no card is present. > > > + // > > > + Status = MMCNotifyState (This, MmcHwInitializationState); > > > + if (EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_ERROR, "MMCIsCardPresent: Error MmcHwInitializationState, Status=%r.\n", Status)); > > > + // If we failed init, go back to requiring card detection > > > + CardDetectState = CardDetectRequired; > > > + return FALSE; > > > + } > > > + > > > + Status = MMCSendCommand (This, MMC_CMD0, 0); > > > + if (EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_ERROR, "MMCIsCardPresent: CMD0 Error, Status=%r.\n", Status)); > > > + goto out; > > > + } > > > + > > > + // > > > + // CMD8 should tell us if an SD card is present. > > > + // > > > + Status = MMCSendCommand (This, MMC_CMD8, CMD8_SD_ARG); > > > + if (!EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe SD card detected.\n")); > > > + CardIsPresent = TRUE; > > > + goto out; > > > + } > > > + > > > + // > > > + // MMC/eMMC won't accept CMD8, but we can try CMD1. > > > + // > > > + Status = MMCSendCommand (This, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); > > > + if (!EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe MMC card detected.\n")); > > > + CardIsPresent = TRUE; > > > + goto out; > > > + } > > > + > > > + // > > > + // SDIO? > > > + // > > > + Status = MMCSendCommand (This, MMC_CMD5, 0); > > > + if (!EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe SDIO card detected.\n")); > > > + CardIsPresent = TRUE; > > > + goto out; > > > + } > > > + > > > + DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Not detected, Status=%r.\n", Status)); > > > + > > > +out: > > > + CardDetectState = CardDetectCompleted; > > > + return CardIsPresent; > > > +} > > > + > > > EFI_STATUS > > > MMCReceiveResponse ( > > > IN EFI_MMC_HOST_PROTOCOL *This, > > > diff --git a/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c b/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > > index 2f31c5eb8c46..aac8b34c4bf4 100644 > > > --- a/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > > +++ b/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > > @@ -64,6 +64,8 @@ STATIC CONST CHAR8 *mFsmState[] = { "identmode", "datamode", "readdata", > > > "genpulses", "writewait2", "?", > > > "startpowdown" }; > > > #endif /* NDEBUG */ > > > +STATIC BOOLEAN CardIsPresent = FALSE; > > > +STATIC CARD_DETECT_STATE CardDetectState = CardDetectRequired; > > > > Add 'm' prefix? > > > > > STATIC UINT32 mLastGoodCmd = MMC_GET_INDX (MMC_CMD0); > > > STATIC inline BOOLEAN > > > @@ -264,14 +266,6 @@ SdHostSetClockFrequency ( > > > return Status; > > > } > > > -STATIC BOOLEAN > > > -SdIsCardPresent ( > > > - IN EFI_MMC_HOST_PROTOCOL *This > > > - ) > > > -{ > > > - return TRUE; > > > -} > > > - > > > STATIC BOOLEAN > > > SdIsReadOnly ( > > > IN EFI_MMC_HOST_PROTOCOL *This > > > @@ -639,6 +633,10 @@ SdNotifyState ( > > > { > > > DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdNotifyState(State: %d) ", State)); > > > + // Stall all operations except init until card detection has occurred. > > > + if (State != MmcHwInitializationState && CardDetectState != CardDetectCompleted) > > > + return EFI_NOT_READY; > > > + > > > > Add {}? > > > > > switch (State) { > > > case MmcHwInitializationState: > > > DEBUG ((DEBUG_MMCHOST_SD, "MmcHwInitializationState\n", State)); > > > @@ -718,6 +716,67 @@ SdNotifyState ( > > > return EFI_SUCCESS; > > > } > > > +STATIC BOOLEAN > > > +SdIsCardPresent ( > > > + IN EFI_MMC_HOST_PROTOCOL *This > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + > > > + // > > > + // If we are already in progress (we may get concurrent calls) > > > + // or completed the detection, just return the current value. > > > + // > > > + if (CardDetectState != CardDetectRequired) > > > + return CardIsPresent; > > > > Add {}? > > > > I.e. in total, fold in: > > diff --git a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > index d2a8ffddbb66..88e9126e3549 100644 > > --- a/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > +++ b/Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c > > @@ -11,8 +11,8 @@ > > #define DEBUG_MMCHOST_SD DEBUG_VERBOSE > > -BOOLEAN CardIsPresent = FALSE; > > -CARD_DETECT_STATE CardDetectState = CardDetectRequired; > > +STATIC BOOLEAN mCardIsPresent = FALSE; > > +STATIC CARD_DETECT_STATE mCardDetectState = CardDetectRequired; > > UINT32 LastExecutedCommand = (UINT32) -1; > > STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; > > @@ -412,8 +412,9 @@ MMCNotifyState ( > > DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCNotifyState(State: %d)\n", State)); > > // Stall all operations except init until card detection has occurred. > > - if (State != MmcHwInitializationState && CardDetectState != CardDetectCompleted) > > + if (State != MmcHwInitializationState && mCardDetectState != CardDetectCompleted) { > > return EFI_NOT_READY; > > + } > > switch (State) { > > case MmcHwInitializationState: > > @@ -497,11 +498,12 @@ MMCIsCardPresent ( > > // If we are already in progress (we may get concurrent calls) > > // or completed the detection, just return the current value. > > // > > - if (CardDetectState != CardDetectRequired) > > - return CardIsPresent; > > + if (mCardDetectState != CardDetectRequired) { > > + return mCardIsPresent; > > + } > > - CardDetectState = CardDetectInProgress; > > - CardIsPresent = FALSE; > > + mCardDetectState = CardDetectInProgress; > > + mCardIsPresent = FALSE; > > // > > // The two following commands should succeed even if no card is present. > > @@ -510,7 +512,7 @@ MMCIsCardPresent ( > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "MMCIsCardPresent: Error MmcHwInitializationState, Status=%r.\n", Status)); > > // If we failed init, go back to requiring card detection > > - CardDetectState = CardDetectRequired; > > + mCardDetectState = CardDetectRequired; > > return FALSE; > > } > > @@ -526,7 +528,7 @@ MMCIsCardPresent ( > > Status = MMCSendCommand (This, MMC_CMD8, CMD8_SD_ARG); > > if (!EFI_ERROR (Status)) { > > DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe SD card detected.\n")); > > - CardIsPresent = TRUE; > > + mCardIsPresent = TRUE; > > goto out; > > } > > @@ -536,7 +538,7 @@ MMCIsCardPresent ( > > Status = MMCSendCommand (This, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); > > if (!EFI_ERROR (Status)) { > > DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe MMC card detected.\n")); > > - CardIsPresent = TRUE; > > + mCardIsPresent = TRUE; > > goto out; > > } > > @@ -546,15 +548,15 @@ MMCIsCardPresent ( > > Status = MMCSendCommand (This, MMC_CMD5, 0); > > if (!EFI_ERROR (Status)) { > > DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Maybe SDIO card detected.\n")); > > - CardIsPresent = TRUE; > > + mCardIsPresent = TRUE; > > goto out; > > } > > DEBUG ((DEBUG_INFO, "MMCIsCardPresent: Not detected, Status=%r.\n", Status)); > > out: > > - CardDetectState = CardDetectCompleted; > > - return CardIsPresent; > > + mCardDetectState = CardDetectCompleted; > > + return mCardIsPresent; > > } > > EFI_STATUS > > diff --git a/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c b/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > index aac8b34c4bf4..0fd1ac6e8985 100644 > > --- a/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > +++ b/Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.c > > @@ -64,8 +64,8 @@ STATIC CONST CHAR8 *mFsmState[] = { "identmode", "datamode", "readdata", > > "genpulses", "writewait2", "?", > > "startpowdown" }; > > #endif /* NDEBUG */ > > -STATIC BOOLEAN CardIsPresent = FALSE; > > -STATIC CARD_DETECT_STATE CardDetectState = CardDetectRequired; > > +STATIC BOOLEAN mCardIsPresent = FALSE; > > +STATIC CARD_DETECT_STATE mCardDetectState = CardDetectRequired; > > STATIC UINT32 mLastGoodCmd = MMC_GET_INDX (MMC_CMD0); > > STATIC inline BOOLEAN > > @@ -634,8 +634,9 @@ SdNotifyState ( > > DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdNotifyState(State: %d) ", State)); > > // Stall all operations except init until card detection has occurred. > > - if (State != MmcHwInitializationState && CardDetectState != CardDetectCompleted) > > + if (State != MmcHwInitializationState && mCardDetectState != CardDetectCompleted) { > > return EFI_NOT_READY; > > + } > > switch (State) { > > case MmcHwInitializationState: > > @@ -727,11 +728,12 @@ SdIsCardPresent ( > > // If we are already in progress (we may get concurrent calls) > > // or completed the detection, just return the current value. > > // > > - if (CardDetectState != CardDetectRequired) > > - return CardIsPresent; > > + if (mCardDetectState != CardDetectRequired) { > > + return mCardIsPresent; > > + } > > - CardDetectState = CardDetectInProgress; > > - CardIsPresent = FALSE; > > + mCardDetectState = CardDetectInProgress; > > + mCardIsPresent = FALSE; > > // > > // The two following commands should succeed even if no card is present. > > @@ -740,7 +742,7 @@ SdIsCardPresent ( > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "SdIsCardPresent: Error MmcHwInitializationState, Status=%r.\n", Status)); > > // If we failed init, go back to requiring card detection > > - CardDetectState = CardDetectRequired; > > + mCardDetectState = CardDetectRequired; > > return FALSE; > > } > > @@ -756,7 +758,7 @@ SdIsCardPresent ( > > Status = SdSendCommand (This, MMC_CMD8, CMD8_SD_ARG); > > if (!EFI_ERROR (Status)) { > > DEBUG ((DEBUG_INFO, "SdIsCardPresent: Maybe SD card detected.\n")); > > - CardIsPresent = TRUE; > > + mCardIsPresent = TRUE; > > goto out; > > } > > @@ -766,15 +768,15 @@ SdIsCardPresent ( > > Status = SdSendCommand (This, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); > > if (!EFI_ERROR (Status)) { > > DEBUG ((DEBUG_INFO, "SdIsCardPresent: Maybe MMC card detected.\n")); > > - CardIsPresent = TRUE; > > + mCardIsPresent = TRUE; > > goto out; > > } > > DEBUG ((DEBUG_INFO, "SdIsCardPresent: Not detected, Status=%r.\n", Status)); > > out: > > - CardDetectState = CardDetectCompleted; > > - return CardIsPresent; > > + mCardDetectState = CardDetectCompleted; > > + return mCardIsPresent; > > } > > BOOLEAN > > > > (Compile tested to ensure I didn't screw up the renamings.) > > > > / > > Leif > > > > > + > > > + CardDetectState = CardDetectInProgress; > > > + CardIsPresent = FALSE; > > > + > > > + // > > > + // The two following commands should succeed even if no card is present. > > > + // > > > + Status = SdNotifyState (This, MmcHwInitializationState); > > > + if (EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_ERROR, "SdIsCardPresent: Error MmcHwInitializationState, Status=%r.\n", Status)); > > > + // If we failed init, go back to requiring card detection > > > + CardDetectState = CardDetectRequired; > > > + return FALSE; > > > + } > > > + > > > + Status = SdSendCommand (This, MMC_CMD0, 0); > > > + if (EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_ERROR, "SdIsCardPresent: CMD0 Error, Status=%r.\n", Status)); > > > + goto out; > > > + } > > > + > > > + // > > > + // CMD8 should tell us if an SD card is present. > > > + // > > > + Status = SdSendCommand (This, MMC_CMD8, CMD8_SD_ARG); > > > + if (!EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_INFO, "SdIsCardPresent: Maybe SD card detected.\n")); > > > + CardIsPresent = TRUE; > > > + goto out; > > > + } > > > + > > > + // > > > + // MMC/eMMC won't accept CMD8, but we can try CMD1. > > > + // > > > + Status = SdSendCommand (This, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); > > > + if (!EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_INFO, "SdIsCardPresent: Maybe MMC card detected.\n")); > > > + CardIsPresent = TRUE; > > > + goto out; > > > + } > > > + > > > + DEBUG ((DEBUG_INFO, "SdIsCardPresent: Not detected, Status=%r.\n", Status)); > > > + > > > +out: > > > + CardDetectState = CardDetectCompleted; > > > + return CardIsPresent; > > > +} > > > + > > > BOOLEAN > > > SdIsMultiBlock ( > > > IN EFI_MMC_HOST_PROTOCOL *This > > > diff --git a/Platform/RaspberryPi/Include/Protocol/RpiMmcHost.h b/Platform/RaspberryPi/Include/Protocol/RpiMmcHost.h > > > index c558e00bf500..78514a31bc4e 100644 > > > --- a/Platform/RaspberryPi/Include/Protocol/RpiMmcHost.h > > > +++ b/Platform/RaspberryPi/Include/Protocol/RpiMmcHost.h > > > @@ -82,6 +82,12 @@ typedef enum _MMC_STATE { > > > MmcDisconnectState, > > > } MMC_STATE; > > > +typedef enum _CARD_DETECT_STATE { > > > + CardDetectRequired = 0, > > > + CardDetectInProgress, > > > + CardDetectCompleted > > > +} CARD_DETECT_STATE; > > > + > > > #define EMMCBACKWARD (0) > > > #define EMMCHS26 (1 << 0) // High-Speed @26MHz at rated device voltages > > > #define EMMCHS52 (1 << 1) // High-Speed @52MHz at rated device voltages > > > -- > > > 2.21.0.windows.1 > > > >