Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469799pxj; Mon, 10 May 2021 03:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuOlYj2pqBpwzqiVaIP4CPXv9MLvoxSGoSU46udGOsfjJqzzwm0PATH5rWJHrzOXO6PDaT X-Received: by 2002:a02:cb0c:: with SMTP id j12mr20649772jap.92.1620643985736; Mon, 10 May 2021 03:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643985; cv=none; d=google.com; s=arc-20160816; b=eJJrYC284WxVFutk3icEvCFRopV8dCoxlfBVcOBtvlgpp1t6/o+t7qbtX0eeY1tb+P fLkhbN0IFNxKQglk1xy+FrDzV/2se1HuzGi2+gHCi3XDccVy40eq7VlPlxkSZMKCx3kf TT8kcvggUVBNdMfKQIU70OkFbnkJGSaN7fg7bEnkInX5LxFa2b+NgsPCA4j370MOJhgK /+KKFyVxxIGP3I8S4S73Mn1nIDoOpn+npTfColilCUpAzY8qsGx6DpcFVAknJxKjwOQP 4RMpzp8PkcOoNx5BU34tpxnM8jdBf3k/OIoZaUfg1IIW9OsIsH4aC/poXz06R2Hk784l 5K9g== 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=aYhA8tHOg6q5vzVH+rGisEj2xZ2j1rcVtJPQCvEoc1U=; b=QSQoa/5eEKiJ0NC/zgAL6cdwUNisyqjvD5m81MeXSArCrR9av9ORUtQCL3GKDDzMsH Qq69qz3lXn5WwvD7SzWScpzn7x0X7Y+yuiISFn2WKnfUcFATDEt8nYbxyqb2xnOtzxsx 48EPSoxeQ79G7DJTCdWQqj/xBwmbJHYcDVZ+VMBo4kZ7GuOeH/JMy0MWswTXplwH+stW dJbH8Pth/7uIEn2Aao+rmROZ/IG6YcE/fnECniaPIaq+FsIbPs3CugpJTCbQoodm+ESS DJ9qRlZg7VmSWTt+hM7r1WZ7aI3p/CsZLo0NCy2kiPSiamD1i9CHkvvHDh+KQyC7b5kO TIAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uf2p+Des; 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 u9si3518141jak.104.2021.05.10.03.52.53; Mon, 10 May 2021 03:53:05 -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=@linuxfoundation.org header.s=korg header.b=Uf2p+Des; 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 S233270AbhEJKwv (ORCPT + 99 others); Mon, 10 May 2021 06:52:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:52756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbhEJKmT (ORCPT ); Mon, 10 May 2021 06:42:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2809E6192E; Mon, 10 May 2021 10:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642739; bh=oQT3PPvqxykPVhMPF6b9p3ASdg0cEpgtCmbnV8N2ChM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uf2p+DesDlbBdzfsRzI13+6FwL4zZFkTZmD6UYd9wNJpFQ4zRg99JMkpPTB6REZ3W vwDrCRu3pPnWVlgpFmHE2vwwuKeEmQCMRXsL4fzaRvoNjjDRcJH4FlaZt3MW+k/6nZ L6Y/S784r7wOeWi2KhBH0PkLCyS0GQ/zfKJH0wTk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Ulf Hansson Subject: [PATCH 5.10 031/299] mmc: sdhci-pci: Fix initialization of some SD cards for Intel BYT-based controllers Date: Mon, 10 May 2021 12:17:08 +0200 Message-Id: <20210510102005.877537773@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Adrian Hunter commit 2970134b927834e9249659a70aac48e62dff804a upstream. Bus power may control card power, but the full reset done by SDHCI at initialization still may not reset the power, whereas a direct write to SDHCI_POWER_CONTROL can. That might be needed to initialize correctly, if the card was left powered on previously. Signed-off-by: Adrian Hunter Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210331081752.23621-1-adrian.hunter@intel.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-pci-core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -516,6 +516,7 @@ struct intel_host { int drv_strength; bool d3_retune; bool rpm_retune_ok; + bool needs_pwr_off; u32 glk_rx_ctrl1; u32 glk_tun_val; u32 active_ltr; @@ -643,9 +644,25 @@ out: static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, unsigned short vdd) { + struct sdhci_pci_slot *slot = sdhci_priv(host); + struct intel_host *intel_host = sdhci_pci_priv(slot); int cntr; u8 reg; + /* + * Bus power may control card power, but a full reset still may not + * reset the power, whereas a direct write to SDHCI_POWER_CONTROL can. + * That might be needed to initialize correctly, if the card was left + * powered on previously. + */ + if (intel_host->needs_pwr_off) { + intel_host->needs_pwr_off = false; + if (mode != MMC_POWER_OFF) { + sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); + usleep_range(10000, 12500); + } + } + sdhci_set_power(host, mode, vdd); if (mode == MMC_POWER_OFF) @@ -1135,6 +1152,14 @@ static int byt_sdio_probe_slot(struct sd return 0; } +static void byt_needs_pwr_off(struct sdhci_pci_slot *slot) +{ + struct intel_host *intel_host = sdhci_pci_priv(slot); + u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL); + + intel_host->needs_pwr_off = reg & SDHCI_POWER_ON; +} + static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) { byt_probe_slot(slot); @@ -1152,6 +1177,8 @@ static int byt_sd_probe_slot(struct sdhc slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3) slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V; + byt_needs_pwr_off(slot); + return 0; }