Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp578355rdb; Thu, 22 Feb 2024 12:32:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWAUriPwuL85h9e9NjQb/v+xuS1BbRu0cAlhlYps3aIUB6kdIbfLNjRYX7cGO580gwWmOb2pL8q8M50fQr0cfccURUalmoHyf1TqYlGtg== X-Google-Smtp-Source: AGHT+IEGyKf01PER5Wjpj2WjJkDhGDk0bY8A23vc388E0NK4q2sOV7WZ+s/wLQpIo/XPF4wEdr/x X-Received: by 2002:a17:906:b352:b0:a3e:6463:2fc7 with SMTP id cd18-20020a170906b35200b00a3e64632fc7mr9822548ejb.4.1708633943802; Thu, 22 Feb 2024 12:32:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708633943; cv=pass; d=google.com; s=arc-20160816; b=QJ6XmWMzICl+Dd/rmk5VMlvS5rx40h7D8u0mcypWEHk8qKW5nzV/kZ0glbwQzifeFZ M+MY4NL/2pn4OUQTetfMJLeBDvqeMfwDiIscY5lTxidPmWl8FF9VBg626glekG/fXxLq RDaP2svQI+bqeaxic9OO+MDdr7eQNNKeRUEQM+opWpz8Oms/kiCHtui7twZZuM7zJevY 0Gr22uRa3yQn8c14DQ/hsUeJCjUia1WuT6FhUrys2dHTY97VA5SE097FFK9BwmvPu0zA 35+KGY1L1dWksDOn9kWqoUz1bVfMOv8X4c3jBrrT/riIpnBXrCwciKcJJ3gShcbtVPNA JHVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=y6gHklRy6mgfq/+kDFgxdQdIm96X6dvMx3GA+sAwVL0=; fh=M1RO158Os50Y+7jr9jkWOUUFaYJ+PXra7vMPvfQbgto=; b=iSwozoltxKV8x6kC3cp+5PEX/pXIbt6OFuy3OgXuRE5QQ4uvqKZhM4m6NRbdTfoiZU U9EydQDBHjx2Ceur1f/zXAS5sl/Q7L45gts3f+vEpRfkQ/5SE6uMGZ6CnfVKouoXegT2 NH7ilCWfsPkWgFMzhKp1ilobsJpSSD0+uHlrDuQlv//yYUCslp9E1G1rIc7KSQFcrhEw sewvoOvQ1HdZGKeBgc+3Cw1qP51EWB3enm7GBI+ZHzrlhHvSz0EuWsrNA2PGQbSPT0vp PeqsRxlbm9obRdczzbqw7R1sfQNH/a0XgJOmAkXxm7WM1GKNmL1x9fnuXckQc74LC4s0 1pwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=HF+7ZUtK; arc=pass (i=1 dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-77321-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r8-20020a170906c28800b00a3ec5a0dd7asi3414656ejz.231.2024.02.22.12.32.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:32:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77321-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=HF+7ZUtK; arc=pass (i=1 dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-77321-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8E7D11F25A2A for ; Thu, 22 Feb 2024 20:32:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BE3D71740; Thu, 22 Feb 2024 20:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="HF+7ZUtK" Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 7E22414B832; Thu, 22 Feb 2024 20:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633933; cv=none; b=Jd7uywvZMey/3RwM59TqIr4rGTw4wEdxxGAznmt3hlRagOWavzoWJz3AqmgS9qiEC8PVosy7jaSCRVL8Tijr8bOu2eQcoCeUDiotiT3C/gxOHIWOs1jF5N4n+rvUcRQmYrRVFRUOfD1OP/Obcurv1huilD5aiEX+Iza26qWKZIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633933; c=relaxed/simple; bh=OEjaR8q/hH/zJzrJq00dzosvg9sB+rc7P5n3BrRx+nE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oIRhFWoF41PUqXxay3aKUXP9jkkWF2l/efPLXjnYekXoNObBe2ry5Gl5tZXCTDw6X8dAOKGj3NqcKxI+lLi/xh0k2qDfAmu09YvMeQzgUd0cGtD8fGbHP7XEz0Idsshu3yhWLkvaQvmV8x+KawUN79hbT7ZJoCPF0imp8Wu9MOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=HF+7ZUtK; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41MK2gHO021857; Thu, 22 Feb 2024 12:32:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=pfpt0220; bh=y6gHklRy 6mgfq/+kDFgxdQdIm96X6dvMx3GA+sAwVL0=; b=HF+7ZUtKWvSxLkooNf2EBlfT NROoRQYyNGdKVVsf5rcihgLluq4TJc665/AEa+xMQhmXGefMhNvGn7QMPf5qn7Q0 ZECbKqCbjOzSnfonDu8MzU40Efb/KINg9vWCePjF2F8QoYoYtuCastUnO1ae7Z0T sfy3QrN8z145GReJsAbBOR0n5QnXerQSOX1Ihd9nOw3yq64/5lGRyX+gykIFyR/5 XdOQ5t9YdBOU7dD4c2J1J6XuKeHSzvZPi2putvz3e6HFVitdWLhXj7PcEYkDd/RV 5zCBgRSk+aZymMqE0HJ2MrZc790FNCe3a/LtvgSuwjvqtvQHzzXIwwLOK1pdbA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3we3dwau65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 12:32:10 -0800 (PST) Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 22 Feb 2024 12:32:08 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 22 Feb 2024 12:32:08 -0800 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id F0E443F7167; Thu, 22 Feb 2024 12:07:20 -0800 (PST) From: Elad Nachman To: , , , , CC: , Subject: [PATCH v3 1/2] mmc: xenon: fix PHY init clock stability Date: Thu, 22 Feb 2024 22:07:11 +0200 Message-ID: <20240222200712.1274919-2-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 9uFZkJciaEAtuSdtVM4mZlXdp_mAVaEV X-Proofpoint-ORIG-GUID: 9uFZkJciaEAtuSdtVM4mZlXdp_mAVaEV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-22_15,2024-02-22_01,2023-05-22_02 From: Elad Nachman 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 --- drivers/mmc/host/sdhci-xenon-phy.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c index 8cf3a375de65..c3096230a969 100644 --- 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" @@ -216,6 +217,19 @@ static int xenon_alloc_emmc_phy(struct sdhci_host *host) 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: @@ -232,6 +246,11 @@ static int xenon_emmc_phy_init(struct sdhci_host *host) 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); -- 2.25.1