From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20153C432BE for ; Tue, 31 Aug 2021 18:11:22 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C5E560232 for ; Tue, 31 Aug 2021 18:11:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6C5E560232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 95DE58310F; Tue, 31 Aug 2021 20:11:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="jnIds4BX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCBB783137; Tue, 31 Aug 2021 20:11:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id 0787B82D93 for ; Tue, 31 Aug 2021 20:11:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stcarlso@linux.microsoft.com Received: by linux.microsoft.com (Postfix, from userid 1075) id 1C21620B9158; Tue, 31 Aug 2021 11:11:06 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1C21620B9158 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1630433466; bh=C1aHEs3v0s2L59MwBVM76e0K08IZe8OTsZI1PO3aea0=; h=Date:From:To:cc:Subject:From; b=jnIds4BXle5oPJw+717NnjqdgCMq54Q1APAieJ4ojTFd4bo9Oq58UQ6qKf1mi2xw7 B8sIoOHxkt7uM95qlNUsnQ6s/dCaFmq5Ijv3vhwRU6An/U6MgP1KSWK01g6xmOoN4d ySls63rU4drAlrUeIVgCuz23/OFz6EXFLe4cvouw= Received: from localhost (localhost [127.0.0.1]) by linux.microsoft.com (Postfix) with ESMTP id 1B16B3070337; Tue, 31 Aug 2021 11:11:06 -0700 (PDT) Date: Tue, 31 Aug 2021 11:11:06 -0700 (PDT) From: Stephen Carlson To: U-Boot Mailing List cc: peng.fan@nxp.com, Jaehoon Chung Subject: Re: Re: [PATCH 2/2] drivers: mmc: Add wait_dat0 support for sdhci driver Message-ID: <976255c9-69b2-af66-91a-a3bfcf5cbf5a@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Jaehoon, readx_poll_timeout expands to read_poll_timeout which accepts the signature: read_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) sdhci_readl requires two arguments, host and SHCI_PRESENT_STATE, which cannot both be provided to that macro in the addr parameter. One potential workaround would be to declare a static helper function to call sdhci_readl with a constant second parameter, but this proposal would increase function call overhead and stack usage. Is it worth changing for the readability improvement? Thanks, Stephen Carlson -----Original Message----- From: Jaehoon Chung Sent: Friday, August 27, 2021 10:14 PM To: stcarlso@linux.microsoft.com; u-boot@lists.denx.de Cc: Peng Fan Subject: Re: [PATCH 2/2] drivers: mmc: Add wait_dat0 support for sdhci driver On 8/18/21 4:46 AM, stcarlso@linux.microsoft.com wrote: > From: Stephen Carlson > > Adds an implementation of the wait_dat0 MMC operation for the DM SDHCI > driver, allowing the driver to continue when the card is ready rather > than waiting for the worst case time on each MMC switch operation. > > Signed-off-by: Stephen Carlson > --- > drivers/mmc/sdhci.c | 20 ++++++++++++++++++++ > include/sdhci.h | 2 ++ > 2 files changed, 22 insertions(+) > > diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index > eea4701d8a..bb55e00ef5 100644 > --- a/drivers/mmc/sdhci.c > +++ b/drivers/mmc/sdhci.c > @@ -775,6 +775,25 @@ static int sdhci_get_cd(struct udevice *dev) > return value; > } > > +static int sdhci_wait_dat0(struct udevice *dev, int state, > + int timeout_us) > +{ > + int tmp; > + struct mmc *mmc = mmc_get_mmc_dev(dev); > + struct sdhci_host *host = mmc->priv; > + unsigned long timeout = timer_get_us() + timeout_us; > + > + // readx_poll_timeout is unsuitable because sdhci_readl accepts > + // two arguments Removed the comment or use "/* */" instead of "//" And i didn't understand what's unsuitable? Best Regards, Jaehoon Chung > + do { > + tmp = sdhci_readl(host, SDHCI_PRESENT_STATE); > + if (!!(tmp & SDHCI_DATA_0_LVL_MASK) == !!state) > + return 0; > + } while (!timeout_us || !time_after(timer_get_us(), timeout)); > + > + return -ETIMEDOUT; > +} > + > const struct dm_mmc_ops sdhci_ops = { > .send_cmd = sdhci_send_command, > .set_ios = sdhci_set_ios, > @@ -783,6 +802,7 @@ const struct dm_mmc_ops sdhci_ops = { #ifdef > MMC_SUPPORTS_TUNING > .execute_tuning = sdhci_execute_tuning, > #endif > + .wait_dat0 = sdhci_wait_dat0, > }; > #else > static const struct mmc_ops sdhci_ops = { diff --git > a/include/sdhci.h b/include/sdhci.h index 0ae9471ad7..dd4eb41442 > 100644 > --- a/include/sdhci.h > +++ b/include/sdhci.h > @@ -65,6 +65,8 @@ > #define SDHCI_CARD_STATE_STABLE BIT(17) > #define SDHCI_CARD_DETECT_PIN_LEVEL BIT(18) > #define SDHCI_WRITE_PROTECT BIT(19) > +#define SDHCI_DATA_LVL_MASK 0x00F00000 > +#define SDHCI_DATA_0_LVL_MASK BIT(20) > > #define SDHCI_HOST_CONTROL 0x28 > #define SDHCI_CTRL_LED BIT(0) >