From patchwork Wed May 22 23:31:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 798210 Delivered-To: patch@linaro.org Received: by 2002:ab3:6414:0:b0:267:d849:ee76 with SMTP id j20csp919129lte; Wed, 22 May 2024 16:37:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFcWJQCVHiRdtP3Axhp0rAw1UEfugr3AJufXQ0X17LjeqEYn8nJMo412jnqKj95zjZgk5ziAfw3vpvlVvmxLKB X-Google-Smtp-Source: AGHT+IHr9Xwo8/CQDZS+MDROP0N2GefpM9smkIN5aCVmNDTmpX4B6S1vkWw/4jihLyilPRtH+oA/ X-Received: by 2002:a17:906:4f82:b0:a62:df4:fa24 with SMTP id a640c23a62f3a-a6228095d05mr188788266b.21.1716421046700; Wed, 22 May 2024 16:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716421046; cv=none; d=google.com; s=arc-20160816; b=GG4x9B1S+Aw2jErN9w7MV6WsZcJyTtIxNAkUYQNBW/eUAOzpud5K7fFrMSqp+FDzKo a6n4dxaUPvMeZkqtYpGbPg6eBKvvqwYVrDCcp0+1XSdD2K+CERge11xFw3j8yCQr/O9l 5E9Mge/ayYhwNqnC7OjYqsVK4Ish7y40vpfMYjRvJHY/G7wGcxYdD9iM7Y+4oLNwKuB2 MQhOeL39W5jmwPO+np9vXm4uT3BcIvKsRmtt8n7rjCJvmiX5j0A2v7DRY79Sg3OrjXy/ YKI3R91tDevDzDewwctMeDukvSPutcLzfwZ5lLb6WlrMxTeIm6btZWE5E4s6zs+ES5Va vHKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=leXg5M9IJZvGZQdRki2akuLu9l5aNtTu1JiIhuyNyJg=; fh=rKABKwMqMrICn6k61SEJ840hlRdVBwJYoqW24UL9gFM=; b=XOPsqTXSv32uoaGl9XCFwgyxOwDH4mueLakVlRVWvrgAzhQ7ImvdWwNm58Z7chpfyl zKpunYYyicn0l88FNYFlHYHZCj/DXvSBK8CYaM8bA1fdVvmUpEUj6l0Ke1j9E6C0Nwg6 4QTuM1EOynJ5HxDGgRiiLdTrUeOEdNGuoJj3+PIdhr3SxRNHczubsAzl11c27klFnV+h AJ/r4fB7pFctUP4OVdcV8s16lBsXyGMzWdsmLNLVSYJ2fuUVsle9pFJHygd7rSUmEkcH P6bJqOEwuu36icVsHu+ZFXPYVRmGZL7ZESs5UGFxUh9Rex59wvyAj4CGVbqGvpKLnwbh zT0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H9ztOLXi; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17ba5772si1542895366b.629.2024.05.22.16.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:37:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H9ztOLXi; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AC4FE8854E; Thu, 23 May 2024 01:32:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="H9ztOLXi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 027FE88551; Thu, 23 May 2024 01:32:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 34FCF88593 for ; Thu, 23 May 2024 01:32:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3c9a0042e7dso2817619b6e.0 for ; Wed, 22 May 2024 16:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716420723; x=1717025523; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=leXg5M9IJZvGZQdRki2akuLu9l5aNtTu1JiIhuyNyJg=; b=H9ztOLXiDSgbc8/JcHddVMKvIIUJ0Gd0DmkdWPEn2B+nYMkRjaT9xngKRtm8HKrcBU inzVFveGQBKDxW9YNNxm+XSZPWl/hriFCEd6yXgJLbmmFIv85S4KZjqH/olgN+EEuAWc unviKbuzyJ12JU5IhcCKrt6BT80LTZnrVlt+qVp18Dju/CWccUOljPot1Vb/5+IzsORP Ng0LoebYAcM4krg86TwqyN4q0JKeds5XZ+iD956G7io4FBgUFcVxhdsCiE5ivxTM1+KR ZMvaubrubC/bDK0ph2Mr16vhr2S2YNXj4blYLd3L89uNk9rVFfZiTrcr2dS+wMy6EZL9 fgRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716420723; x=1717025523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=leXg5M9IJZvGZQdRki2akuLu9l5aNtTu1JiIhuyNyJg=; b=EOwpgU1oPiTBcLwOn2gpq1ZBLA9vwdERlqs9gXycRr1o0nJ6W4GIaLEd1cRy/tk73L u8uSAHX22i8SGIgth4bAeqDlhQqIB8ZOaJu89F9i64l/6vbjQx25kZ2aOVuPmMEtYf5/ sZmHppqph76jw5Mxmd4o3Sgrnd/W9NdQWXhWyPlU+U8q2lMsQH00kkcp7cN8bAIJ1OyA TVqCpJ/Be1KMiqWaFX2LO1tSSAPDR0gGuZ3bCbvI+o6tpbuzlF7eOfBEPx4hTE9Muf1y cYQsWacWaNXg6/7w5bDVh6PyoXNGezexwp5I+d2oYslLR0nHSbJEUq2qAMn6ocJsXBXC J3tQ== X-Forwarded-Encrypted: i=1; AJvYcCXrsIPzKkTvCIf82SvPbJWwQXdKB1+HlQ4efYTfv333i+f6ucX+Tb3AWqxv6xVuk78W1FUY5j7J9v4Zmxf/ZrBkYrI2xw== X-Gm-Message-State: AOJu0YwK2EjxKGwr3c1t6OY+96+ihGCeHjG6S5WzW39pQHrVgx7uufTW 2QTG+L80Iyq/rdrWGoX7kxCOTW8vq+z8Y6ljSmO0dsbdAHP9wAOVKnF0Pg3yVPk= X-Received: by 2002:a05:6808:2393:b0:3c9:7a7b:a7cd with SMTP id 5614622812f47-3cdbb525531mr4261577b6e.51.1716420722896; Wed, 22 May 2024 16:32:02 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3c9cb0ef7desm2148993b6e.56.2024.05.22.16.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:32:02 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: Philipp Tomsich , Kever Yang , Eugeniy Paltsev , Peter Robinson , Jonas Karlman , Yang Xiwen , Ferass El Hafidi , Sean Anderson , u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Subject: [PATCH 31/42] mmc: exynos_dw_mmc: Read and use DDR timing when available Date: Wed, 22 May 2024 18:31:24 -0500 Message-Id: <20240522233135.26835-32-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522233135.26835-1-semen.protsenko@linaro.org> References: <20240522233135.26835-1-semen.protsenko@linaro.org> MIME-Version: 1.0 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 DDR timing values should be defined in "samsung,dw-mshc-ddr-timing" dts property, and used when DDR MMC mode is selected. Read that value from dts and use it. If it's not available, use SDR timing values instead. This change is following upstream Linux kernel implementation. Signed-off-by: Sam Protsenko --- drivers/mmc/exynos_dw_mmc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 91300f67b9fe..d3708ecb6407 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -53,6 +53,7 @@ struct dwmci_exynos_priv_data { #endif struct clk clk; u32 sdr_timing; + u32 ddr_timing; const struct exynos_dwmmc_variant *chip; }; @@ -128,8 +129,14 @@ static int exynos_dwmmc_set_sclk(struct dwmci_host *host, unsigned long rate) static int exynos_dwmci_clksel(struct dwmci_host *host) { struct dwmci_exynos_priv_data *priv = exynos_dwmmc_get_priv(host); + u32 timing; - dwmci_writel(host, priv->chip->clksel, priv->sdr_timing); + if (host->mmc->selected_mode == MMC_DDR_52) + timing = priv->ddr_timing; + else + timing = priv->sdr_timing; + + dwmci_writel(host, priv->chip->clksel, timing); return 0; } @@ -305,6 +312,17 @@ static int exynos_dwmmc_of_to_plat(struct udevice *dev) priv->sdr_timing = DWMMC_MMC2_SDR_TIMING_VAL; } + err = dev_read_u32_array(dev, "samsung,dw-mshc-ddr-timing", timing, 2); + if (err) { + debug("DWMMC%d: Can't get ddr-timings, using sdr-timings\n", + host->dev_index); + priv->ddr_timing = priv->sdr_timing; + } else { + priv->ddr_timing = DWMCI_SET_SAMPLE_CLK(timing[0]) | + DWMCI_SET_DRV_CLK(timing[1]) | + DWMCI_SET_DIV_RATIO(div); + } + host->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0); host->bus_hz = dev_read_u32_default(dev, "clock-frequency", 0);