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 5130721FF39; Mon, 2 Jun 2025 14:31:53 +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=1748874714; cv=none; b=k0+uMwFYGenzP3Gcy/C+vlVgZEwR889vKnbR29XM6+PPbU/yib7pMpJOf9iLBaxcTCgDnfbRM6avH5TqLn7fQhwrbGmlvoPpMDZOAx7it2z6qMxczrfFyQSDB4wTzUvIqaJujzAkymA1akUZu4mQyT+j5lTyCROkgkcV4klAMk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748874714; c=relaxed/simple; bh=GkE/5cgRrt3FaRqa7OGibkPkNZi5nxlQ6Yc/IJLhiDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gHVDX1t3MTvo86T38fK4OtpEm+QEP36WKt68DgZwmRhkiJStI4Tw4xjIoxI6k6d6gVNiWMc3R+/V9z0iFHgSk9UI9wnOgkmZ3nLvNZq7vW+plWXiR3ftZprV2QyVAgvhZgIQdG7Hr11by754UroeCPRx2uVke4oCN45Xosnhwwg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yGnEQAND; 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="yGnEQAND" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 495A9C4CEEB; Mon, 2 Jun 2025 14:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748874713; bh=GkE/5cgRrt3FaRqa7OGibkPkNZi5nxlQ6Yc/IJLhiDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yGnEQANDZ72WCBMgiIvoOQFjeX1Z3hitpnfmnTdd5+gEieUITKX1UmWlQRuLS737w +6z1WiavVqFg5ExOi4chTZ6q7TadWmkpri/f+70kTTNk4O1+Thr7cwf+KVbJdUi290 br4qC9zP48P6RIgFqJf4hZ3aIQsG7vlpnfiVB2wg= 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 5.4 113/204] mmc: sdhci: Disable SD card clock before changing parameters Date: Mon, 2 Jun 2025 15:47:26 +0200 Message-ID: <20250602134300.099246548@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134255.449974357@linuxfoundation.org> References: <20250602134255.449974357@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.4-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 4004e4e7b6226..f8d0a0e49abec 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1708,10 +1708,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