From patchwork Mon May 15 06:07:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Ziyuan X-Patchwork-Id: 762252 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wR9Lc21Pwz9s5L for ; Mon, 15 May 2017 16:15:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EE2A5C21EFD; Mon, 15 May 2017 06:11:08 +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=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 5CC79C21CFD; Mon, 15 May 2017 06:11:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D0061C21D68; Mon, 15 May 2017 06:10:39 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.138]) by lists.denx.de (Postfix) with ESMTPS id C89F1C21D5F for ; Mon, 15 May 2017 06:09:38 +0000 (UTC) Received: from xzy.xu?rock-chips.com (unknown [192.168.165.141]) by regular1.263xmail.com (Postfix) with ESMTP id DF6A779E6 for ; Mon, 15 May 2017 14:08:03 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from smtp.263.net (sg-smtp01.263.net [54.255.195.220]) by smtp.263.net (Postfix) with ESMTP id DB2503DD; Mon, 15 May 2017 14:08:03 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 4E22EDF312; Mon, 15 May 2017 14:08:05 +0800 (CST) X-RL-SENDER: xzy.xu@rock-chips.com X-FST-TO: u-boot@lists.denx.de X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: xzy.xu@rock-chips.com X-UNIQUE-TAG: <30934f315be76636a1199fba781190bc> X-ATTACHMENT-NUM: 0 X-SENDER: xzy.xu@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 146864118T; Mon, 15 May 2017 14:08:05 +0800 (CST) From: Ziyuan Xu To: u-boot@lists.denx.de Date: Mon, 15 May 2017 14:07:01 +0800 Message-Id: <1494828447-24332-7-git-send-email-xzy.xu@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494828447-24332-1-git-send-email-xzy.xu@rock-chips.com> References: <1494828447-24332-1-git-send-email-xzy.xu@rock-chips.com> Subject: [U-Boot] [PATCH 07/33] mmc: dw_mmc: implement card_busy detection 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Ziyuan Xu --- drivers/mmc/dw_mmc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 700f764..baf2280 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -384,6 +384,26 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) } #ifdef CONFIG_DM_MMC_OPS +static bool dwmci_card_busy(struct udevice *dev) +{ + struct mmc *mmc = mmc_get_mmc_dev(dev); +#else +static bool dwmci_card_busy(struct mmc *mmc) +{ +#endif + u32 status; + struct dwmci_host *host = (struct dwmci_host *)mmc->priv; + + /* + * Check the busy bit which is low when DAT[3:0] + * (the data lines) are 0000 + */ + status = dwmci_readl(host, DWMCI_STATUS); + + return !!(status & DWMCI_BUSY); +} + +#ifdef CONFIG_DM_MMC_OPS static int dwmci_set_ios(struct udevice *dev) { struct mmc *mmc = mmc_get_mmc_dev(dev); @@ -475,12 +495,14 @@ int dwmci_probe(struct udevice *dev) } const struct dm_mmc_ops dm_dwmci_ops = { + .card_busy = dwmci_card_busy, .send_cmd = dwmci_send_cmd, .set_ios = dwmci_set_ios, }; #else static const struct mmc_ops dwmci_ops = { + .card_busy = dwmci_card_busy, .send_cmd = dwmci_send_cmd, .set_ios = dwmci_set_ios, .init = dwmci_init,