From patchwork Tue Jul 2 08:53:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 1126089 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="oyc5txZK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45dJ9H3p1gz9s00 for ; Tue, 2 Jul 2019 19:00:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0865EC21BE5; Tue, 2 Jul 2019 08:58:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1086DC21E15; Tue, 2 Jul 2019 08:58:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 056AEC21E1A; Tue, 2 Jul 2019 08:54:15 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lists.denx.de (Postfix) with ESMTPS id D26E3C21DD4 for ; Tue, 2 Jul 2019 08:54:11 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x628s9wh074174; Tue, 2 Jul 2019 03:54:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562057649; bh=HLZjqELgZAIx/Cp6S0WgnC/ZMN7mqZFdNmJtnuxGS8Y=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oyc5txZKSxZihLzfqHnG8FkNNpdZU+U2xWwhDeDoKPpkR4d39QQBR/RU2ykoul+KB hDaRPe4HkCaVbuGu/xZdplSN9A8qGfAtuMXOt1EoFXR21kinWdR9xFYCa+xCpTTvV3 9Rk15xMR3+a1N8Y2jZyUmDlgWHa36H6jTPmFQN1w= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x628s9Mp063279 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Jul 2019 03:54:09 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 2 Jul 2019 03:54:09 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 2 Jul 2019 03:54:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x628s8dl026518; Tue, 2 Jul 2019 03:54:09 -0500 From: Jean-Jacques Hiblot To: Date: Tue, 2 Jul 2019 10:53:53 +0200 Message-ID: <20190702085358.27368-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702085358.27368-1-jjhiblot@ti.com> References: <20190702085358.27368-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: Baruch Siach , u-boot@lists.denx.de, Marek Vasut Subject: [U-Boot] [PATCH v2 06/11] mmc: if possible, poll the busy state using DAT0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Using the DAT0 line as a rdy/busy line is an alternative to reading the status register of the card. It especially useful in situation where the bus is not in a good shape, like when modes are switched. This is also how the linux driver behaves. Note of warning: As per the specification, while polling on DAT0 the CLK must not turned off: "[...] Without a clock edge the Device (unless previously disconnected by a deselect command (CMD7)) will force the DAT0 line down, forever. [...]" Signed-off-by: Jean-Jacques Hiblot --- Changes in v2: - update commit log to warn that the CLK must not be turned off while polling on DAT0 drivers/mmc/mmc-uclass.c | 2 -- drivers/mmc/mmc.c | 6 ++++-- include/mmc.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 6742d99e3d..65d9da48f6 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -47,7 +47,6 @@ int mmc_set_ios(struct mmc *mmc) return dm_mmc_set_ios(mmc->dev); } -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout) { struct dm_mmc_ops *ops = mmc_get_ops(dev); @@ -61,7 +60,6 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout) { return dm_mmc_wait_dat0(mmc->dev, state, timeout); } -#endif int dm_mmc_get_wp(struct udevice *dev) { diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 36cce79eaf..a61e311cca 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -29,12 +29,10 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps); #if !CONFIG_IS_ENABLED(DM_MMC) -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) static int mmc_wait_dat0(struct mmc *mmc, int state, int timeout) { return -ENOSYS; } -#endif __weak int board_mmc_getwp(struct mmc *mmc) { @@ -233,6 +231,10 @@ int mmc_poll_for_busy(struct mmc *mmc, int timeout) unsigned int status; int err; + err = mmc_wait_dat0(mmc, 1, timeout); + if (err != -ENOSYS) + return err; + while (1) { err = mmc_send_status(mmc, &status); if (err) diff --git a/include/mmc.h b/include/mmc.h index 920f4cc53c..854778deed 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -441,7 +441,6 @@ struct dm_mmc_ops { int (*execute_tuning)(struct udevice *dev, uint opcode); #endif -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) /** * wait_dat0() - wait until dat0 is in the target state * (CLK must be running during the wait) @@ -452,7 +451,6 @@ struct dm_mmc_ops { * @return 0 if dat0 is in the target state, -ve on error */ int (*wait_dat0)(struct udevice *dev, int state, int timeout); -#endif }; #define mmc_get_ops(dev) ((struct dm_mmc_ops *)(dev)->driver->ops)