Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2495434pxj; Mon, 10 May 2021 04:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyuS15BXoGMWFQ5jadJZzAHMrEtbYDNzP0ZZlFshkE2t3oHavUEmiJXTvBfqmVU0gUg8a4 X-Received: by 2002:a05:6e02:1353:: with SMTP id k19mr975946ilr.171.1620646209229; Mon, 10 May 2021 04:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620646209; cv=none; d=google.com; s=arc-20160816; b=fCgpxr/uWj7bQMB48pRlfB40XVH2kRqkWCaV7RiPigFgaUW1XR8YSMg7KPP4LAtDxW eetAiqn1+N7Fpho3LveMpM5ghY2OJKrVNJhUrLYq/TEJIKkbFvbXiiLkxp8wp5fX2EGS lv8E+GdBy5aj2zV045XlfwPApfjbgWB+dfMS7YQXZFXGai91WzS0JzHNrMmb0VOV2vDi yrj3PRot1A3OpPucfw5WdHyUfIFgkzCgNX+vuXAekg81LzqV+0gVmnAstX7hpg97lBXK JK79fX6kuvyfL6qnR6nCxkUiJCCQpnNW+S0b2/+gWXUwAPhPEVqkGY74hlRrc/JyZLRO KgMg== 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=Jg3nrbbQootf12IpGlH7yqU8dMB0QyMxH4KZbx5w/h3ZSkAY+WUvpNhb799AbKctzV GBR1zDzOs+Xp6PaL6USZbx4f26GK2tHUG/XXWOlCpicZM1nZquK4nVerRh7wKijyPqsT aWgoq0z5Bk7WAAkOKybxMr33fM7qdhHBhPmq/pTx9+f5KqK/c5VXg5ajkpro4iR1aqfa i0sR+w10Q5eSz2hx8L93WacCceA/naM7uK8kCxEfcMctChOmrG33HkS6csDKkyLBMIML OKQQ7rHJYTPAggOG+nhmHieYvpTb/LUg6hxqI7RZRDzs+lEnj48y+MCbo2FfRYo3BBfz qU+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K1M0yEfm; 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 c6si18712996iot.35.2021.05.10.04.29.55; Mon, 10 May 2021 04:30:09 -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=K1M0yEfm; 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 S237244AbhEJLZX (ORCPT + 99 others); Mon, 10 May 2021 07:25:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:52164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234261AbhEJK4G (ORCPT ); Mon, 10 May 2021 06:56:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D92861490; Mon, 10 May 2021 10:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643504; bh=oQT3PPvqxykPVhMPF6b9p3ASdg0cEpgtCmbnV8N2ChM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1M0yEfmfgd0e1+H5vm21wFygilPsRzRNFokRoCth07g59iUcmmrThvaxU97kJ1bH RQ6r+/8FyDRIdd46GxbmPbsrVvJeJiwsbU58TdYZGxZipFLiJHZ2ghBQLqVPLS23Q3 MdGGtzFI6tpEz20gBx+nb+y0LGJLGiA2sote+gZw= 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.11 041/342] mmc: sdhci-pci: Fix initialization of some SD cards for Intel BYT-based controllers Date: Mon, 10 May 2021 12:17:11 +0200 Message-Id: <20210510102011.462031104@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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; }