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 649C1280023; Tue, 27 May 2025 17:28:12 +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=1748366892; cv=none; b=EuTlvwpJQkVwGg8ECOgH3M++JLyWRquEbE2rSeFGXxycyQ9p2V6yKBnrHMOBuC1XO8cAfPD8S/T3NaBPR3cxMncXQj2CkAp4Rvv6NkxkIJ91hpVgOIKyWf6/aSqcn7phDUxwVmwB9YG7WyNj8br6meOOWcMPbFUOPbLXX76tVYc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748366892; c=relaxed/simple; bh=K7R4nH+lbDFDLOeOCeSLyvgsUOFjFjGH3SvdwC6QDK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OFVTykzqayM0c9hFEEsh92rOmwsZ+WLOO1AjA0ayN/zmPYs4f8o28iO3ocGHhrrcdP8DLiY2vsOM6pRi/mNah/shFRU9QZ0imGJrzpFVPDgzuG7HwmuPBQwUPuFVybEYnZ4n0sC/tTAKh6cjMY3pDkedXe68l+iMqXzyM1Atwd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=doYddyA4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="doYddyA4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDA05C4CEE9; Tue, 27 May 2025 17:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748366892; bh=K7R4nH+lbDFDLOeOCeSLyvgsUOFjFjGH3SvdwC6QDK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doYddyA4+jEuQMdzo1rKbLCuJu4UBZ631ek7CKQjaa6V0DfAJYL3iS0p67i7jWzjd b4/0CpiYiDrHk4WcGzwjJirMPT7Um3Q/rrg/fdBuBKjuoM4HYOyHybg2LkxXI2zV61 JqHgd4gWM1xtf+kOLVwDAP+BfohSne5cz2Djcz44= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kyle Roeschley , Brad Mouring , Erick Shepherd , Adrian Hunter , Ulf Hansson , Sasha Levin Subject: [PATCH 6.14 210/783] mmc: sdhci: Disable SD card clock before changing parameters Date: Tue, 27 May 2025 18:20:07 +0200 Message-ID: <20250527162521.687823743@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162513.035720581@linuxfoundation.org> References: <20250527162513.035720581@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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