From patchwork Thu Mar 19 08:22:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 451775 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E02FE140083 for ; Thu, 19 Mar 2015 19:23:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 33C104A03C; Thu, 19 Mar 2015 09:23:17 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uNgL1boB8mS1; Thu, 19 Mar 2015 09:23:17 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B3DFB4A039; Thu, 19 Mar 2015 09:23:16 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C84C54A039 for ; Thu, 19 Mar 2015 09:23:14 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CewOX9t2S9Un for ; Thu, 19 Mar 2015 09:23:14 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0112.outbound.protection.outlook.com [157.56.111.112]) by theia.denx.de (Postfix) with ESMTPS id 23A864A036 for ; Thu, 19 Mar 2015 09:23:11 +0100 (CET) Received: from DM2PR03CA0045.namprd03.prod.outlook.com (10.141.96.44) by CY1PR0301MB0681.namprd03.prod.outlook.com (25.160.158.151) with Microsoft SMTP Server (TLS) id 15.1.118.21; Thu, 19 Mar 2015 08:23:07 +0000 Received: from BN1BFFO11OLC001.protection.gbl (2a01:111:f400:7c10::1:117) by DM2PR03CA0045.outlook.office365.com (2a01:111:e400:2428::44) with Microsoft SMTP Server (TLS) id 15.1.118.21 via Frontend Transport; Thu, 19 Mar 2015 08:23:07 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11OLC001.mail.protection.outlook.com (10.58.145.12) with Microsoft SMTP Server (TLS) id 15.1.125.13 via Frontend Transport; Thu, 19 Mar 2015 08:23:07 +0000 Received: from linux-jyl1.ap.freescale.net (b51431-11.ap.freescale.net [10.193.99.70]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t2J8MnJH016872; Thu, 19 Mar 2015 01:23:04 -0700 From: Peng Fan To: Date: Thu, 19 Mar 2015 16:22:46 +0800 Message-ID: <1426753366-27618-1-git-send-email-Peng.Fan@freescale.com> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.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; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=Peng.Fan@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(46102003)(50466002)(19580395003)(19580405001)(87936001)(575784001)(86362001)(50986999)(48376002)(106466001)(105606002)(85426001)(229853001)(2351001)(92566002)(50226001)(77156002)(62966003)(77096005)(104016003)(47776003)(110136001)(36756003)(6806004); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB0681; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0681; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:CY1PR0301MB0681; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB0681; X-Forefront-PRVS: 052017CAF1 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2015 08:23:07.4220 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0681 Cc: trini@konsulko.com, panto@antoniou-consulting.com Subject: [U-Boot] [PATCH] mmc: fix OCR Polling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" If in mmc_send_op_cond, OCR_BUSY is set in CMD1's response, then state is transfered to Ready state, and there is no need to send CMD1 again. Otherwise following CMD1 will recieve no response, or timeour error from driver such as fsl_esdhc.c. If not into Ready state in previous CMD1, then continue CMD1 command. In mmc_complete_op_cond, we use the value mmc->op_cond_response from mmc_send_op_cond, since there should be no CMD1 command between mmc_send_op_cond and mmc_complete_op_cond Before fixing this, uboot log shows: " CMD_SEND:0 ARG 0x00000000 MMC_RSP_NONE CMD_SEND:8 ARG 0x000001AA MMC_RSP_R1,5,6,7 0x18EC1504 CMD_SEND:55 ARG 0x00000000 MMC_RSP_R1,5,6,7 0x18EC1504 CMD_SEND:0 ARG 0x00000000 MMC_RSP_NONE CMD_SEND:1 ARG 0x00000000 MMC_RSP_R3,4 0x00FF8080 CMD_SEND:1 ARG 0x40300000 MMC_RSP_R3,4 0xC0FF8080 --> Already OCR_BUSY set CMD_SEND:1 ARG 0x40300000 MMC_RSP_R3,4 0x0096850A --> Failed CMD1 MMC init failed " Using this patch, this issue is fixed, emmc can be detected correctly. Signed-off-by: Peng Fan --- drivers/mmc/mmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a13769e..43a9a8a 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -406,14 +406,23 @@ static int mmc_complete_op_cond(struct mmc *mmc) mmc->op_cond_pending = 0; start = get_timer(0); - do { + /* + * If in mmc_send_op_cond, OCR_BUSY is set in CMD1's response, then + * state is transfered to Ready state, and there is no need to + * send CMD1 again. Otherwise following CMD1 will recieve no response, + * or timeour error from driver such as fsl_esdhc.c. + * + * If not into Ready state in previous CMD1, then continue CMD1 + * command. + */ + while (!(mmc->op_cond_response & OCR_BUSY)) { err = mmc_send_op_cond_iter(mmc, &cmd, 1); if (err) return err; if (get_timer(start) > timeout) return UNUSABLE_ERR; udelay(100); - } while (!(mmc->op_cond_response & OCR_BUSY)); + } if (mmc_host_is_spi(mmc)) { /* read OCR for spi */ cmd.cmdidx = MMC_CMD_SPI_READ_OCR;