Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp863995ybs; Mon, 25 May 2020 00:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmJhwBQIIlGtcDut2lCu56S4vZpgItBW82poMjX17PcRmdHM0V35DkTfcof53jjMpKN8kt X-Received: by 2002:a05:6402:2032:: with SMTP id ay18mr13786836edb.281.1590392660651; Mon, 25 May 2020 00:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590392660; cv=none; d=google.com; s=arc-20160816; b=xlkIr9F1Ynh4H4iFF/t6N2Bd34fShvZW0TZhn4+YVeYOdibV8BlC+lD76rBy7VyOKY WBE6E63gHpjkCz3atM76DBqhUElD2BjyRHBjrniEHs5P4DPquPkS1Dl+5VDLA7/eful1 oxXIAUQMHPPKptBEsRD/foerS/eI90Ai/snCS9jaiveGFnAQ0KOJZl5Pr9VkOJzp16F7 soE7nz+Gm28gRkXMvqC9HX2gNuIZlqW3BeGQJZDwPk4/zpPxwFIdQjE6qmRt68lmBHs2 5Xg3Nf9MxVuhO9vU4zmy5A0o2v0txRzYj45mP43Ihqt6I6MFLMUcjQ7vOWCERSGBO6iV e3tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=LUlJzVmYUWIQzQohv8tcybKvQ4H6h5GMbFZALuQMFSo=; b=kcoiJ6mUeWkV9OWq4+gbN8IA1zPg0vqXAY9GS5eLUWjx854y+KC8MW9hRnNbDe7K5k mMccTzcG5zUKNjrJNTbYzpBJ5YKiEFy+i0pjSC6A8Xh5z9BRsKMnTs/4XPRWpo3kzdEf sQ2Q+pNIV2rhIqEb+rVJ5rEH9cas/Q+UCo9MlqVjpfpzQ5Xo/t10C35FHrf0fkT1nm0a Ek3oOoBRypO2MkFJNVoWPzHFVY+W4tLlIWWEKZRYX5q4x1grbVuLzSCGxaGBC7AP/vMJ jDt8Bs2pi8ZwiaZ1ZE7T7G2nwcIGQH5BJ7IkdjOvVbhh8y9jy5jgEP01+cm/mZTewLyr q0ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u19si8953456ejx.254.2020.05.25.00.43.57; Mon, 25 May 2020 00:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389152AbgEYHl6 (ORCPT + 99 others); Mon, 25 May 2020 03:41:58 -0400 Received: from mga18.intel.com ([134.134.136.126]:12119 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389100AbgEYHl5 (ORCPT ); Mon, 25 May 2020 03:41:57 -0400 IronPort-SDR: ZQRDNMhBSUx6nRkPnDD0ILHp54ZncEzzaOyGQYSXem8tecFP3DHmIrPDEElGmSfYkYL5j4Sebr H4GIcICPNfgg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2020 00:41:56 -0700 IronPort-SDR: EhtfxJKT7puHs//4h3Slq54GHPt/QVzuAECaYnBD8tT1p1zn517rJvIwSricqYg4jfICNRJVFG +HVxXShnfa+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,432,1583222400"; d="scan'208";a="266078332" Received: from cvg-ubt08.iil.intel.com (HELO cvg-ubt08.me-corp.lan) ([10.185.176.12]) by orsmga003.jf.intel.com with ESMTP; 25 May 2020 00:41:55 -0700 From: Vladimir Kondratiev To: Adrian Hunter , Ulf Hansson , linux-mmc@vger.kernel.org Cc: Vladimir Kondratiev , linux-kernel@vger.kernel.org Subject: [PATCH] mmc: sdhci-cadence: fix PHY write Date: Mon, 25 May 2020 10:40:53 +0300 Message-Id: <20200525074053.7309-1-vladimir.kondratiev@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Accordingly to Cadence documentation, PHY write procedure is: 1. Software sets the PHY Register Address (HRS04[5:0]) and the PHY Write Data (HRS04[15:8]) fields. 2. Software sets the PHY Write Transaction Request (HRS04[24]) field to 1. 3. Software waits as the PHY Write Transaction Acknowledge (HRS04[26]) field is equal to 0. 4. Hardware performs the write transaction to PHY register where HRS04[15:8] is a data written to register under HRS04[5:0] address. 5. Hardware sets the PHY Transaction Acknowledge (HRS04[26]) to 1 when transaction is completed. 6. Software clears the PHY Write Transaction Request (HRS04[24]) to 1 after noticing that the PHY Write Transaction Acknowledge (HRS04[26]) field is equal to 1. 7. Software waits for the PHY Acknowledge Register (HRS04[26]) field is equal to 0. Add missing steps 3 and 7. Lack of these steps causes integrity errors detested by hardware. Signed-off-by: Vladimir Kondratiev --- drivers/mmc/host/sdhci-cadence.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c index e474d3fa099e..6b2e7c43cbc1 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -114,6 +114,11 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv, u32 tmp; int ret; + ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS04_ACK), + 0, 10); + if (ret) + return ret; + tmp = FIELD_PREP(SDHCI_CDNS_HRS04_WDATA, data) | FIELD_PREP(SDHCI_CDNS_HRS04_ADDR, addr); writel(tmp, reg); @@ -128,7 +133,10 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv, tmp &= ~SDHCI_CDNS_HRS04_WR; writel(tmp, reg); - return 0; + ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS04_ACK), + 0, 10); + + return ret; } static unsigned int sdhci_cdns_phy_param_count(struct device_node *np) -- 2.20.1 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.