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 693B9C77B72 for ; Thu, 20 Apr 2023 15:55:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D53286340; Thu, 20 Apr 2023 17:55:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se 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=kwiboo.se header.i=@kwiboo.se header.b="STyVOe1l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5ABE186344; Thu, 20 Apr 2023 17:55:19 +0200 (CEST) Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7403886334 for ; Thu, 20 Apr 2023 17:55:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:mime-version:to:cc:content-transfer-encoding: content-type:cc:content-type:from:subject:to; s=s1; bh=4Wg6g2LSrqr7pcCESKK9SRHrebYUMcTu0g7Yy/vNTGI=; b=STyVOe1lqJVCQiTN+uGs34GeMM2EUkiu8AZ6hSZMyr/MMwL3ZDbYLp0id8eBFd/leSCi iQ3PDeP7PIMFoVhyLlir/OrPpxmG76iSg9zLjHS7MEvhQSHLGtbd5Gf1g4zYtVneiCy4KV 1haJTzF3GCOt16p9lIg2Sww3qPIR7NFF83MY7KX/2apBRcJ5AnwMy+VveT96u1a9njtXRZ 5EDE1hETHoUX6zulxWBJn6lmPjDJmtr/V2UK5bcKbN6VxBQNhGSca3PvD+LZc2PK/hmDFz UHJ666wKIVLxP45f0SQzPNfJieFJoZTKGkTmWboaJoPIL3blW/1R7S7CtaaVr4Ug== Received: by filterdrecv-68f8d557c9-bsxpv with SMTP id filterdrecv-68f8d557c9-bsxpv-1-64416063-3 2023-04-20 15:55:15.110129398 +0000 UTC m=+4983822.959741776 Received: from bionic.localdomain (unknown) by geopod-ismtpd-5 (SG) with ESMTP id KMOEZBsJSbyqE0KaSioq6w Thu, 20 Apr 2023 15:55:14.876 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v3 06/17] mmc: rockchip_sdhci: Use set_clock and config_dll sdhci_ops Date: Thu, 20 Apr 2023 15:55:15 +0000 (UTC) Message-Id: <20230420155512.3710907-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h8EoJ3QZjRd3=2F13u7?= =?us-ascii?Q?KcRX1UtPyvRHSvTbPxOkBiUyXHyvgbvgUD=2FWswK?= =?us-ascii?Q?KOYv2HFcmXn1FNmxx0ok61nwq+0GxENJ5=2Fg1+bH?= =?us-ascii?Q?hjvwoCEmVdIwdUBcAKJ=2F9EKr8HtKYf06vrYozru?= =?us-ascii?Q?UyPA7Zs7KuxIfNAuZHLhQZ+=2F1rz0yO00gTZnfK?= To: Kever Yang , Simon Glass , Philipp Tomsich , Peng Fan , Jaehoon Chung Cc: Jonas Karlman , Eugen Hristev , Vasily Khoruzhick , u-boot@lists.denx.de X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 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.8 at phobos.denx.de X-Virus-Status: Clean Change to configure clock and DLL in set_clock and config_dll ops instead of in the set_ios_post ops. With this change the output clock is turned off while configuring DLL parameters, according to the design recommendations. Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- v3: - Resolve conflict with "rockchip: sdhci: rk3568: fix clock setting logic" at [1] - Collect r-b tag v2: - No change [1] https://patchwork.ozlabs.org/project/uboot/patch/20230307212646.56576-1-anarsoul@gmail.com/ drivers/mmc/rockchip_sdhci.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index 85858f3ed9a3..e56043fce88e 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -291,18 +291,24 @@ static int rk3399_sdhci_set_ios_post(struct sdhci_host *host) return 0; } -static int rk3568_sdhci_emmc_set_clock(struct sdhci_host *host, unsigned int clock) +static void rk3568_sdhci_set_clock(struct sdhci_host *host, u32 div) { struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, host); + struct mmc *mmc = host->mmc; + ulong rate; + + rate = clk_set_rate(&priv->emmc_clk, mmc->clock); + if (IS_ERR_VALUE(rate)) + printf("%s: Set clock rate failed: %ld\n", __func__, (long)rate); +} + +static int rk3568_sdhci_config_dll(struct sdhci_host *host, u32 clock, bool enable) +{ int val, ret; u32 extra; - if (clock > host->max_clk) - clock = host->max_clk; - if (clock) - clk_set_rate(&priv->emmc_clk, clock); - - sdhci_set_clock(host->mmc, clock); + if (!enable) + return 0; if (clock >= 100 * MHz) { /* reset DLL */ @@ -386,14 +392,8 @@ static int rk3568_sdhci_set_enhanced_strobe(struct sdhci_host *host) static int rk3568_sdhci_set_ios_post(struct sdhci_host *host) { struct mmc *mmc = host->mmc; - uint clock = mmc->clock; u32 reg, vendor_reg; - if (mmc->tran_speed && mmc->clock > mmc->tran_speed) - clock = mmc->tran_speed; - - rk3568_sdhci_emmc_set_clock(host, clock); - if (mmc->selected_mode == MMC_HS_400 || mmc->selected_mode == MMC_HS_400_ES) { reg = sdhci_readw(host, SDHCI_HOST_CONTROL2); reg &= ~SDHCI_CTRL_UHS_MASK; @@ -601,6 +601,8 @@ static const struct sdhci_data rk3399_data = { static const struct sdhci_data rk3568_data = { .get_phy = rk3568_emmc_get_phy, .set_ios_post = rk3568_sdhci_set_ios_post, + .set_clock = rk3568_sdhci_set_clock, + .config_dll = rk3568_sdhci_config_dll, .set_enhanced_strobe = rk3568_sdhci_set_enhanced_strobe, }; -- 2.40.0