Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1390066ybz; Thu, 16 Apr 2020 08:20:13 -0700 (PDT) X-Google-Smtp-Source: APiQypKIj/DsMMg+ySHi+T2iic41lg3EoO2FM0JrWBHf/fSI0YwLx+/gyCyNitgiKhI1CRB1/Iik X-Received: by 2002:a17:906:3048:: with SMTP id d8mr10214642ejd.97.1587050413354; Thu, 16 Apr 2020 08:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587050413; cv=none; d=google.com; s=arc-20160816; b=f9kSKNfPyloSpivKwGRUjLZvnIAnOCwaHQtK/UMdEAmiAjLrIDoFkjFLtRvBeag0ia Oad6epCP6c19+O7Tecl9gPdMZF1S+edmZ3k2tc5TuEqldib/bWevl5xj5nSaQCB3v7tD 3zdljG9k0R23DIhRzANg9N6K91G5xBnr8OgW4yTwcri5Sx1avtq5zBmDJkrAUjdnCdhY 5g7ZUxt7++1XcAtnDiBe6EVyPag0+pRs5NE69htjJ+ZTbKSrSz+NdzQXKhk6O0aDpShM 1gP/d/4t/6Y6q9tfdgsBwNRFZCsD/kdW1/FYtG7/lkWmq3bgAlZKLYNVWwkrDOXmIvAP XaWg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=USaOIEEYeg8z4JWB3Ee5mwjSdsbu8DJI5yPJJnH1I0w=; b=kepbHmTni1oD6ShWIl4xg3ykDVdeePwbhchlr64/VQ97jahRIshGjKKc9n8tJ2G+Uc hFSxiZrjSr7i/m1vI1TK3VetiVKzENrzOFww5GG6spkH7vLJ6QP2x9MuL3lVdVJ0lr+s iUCQh8AQV/DnlAPUs2GKD9z9TGMG/qY3fgILQsxpVUGXOD6nxV5Be3WfITPgi7UyMO+z UnMIKsatrwaW3r9JOS1tz3mjvZY52iwq9VqOshC+0ValG1yQv+A1Z14ATDzvxDBI9hcA w/gASrevsrB9gLXlCV8DQxOOcrzbaYxRY4Cpm8uoavxEhqqmNOew2AwPR+l6ujJPIUx6 tpJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Sz3birDb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si8093931edw.322.2020.04.16.08.19.49; Thu, 16 Apr 2020 08:20:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Sz3birDb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442176AbgDPPRy (ORCPT + 99 others); Thu, 16 Apr 2020 11:17:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898750AbgDPNsi (ORCPT ); Thu, 16 Apr 2020 09:48:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A70B621974; Thu, 16 Apr 2020 13:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044914; bh=wfXgQROazFBxrkbDeVJO+X/lLtDftS0z146jAskHZgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sz3birDbrk/vbUXhPw33ylEZQ+yDnpR3ErXloE2DrBvg9cXMZ6aAoVzmd9GEUaYiq TSjbVkbGyN/s8YK4Ancfcs7Pq98YmZ311ZDOdN37Qx7I47ThFDFt2s0RD8eNZkGNRW EcB/L7CNUVwW68KK/kvyHPBSpRxRCIEok1/bP0cE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yangbo Lu , Adrian Hunter , Ulf Hansson Subject: [PATCH 5.4 153/232] mmc: sdhci-of-esdhc: fix esdhc_reset() for different controller versions Date: Thu, 16 Apr 2020 15:24:07 +0200 Message-Id: <20200416131334.133946063@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yangbo Lu commit 2aa3d826adb578b26629a79b775a552cfe3fedf7 upstream. This patch is to fix operating in esdhc_reset() for different controller versions, and to add bus-width restoring after data reset for eSDHC (verdor version <= 2.2). Also add annotation for understanding. Signed-off-by: Yangbo Lu Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/20200108040713.38888-1-yangbo.lu@nxp.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-of-esdhc.c | 43 ++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -734,23 +734,58 @@ static void esdhc_reset(struct sdhci_hos { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); - u32 val; + u32 val, bus_width = 0; + /* + * Add delay to make sure all the DMA transfers are finished + * for quirk. + */ if (esdhc->quirk_delay_before_data_reset && (mask & SDHCI_RESET_DATA) && (host->flags & SDHCI_REQ_USE_DMA)) mdelay(5); + /* + * Save bus-width for eSDHC whose vendor version is 2.2 + * or lower for data reset. + */ + if ((mask & SDHCI_RESET_DATA) && + (esdhc->vendor_ver <= VENDOR_V_22)) { + val = sdhci_readl(host, ESDHC_PROCTL); + bus_width = val & ESDHC_CTRL_BUSWIDTH_MASK; + } + sdhci_reset(host, mask); - sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); - sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); + /* + * Restore bus-width setting and interrupt registers for eSDHC + * whose vendor version is 2.2 or lower for data reset. + */ + if ((mask & SDHCI_RESET_DATA) && + (esdhc->vendor_ver <= VENDOR_V_22)) { + val = sdhci_readl(host, ESDHC_PROCTL); + val &= ~ESDHC_CTRL_BUSWIDTH_MASK; + val |= bus_width; + sdhci_writel(host, val, ESDHC_PROCTL); + + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); + } - if (mask & SDHCI_RESET_ALL) { + /* + * Some bits have to be cleaned manually for eSDHC whose spec + * version is higher than 3.0 for all reset. + */ + if ((mask & SDHCI_RESET_ALL) && + (esdhc->spec_ver >= SDHCI_SPEC_300)) { val = sdhci_readl(host, ESDHC_TBCTL); val &= ~ESDHC_TB_EN; sdhci_writel(host, val, ESDHC_TBCTL); + /* + * Initialize eSDHC_DLLCFG1[DLL_PD_PULSE_STRETCH_SEL] to + * 0 for quirk. + */ if (esdhc->quirk_unreliable_pulse_detection) { val = sdhci_readl(host, ESDHC_DLLCFG1); val &= ~ESDHC_DLL_PD_PULSE_STRETCH_SEL;