From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D170B8F58; Mon, 4 Mar 2024 21:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709588410; cv=none; b=tRIapdBhckK2/waDY7dMPVr09pH4QpeHo/uWA+3aaZXA1YYjLWtdXGH9q/OqFNjo6eHyRGEkYKR8Zjmgtzf9/oIdMyUxdJG4i184F96qGowLUXDggJ+9jZjZKcGlbUPIFK3Yc6/w1IKgzWZR3DP6SLRCHE/fartSTkR0nWehk7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709588410; c=relaxed/simple; bh=BC1ZP65sRGxp4kbtbzN0oTgr8wk4cAMIl86/UZAfxKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yz8o+VUUIG6hmIqfBzbjKxIcJrWSA4OfDZKlDESDOrP2gyRo26aKMByEMLfmx55u1agXjnvjDm1Vi26b4vt7hIt8gn8+BssaXVk9dqvURooDEoONMvVaInwh1Ksaapw42pwRUMmlcmeM2MQUAcu/+iWItmegXOlDdPukdLQZV/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Nmnju7S1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Nmnju7S1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64049C433F1; Mon, 4 Mar 2024 21:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709588410; bh=BC1ZP65sRGxp4kbtbzN0oTgr8wk4cAMIl86/UZAfxKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nmnju7S1EStXpMAB0zsProz0FRyoxehZYNfDm9XfjXd4/7KKW8SAgtRmYD2JAdmKN BEoAeAMVRQ1218nxmTCO23DTLtzeH7lE0smTc/TjTY6YtM03ISiT0071ySPQmpKjAT ajKsc4h3i0zM9zXyygcBLzPUDQc7iXl1YdaHB4a4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Hunter , Elad Nachman , Ulf Hansson Subject: [PATCH 6.6 096/143] mmc: sdhci-xenon: fix PHY init clock stability Date: Mon, 4 Mar 2024 21:23:36 +0000 Message-ID: <20240304211552.988301836@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240304211549.876981797@linuxfoundation.org> References: <20240304211549.876981797@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Elad Nachman commit 8e9f25a290ae0016353c9ea13314c95fb3207812 upstream. Each time SD/mmc phy is initialized, at times, in some of the attempts, phy fails to completes its initialization which results into timeout error. Per the HW spec, it is a pre-requisite to ensure a stable SD clock before a phy initialization is attempted. Fixes: 06c8b667ff5b ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC") Acked-by: Adrian Hunter Cc: stable@vger.kernel.org Signed-off-by: Elad Nachman Link: https://lore.kernel.org/r/20240222200930.1277665-1-enachman@marvell.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-xenon-phy.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/mmc/host/sdhci-xenon-phy.c +++ b/drivers/mmc/host/sdhci-xenon-phy.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "sdhci-pltfm.h" @@ -218,6 +219,19 @@ static int xenon_alloc_emmc_phy(struct s return 0; } +static int xenon_check_stability_internal_clk(struct sdhci_host *host) +{ + u32 reg; + int err; + + err = read_poll_timeout(sdhci_readw, reg, reg & SDHCI_CLOCK_INT_STABLE, + 1100, 20000, false, host, SDHCI_CLOCK_CONTROL); + if (err) + dev_err(mmc_dev(host->mmc), "phy_init: Internal clock never stabilized.\n"); + + return err; +} + /* * eMMC 5.0/5.1 PHY init/re-init. * eMMC PHY init should be executed after: @@ -234,6 +248,11 @@ static int xenon_emmc_phy_init(struct sd struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host); struct xenon_emmc_phy_regs *phy_regs = priv->emmc_phy_regs; + int ret = xenon_check_stability_internal_clk(host); + + if (ret) + return ret; + reg = sdhci_readl(host, phy_regs->timing_adj); reg |= XENON_PHY_INITIALIZAION; sdhci_writel(host, reg, phy_regs->timing_adj);