From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98BB62D9992; Mon, 5 May 2025 22:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746483678; cv=none; b=lr52+k8AhyRTaJQ0d59RDH+cOJeQInsFahvU7mJkpyHNfquYmegKtvPv3c0NH04kKvKwGWdCqJVq1FmnCJo2X4MqzpzlStHI/ua3pvYt27wSZ5oEErB2gimY2A5369lfZqyaqd7K1HtF6f2UyNAUmHHJ8nU88MR5W4qnkQN2uLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746483678; c=relaxed/simple; bh=kCeaIbSSB1ifxm79iZjfgg5Xb2wk6xbwvMFE2K3KtSs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=u4tiMKvxJrCeP7QpXPWMevgpPQpzSbZoLGFh1dU9n37w39+Qk2Ym86YSza6dZjrNcfJbgYr8rH7n+KRhEvNd/9xi33Br8ybEsROwZlWx0xwQQtUlTgR9SxCSRwFqv4fMmHbQvlqfSD3+rNDZ6rihoVnvKHe7T2S78VW4tTgT+nE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uq4BS9oi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uq4BS9oi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1918AC4CEED; Mon, 5 May 2025 22:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746483678; bh=kCeaIbSSB1ifxm79iZjfgg5Xb2wk6xbwvMFE2K3KtSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uq4BS9oiapH+kgOi9C2SIrSkStVe0h033tRZH3EqDMZVZLO91/uaRHmrb5hJkAodM tAEbBdpkU5R13WOijiAsjw8SVpSH14CqXf1j/GENEGpWx81QyDbonKeFco0yzqjSuh nApit09lrG0PKQ1jGkHHCgv0A8s/cH9gtwp7dbs0CSEBq7rSzIv6lL34jGlDkVVORN CqN00iEHjKZwPKZwUz5vAulDFJHmP3nzzjL76HSepXkeoKpYMu9V5+jnEsA7npaM7A AI6tu7B2tzWDhRyS9GOQFE3kgKFTRGMMq2bYO2wcXd0hBdmoJXnF8sEwLZNS07f135 +x3bN0Mv1BEOw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Erick Shepherd , Kyle Roeschley , Brad Mouring , Adrian Hunter , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 175/642] mmc: sdhci: Disable SD card clock before changing parameters Date: Mon, 5 May 2025 18:06:31 -0400 Message-Id: <20250505221419.2672473-175-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505221419.2672473-1-sashal@kernel.org> References: <20250505221419.2672473-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.5 Content-Transfer-Encoding: 8bit From: Erick Shepherd [ Upstream commit fb3bbc46c94f261b6156ee863c1b06c84cf157dc ] Per the SD Host Controller Simplified Specification v4.20 ยง3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. Signed-off-by: Kyle Roeschley Signed-off-by: Brad Mouring Signed-off-by: Erick Shepherd Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/20250211214645.469279-1-erick.shepherd@ni.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index f4a7733a8ad22..5f91b44891f9b 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2065,10 +2065,15 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) host->mmc->actual_clock = 0; - sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + if (clk & SDHCI_CLOCK_CARD_EN) + sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN, + SDHCI_CLOCK_CONTROL); - if (clock == 0) + if (clock == 0) { + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); return; + } clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); sdhci_enable_clk(host, clk); -- 2.39.5