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 816683D8129; Mon, 4 May 2026 14:13:25 +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=1777904005; cv=none; b=Hw69SYqPd4cGnisfTuaZWfjww4YtzjRja/ij/FIH3G5YUlpZjuX7mplBcFsr8PVZ4RQsektAy3NNPcctzQ/UKQ4UN+5OsxSiuAz3ABSTTg8vTxaWczDtFc+Yl2N04WaEJiW96XZ2+6WKUtVKg4Rz6ZodpXtn4Lv/zgA5OlEDrpk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777904005; c=relaxed/simple; bh=SpAtGZVT7mCXhR2yGqsveCNRaOD/MyOMcaZemI3WiA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zb4Un88z4jUQjd+XiFpJbNJPNa0dw7wwAf+gpQQm6r60DXRE/e9LGWrN8W98oE2NWCwdtrp9tOWQs9KdNeepvKIvOBVLdVHE4CbuiDnk/HLshAtF0bnuE0KI1Bcih3gSAB3JXC3R1jW+G+v9X0DlK2m0OsuA/u6dmLqP0OhfTTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OEam8Vbr; 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="OEam8Vbr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D140C2BCC4; Mon, 4 May 2026 14:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777904005; bh=SpAtGZVT7mCXhR2yGqsveCNRaOD/MyOMcaZemI3WiA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OEam8VbrYN/TmwJ/T8PiKLF8bURJyUISeY9aKaEEBD5na8cBNYHkxLNDB29Vo0f3o 0ynP9FjvzKiWonBoyOQYT1imJ0L4NmcY8Ka0ZPM8QAuHxSRZbEx9eNOThJgzroe8EE Lxf0q92IOZKpUm7QoIBKkKSFZNYXxrZh65Zp7MnU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shawn Lin , Adrian Hunter , Ulf Hansson Subject: [PATCH 6.18 146/275] mmc: sdhci-of-dwcmshc: Disable clock before DLL configuration Date: Mon, 4 May 2026 15:51:26 +0200 Message-ID: <20260504135148.353016155@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.929052779@linuxfoundation.org> References: <20260504135142.929052779@linuxfoundation.org> User-Agent: quilt/0.69 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-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Lin commit 6546a49bbe656981d99a389195560999058c89c4 upstream. According to the ASIC design recommendations, the clock must be disabled before operating the DLL to prevent glitches that could affect the internal digital logic. In extreme cases, failing to do so may cause the controller to malfunction completely. Adds a step to disable the clock before DLL configuration and re-enables it at the end. Fixes: 08f3dff799d4 ("mmc: sdhci-of-dwcmshc: add rockchip platform support") Cc: stable@vger.kernel.org Signed-off-by: Shawn Lin Acked-by: Adrian Hunter Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-of-dwcmshc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -607,12 +607,15 @@ static void dwcmshc_rk3568_set_clock(str extra &= ~BIT(0); sdhci_writel(host, extra, reg); + /* Disable clock while config DLL */ + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); + if (clock <= 52000000) { if (host->mmc->ios.timing == MMC_TIMING_MMC_HS200 || host->mmc->ios.timing == MMC_TIMING_MMC_HS400) { dev_err(mmc_dev(host->mmc), "Can't reduce the clock below 52MHz in HS200/HS400 mode"); - return; + goto enable_clk; } /* @@ -632,7 +635,7 @@ static void dwcmshc_rk3568_set_clock(str DLL_STRBIN_DELAY_NUM_SEL | DLL_STRBIN_DELAY_NUM_DEFAULT << DLL_STRBIN_DELAY_NUM_OFFSET; sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); - return; + goto enable_clk; } /* Reset DLL */ @@ -659,7 +662,7 @@ static void dwcmshc_rk3568_set_clock(str 500 * USEC_PER_MSEC); if (err) { dev_err(mmc_dev(host->mmc), "DLL lock timeout!\n"); - return; + goto enable_clk; } extra = 0x1 << 16 | /* tune clock stop en */ @@ -692,6 +695,16 @@ static void dwcmshc_rk3568_set_clock(str DLL_STRBIN_TAPNUM_DEFAULT | DLL_STRBIN_TAPNUM_FROM_SW; sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); + +enable_clk: + /* + * The sdclk frequency select bits in SDHCI_CLOCK_CONTROL are not functional + * on Rockchip's SDHCI implementation. Instead, the clock frequency is fully + * controlled via external clk provider by calling clk_set_rate(). Consequently, + * passing 0 to sdhci_enable_clk() only re-enables the already-configured clock, + * which matches the hardware's actual behavior. + */ + sdhci_enable_clk(host, 0); } static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask)