From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0045.outbound.protection.outlook.com [104.47.36.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 90DE021E95E00 for ; Wed, 30 Aug 2017 01:29:46 -0700 (PDT) Received: from BLUPR0301CA0008.namprd03.prod.outlook.com (2a01:111:e400:5259::18) by MWHSPR01MB180.namprd03.prod.outlook.com (2603:10b6:301:7b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Wed, 30 Aug 2017 08:32:25 +0000 Received: from BN1AFFO11FD044.protection.gbl (2a01:111:f400:7c10::118) by BLUPR0301CA0008.outlook.office365.com (2a01:111:e400:5259::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10 via Frontend Transport; Wed, 30 Aug 2017 08:32:25 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD044.mail.protection.outlook.com (10.58.52.191) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Wed, 30 Aug 2017 08:32:23 +0000 Received: from uefi-OptiPlex-790.ap.freescale.net (uefi-OptiPlex-790.ap.freescale.net [10.232.132.78]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7U8WIQN012483; Wed, 30 Aug 2017 01:32:21 -0700 From: Meenakshi Aggarwal To: Date: Wed, 30 Aug 2017 19:50:59 +0530 Message-ID: <1504102859-13477-2-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1504102859-13477-1-git-send-email-meenakshi.aggarwal@nxp.com> References: <1504102859-13477-1-git-send-email-meenakshi.aggarwal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131485555445635318; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(4326008)(305945005)(77096006)(50466002)(105606002)(106466001)(5660300001)(2351001)(48376002)(68736007)(626005)(189998001)(356003)(8656003)(97736004)(2906002)(8676002)(36756003)(50226002)(8936002)(50986999)(81156014)(110136004)(81166006)(2950100002)(76176999)(6916009)(575784001)(86362001)(85426001)(6666003)(104016004)(498600001)(5003940100001)(53936002)(47776003)(33646002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHSPR01MB180; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD044; 1:iQQ5ZO1Aidf0B3eWyaRBCghinucNViN11w5QaodPBSczL3Rk+EPFJg63ACfrD67zoZIlIFEPHRRjk2SuU204ARNbSnMqmZHubXEZfIDYF4ODrsshV9pzuA3qyAY2ynIj MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb274590-ec38-480c-98f6-08d4ef81a3e5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300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/PtVMgyjX4381Vjud5gJl2CMb5cFFH7amNiI=; 4:Cap3aGvWIxMsYN2ytUCWf23vR2flXGy+0eaF4YxSQqk0lO4JKoSOCSTuzJ6wzL/tQrM3hE4C8nZd11ltdIi9RdPcibnPWUEzSKpQrIm9uC+d4M+xZOSAcGE54ipB+gXg2UTijBBpECXQoBnHj1QJU29iQu4dr1bj6Hy7gPVO6MrF7zpXDzpSZVfv6QOpliEYAKQt7fSqzEMeP6jbih60uncXGBusZ+bQNqOA4/Bhu57KnQR9ooXmI8NNPggOangnsIyThSs7k+v92gYEo6kgCycjNYEMrs0tW4tZ8wRvcAY= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(5005006)(13018025)(13016025)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123563025)(20161123556025)(20161123565025)(20161123559100)(20161123561025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHSPR01MB180; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHSPR01MB180; X-Forefront-PRVS: 041517DFAB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHSPR01MB180; 23:YRCJmSUAvHIpt1ng8Gqu7TxD7VUX0T9QlHuXWZMb6?= =?us-ascii?Q?wDKSD4nzU2li0kmqw487obiVyZkl6PylzqOwEJUhHTHiSZDHKeJyWj6L++rh?= =?us-ascii?Q?XTaWr8NVyIyErgfsW38Y0T+Z7sTAhdD7O+On6IRUfpRjpxZxr9q0zTOCeGAU?= =?us-ascii?Q?/YSOhwvkSPwjXS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enant-OriginalArrivalTime: 30 Aug 2017 08:32:23.7211 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHSPR01MB180 Subject: [PATCH 2/2] SD : Updated CMD 6 implememtation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2017 08:29:47 -0000 Content-Type: text/plain For setting high speed in SD card, First CMD 6 (Switch) is send to check if card supports High Speed and Second command is send to switch card to high speed mode. In current inplementation, CMD 6 was sent only once to switch the card into HS mode without checking if card supports HS or not, which is not as per specification and also we are not setting the HS i.e. 50000000 but directly asking the card to switch to 26000000 which is incorrect as SD card supports either 25000000 or 50000000. Signed-off-by: Meenakshi Aggarwal --- EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 64 ++++++++++++++++++++---- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index 7f74c54..3071b3b 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c @@ -317,6 +317,24 @@ InitializeEmmcDevice ( return Status; } + +STATIC +UINT32 +CreateSwitchCmdArgument ( + IN UINT8 Mode, + IN UINT8 Group, + IN UINT8 Value + ) +{ + UINT32 Argument; + + Argument = Mode << 31 | 0x00FFFFFF; + Argument &= ~(0xF << (Group * 4)); + Argument |= Value << (Group * 4); + + return Argument; +} + STATIC EFI_STATUS InitializeSdMmcDevice ( @@ -326,6 +344,7 @@ InitializeSdMmcDevice ( UINT32 CmdArg; UINT32 Response[4]; UINT32 Buffer[128]; + UINT32 Speed; UINTN BlockSize; UINTN CardSize; UINTN NumBlocks; @@ -334,6 +353,7 @@ InitializeSdMmcDevice ( EFI_STATUS Status; EFI_MMC_HOST_PROTOCOL *MmcHost; + Speed = 25000000; MmcHost = MmcHostInstance->MmcHost; // Send a command to get Card specific data @@ -439,43 +459,69 @@ InitializeSdMmcDevice ( } } if (CccSwitch) { + /* SD Switch, Mode:0, Group:0, Value:0 */ + CmdArg = CreateSwitchCmdArgument(0, 0, 0); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): Failed with Status = %r\n", __func__, Status)); + return Status; + } else { + Status = MmcHost->ReadBlockData (MmcHost, 0, 64, Buffer); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): ReadBlockData Failed with Status = %r\n", __func__, Status)); + return Status; + } + } + + if (!(Buffer[3] & 0x20000)) { + DEBUG ((EFI_D_ERROR, "%aHigh Speed not supported by Card %r\n", __func__, Status)); + return Status; + } + + Speed = 50000000; //High Speed for SD card is 50 MHZ + /* SD Switch, Mode:1, Group:0, Value:1 */ - CmdArg = 1 << 31 | 0x00FFFFFF; - CmdArg &= ~(0xF << (0 * 4)); - CmdArg |= 1 << (0 * 4); + CmdArg = CreateSwitchCmdArgument(1, 0, 1); Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): Error and Status = %r\n", Status)); + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): Error and Status = %r\n", __func__, Status)); return Status; } else { Status = MmcHost->ReadBlockData (MmcHost, 0, 64, Buffer); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): ReadBlockData Error and Status = %r\n", Status)); + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): ReadBlockData Error and Status = %r\n",__func__, Status)); + return Status; + } + + if ((Buffer[4] & 0x0f000000) != 0x01000000) { + DEBUG((EFI_D_ERROR, "Problem switching SD card into high-speed mode\n")); return Status; } } } + if (Scr.SD_BUS_WIDTHS & SD_BUS_WIDTH_4BIT) { CmdArg = MmcHostInstance->CardInfo.RCA << 16; Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, CmdArg); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a(MMC_CMD55): Error and Status = %r\n", Status)); + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD55): Error and Status = %r\n", __func__, Status)); return Status; } /* Width: 4 */ Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, 2); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): Error and Status = %r\n", Status)); + DEBUG ((EFI_D_ERROR, "%a(MMC_CMD6): Error and Status = %r\n", __func__, Status)); return Status; } } if (MMC_HOST_HAS_SETIOS(MmcHost)) { - Status = MmcHost->SetIos (MmcHost, 26 * 1000 * 1000, 4, EMMCBACKWARD); + Status = MmcHost->SetIos (MmcHost, Speed, 4, EMMCBACKWARD); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a(SetIos): Error and Status = %r\n", Status)); + DEBUG ((EFI_D_ERROR, "%a(SetIos): Error and Status = %r\n", __func__, Status)); return Status; } } + return EFI_SUCCESS; } -- 1.9.1