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 948F8C6FD18 for ; Tue, 18 Apr 2023 16:48:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 798638615C; Tue, 18 Apr 2023 18:46:43 +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="AjW4TMHp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 415DE86101; Tue, 18 Apr 2023 18:46:34 +0200 (CEST) Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) (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 CA9F8860D6 for ; Tue, 18 Apr 2023 18:46:31 +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:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=zjw0HHctCwPOpSvXi2oEwbDI1yMAV3Qlvv493YtiwS0=; b=AjW4TMHp0TxLF25YT9wRPfr2CVKsDsfpsJTw8xeA+vaFa1rQZsbvIOHY5K0NYDdgESop 04AjeURud8d3AmqTkjIQX9+PrO7wjW+Xvdhw3BeWOZQMZw435SGxWvPVnCnn6xkTf+7zx8 5VC9nzb/CAb+77iEfbpazkjgASWGgRRnMgI8mZfTzTP9w3rabgJBq7BWe5phpOOo/6BRg1 UZzufzpa7WfkjsFNl/Z5Tf5Hw05+ilGVj/9FB6qjVuZFIT8STk0H0NMRjYc2WYi1k1Jq3Z 3VUGV94vMSTZrNfWxiryqja4Rb8TuP3chGmU8fJaAl/9EZnTQgVDw2xI3jMhccsg== Received: by filterdrecv-5848969764-ck886 with SMTP id filterdrecv-5848969764-ck886-1-643EC966-10 2023-04-18 16:46:30.296739768 +0000 UTC m=+4814091.588649420 Received: from bionic.localdomain (unknown) by geopod-ismtpd-4 (SG) with ESMTP id c-R-LI_GSu-J-D0gN02x-w Tue, 18 Apr 2023 16:46:30.064 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 06/17] mmc: rockchip_sdhci: Use set_clock and config_dll sdhci_ops Date: Tue, 18 Apr 2023 16:46:30 +0000 (UTC) Message-Id: <20230418164618.2571309-7-jonas@kwiboo.se> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230418164618.2571309-1-jonas@kwiboo.se> References: <20230418164618.2571309-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h7gvCYNAzg4k1YY8b?= =?us-ascii?Q?=2FjfU34NVg=2FjA1GfUpKDfQicFyj9zg8Wz+qi0JOP?= =?us-ascii?Q?=2FoH7O=2FMPfXBnSKvkFeURmk7aMtaNnoxeQuiedsP?= =?us-ascii?Q?qXvEF+Hxqe1DM=2FHKmt8tnJA7RlTl1vNfrgQiEOq?= =?us-ascii?Q?tx+R8qGJ5GSI2VWnyLAhurslXr0hOPkoqEGqmI?= To: Kever Yang , Simon Glass , Philipp Tomsich , Peng Fan , Jaehoon Chung Cc: u-boot@lists.denx.de, Jonas Karlman , Eugen Hristev 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 --- v2: - No change 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 bc9838ac7c45..fdf48f4066c9 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->tran_speed; u32 reg, vendor_reg; - if (!clock) - clock = mmc->clock; - - 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; @@ -614,6 +614,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