From nobody Mon Feb 9 10:12:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+51337+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51337+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1574858247; cv=none; d=zohomail.com; s=zohoarc; b=bdTWVbaDTMoEU6CYfkGNCZF+8KCOrHdbZX3HGcI8VEsyuIFD8OgPlin5HyiLF/lZPhPMQkIPFj5zM1yGq7Glqk9AukEFAi37F6DKOmQeiIBqAAi6GawPDT/d6TeJhVuJGFh4ZI1zTJdx/5H9exoRf72OS14A7F3lfl8CLSOqRP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574858247; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TIvSqTdvT7Pa6k6b7TEa2uLWrISLlnDLHMjG2RXx2Sc=; b=XtJqW0WigxpwAgaox2qtX1VVU/u6WtsbUB9mGTTET8TWTQmTznTZxARS9Ge0vgwkuCUbfyPoycCkeWWYQqNQSEEExYyCu7yMeIi2vN2nWpszCw3LvaGLWQjGXCppnQsx8e0Jx1s5TyOXADR02OTTDSjekWXb4mprpQ11SfM3bmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51337+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1574858247495410.2133253025394; Wed, 27 Nov 2019 04:37:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Wed, 27 Nov 2019 04:37:27 -0800 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web11.5378.1574858246105427849 for ; Wed, 27 Nov 2019 04:37:26 -0800 X-Received: by mail-wm1-f66.google.com with SMTP id p17so1408583wma.1 for ; Wed, 27 Nov 2019 04:37:25 -0800 (PST) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqxem01r+GxELYeZk6o0wKk5aljfmaezc2ftdjEWVd5fKiAJa670J70MNxCSwByrw0C9IO1mpQ== X-Received: by 2002:a1c:a743:: with SMTP id q64mr4201929wme.44.1574858244304; Wed, 27 Nov 2019 04:37:24 -0800 (PST) X-Received: from localhost.localdomain ([84.203.37.1]) by smtp.gmail.com with ESMTPSA id p9sm18847833wrs.55.2019.11.27.04.37.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Nov 2019 04:37:23 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com, samer.el-haj-mahmoud@arm.com, andrey.warkentin@gmail.com Subject: [edk2-devel] [edk2-platforms][PATCH 3/5] Platform/RPi/MmcDxe: Factorize SCR call and clean up MMC init Date: Wed, 27 Nov 2019 12:37:04 +0000 Message-Id: <20191127123706.4604-4-pete@akeo.ie> In-Reply-To: <20191127123706.4604-1-pete@akeo.ie> References: <20191127123706.4604-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1574858247; bh=c0pgxiWN5jUFdLxEeZivt2s2W3kWnthrYcuXFG19+ro=; h=Cc:Date:From:Reply-To:Subject:To; b=iJyTh2Egyo1xfJQ0IRdA/k8gXR7QBOmCLhVTUJKceUIxUgtkc1zBotinio37T6uBSm1 i7m7MP2VNRWyhrNwhgAmseCVobgEdpRn9BWAmeQN+XHiz1FrSx71Xw37MkaqhEFcVlDb9 OZkFO//cxcQDQE4M8SZx786FsECo8SBmDbQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Andrei Warkentin This is mostly a maintainability improvement for the InitializeSdMmcDevice () call achieved by factorizing the code related to SCR execution into a new SdExecuteScr () call. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Drivers/MmcDxe/MmcIdentification.c | 105 ++++++++++++= -------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/MmcDxe/MmcIdentification.c b/Plat= form/RaspberryPi/Drivers/MmcDxe/MmcIdentification.c index 4ee5c5ca6fb2..34a97e954220 100644 --- a/Platform/RaspberryPi/Drivers/MmcDxe/MmcIdentification.c +++ b/Platform/RaspberryPi/Drivers/MmcDxe/MmcIdentification.c @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2019, Andrei Warkentin * Copyright (c) 2011-2015, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent @@ -567,6 +568,48 @@ SdSetSpeed ( return EFI_SUCCESS; } =20 +STATIC +EFI_STATUS +SdExecuteScr ( + IN MMC_HOST_INSTANCE *MmcHostInstance, + OUT SCR *Scr + ) +{ + EFI_STATUS Status; + UINT32 Response[4]; + EFI_MMC_HOST_PROTOCOL *MmcHost =3D MmcHostInstance->MmcHost; + + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD55, + MmcHostInstance->CardInfo.RCA << 16); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status =3D %r\n", __FU= NCTION__, Status)); + return Status; + } + Status =3D MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Resp= onse); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status =3D %r\n", __FU= NCTION__, Status)); + return Status; + } + if ((Response[0] & MMC_STATUS_APP_CMD) =3D=3D 0) { + return EFI_SUCCESS; + } + + /* SCR */ + Status =3D MmcHost->SendCommand (MmcHost, MMC_ACMD51, 0); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): Error and Status =3D %r\n", __fu= nc__, Status)); + return Status; + } + + Status =3D MmcHost->ReadBlockData (MmcHost, 0, 8, (VOID *) Scr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): ReadBlockData Error and Status = =3D %r\n", __func__, Status)); + return Status; + } + + return EFI_SUCCESS; +} + STATIC EFI_STATUS InitializeSdMmcDevice ( @@ -574,7 +617,6 @@ InitializeSdMmcDevice ( ) { UINT32 Response[4]; - UINT32 Buffer[128]; UINTN BlockSize; UINTN CardSize; UINTN NumBlocks; @@ -621,58 +663,35 @@ InitializeSdMmcDevice ( return Status; } =20 - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD55, - MmcHostInstance->CardInfo.RCA << 16); + Status =3D SdExecuteScr (MmcHostInstance, &Scr); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status =3D %r\n", __FU= NCTION__, Status)); - return Status; - } - Status =3D MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Resp= onse); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status =3D %r\n", __FU= NCTION__, Status)); - return Status; - } - if ((Response[0] & MMC_STATUS_APP_CMD) =3D=3D 0) { - return EFI_SUCCESS; + return Status; } =20 - /* SCR */ - Status =3D MmcHost->SendCommand (MmcHost, MMC_ACMD51, 0); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): Error and Status =3D %r\n", __fu= nc__, Status)); - return Status; - } else { - Status =3D MmcHost->ReadBlockData (MmcHost, 0, 8, Buffer); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): ReadBlockData Error and Status= =3D %r\n", __func__, Status)); - return Status; - } - CopyMem (&Scr, Buffer, 8); - if (Scr.SD_SPEC =3D=3D 2) { - if (Scr.SD_SPEC3 =3D=3D 1) { - if (Scr.SD_SPEC4 =3D=3D 1) { - DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 4.xx\n")); - } else { - DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 3.0x\n")); - } + if (Scr.SD_SPEC =3D=3D 2) { + if (Scr.SD_SPEC3 =3D=3D 1) { + if (Scr.SD_SPEC4 =3D=3D 1) { + DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 4.xx\n")); } else { - if (Scr.SD_SPEC4 =3D=3D 0) { - DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 2.0\n")); - } else { - DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n")); - } + DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 3.0x\n")); } } else { - if ((Scr.SD_SPEC3 =3D=3D 0) && (Scr.SD_SPEC4 =3D=3D 0)) { - if (Scr.SD_SPEC =3D=3D 1) { - DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.10\n")); - } else { - DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.0\n")); - } + if (Scr.SD_SPEC4 =3D=3D 0) { + DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 2.0\n")); } else { DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n")); } } + } else { + if ((Scr.SD_SPEC3 =3D=3D 0) && (Scr.SD_SPEC4 =3D=3D 0)) { + if (Scr.SD_SPEC =3D=3D 1) { + DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.10\n")); + } else { + DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.0\n")); + } + } else { + DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n")); + } } =20 Status =3D SdSetSpeed (MmcHostInstance, CccSwitch); --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51337): https://edk2.groups.io/g/devel/message/51337 Mute This Topic: https://groups.io/mt/62504742/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-