From patchwork Fri Mar 11 12:01:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 86412 X-Patchwork-Delegate: afleming@freescale.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 436B8B6F11 for ; Fri, 11 Mar 2011 23:01:55 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C8770280D6; Fri, 11 Mar 2011 13:01:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 SeczuNb07yQH; Fri, 11 Mar 2011 13:01:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 47480280AD; Fri, 11 Mar 2011 13:01:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 891822809D for ; Fri, 11 Mar 2011 13:01:26 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 g-++0xoUDI9C for ; Fri, 11 Mar 2011 13:01:24 +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 mail-ew0-f44.google.com (mail-ew0-f44.google.com [209.85.215.44]) by theia.denx.de (Postfix) with ESMTPS id 6AE7E2809E for ; Fri, 11 Mar 2011 13:01:24 +0100 (CET) Received: by ewy19 with SMTP id 19so909154ewy.3 for ; Fri, 11 Mar 2011 04:01:24 -0800 (PST) Received: by 10.14.11.31 with SMTP id 31mr3448696eew.15.1299844884022; Fri, 11 Mar 2011 04:01:24 -0800 (PST) Received: from localhost.localdomain (ip-88-137.sn2.eutelia.it [83.211.88.137]) by mx.google.com with ESMTPS id u45sm1097225eeh.8.2011.03.11.04.01.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Mar 2011 04:01:23 -0800 (PST) From: Raffaele Recalcati To: u-boot list Date: Fri, 11 Mar 2011 13:01:13 +0100 Message-Id: <1299844874-7605-3-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1299844874-7605-1-git-send-email-lamiaposta71@gmail.com> References: <1299844874-7605-1-git-send-email-lamiaposta71@gmail.com> Cc: Raffaele Recalcati Subject: [U-Boot] [RFC 2/3][v4] mmc: SEND_OP_COND considers card capabilities (voltage) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Raffaele Recalcati The first SEND_OP_COND (CMD1) command added is used to ask card capabilities. After it an AND operation is done between card capabilities and host capabilities (at the moment only for the voltage field). Finally the correct value is sent to the MMC, waiting that the card exits from busy state. Signed-off-by: Raffaele Recalcati Tested-by:Lei Wen --- drivers/mmc/mmc.c | 19 +++++++++++++++++-- include/mmc.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index fc1792a..5bea476 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -351,17 +351,32 @@ sd_send_op_cond(struct mmc *mmc) int mmc_send_op_cond(struct mmc *mmc) { - int timeout = 1000; + int timeout = 10000; struct mmc_cmd cmd; int err; /* Some cards seem to need this */ mmc_go_idle(mmc); + /* Asking to the card its capabilities */ + cmd.cmdidx = MMC_CMD_SEND_OP_COND; + cmd.resp_type = MMC_RSP_R3; + cmd.cmdarg = 0; + cmd.flags = 0; + + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + + udelay(1000); + do { cmd.cmdidx = MMC_CMD_SEND_OP_COND; cmd.resp_type = MMC_RSP_R3; - cmd.cmdarg = OCR_HCS | mmc->voltages; + cmd.cmdarg = ((mmc->voltages & + (cmd.response[0] & OCR_VOLTAGE_MASK)) | + (cmd.response[0] & OCR_ACCESS_MODE)); cmd.flags = 0; err = mmc_send_cmd(mmc, &cmd, NULL); diff --git a/include/mmc.h b/include/mmc.h index 4ee8e1c..d18526d 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -93,6 +93,8 @@ #define OCR_BUSY 0x80000000 #define OCR_HCS 0x40000000 +#define OCR_VOLTAGE_MASK 0x007FFF80 +#define OCR_ACCESS_MODE 0x60000000 #define MMC_STATUS_MASK (~0x0206BF7F) #define MMC_STATUS_RDY_FOR_DATA (1<<8)