Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4004675pxb; Tue, 2 Mar 2021 04:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDsALg1+2rZzO37VNQvt1yjmUtAD0lu4f9WFxQ08WWhjiPo1FkDbH2QD+NsbO1oW4ESL7j X-Received: by 2002:a17:906:ad96:: with SMTP id la22mr21381995ejb.237.1614688077789; Tue, 02 Mar 2021 04:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614688077; cv=none; d=google.com; s=arc-20160816; b=B0Nk/LH+V86DzCGXK63CJS/op8CEbgPKPQm169pDrAV/ynVxve5v4fERuTX/QwLijv 90PnmL7NRni8fLgGt9lmHT8M5W3zmd5a/d6K9Dpa4qVTUwztR5X7NPTmW7AUoPTPlCl7 iBLtfl75dS2pyTwlmv60CwmlhGQW9ppigqCdQIU+XYaGnUkDSSnIpZpYMJ+1dFfmCkm4 86M/mAB1oLN2CF+53X7yicVWgvX/q1C3xxqw/97Iwfq/RsmzaKTcvi8h/I6MAExGDMAG fBJptciFPsaeJENI9jmz9VAhS1bq432i1mhxu57MM25BBR0VkSDri11XM8ODPFTDXWAi 7Org== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3lfP4FvczrRryE1Y/svvfwo1u0baHyMhd6BoseqhWtk=; b=h44p0BGFMLcytCS29XK8qXJCyGzn+vSs2PMR91E8VBUUrAVVhhaGRACyHeo3jer7g7 Qw2zcVwGrUQt18s1St9NtyHYdhnu7Ic9NEv3n/S8DIBgGDkUyuXJhNmMJVa1d8727mP5 AhPELPUaLAqUZaoTKptTz2j6EStky4LB/hRF3Xkq4ShXb4TXnM8nQteY2IZ9yxwgcKnF +0F5nVfulXnfxvQKcJ3yPlmqX6XwSpsTcIf7H71BO31gyZXNUkJtQyQO6mrwExb4Yobj l8WqZLzGxch3L1DagZIKleWgg/fr8PkcNk+UgPlN/JYoLvvY4vp1kTHRwS3nBF9ObA88 9ZYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fgVxRGLo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si2436275ejn.699.2021.03.02.04.27.35; Tue, 02 Mar 2021 04:27:57 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fgVxRGLo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442835AbhCBCQ3 (ORCPT + 99 others); Mon, 1 Mar 2021 21:16:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:55186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242202AbhCAToD (ORCPT ); Mon, 1 Mar 2021 14:44:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B54565285; Mon, 1 Mar 2021 17:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619858; bh=JUnO/GnhXr0F5Kh2N1zUw2QEMreqFEMEf1hOYK+S6yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fgVxRGLoTVQkV4RHZ6TgjX9zzeFE8sz90c80tw0RQp4oSsPYU5NmRggH65GYE87mQ LbCRY1RH9L3UBNmPX0kYlbeIVNrmpgYtRZC7hdOPPD9oFy4O3+BTSmjqonkxLCMKUl RgOwNAjZd0uhyyS1Ddn28jkmyzha14Vz5fUHzNew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shirley Her , Ulf Hansson Subject: [PATCH 5.10 606/663] mmc: sdhci-pci-o2micro: Bug fix for SDR104 HW tuning failure Date: Mon, 1 Mar 2021 17:14:14 +0100 Message-Id: <20210301161211.834553281@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shirley Her commit 1ad9f88014ae1d5abccb6fe930bc4c5c311bdc05 upstream. Force chip enter L0 power state during SDR104 HW tuning to avoid tuning failure Signed-off-by: Shirley Her Link: https://lore.kernel.org/r/20210206014051.3418-1-shirley.her@bayhubtech.com Fixes: 7b7d897e8898 ("mmc: sdhci-pci-o2micro: Add HW tuning for SDR104 mode") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-pci-o2micro.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -33,6 +33,8 @@ #define O2_SD_ADMA2 0xE7 #define O2_SD_INF_MOD 0xF1 #define O2_SD_MISC_CTRL4 0xFC +#define O2_SD_MISC_CTRL 0x1C0 +#define O2_SD_PWR_FORCE_L0 0x0002 #define O2_SD_TUNING_CTRL 0x300 #define O2_SD_PLL_SETTING 0x304 #define O2_SD_MISC_SETTING 0x308 @@ -300,6 +302,8 @@ static int sdhci_o2_execute_tuning(struc { struct sdhci_host *host = mmc_priv(mmc); int current_bus_width = 0; + u32 scratch32 = 0; + u16 scratch = 0; /* * This handler only implements the eMMC tuning that is specific to @@ -312,6 +316,17 @@ static int sdhci_o2_execute_tuning(struc if (WARN_ON((opcode != MMC_SEND_TUNING_BLOCK_HS200) && (opcode != MMC_SEND_TUNING_BLOCK))) return -EINVAL; + + /* Force power mode enter L0 */ + scratch = sdhci_readw(host, O2_SD_MISC_CTRL); + scratch |= O2_SD_PWR_FORCE_L0; + sdhci_writew(host, scratch, O2_SD_MISC_CTRL); + + /* wait DLL lock, timeout value 5ms */ + if (readx_poll_timeout(sdhci_o2_pll_dll_wdt_control, host, + scratch32, (scratch32 & O2_DLL_LOCK_STATUS), 1, 5000)) + pr_warn("%s: DLL can't lock in 5ms after force L0 during tuning.\n", + mmc_hostname(host->mmc)); /* * Judge the tuning reason, whether caused by dll shift * If cause by dll shift, should call sdhci_o2_dll_recovery @@ -344,6 +359,11 @@ static int sdhci_o2_execute_tuning(struc sdhci_set_bus_width(host, current_bus_width); } + /* Cancel force power mode enter L0 */ + scratch = sdhci_readw(host, O2_SD_MISC_CTRL); + scratch &= ~(O2_SD_PWR_FORCE_L0); + sdhci_writew(host, scratch, O2_SD_MISC_CTRL); + sdhci_reset(host, SDHCI_RESET_CMD); sdhci_reset(host, SDHCI_RESET_DATA);