From patchwork Thu Aug 8 03:14:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 817693 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp675850wrt; Wed, 7 Aug 2024 20:20:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvwJshUzl3c32BNDTl5NMM9SQPkV7lbLGL/g9TC5hIWZSxm4eEej8Nn1J/uHyBW/MzJIUF3IiTbM3kRFRRc9+S X-Google-Smtp-Source: AGHT+IHVvuLz+lPFlpEksv5zGOWwL4kdz3LKwv+Rv/GanH7maHNPIDqCZpWr05NvXXsJeIW9ZW5b X-Received: by 2002:a17:907:f724:b0:a7a:a30b:7b92 with SMTP id a640c23a62f3a-a8090c02a4bmr31559066b.1.1723087210262; Wed, 07 Aug 2024 20:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723087210; cv=none; d=google.com; s=arc-20160816; b=dPp2BBSmI/dZsz/zBn9qCPCx+t/ieNn3e4pK3tPqAsBp2BB9MeoMM2ypO4gIdRD0vT 1hpHd5Zl2y3s6FyWsMpa+GNSVBMPrQ/bG3tB3vmkx8VP9u/vqNgnGfPTzlMAjY4aDiXD LGyT8iiC+62A/bAtXQWwaORy5im1h1LDqCXlOERxF0Eb5TaHFqFuBnacsqZZbfOZRnG3 3LY3Hkp50cIJaG725yJj1EBNaonQARoBbfY/iQ0a86jXEHESOJ6YbhAKICQHR7Ksnrko g4M7J7clJv+AyDwDEQA5C6FYzIqFkTxAwVyVXepd6rfyHe01XF7I9wUwbg5QFUuZ4Jn5 4OJQ== 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=fWrhxoCkEjPUic6kyEGt3ZwqMIeuuOwcuUhFbLTHQ3Q=; fh=ah5ct/5fz+6pitH2Q0Q2vs0v4cNjiuHZWqfUP1JTzU4=; b=oz6Xxu+lwqlXdisslG+kpc09YQo6mtVNMj8J240+tyKmxwL/38pqyPJxsDEsgbg4Em dJL1WOL2JQm3kWzPv686tQTtAxqvOO5qewCciss4JPA7ewNf84MZ1774QzF2lu8G+00i Mtn2JlWATgygE5azQxsENv2obQafdEhkl2nnHyH2QoeMsAW3BrtxNQdEGqWsbzzOt/6j A9e8MTt0C8AThKydzwp76inEyRrjaBX71tj8e45o7L6AIZRzU8nqFoFvFyT4nXmreGB/ WddkIJM+iuymKuviCER2rXsoh5lNyqaB2Wj0LfCWe0IYdQWRAa0LVDH6JaakdZe+dqhA T+ZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FiCcR0Aj; 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; dara=neutral header.i=@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-a7dc9bd04d2si732366266b.101.2024.08.07.20.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:20:10 -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=FiCcR0Aj; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 13C7788C0F; Thu, 8 Aug 2024 05:15:17 +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="FiCcR0Aj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D40D588B8D; Thu, 8 Aug 2024 05:15:10 +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-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) (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 8C20E88B1E for ; Thu, 8 Aug 2024 05:15:08 +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-oo1-xc35.google.com with SMTP id 006d021491bc7-5d5b986a806so736522eaf.1 for ; Wed, 07 Aug 2024 20:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723086907; x=1723691707; 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=fWrhxoCkEjPUic6kyEGt3ZwqMIeuuOwcuUhFbLTHQ3Q=; b=FiCcR0AjyqDPumbGI9lpf/iYgZ53oSFjVDtRsiNGlzBxjkB7lnt3uc8KH8xiOPfrZ0 SDZnlNiktyhdnBBAAPGusQwSKBH2/kSh7IKjh91LZTPO+v2bsgviCNVWET8vmON/NqhR bLQVxMLXLSj9tX6JE7Gne69KAg+lxj2yDOo+US81F20J5jX+u3+v6JykiZPvB82il5+e 98mIiDnFGLGtvwsG/w6fyUi9qTjGEJK2EwB8dj9gDBDj6FrXHL8NQ13R6tI6LQPLeZAd lu+HSiZke11CqjkGIsqk23lxgtBuap0Ws/9JsmHkYfVZCX4UWx3vluWF+s5JLGMs+LKl 9W4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723086907; x=1723691707; 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=fWrhxoCkEjPUic6kyEGt3ZwqMIeuuOwcuUhFbLTHQ3Q=; b=V6IuUI4qpiAa71aD/fZPUwHUOl+vAP7NkGXDATMVgREMUU73CBHF53Yqb1iHcpPtWI kBlWFQ+Lk38SRsi7PLbQ51bm8d8xdQzCs85xMUnmYcXJiggYEF3mucS6iGVqKQ84oMr4 ymt/Zjthk1sLLLxRQDPEW1LGgD5u9N5T3w6zu9MvYIw5mczuHElCGeSyfIbGanfO25rT uTWdGzBFkjRJ20Nrb+/fVNlbR6gty0hjknLFBghB/RXYIs92+DM4wpWk6KBzMNfGR33+ wByLY6kzzRUd4lJB+99Wwrz0+mLId7HV87oGL04nG26obK/C+PyiEkE24jhCTaMFX1cg gxvg== X-Forwarded-Encrypted: i=1; AJvYcCXsPcfGUtCcNWMONHCoRZxh/E8TPyDtCsIMN7/psv18t04mRw2WlkKU3ancak5wpdr4Tdvr2AjJzDMDPSg86sXKgRMlDg== X-Gm-Message-State: AOJu0YyLIHqDmvP+kd4j4qFg92yFX3jq+cMchkblEXepDtdMnCelJesO uiAPePEVhmWYliCWhd5iNa6ZTUe8B/GqyRSSZrX+hX+hJ3mNWEYyBiKB+ajgy5g= X-Received: by 2002:a05:6808:16ab:b0:3db:14d0:32c6 with SMTP id 5614622812f47-3dc3bfb13bfmr119546b6e.24.1723086907315; Wed, 07 Aug 2024 20:15:07 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3db563b8815sm4621381b6e.39.2024.08.07.20.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:15:07 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang , Jaehoon Chung Cc: Tom Rini , Henrik Grimler , Peng Fan , Simon Glass , Quentin Schulz , 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 v5 30/38] mmc: exynos_dw_mmc: Set requested freq in get_mmc_clk() callback Date: Wed, 7 Aug 2024 22:14:36 -0500 Message-Id: <20240808031444.9619-31-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240808031444.9619-1-semen.protsenko@linaro.org> References: <20240808031444.9619-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 By now exynos_dw_mmc driver was relying on the correct CIU clock frequency being set on driver init. But dw_mmc core is actually trying to change CIU clock rate dynamically, on init and in set_ios() callback, which it's requesting via host->get_mmc_clk() callback (the name is misleading: although it's called "get_mmc_clk()", it can actually request both get and set operations). Implement setting the requested rate for CIU clock in Exynos driver to achieve the correct dw_mmc core driver operation at all times. DDR mode requires the clock to be twice as fast (when 8 bit bus is used), so handle this too, to make DDR function properly. This change makes the eMMC throughput on E850-96 board twice as fast. That's because "clock-frequency" is set to 800 MHz in E850-96 device tree, but for DDR52 mode it should be 416 MHz (and TRM states it should be 400 MHz for DDR50/8bit mode). The dw_mmc core is requesting 52 MHz bus_hz for DDR52 mode, and DDR+8bit mode means it should be x2 fast, so: f_ciu = 2 * ciu_div * f_bus = 2 * 4 * 52e6 = 416 MHz, where f_ciu - freq of clock fed to DW MMC block from CMU (SDCLKIN), Hz f_bus - freq of clock fed to the card (CCLKIN), Hz ciu_div - value of internal divider (in DW MMC block). Another way to work that around would be overriding the "clock-frequency" property in corresponding dts. But setting the clock frequency dynamically as it's done here looks much neater. This implementation follows what's done in Linux kernel dw_mmc-exynos driver in .set_ios() callback for MMC_TIMING_MMC_DDR52 case. Signed-off-by: Sam Protsenko --- Changes in v5: - (none) Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - (none) drivers/mmc/exynos_dw_mmc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 32f3ea168b6c..ee3ae9f5e650 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -169,7 +169,17 @@ unsigned int exynos_dwmci_get_clk(struct dwmci_host *host, uint freq) u8 clk_div; int err; + /* Should be double rate for DDR mode */ + if (host->mmc->selected_mode == MMC_DDR_52 && host->mmc->bus_width == 8) + freq *= 2; + clk_div = exynos_dwmmc_get_ciu_div(host); + err = exynos_dwmmc_set_sclk(host, freq * clk_div); + if (err) { + printf("DWMMC%d: failed to set clock rate (%d); " + "continue anyway\n", host->dev_index, err); + } + err = exynos_dwmmc_get_sclk(host, &sclk); if (err) { printf("DWMMC%d: failed to get clock rate (%d)\n",