From patchwork Wed Sep 15 10:28:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 12495951 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 63FA7C433EF for ; Wed, 15 Sep 2021 10:32:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2604F61242 for ; Wed, 15 Sep 2021 10:32:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2604F61242 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4KF+d5GoVAMsk/mYr/VrkS/aTmwx3UFeCrlm2762Kl8=; b=a20ZbXRUEw0A26 0hpeUEPIz8M8TdCyFBZEwMvXqxwJAxx+CFUAD0QoNWpGO+mR/7TNpV1K37T/addZ2J5HRWfWk7e3h 31DVASYGVfDuJgMJ8XMrCTE1iAfqUS9wUZwrS7TbVwAD8Rz0+6rXOQkBc4TX7rGHMAW/hDCPQZjBl WFp9oL0Jm0tZxtv/Epidwbjc+dCZLynXKuKEGffSxxeO0XEDog/g+RXiA7fvqRR8tgqhVU9iloSw3 5FNwywiyG0I227fusQMXIuI1Wauh1KaqF7bX//jDd8EUybBFw5psj2wp0avb4wBZA2cLSHQjbUqyu OfWTKjtbf5BG5IddOoEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQSAy-008oXl-Uu; Wed, 15 Sep 2021 10:30:01 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQSAv-008oXQ-7L for linux-arm-kernel@lists.infradead.org; Wed, 15 Sep 2021 10:29:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1631701797; x=1663237797; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ou5/IuCCEHLg/7BedlK6vCkNqIXckQk5gqJ5mD6Cm3U=; b=VULlC8dvEK7c23KEQ/8dMdM+tl5qDY7BSWJbk9lkLCQ2jwk7QGev3KxO M/FLSxBQc01KJsGVgX8Hm4BM5SOqhGYtQNGjY/3qEsApGN2sGglx/iKsd AuLiOxzOADdnvpiJTBs6e7M8ORbG3rNvCB/UgBFlXEjBWCcXwHHpVWUAy TL/KUzUpLygdwI4t++QCuFlOv0W1J/7hDiW2+Z7xPVY84WeiMPpCWhXOL +pCuWd4Jyeku6zTdP9VDxcBuNYa7DSbjg8lg7d3gWWzGd1He9rq4RTfvU BBpqkUfDxziufHBoiwfGTiibXH3FL3NXIZRyw30UPHsZWtP2wGgv1+Czx w==; IronPort-SDR: 3+W0NDb2MORr77B4UPR5iVG/R/0nFdRIRHwsRkA9CJH/03xPGjoGwb6ix1UNtJPAeCVbOU8/bG 6EdOdN0gbZFWiXZ68lrtkaSOmNGwkL6JTPCrjdJBILF6YW/zcNgYHLfNVy0YpVgjwN4jQ64uJC c6o5dduCWaEKP5HHFXevEI8VEUHfkHbtf36iP2uYJKrEUhZaA7yQqce+OdbtkmCoGY7mZQ+fF1 oMsTCFu6ugkHrrJiCTVSv1xzbUTDInVF2wFLUow0jASG+JqnACpBYFzdwGA+QNG5MpjSS/Zc8W UfkuUltsC1J4gpqCCh0jnHSp X-IronPort-AV: E=Sophos;i="5.85,295,1624345200"; d="scan'208";a="136616764" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Sep 2021 03:29:54 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 15 Sep 2021 03:29:54 -0700 Received: from rob-dk-mpu01.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 15 Sep 2021 03:29:51 -0700 From: Claudiu Beznea To: , , , , , CC: , , , Claudiu Beznea Subject: [PATCH] mmc: sdhci-of-at91: wait for calibration done before proceed Date: Wed, 15 Sep 2021 13:28:38 +0300 Message-ID: <20210915102838.8344-1-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210915_032957_435961_F83F41DD X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Datasheet specifies that at the end of calibration the SDMMC_CALCR_EN bit will be cleared. No commands should be send before calibration is done. Fixes: dbdea70f71d67 ("mmc: sdhci-of-at91: fix CALCR register being rewritten") Fixes: 727d836a375ad ("mmc: sdhci-of-at91: add DT property to enable calibration on full reset") Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre --- drivers/mmc/host/sdhci-of-at91.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index 5564d7b23e7c..2b28711e039d 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c @@ -114,6 +114,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host); + unsigned long timeout = jiffies + msecs_to_jiffies(20); + unsigned int tmp; sdhci_reset(host, mask); @@ -126,6 +128,14 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask) sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, SDMMC_CALCR); + + do { + tmp = sdhci_readl(host, SDMMC_CALCR); + } while (time_before(jiffies, timeout) && + (tmp & SDMMC_CALCR_EN)); + + if (tmp & SDMMC_CALCR_EN) + dev_err(mmc_dev(host->mmc), "Failed to calibrate\n"); } }