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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 21758C6379D for ; Wed, 25 Nov 2020 21:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFC23207BB for ; Wed, 25 Nov 2020 21:30:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="ywxJmmf4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732168AbgKYVaR (ORCPT ); Wed, 25 Nov 2020 16:30:17 -0500 Received: from www.zeus03.de ([194.117.254.33]:50282 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732181AbgKYVaQ (ORCPT ); Wed, 25 Nov 2020 16:30:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=aE3wqLs30NB8bR VMcLLuxzHypyiCP75iOyI8qCJmj5A=; b=ywxJmmf4XrJsz4tAQVBQRIwxNLnv3g O9c3EqMtQGu1Kckg/g7i6aaNweLgY5RgWDqqU3cVk7fZBNi//i3uyXFz+MLqa6bp 4i5gEJHKApRwOvgHUFVVT/rhE6UbyWEfzgO9eOW/Cc8ATJWsVVwEJNVnmK4JamCS KWFxI7n7BQW3E= Received: (qmail 3441497 invoked from network); 25 Nov 2020 22:30:14 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 25 Nov 2020 22:30:14 +0100 X-UD-Smtp-Session: l3s3148p1@7JQKIvW0kL8gAwDPXwZjAA625bO7DiyS From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang , Wolfram Sang Subject: [PATCH 2/3] mmc: tmio: add hook for custom busy_wait calculation Date: Wed, 25 Nov 2020 22:30:00 +0100 Message-Id: <20201125213001.15003-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201125213001.15003-1-wsa+renesas@sang-engineering.com> References: <20201125213001.15003-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org From: Wolfram Sang Newer SDHI variants can 'wait while busy' longer than the generic TMIO. Provide a hook to get the maximum cycle count to wait for. If the hook is not populated, fall back to a generic version which works well with all older TMIO/SDHI variants. Signed-off-by: Wolfram Sang --- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 819198af17f4..f60559bc413a 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -181,6 +181,7 @@ struct tmio_mmc_host { void (*reset)(struct tmio_mmc_host *host); bool (*check_retune)(struct tmio_mmc_host *host); void (*fixup_request)(struct tmio_mmc_host *host, struct mmc_request *mrq); + unsigned int (*get_timeout_cycles)(struct tmio_mmc_host *host); void (*prepare_hs400_tuning)(struct tmio_mmc_host *host); void (*hs400_downgrade)(struct tmio_mmc_host *host); diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index da9a6243f146..f0711f4c1e5b 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -887,16 +887,20 @@ static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host, sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg); } -static void tmio_mmc_max_busy_timeout(struct tmio_mmc_host *host) +static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host) { u16 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT); - unsigned int clk_rate = host->mmc->actual_clock ?: host->mmc->f_max; - unsigned int cycles; val = (val & CARD_OPT_TOP_MASK) >> CARD_OPT_TOP_SHIFT; - cycles = 1 << (13 + val); + return 1 << (13 + val); +} + +static void tmio_mmc_max_busy_timeout(struct tmio_mmc_host *host) +{ + unsigned int clk_rate = host->mmc->actual_clock ?: host->mmc->f_max; - host->mmc->max_busy_timeout = cycles / (clk_rate / MSEC_PER_SEC); + host->mmc->max_busy_timeout = host->get_timeout_cycles(host) / + (clk_rate / MSEC_PER_SEC); } /* Set MMC clock / power. @@ -1116,6 +1120,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT)) _host->write16_hook = NULL; + if (pdata->flags & TMIO_MMC_USE_BUSY_TIMEOUT && !_host->get_timeout_cycles) + _host->get_timeout_cycles = tmio_mmc_get_timeout_cycles; + _host->set_pwr = pdata->set_pwr; ret = tmio_mmc_init_ocr(_host); -- 2.28.0