Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32671C54E76 for ; Tue, 17 Jan 2023 17:08:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F3D2855BA; Tue, 17 Jan 2023 18:08:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="yY2giKs/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 276CD855CD; Tue, 17 Jan 2023 18:08:02 +0100 (CET) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A70E78559B for ; Tue, 17 Jan 2023 18:07:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=jhrzv9zXZ+1K6usuRHBh6rWcBgewLu/UktbKGB4AEsk=; b=yY 2giKs/NHRdJo9WiDHli/QxUL10UxzvPVn7V/cGRuvZfB8hUgd40oXU0cdrj44OGZjwE9mbCDFTijL LiIkLz05gyc3EtjA1ONpT+nRJK9f3LTfjPy3pM8GK6ynLYOfJssSLFZi4ezN+ZbiZgxwOeDO6solQ PDmeShMgqGVOTOj9Zi6+Kd5KrLsuGDmEDFIpn2Y+WkIIndUBvi+o6g3qWQh+yRZIJLtdHXoGRPDWY caOxF9bB3OjpqhRbIfJ2CfhljuAE1ht/qJWq81OD8136yS+ufSSGekA1jKuEktYSF1+j5VhTKP7wl OJvQgLy4m/Iy5CZlGJHtmO6V2nkWj6SA==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pHpRE-0000l6-7N; Tue, 17 Jan 2023 17:07:56 +0000 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Peng Fan , Jaehoon Chung , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH] mmc: rockchip_dw_mmc: fix DDR52 8-bit mode handling Date: Tue, 17 Jan 2023 17:07:47 +0000 Message-Id: <20230117170748.1575441-1-john@metanate.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The RK3288 TRM states that, for 8-bit DDR modes: The CLKDIV register should always be programmed with a value higher than zero (0); that is, a clock divider should always be used for 8-bit DDR mode. In Linux, the driver applies this logic for all SoCs using the driver and does not distinguish RK3288, so presumably this requirement is the same for all other Rockchip SoCs using this IP. Add the necessary code to double the clock frequency when 8-bit DDR is selected. The dw_mmc core already handles setting CLKDIV correctly given the input clock and desired bus clock. Signed-off-by: John Keeping --- drivers/mmc/rockchip_dw_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 573bf16c87..3661ce3314 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -41,6 +41,14 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq) struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); int ret; + /* + * The clock frequency chosen here affects CLKDIV in the dw_mmc core. + * That can be either 0 or 1, but it must be set to 1 for eMMC DDR52 + * 8-bit mode. It will be set to 0 for all other modes. + */ + if (host->mmc->selected_mode == MMC_DDR_52 && host->mmc->bus_width == 8) + freq *= 2; + ret = clk_set_rate(&priv->clk, freq); if (ret < 0) { debug("%s: err=%d\n", __func__, ret); -- 2.39.0